From e40984e30e46c1d189ccb5c2190d9a70e429ac62 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 21 Aug 2009 14:33:35 +0000 Subject: [PATCH] * add WebSection_viewToolbarWidget that can be used for all web sites with the same appearance. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28550 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../WebSection_viewToolbarWidget.xml | 320 ++++++++++++++++++ .../erp5_web_toolbar.css.xml | 225 ++++++++++++ .../erp5_web_toolbar.js.xml | 67 ++++ bt5/erp5_web/bt/change_log | 3 + bt5/erp5_web/bt/revision | 2 +- 5 files changed, 616 insertions(+), 1 deletion(-) create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewToolbarWidget.xml create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.css.xml create mode 100644 bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.js.xml diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewToolbarWidget.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewToolbarWidget.xml new file mode 100644 index 0000000000..c8379cc0b0 --- /dev/null +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSection_viewToolbarWidget.xml @@ -0,0 +1,320 @@ +<?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[ + +<!-- Floating Panel -->\n +\n +<!-- header_definitions must be re-called and is_web_mode redefined because calling\n + the current page template through editor_field in the form layout seems to reset\n + the context needed by action drop-down list.\n +\n + TODO: Is this case should be handle by automatically by erp5_xhtml_style ?\n + More translation is required.\n +-->\n +\n +<tal:block\n + tal:define="is_web_mode python: True;\n + actions request/actions | python:\n + here.Base_filterDuplicateActions(\n + here.portal_actions.listFilteredActionsFor(here));\n + dummy python:request.set(\'actions\', actions);\n + portal_url python: getattr(here, \'getWebSiteValue\', here.getPortalObject)().absolute_url();\n + portal_type here/getPortalType">\n +<ul>\n + <!-- Edit button menu -->\n + <li class="toolboxSection">\n + <h3 class="menu_title" i18n:translate="" i18n:domain="ui">Edit</h3>\n + <div class="menu" style="display:none">\n + <ul tal:define="edit_link_list python: here.Base_getAdminToolboxEditShortcutList()">\n + <li tal:repeat="link edit_link_list">\n + <a tal:attributes="href python: link[\'url\']">\n + <span>\n + <img tal:attributes="src python: link[\'icon\'];\n + title python: link[\'label\'];\n + alt python: \'%s Icon\' % link[\'label\'];"/>\n + <tal:block tal:replace="python: link[\'title\']"/>\n + </span>\n + </a>\n + </li>\n + </ul>\n + </div>\n + </li>\n +\n + <!-- A pop-up menu with all actions which can be applied to\n + the current object and which have no button equivalent\n +\n + We need to setup the actions variable from the request because\n + this template is called from outside the main rendering process\n +\n + XXX - the location of context_box_render is hardcoded.\n + -->\n + <li class="toolboxSection">\n + <h3 class="menu_title"><tal:block tal:content="portal_type"/> Actions</h3>\n + <div class="menu" style="display:none">\n + <label i18n:translate="" i18n:domain="ui">Add</label>\n + <ul>\n + <tal:block tal:define="allowed_content_type_list here/getVisibleAllowedContentTypeList | python:[] ">\n + <li tal:repeat="content_id allowed_content_type_list">\n + <button class="menu-link" \n + tal:attributes="title string:Add ${content_id};\n + name python:\'Base_doAction:method\';\n + value python: \'add %s\' % (content_id,) "\n + i18n:translate="" i18n:domain="ui">\n + Add <tal:block tal:content="content_id"\n + i18n:name="portal_type" \n + i18n:translate="" i18n:domain="ui" />\n + </button>\n + </li>\n + </tal:block>\n + <li tal:repeat="action actions/object_add | nothing">\n + <button class="menu-link" \n + tal:attributes="title string:Add ${action/name};\n + name python:\'Base_doAction:method\';\n + value string:object ${action/url}"\n + i18n:translate="" i18n:domain="ui">\n + Add <tal:block tal:content="action/name" i18n:name="portal_type" i18n:translate="" />\n + </button>\n + </li>\n + <tal:block tal:define="document_template_list here/getDocumentTemplateList | nothing"\n + tal:condition="document_template_list">\n + <li tal:repeat="document_template document_template_list">\n + <button class="menu-link"\n + tal:attributes="title string:Add ${document_template/getTitle};\n + name python:\'Base_doAction:method\';\n + value python:\'template %s\' % (document_template.getRelativeUrl(), )"\n + i18n:translate="" i18n:domain="ui">\n + Add <tal:block tal:content="document_template/getTitle"\n + i18n:name="document_template" />\n + </button>\n + </li>\n + </tal:block>\n + </ul>\n +\n + <label i18n:translate="" i18n:domain="ui">Workflows</label>\n + <ul>\n + <li tal:repeat="action actions/workflow">\n + <button class="menu-link" tal:content="action/name"\n + tal:attributes="title action/name;\n + name python:\'Base_doAction:method\';\n + value python:\'workflow %s\' % (action[\'url\'], )"\n + i18n:translate="" i18n:domain="ui">\n + </button>\n + </li>\n + </ul>\n +\n + <label i18n:translate="" i18n:domain="ui">Object</label>\n + <ul>\n + <li tal:repeat="action actions/object_action | nothing">\n + <button class="menu-link" tal:content="action/name"\n + tal:attributes="title action/name;\n + name python:\'Base_doAction:method\';\n + value python:\'object %s\' % (action[\'url\'], )"\n + i18n:translate="" i18n:domain="ui"></button>\n + </li>\n + <tal:block tal:define="object_view_list actions/object_view|nothing;\n + module_view_list python:[i for i in object_view_list if i[\'id\']==\'module_view\']"\n + tal:condition="module_view_list">\n + <li tal:repeat="action module_view_list">\n + <button class="menu-link" tal:content="action/name"\n + tal:attributes="title action/name;\n + name python:\'Base_doAction:method\';\n + value python:\'object %s\' % (action[\'url\'], )"\n + i18n:translate="" i18n:domain="ui"></button>\n + </li>\n + </tal:block>\n + </ul>\n + </div>\n + </li>\n +\n + <!-- Document creation panel.\n + \n + This part is displayed for any document apart Web Site and Web Section.\n + But if Web Site and Web Section have a default page, then it will be displayed anyway\n + in order to let the user clone the default page.\n +\n + XXX - This is not so good to create new content in a section\n + Behaviour should be to create content in section / site\n + -->\n + <li class="toolboxSection"\n + tal:condition="python:here.isDocument">\n + <h3 class="menu_title">\n + <span id="create_new_document_title"></span>\n + <span id="clone_document_title">\n + <tal:block tal:replace="string:Clone $portal_type"/>\n + </span>\n + </h3>\n + <div class="menu" style="display:none">\n + <fieldset style="display:block;">\n + <div class="field">\n + <label i18n:translate="" i18n:domain="ui">Title</label>\n + <div class="input">\n + <input class="input" size="12" \n + type="text" name="clone_title"\n + tal:attributes="value here/getTitle | nothing"/>\n + </div>\n + </div>\n +\n + <div class="field">\n + <label i18n:translate="" i18n:domain="ui">Reference</label>\n + <div class="input">\n + <input class="input" size="12" \n + type="text" name="clone_reference"\n + tal:attributes="value here/getReference | nothing"/>\n + </div>\n + </div>\n +\n + <div class="field">\n + <label i18n:translate="" i18n:domain="ui">Version</label>\n + <div class="input">\n + <input class="input" size="5" \n + type="text" name="clone_version"\n + tal:attributes="value here/getVersion | nothing"/>\n + </div>\n + </div>\n +\n + <div class="field">\n + <label i18n:translate="" i18n:domain="ui">Language</label>\n + <div class="input">\n + <input class="input" size="5" \n + type="text" name="clone_language"\n + tal:attributes="value here/getLanguage | nothing"/>\n + </div>\n + </div>\n +\n + <div class="field">\n + <label i18n:translate="" i18n:domain="ui">Portal type</label>\n + <div class="input">\n + <select class="input" name="clone_portal_type" \n + size="1" onchange="setCreationMode(this)">\n + <option value="None" selected>— Same as Current —</option>\n + <option tal:repeat="portal_type python: here.getPortalWebDocumentTypeList()"\n + tal:content="portal_type"\n + tal:attributes="value portal_type"\n + i18n:translate="" i18n:domain="ui">portal_type</option>\n + </select>\n + </div>\n + </div>\n +\n + <div class="field hiddenLabel">\n + <label> </label>\n + <div class="input">\n + <button alt=\'Clone & Edit\' id="clone_action_button" \n + title=\'Clone & Edit\'\n + name="Base_cloneContent:method">\n + <img src="admin_toolbox_clone_document.png" id="clone_action_icon"\n + tal:attributes="src string:$portal_url/admin_toolbox_clone_document.png" />\n + <span id="duplicate_document_action">Clone & Edit</span>\n + </button>\n + </div>\n + </div>\n + </fieldset>\n +\n + <script type="text/javascript" language="JavaScript" tal:content="string:\n + // preload action icons\n + if (document.images) {\n + clone_icon = new Image();\n + new_icon = new Image();\n + clone_icon.src = \'$portal_url/admin_toolbox_clone_document.png\';\n + new_icon.src = \'$portal_url/admin_toolbox_new_document.png\';\n + }\n +\n + function setCreationMode (sel) {\n + // default is cloning\n + var action = \'clone\';\n + var action_name = \'Clone & Edit\';\n + var icon = \'admin_toolbox_clone_document.png\';\n + var name = \'Base_cloneContent:method\';\n + var clone_display = \'inline\';\n + var new_title = \'\';\n +\n + // a portal type is given, so create a new document\n + var portal_type = sel.options[sel.selectedIndex].value;\n + if (portal_type != \'None\') {\n + action = \'new\'\n + action_name = \'Create New & Edit\';\n + icon = \'admin_toolbox_new_document.png\';\n + name = \'Base_newContent:method\';\n + clone_display = \'none\';\n + new_title = \'Create New Document\';\n + }\n +\n + // update action dependent values\n + document.getElementById(\'create_new_document_title\').innerHTML = new_title;\n + document.getElementById(\'clone_document_title\' ).style.display = clone_display;\n + document.getElementById(\'duplicate_document_action\').innerHTML = action_name;\n +\n + // replace the action icon\n + document.getElementById(\'clone_action_icon\').src = eval(action + \'_icon.src\');\n +\n + // update action button alt & title\n + var button = document.getElementById(\'clone_action_button\');\n + button.alt = action_name;\n + button.title = action_name;\n + button.name = name;\n + }\n + " />\n + </div>\n + </li>\n + <script type="text/javascript" src="erp5_web_toolbar.js" tal:attributes="src string:$portal_url/erp5_web_toolbar.js"></script>\n +</ul>\n +</tal:block> + +]]></string> </value> + </item> + <item> + <key> <string>content_type</string> </key> + <value> <string>text/html</string> </value> + </item> + <item> + <key> <string>expand</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>WebSection_viewToolbarWidget</string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.css.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.css.xml new file mode 100644 index 0000000000..761110d3e8 --- /dev/null +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.css.xml @@ -0,0 +1,225 @@ +<?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 define="dummy python: request.RESPONSE.setHeader(\'Content-Type\', \'text/css;; charset=utf-8\')"/>\n +<tal:block>\n +div.web-toolbar {\n + z-index:999;\n + font-size:12px !important;\n + bottom:0;\n + left:0;\n + position:fixed;\n + width:100%;\n + background:#eef;\n + height:20px;\n + border-top:1px #ccc solid;\n + padding:0 10px;\n + margin:0;\n +}\n +div.web-toolbar h3 {\n + font-size:100%;\n + font-weight:bold;\n + padding:0 10px;\n + cursor:pointer;\n +}\n +div.web-toolbar h3:hover {\n + background:#ccf;\n +}\n +div.web-toolbar u1 {\n + margin:0;\n + padding:0;\n + list-style:none\n +}\n +li.toolboxSection {\n + display:inline;\n + float:left;\n +}\n +li.toolboxSection > div {\n + display:none;\n + marding:0;\n + bottom:20px;\n + position:fixed;\n + background-color:white;\n + border:1px solid #ccc;\n + padding:8px;\n +}\n +div.web-toolbar select {\n + max-width: 15em;\n +}\n +\n +div.web-toolbar.field label {\n + display: none!important;\n +}\n +\n +div.web-toolbar div.hiddenLabel label {\n + display: none!important;\n +}\n +\n +/* Sub section title */\n +div.web-toolbar h3 {\n + font-size:120% !important /*Non-IE6*/; font-size:100% /*IE6*/;\n + margin:0;\n +}\n +\n +/* Title */\n +div.web-toolbar > div > h3 {\n + background: #f77;\n + padding: 0.5em 0;\n + margin: 0;\n + color: #fff;\n + cursor: pointer;\n +}\n +\n +div.web-toolbar > div > h3:hover {background: #f00}\n +\n +div.web-toolbar li {\n + margin: 0;\n + padding: 0;\n + background: none;\n +}\n +\n +div.web-toolbar li > a,\n +div.web-toolbar li > a:hover,\n +div.web-toolbar li > a:visited,\n +div.web-toolbar li > a:active {text-decoration: none}\n +\n +div.web-toolbar button[type="submit"] {\n + display: none;\n +}\n +\n +/* Reset default styling of fields in admin tool box\n +** TODO: find a CSS trick to let forms and fieldset embedded in\n +** ".web-toolbar" behave like default one instead of using\n +** the one defined by default "div.wrapper div.field" rules.\n +*/\n +div.web-toolbar fieldset { /* Should be the same as "fieldset" rule */\n + background: none;\n + border: inherit;\n + margin: 0;\n + border: 0;\n +}\n +div.web-toolbar fieldset > div.field { /* Should be similar to "fieldset > div" rule */\n + padding: 0;\n + margin: 0;\n + border: none;\n + width: 100%;\n +}\n +\n +/* Those values differ from default "fieldset label" rule to reduce admin toolbox minimum width */\n +div.web-toolbar div.field div.input {margin-left: 0em}\n +\n +/* Cut the cascading heritance if margin-left for input */\n +div.web-toolbar > div.input {margin-left: inherit}\n +div.web-toolbar fieldset div.field label:after {content: inherit}\n +\n +\n +/* Admin toolbox edit buttons have the same style as actions buttons */\n +div.web-toolbar li > a,\n +div.web-toolbar button {\n + border: 1px #ddd solid;\n + color: #999;\n + background: #eee;\n + cursor: pointer;\n + display: block;\n + margin: 0.3em 0;\n + width:100%;\n + font-family:sans-serif;\n + font-size:90%;\n +}\n +div.web-toolbar li > a span,\n +div.web-toolbar button {\n + text-align:left;\n + padding: .2em;\n + display:block;\n +}\n +\n +div.web-toolbar li > a:hover,\n +button:hover {\n + color: #333;\n + background: #b0cfcb;\n + border-color: #9abdb7;\n +}\n +\n +div.web-toolbar a img,\n +div.web-toolbar a:hover img,\n +div.web-toolbar button img {\n + border:0 none;\n + float:none;\n + margin:0;\n +}\n +\n +div.web-toolbar ul {\n + margin:0;\n +}\n +\n +div.web-toolbar ul li {\n + font-size:100% !important;\n +}\n +\n +div.web-toolbar li.toolboxSection label {\n + display:block;\n + margin:0.2em 0 0 0;\n +}\n +</tal:block>\n + + +]]></string> </value> + </item> + <item> + <key> <string>content_type</string> </key> + <value> <string>text/html</string> </value> + </item> + <item> + <key> <string>expand</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>erp5_web_toolbar.css</string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.js.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.js.xml new file mode 100644 index 0000000000..f245439f54 --- /dev/null +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/erp5_web_toolbar.js.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="File" module="OFS.Image"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_EtagSupport__etag</string> </key> + <value> <string>ts50863427.77</string> </value> + </item> + <item> + <key> <string>__name__</string> </key> + <value> <string>erp5_web_toolbar.js</string> </value> + </item> + <item> + <key> <string>content_type</string> </key> + <value> <string>application/javascript</string> </value> + </item> + <item> + <key> <string>data</string> </key> + <value> <string>function initialize_toolbar(){\n + // for each menues\n + var menus = getElementsByTagAndClassName(\'li\', \'toolboxSection\');\n + forEach(menus, function (menu) {\n + var menu_title = getFirstElementByTagAndClassName(\'h3\', \'menu_title\', menu);\n + var item = getFirstElementByTagAndClassName(\'div\', \'menu\', menu);\n + connect(menu_title, \'onclick\', function (){display_menu(item)});\n + });\n +}\n +\n +function display_menu(clicked_item){\n + toggle(clicked_item, \'appear\', {duration:0});\n + // for each menues\n + var menus = getElementsByTagAndClassName(\'li\', \'toolboxSection\');\n + forEach(menus, function (menu) {\n + var item = getFirstElementByTagAndClassName(\'div\', \'menu\', menu);\n + if (item != clicked_item) {\n + //item.style.display = \'none\';\n + fade(item, {duration:0});\n + }\n + });\n +}\n +\n +initialize_toolbar();\n +</string> </value> + </item> + <item> + <key> <string>precondition</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>size</string> </key> + <value> <int>809</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web/bt/change_log b/bt5/erp5_web/bt/change_log index 3ecd4f64b5..52cac7aa25 100644 --- a/bt5/erp5_web/bt/change_log +++ b/bt5/erp5_web/bt/change_log @@ -1,3 +1,6 @@ +2009-08-21 Kazuhiko +* add WebSection_viewToolbarWidget that can be used for all web sites with the same appearance. + 2009-06-29 nicolas * Check that user doesn't already exists diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision index f08bce7b1c..3f986b9191 100644 --- a/bt5/erp5_web/bt/revision +++ b/bt5/erp5_web/bt/revision @@ -1 +1 @@ -841 \ No newline at end of file +842 \ No newline at end of file -- 2.30.9