Commit 30b6820e authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: support languages translated

parent 580c359e
...@@ -148,16 +148,16 @@ ...@@ -148,16 +148,16 @@
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="delete">\n <form class="delete">\n
<button data-rel="close" type="submit" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>\n <button data-rel="close" type="submit" data-i18n="Close" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>\n
</form>\n </form>\n
</div>\n </div>\n
</div>\n </div>\n
\n \n
<h1 class="ui-title" role="heading" aria-level="1">Filter Editor</h1>\n <h1 class="ui-title" role="heading" data-i18n="Filter Editor" aria-level="1">Filter Editor</h1>\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="submit">\n <form class="submit">\n
<button data-rel="save" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n <button data-rel="save" data-i18n="submit" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n
</form>\n </form>\n
</div>\n </div>\n
</div>\n </div>\n
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
\n \n
\n \n
<section class="ui-content-header-plain">\n <section class="ui-content-header-plain">\n
<h3 class="ui-content-title ui-body-c">\n <h3 class="ui-content-title ui-body-c" data-i18n="Custom Filter">\n
<span class="ui-icon ui-icon-custom">&nbsp;</span>\n <span class="ui-icon ui-icon-custom">&nbsp;</span>\n
Custom Filter\n Custom Filter\n
</h3>\n </h3>\n
...@@ -174,12 +174,12 @@ ...@@ -174,12 +174,12 @@
<fieldset data-role="controlgroup" class="ui-controlgroup ui-corner-all">\n <fieldset data-role="controlgroup" class="ui-controlgroup ui-corner-all">\n
\n \n
<div class="ui-radio">\n <div class="ui-radio">\n
<label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-on">All criterions(AND)</label>\n <label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-on" data-i18n="All criterions(AND)">All criterions(AND)</label>\n
<input type="radio" value="Off" name="heard_about" id="heard_about_a" class="and checkboxradio" data-cacheval="true" data-enhanced="true">\n <input type="radio" value="Off" name="heard_about" id="heard_about_a" class="and checkboxradio" data-cacheval="true" data-enhanced="true">\n
</div>\n </div>\n
\n \n
<div class="ui-radio">\n <div class="ui-radio">\n
<label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off">At lease one(OR)</label>\n <label class="ui-btn ui-corner-all ui-btn-inherit ui-btn-icon-left ui-radio-off" data-i18n="At lease one(OR)">At lease one(OR)</label>\n
<input type="radio" value="Off" name="heard_about" id="heard_about_b" class="or checkboxradio" data-cacheval="false" data-enhanced="true">\n <input type="radio" value="Off" name="heard_about" id="heard_about_b" class="or checkboxradio" data-cacheval="false" data-enhanced="true">\n
</div>\n </div>\n
\n \n
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
\n \n
\n \n
<section class="ui-content-header-plain">\n <section class="ui-content-header-plain">\n
<h3 class="ui-content-title ui-body-c">\n <h3 class="ui-content-title ui-body-c" data-i18n="Predefined Filter">\n
<span class="ui-icon ui-icon-custom">&nbsp;</span>\n <span class="ui-icon ui-icon-custom">&nbsp;</span>\n
Predefined Filter\n Predefined Filter\n
</h3>\n </h3>\n
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.58401.24333.56064</string> </value> <value> <string>946.2931.62817.63914</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1442993681.59</float> <float>1443620387.19</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -234,6 +234,7 @@ ...@@ -234,6 +234,7 @@
select_list = [],\n select_list = [],\n
dataset,\n dataset,\n
counter,\n counter,\n
paging_info_counter,\n
hide_item = gadget.props.hide_item,\n hide_item = gadget.props.hide_item,\n
sort_list = gadget.props.sort_list || [],\n sort_list = gadget.props.sort_list || [],\n
i,\n i,\n
...@@ -441,6 +442,7 @@ ...@@ -441,6 +442,7 @@
len;\n len;\n
\n \n
th.setAttribute("colspan", field_json.column_list.length);\n th.setAttribute("colspan", field_json.column_list.length);\n
th.setAttribute("class", "foot_colspan");\n
// NOTE: Romain: paging menu with 3+ buttons should have another class name (like ui-paging-grid)\n // NOTE: Romain: paging menu with 3+ buttons should have another class name (like ui-paging-grid)\n
paging_menu.className = "ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu";\n paging_menu.className = "ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu";\n
paging_wrap.className = "ui-controlgroup-controls";\n paging_wrap.className = "ui-controlgroup-controls";\n
...@@ -449,18 +451,18 @@ ...@@ -449,18 +451,18 @@
paging_prev.textContent = "Previous";\n paging_prev.textContent = "Previous";\n
paging_prev.setAttribute("data-i18n", "Previous");\n paging_prev.setAttribute("data-i18n", "Previous");\n
paging_prev.href = url_list[0];\n paging_prev.href = url_list[0];\n
paging_info.className = "ui-btn ui-disabled";\n paging_info.className = "paging_info ui-btn ui-disabled";\n
if ((begin_from === 0) && (counter === 0)) {\n if ((begin_from === 0) && (counter === 0)) {\n
paging_info.textContent = "No records";\n paging_info.textContent = "No records";\n
paging_info.setAttribute("data-i18n", "No Records");\n paging_info.setAttribute("data-i18n", "No Records");\n
} else if ((dataset.data.rows.length <= lines) && (begin_from === 0)) {\n } else if ((dataset.data.rows.length <= lines) && (begin_from === 0)) {\n
paging_info.setAttribute("data-i18n", "[last]Record(s)");\n paging_info.setAttribute("data-i18n", "[last]Record(s)");\n
paging_info.appendChild(document.createTextNode(counter));\n paging_info_counter = "1 -" + counter;\n
paging_info.appendChild(document.createTextNode("Record(s)"));\n paging_info.appendChild(document.createTextNode("Record(s) "));\n
} else {\n } else {\n
paging_info.setAttribute("data-i18n", "[node]Record(s)");\n paging_info.setAttribute("data-i18n", "[node]Record(s)");\n
paging_info.appendChild(document.createTextNode("Records "));\n paging_info.appendChild(document.createTextNode("Records "));\n
paging_info.appendChild(document.createTextNode((((begin_from + lines) / lines - 1) * lines + 1) + " - " + (((begin_from + lines) / lines - 1) * lines + counter)));\n paging_info_counter = (((begin_from + lines) / lines - 1) * lines + 1) + " - " + (((begin_from + lines) / lines - 1) * lines + counter);\n
}\n }\n
// paging_info.textContent = "Page " + ((begin_from + lines) / lines);\n // paging_info.textContent = "Page " + ((begin_from + lines) / lines);\n
paging_next.className = "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child";\n paging_next.className = "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child";\n
...@@ -492,15 +494,17 @@ ...@@ -492,15 +494,17 @@
temp_table.appendChild(fragment);\n temp_table.appendChild(fragment);\n
temp.appendChild(temp_table);\n temp.appendChild(temp_table);\n
table.appendChild(temp.querySelector("tbody"));\n table.appendChild(temp.querySelector("tbody"));\n
return gadget.translateHtml(temp.querySelector("tfoot").innerHTML);\n temp.appendChild(document.createElement("tbody"));\n
return gadget.translateHtml(temp.innerHTML);\n
})\n })\n
.push(function (my_translated_html) {\n .push(function (my_translated_html) {\n
var temp = document.createElement("tfoot");\n var temp = document.createElement("table");\n
temp.innerHTML = my_translated_html;\n temp.innerHTML = my_translated_html;\n
table.appendChild(temp);\n temp.querySelector(".paging_info").appendChild(document.createTextNode(paging_info_counter));\n
table.appendChild(temp.querySelector("tfoot"));\n
})\n })\n
.fail(function (error) {\n .fail(function (error) {\n
if (error.target.status === 500) {\n if (error.target && error.target.status === 500) {\n
return gadget.showQueryError(" Unsupportred Query");\n return gadget.showQueryError(" Unsupportred Query");\n
}\n }\n
throw error;\n throw error;\n
...@@ -537,6 +541,8 @@ ...@@ -537,6 +541,8 @@
hide_submit_form = document.createElement("form"),\n hide_submit_form = document.createElement("form"),\n
hide_show_all = document.createElement("button"),\n hide_show_all = document.createElement("button"),\n
query_list = [],\n query_list = [],\n
translate_div,\n
colspan = gadget.props.element.querySelector(".foot_colspan"),\n
checkbox;\n checkbox;\n
all_hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n all_hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element:checked");\n hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element:checked");\n
...@@ -544,6 +550,7 @@ ...@@ -544,6 +550,7 @@
if (all_hide_form_elements.length > 0) {\n if (all_hide_form_elements.length > 0) {\n
//if nothing is selected, show all\n //if nothing is selected, show all\n
if (hide_form_elements.length === 0) {\n if (hide_form_elements.length === 0) {\n
colspan.setAttribute("colspan", parseInt(colspan.getAttribute("colspan"), 10) - 1);\n
return gadget.redirect({jio_key: gadget.props.jio_key,\n return gadget.redirect({jio_key: gadget.props.jio_key,\n
"extended_search": gadget.props.extended_search || "",\n "extended_search": gadget.props.extended_search || "",\n
"domain_tree": gadget.props.domain_tree || "",\n "domain_tree": gadget.props.domain_tree || "",\n
...@@ -553,6 +560,7 @@ ...@@ -553,6 +560,7 @@
//all selected\n //all selected\n
//no need to submit\n //no need to submit\n
if (hide_form_elements.length + 1 === all_hide_form_elements.length) {\n if (hide_form_elements.length + 1 === all_hide_form_elements.length) {\n
colspan.setAttribute("colspan", parseInt(colspan.getAttribute("colspan"), 10) - 1);\n
for (i = 0; i < all_hide_form_elements.length; i += 1) {\n for (i = 0; i < all_hide_form_elements.length; i += 1) {\n
all_hide_form_elements[i].parentElement.removeChild(all_hide_form_elements[i]);\n all_hide_form_elements[i].parentElement.removeChild(all_hide_form_elements[i]);\n
}\n }\n
...@@ -582,11 +590,19 @@ ...@@ -582,11 +590,19 @@
}\n }\n
\n \n
hide_show_all.setAttribute("type", "submit");\n hide_show_all.setAttribute("type", "submit");\n
hide_show_all.textContent = "Show All";\n hide_show_all.setAttribute("data-i18n", "Show All");\n
hide_show_all.className = "ui-btn responsive ui-last-child";\n hide_show_all.className = "ui-btn responsive ui-last-child";\n
hide_submit_form.appendChild(hide_show_all);\n translate_div = document.createElement("div");\n
translate_div.appendChild(hide_show_all);\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.translateHtml(translate_div.innerHTML);\n
})\n
.push(function (innerHTML) {\n
translate_div.innerHTML = innerHTML;\n
hide_submit_form.innerHTML = innerHTML;\n
th = document.createElement("th");\n th = document.createElement("th");\n
\n colspan.setAttribute("colspan", parseInt(colspan.getAttribute("colspan"), 10) + 1);\n
th.setAttribute("class", "hide_form_element");\n th.setAttribute("class", "hide_form_element");\n
th.appendChild(hide_submit_form);\n th.appendChild(hide_submit_form);\n
loopEventListener(\n loopEventListener(\n
...@@ -608,6 +624,7 @@ ...@@ -608,6 +624,7 @@
checkbox.setAttribute("class", "hide_form_element");\n checkbox.setAttribute("class", "hide_form_element");\n
tr_list[i].insertBefore(checkbox, tr_list[i].firstChild);\n tr_list[i].insertBefore(checkbox, tr_list[i].firstChild);\n
}\n }\n
});\n
}\n }\n
);\n );\n
})\n })\n
...@@ -789,7 +806,7 @@ ...@@ -789,7 +806,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>946.4415.55526.9147</string> </value> <value> <string>946.5543.47694.6075</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -807,7 +824,7 @@ ...@@ -807,7 +824,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1443535241.5</float> <float>1443622529.3</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -136,16 +136,16 @@ ...@@ -136,16 +136,16 @@
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="delete">\n <form class="delete">\n
<button data-rel="close" type="submit" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>\n <button data-i18n="Close" data-rel="close" type="submit" class="close responsive ui-first-child ui-btn ui-btn-icon-left ui-icon-times">Close</button>\n
</form>\n </form>\n
</div>\n </div>\n
</div>\n </div>\n
\n \n
<h1 class="ui-title" role="heading" aria-level="1">Sort Editor</h1>\n <h1 class="ui-title" role="heading" data-i18n="sort Editor" aria-level="1">Sort Editor</h1>\n
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n <div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">\n
<div class="ui-controlgroup-controls">\n <div class="ui-controlgroup-controls">\n
<form class="submit">\n <form class="submit">\n
<button data-rel="save" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n <button data-rel="save" data-i18n="Submit" type="submit" class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check">Submit</button>\n
</form>\n </form>\n
</div>\n </div>\n
</div>\n </div>\n
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.60934.57457.64460</string> </value> <value> <string>946.4096.6867.34269</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1443515526.27</float> <float>1443620255.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -153,7 +153,6 @@ ...@@ -153,7 +153,6 @@
}\n }\n
}\n }\n
select_reference.innerHTML = tmp;\n select_reference.innerHTML = tmp;\n
$(select_reference).selectmenu();\n
tmp = "";\n tmp = "";\n
if (sort_value_list[1] === "ascending") {\n if (sort_value_list[1] === "ascending") {\n
tmp += selected_option_template({\n tmp += selected_option_template({\n
...@@ -180,17 +179,35 @@ ...@@ -180,17 +179,35 @@
}\n }\n
\n \n
select_operator.innerHTML = tmp;\n select_operator.innerHTML = tmp;\n
$(select_operator).selectmenu();\n
\n \n
return div;\n
}\n
\n
function createTranslatedItem(gadget, key) {\n
var container = gadget.props.element.querySelector(".sort_item_container"),\n
sort_item = createSortItem(gadget, key);\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.translateHtml(sort_item.innerHTML);\n
})\n
.push(function (innerHTML) {\n
var select_list,\n
i;\n
sort_item.innerHTML = innerHTML;\n
select_list = sort_item.querySelectorAll("select");\n
for (i = 0; i < select_list.length; i += 1) {\n
$(select_list[i]).selectmenu();\n
}\n
container.insertBefore(sort_item, container.lastChild);\n
loopEventListener(\n loopEventListener(\n
minus_button,\n sort_item.querySelector(".ui-icon-delete"),\n
"click",\n "click",\n
false,\n false,\n
function () {\n function () {\n
div.parentElement.removeChild(div);\n container.removeChild(sort_item);\n
}\n }\n
);\n );\n
return div;\n });\n
}\n }\n
\n \n
\n \n
...@@ -245,7 +262,6 @@ ...@@ -245,7 +262,6 @@
.declareMethod(\'render\', function (options) {\n .declareMethod(\'render\', function (options) {\n
var gadget = this,\n var gadget = this,\n
i,\n i,\n
container = gadget.props.element.querySelector(".sort_item_container"),\n
sort_form_list;\n sort_form_list;\n
sort_form_list = gadget.props.element.querySelectorAll(".sortForm");\n sort_form_list = gadget.props.element.querySelectorAll(".sortForm");\n
for (i = 0; i < sort_form_list.length; i += 1) {\n for (i = 0; i < sort_form_list.length; i += 1) {\n
...@@ -259,29 +275,29 @@ ...@@ -259,29 +275,29 @@
return gadget.jio_getAttachment(options.jio_key, options.view);\n return gadget.jio_getAttachment(options.jio_key, options.view);\n
})\n })\n
.push(function (result) {\n .push(function (result) {\n
var key;\n var key,\n
queue = new RSVP.Queue();\n
gadget.props.column_list = result._embedded._view.listbox.column_list;\n gadget.props.column_list = result._embedded._view.listbox.column_list;\n
for (key in options.form_definition.sort_list) {\n for (key in options.form_definition.sort_list) {\n
if (options.form_definition.sort_list.hasOwnProperty(key)) {\n if (options.form_definition.sort_list.hasOwnProperty(key)) {\n
if (options.form_definition.sort_list[key] !== "") {\n if (options.form_definition.sort_list[key] !== "") {\n
container.insertBefore(createSortItem(gadget, options.form_definition.sort_list[key]), container.lastChild);\n queue.push(createTranslatedItem(gadget, options.form_definition.sort_list[key]));\n
}\n }\n
}\n }\n
}\n }\n
return queue;\n
});\n });\n
})\n })\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
.declareService(function () {\n .declareService(function () {\n
var gadget = this;\n var gadget = this;\n
function plusItem() {\n
var container = gadget.props.element.querySelector(".sort_item_container");\n
container.insertBefore(createSortItem(gadget), container.lastChild);\n
}\n
loopEventListener(\n loopEventListener(\n
gadget.props.element.querySelector(".plus"),\n gadget.props.element.querySelector(".plus"),\n
"submit",\n "submit",\n
false,\n false,\n
plusItem\n function () {\n
return createTranslatedItem(gadget);\n
}\n
);\n );\n
\n \n
loopEventListener(\n loopEventListener(\n
...@@ -459,7 +475,7 @@ ...@@ -459,7 +475,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>945.62441.17317.23193</string> </value> <value> <string>946.6000.3675.35362</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -477,7 +493,7 @@ ...@@ -477,7 +493,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1443515446.86</float> <float>1443629882.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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