Commit 8239d658 authored by Sven Franck's avatar Sven Franck Committed by Romain Courteaud

erp5_web_renderjs_ui: fixed display of languages when no languages are set, combined templates

parent 1fa43554
......@@ -120,7 +120,7 @@
<script src="jquery.js" type="text/javascript"></script>\n
<script src="jquerymobile.js" type="text/javascript"></script>\n
\n
<script id="panel-template" type="text/x-handlebars-template">\n
<script id="panel-template-header" type="text/x-handlebars-template">\n
<div data-role="header" class="ui-bar-inherit">\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n
<div class="ui-controlgroup-controls">\n
......@@ -137,47 +137,36 @@
</div>\n
</div>\n
</script>\n
<script id="panel-template-nolang" type="text/x-handlebars-template">\n
<div class="ui-content">\n
<ul data-role="listview">\n
<li><a href="{{module_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Modules">Modules</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-clipboard" data-i18n="Worklists">Worklists</a></li>\n
<li><a href="{{history_href}}" class="ui-btn ui-btn-icon-left ui-icon-history" data-i18n="History">History</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="Preference">Preferences</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-comment-o" data-i18n="Language">Language</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Logout">Logout</a></li>\n
</ul>\n
</div>\n
</script>\n
\n
<!-- listview needs to be pre-enhanced for language collapsibe to work -->\n
<script id="panel-template-lang" type="text/x-handlebars-template">\n
\n
<script id="panel-template-body" type="text/x-handlebars-template">\n
<div class="ui-content">\n
<ul data-role="listview" class="ui-listview" data-enhanced="true">\n
<li class="ui-first-child"><a href="{{module_href}}" class="ui-btn ui-btn-icon-left ui-icon-puzzle-piece" data-i18n="Modules">Modules</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-clipboard" data-i18n="Worklists">Worklists</a></li>\n
<li><a href="{{history_href}}" class="ui-btn ui-btn-icon-left ui-icon-history" data-i18n="History">History</a></li>\n
<li><a class="ui-btn ui-btn-icon-left ui-icon-gear" data-i18n="Preference">Preferences</a></li>\n
<li data-role="collapsible" data-enhanced="true" data-collapsed="true" data-collapsed-icon="comment-o" class="ui-collapsible ui-collapsible-collapsed">\n
<h4 class="ui-collapsible-heading ui-collapsible-heading-collapsed ui-li-divider ui-li-has-icon">\n
<a class="ui-collapsible-heading-toggle ui-icon-comment-o ui-btn-icon-left ui-btn-inherit" href="#" data-i18n="[last]Languages">\n
<span data-i18n="Click to expand content" class="ui-collapsible-heading-status"></span>Languages\n
</a>\n
</h4>\n
<div class="ui-collapsible-content ui-collapsible-content-collapsed" aria-hidden="true">\n
<fieldset data-role="controlgroup">\n
{{#each document_list}}\n
<form method="POST" action="">\n
<div class="ui-btn ui-input-btn ui-corner-all ui-shadow ui-btn-icon-right ui-icon-carat-r" data-i18n="[node]{{lang}}">\n
&nbsp;\n
<input type="submit" data-enhanced="true" name="lang" id="lang-{{count}}" value="{{lang}}" />\n
</div>\n
<label class="ui-hidden-accessible" for="lang-{{count}}" data-i18n="{{lang}}"></label>\n
</form>\n
{{/each}}\n
</fieldset>\n
</div>\n
</li>\n
{{#if language_list}}\n
<li data-role="collapsible" data-enhanced="true" data-collapsed="true" data-collapsed-icon="comment-o" class="ui-collapsible ui-collapsible-collapsed">\n
<h4 class="ui-collapsible-heading ui-collapsible-heading-collapsed ui-li-divider ui-li-has-icon">\n
<a class="ui-collapsible-heading-toggle ui-icon-comment-o ui-btn-icon-left ui-btn-inherit" href="#" data-i18n="[last]Languages">\n
<span data-i18n="Click to expand content" class="ui-collapsible-heading-status"></span>Languages\n
</a>\n
</h4>\n
<div class="ui-collapsible-content ui-collapsible-content-collapsed" aria-hidden="true">\n
<fieldset data-role="controlgroup">\n
{{#each document_list}}\n
<form method="POST" action="">\n
<div class="ui-btn ui-input-btn ui-corner-all ui-shadow ui-btn-icon-right ui-icon-carat-r" data-i18n="[node]{{lang}}">\n
&nbsp;\n
<input type="submit" data-enhanced="true" name="lang" id="lang-{{count}}" value="{{lang}}" />\n
</div>\n
<label class="ui-hidden-accessible" for="lang-{{count}}" data-i18n="{{lang}}"></label>\n
</form>\n
{{/each}}\n
</fieldset>\n
</div>\n
</li>\n
{{/if}}\n
<li class="ui-last-child"><a class="ui-btn ui-btn-icon-left ui-icon-power-off" data-i18n="Logout">Logout</a></li>\n
</ul>\n
</div>\n
......@@ -315,7 +304,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
<value> <string>sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -329,7 +318,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>939.64258.51349.15786</string> </value>
<value> <string>942.11707.40779.32529</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -347,7 +336,7 @@
</tuple>
<state>
<tuple>
<float>1420197041.32</float>
<float>1428416647.44</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -107,22 +107,18 @@
"use strict";\n
\n
/////////////////////////////////////////////////////////////////\n
// Handlebars\n
// temlates\n
/////////////////////////////////////////////////////////////////\n
// Precompile templates while loading the first gadget instance\n
var gadget_klass = rJS(window),\n
source = gadget_klass.__template_element\n
.getElementById("panel-template")\n
source_header = gadget_klass.__template_element\n
.getElementById("panel-template-header")\n
.innerHTML,\n
panel_template = Handlebars.compile(source),\n
source_content = gadget_klass.__template_element\n
.getElementById("panel-template-lang")\n
panel_template_header = Handlebars.compile(source_header),\n
source_body = gadget_klass.__template_element\n
.getElementById("panel-template-body")\n
.innerHTML,\n
panel_template_lang = Handlebars.compile(source_content),\n
source_content_no_lang = gadget_klass.__template_element\n
.getElementById("panel-template-nolang")\n
.innerHTML,\n
panel_template_nolang = Handlebars.compile(source_content_no_lang);\n
panel_template_body = Handlebars.compile(source_body);\n
\n
gadget_klass\n
/////////////////////////////////////////////////////////////////\n
......@@ -139,7 +135,10 @@
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("changeLanguage", "changeLanguage")\n
.declareAcquiredMethod("getLanguageList", "getLanguageList")\n
.declareAcquiredMethod("whoWantToDisplayThisFrontPage", "whoWantToDisplayThisFrontPage")\n
.declareAcquiredMethod(\n
"whoWantToDisplayThisFrontPage",\n
"whoWantToDisplayThisFrontPage"\n
)\n
\n
// Assign the element to a variable\n
.ready(function (g) {\n
......@@ -169,35 +168,28 @@
]);\n
})\n
.push(function (all_result) {\n
var i,\n
var raw_language_list = JSON.parse(all_result[2]),\n
len = raw_language_list.length,\n
i,\n
i_len,\n
tmp,\n
language_list,\n
document_list = [],\n
raw_language_list = all_result[2];\n
tmp;\n
\n
// XXX: Customize panel header!\n
tmp = panel_template();\n
tmp = panel_template_header();\n
\n
// translation list available\n
if (raw_language_list) {\n
language_list = JSON.parse(raw_language_list);\n
i_len = language_list.length;\n
for (i = 0; i < i_len; i += 1) {\n
document_list.push({"count": i, "lang": language_list[i]});\n
// languages\n
if (len > 0) {\n
language_list = [];\n
for (i = 0, i_len = len; i < i_len; i += 1) {\n
language_list.push({"count": i, "lang": language_list[i]});\n
}\n
tmp += panel_template_lang({\n
module_href: all_result[0],\n
history_href: all_result[1],\n
document_list: document_list\n
});\n
return g.translateHtml(tmp);\n
}\n
\n
// no translations available or not loaded when reaching this point\n
tmp += panel_template_nolang({\n
module_href: all_result[0],\n
history_href: all_result[1]\n
tmp += panel_template_body({\n
"module_href": all_result[0],\n
"history_href": all_result[1],\n
"language_list": language_list\n
});\n
return tmp;\n
})\n
......@@ -407,7 +399,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>sven</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -421,7 +413,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.16198.52720.49783</string> </value>
<value> <string>942.11711.24841.37034</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -439,7 +431,7 @@
</tuple>
<state>
<tuple>
<float>1421080772.85</float>
<float>1428416611.09</float>
<string>GMT</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment