From 605397db1a2533db964aed170d5d5206db0ce61a Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Fri, 2 Jul 2010 10:46:54 +0000
Subject: [PATCH] Allow in download widget to select from all possible convert
 to formats (incl. original). Use explicitly MochiKit prefix in all KM
 JavaScript code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36802 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../old}/Document_viewDownloadWidget.xml      |  0
 .../download_widget.xml                       |  2 +-
 .../erp5_km_theme/km_css/layout.css.xml       | 46 +++++++++++-
 .../erp5_km_theme/km_js/erp5_km.js.xml        | 14 +++-
 .../Base_viewDownloadWidget.xml               | 74 +++++++++++++++++++
 bt5/erp5_km/bt/revision                       |  2 +-
 6 files changed, 131 insertions(+), 7 deletions(-)
 rename bt5/erp5_km/SkinTemplateItem/portal_skins/{erp5_km_widget_library => erp5_km/old}/Document_viewDownloadWidget.xml (100%)
 create mode 100644 bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Base_viewDownloadWidget.xml

diff --git a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Document_viewDownloadWidget.xml b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km/old/Document_viewDownloadWidget.xml
similarity index 100%
rename from bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Document_viewDownloadWidget.xml
rename to bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km/old/Document_viewDownloadWidget.xml
diff --git a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/WebSection_viewMinimalKMWidgetFieldLibrary/download_widget.xml b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/WebSection_viewMinimalKMWidgetFieldLibrary/download_widget.xml
index ee4b537f25..0d1d74fdce 100644
--- a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/WebSection_viewMinimalKMWidgetFieldLibrary/download_widget.xml
+++ b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/WebSection_viewMinimalKMWidgetFieldLibrary/download_widget.xml
@@ -307,7 +307,7 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>request/current_web_document/Document_viewDownloadWidget</string> </value>
+            <value> <string>request/current_web_document/Base_viewDownloadWidget</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_css/layout.css.xml b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_css/layout.css.xml
index e028983348..ceaa7d4076 100644
--- a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_css/layout.css.xml
+++ b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_css/layout.css.xml
@@ -1519,7 +1519,51 @@ div.centeredInner {\n
 /* Search listbox styling */\n
 div.searchDetails, span.found{\n
   padding-top: 5px;\n
-}
+}\n
+\n
+/* Download widget */\n
+div.download-document-format-list-container{\n
+  display:block;\n
+  float:left;\n
+  max-width: 200px;\n
+}\n
+div.download-document-format-list-container span{\n
+  cursor: pointer; \n
+  display:block;\n
+  float:right;\n
+  background:transparent url(km_img/collapse-down-arrow.gif) no-repeat scroll right 6px;\n
+  padding: 3px;\n
+  padding-right: 10px;\n
+  font-weight: bold;\n
+}\n
+\n
+div.download-document-format-list-menu{\n
+  display:block;\n
+  float:left;\n
+  border: 1px solid #ECEBE2;\n
+}\n
+div.download-document-format-list-container span:hover,\n
+div.download-document-format-list-menu ul li:hover{\n
+  background-color: #ECEBE2;\n
+}\n
+div.download-document-format-list-menu ul{\n
+  list-style-type:none;\n
+  padding:0.4em;\n
+  margin-bottom:0;\n
+  margin-top:0;\n
+}\n
+div.download-document-format-list-menu ul li{\n
+  margin-bottom:2px;\n
+}\n
+div.download-document-format-list-menu ul li.separator{\n
+  border-bottom: 1px solid #ECEBE2;\n
+  margin-bottom:5px;\n
+  padding-bottom:3px;\n
+}\n
+\n
+\n
+\n
+
 
 ]]></string> </value>
         </item>
diff --git a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_js/erp5_km.js.xml b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_js/erp5_km.js.xml
index e624629294..327031e689 100644
--- a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_js/erp5_km.js.xml
+++ b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_theme/km_js/erp5_km.js.xml
@@ -15,7 +15,7 @@
         </item>
         <item>
             <key> <string>_EtagSupport__etag</string> </key>
-            <value> <string>ts77887532.32</string> </value>
+            <value> <string>ts78059655.7</string> </value>
         </item>
         <item>
             <key> <string>__name__</string> </key>
@@ -31,8 +31,8 @@
 
 // Browser gadget toggle section\n
 function toggleSection(section_id, image_id){\n
-  section_obj = getElement(section_id);\n
-  image_obj = getElement(image_id);\n
+  section_obj = MochiKit.DOM.getElement(section_id);\n
+  image_obj = MochiKit.DOM.getElement(image_id);\n
   if(section_obj.style.display==\'none\'){\n
     section_obj.style.display=\'block\';\n
     image_obj.src=\'images/tree_open.png\';}\n
@@ -64,6 +64,12 @@ function toggleDocumentDetailsPopupWindow(dom_id, show, url){\n
     }\n
 }\n
 \n
+// Toggle any element\n
+function toggleElement(tag_name, class_name){\n
+  dom_element = MochiKit.DOM.getFirstElementByTagAndClassName(tag_name, class_name);\n
+  MochiKit.Visual.toggle(dom_element);\n
+}\n
+\n
 MochiKit.DOM.addLoadEvent(setScreenClass);\n
 connect(window, "onresize", setScreenClass);\n
 \n
@@ -82,7 +88,7 @@ function setScreenClass(){\n
         </item>
         <item>
             <key> <string>size</string> </key>
-            <value> <int>1319</int> </value>
+            <value> <int>1540</int> </value>
         </item>
         <item>
             <key> <string>title</string> </key>
diff --git a/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Base_viewDownloadWidget.xml b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Base_viewDownloadWidget.xml
new file mode 100644
index 0000000000..e773d07b1a
--- /dev/null
+++ b/bt5/erp5_km/SkinTemplateItem/portal_skins/erp5_km_widget_library/Base_viewDownloadWidget.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+<tal:block replace="nothing">\n
+  <!--\n
+  This widget displays download widget of a document.\n
+ \n
+  -->\n
+</tal:block>\n
+\n
+<div class="download-document-format-list-container"\n
+     tal:define="target_format_item_list python: here.getTargetFormatItemList();\n
+                       document_url here/absolute_url">\n
+ <span onClick="javascript:toggleElement(\'div\', \'download-document-format-list-menu\');"> Download</span>\n
+  <div class="download-document-format-list-menu" style="opacity: 0.999999; display: none;">\n
+    <ul>\n
+      <li class="separator"><a tal:attributes="href document_url"> Original </a></li>\n
+      <li tal:repeat="target_format_item target_format_item_list">\n
+        <a tal:attributes="href python: \'%s?format=%s\' %(document_url, target_format_item[1])"\n
+           tal:content="python: target_format_item[0]"/>\n
+      </li>\n
+    </ul>\n
+  </div>\n
+\n
+</div>
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_viewDownloadWidget</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_km/bt/revision b/bt5/erp5_km/bt/revision
index 0e8ebf59f2..063fa394f4 100644
--- a/bt5/erp5_km/bt/revision
+++ b/bt5/erp5_km/bt/revision
@@ -1 +1 @@
-1476
\ No newline at end of file
+1478
\ No newline at end of file
-- 
2.30.9