Commit 2b842d3a authored by Xiaowu Zhang's avatar Xiaowu Zhang

Do translation in form gadget

now each gadget should do translation by itself
for the iframe reason
parent 9295c722
......@@ -130,7 +130,7 @@
})\n
\n
.declareAcquiredMethod("aq_put", "jio_put")\n
\n
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.allowPublicAcquisition("notifyInvalid", function (param_list, scope) {\n
return this.getDeclaredGadget(scope)\n
.push(function (gadget) {\n
......@@ -214,8 +214,6 @@
if (group[0] !== "bottom") {\n
field_element.appendChild(label_element);\n
}\n
field_element.appendChild(gadget_element);\n
fieldset_element.appendChild(field_element);\n
if (renderered_field.type === \'ListField\') {\n
// (renderered_field.type === \'ParallelListField\') ||\n
// (renderered_field.type === \'MultiListField\')) {\n
......@@ -237,6 +235,14 @@
}\n
\n
return field_queue\n
.push(function () {\n
return form_gadget.translateHtml(field_element.innerHTML);\n
})\n
.push(function (my_translate_html) {\n
field_element.innerHTML = my_translate_html;\n
field_element.appendChild(gadget_element);\n
fieldset_element.appendChild(field_element);\n
})\n
.push(function () {\n
return form_gadget.declareGadget(field_url, {\n
scope: renderered_field.key,\n
......@@ -277,6 +283,7 @@
}\n
dom_element.appendChild(parent_element);\n
// return $(parent_element).trigger("create");\n
\n
});\n
})\n
\n
......@@ -465,7 +472,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -479,7 +486,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.2226.16128.23057</string> </value>
<value> <string>940.10454.31463.21265</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -497,8 +504,8 @@
</tuple>
<state>
<tuple>
<float>1420242897.6</float>
<string>GMT</string>
<float>1420736435.02</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -132,8 +132,8 @@
<!-- XXX action, method, fieldset -->\n
<!-- XXX needs a theme -->\n
<form class="save_form ui-body-c" novalidate>\n
<button data-i18n="save" type="submit" class="ui-btn ui-btn-b ui-btn-inline\n
ui-icon-edit ui-btn-icon-right ui-screen-hidden">Save</button>\n
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline\n
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>\n
\n
<div data-gadget-url="gadget_erp5_form.html"\n
data-gadget-scope="erp5_form"\n
......@@ -264,7 +264,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>super_sven</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -278,7 +278,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>939.51440.6706.38775</string> </value>
<value> <string>940.10457.48901.33450</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -296,8 +296,8 @@
</tuple>
<state>
<tuple>
<float>1419417591.82</float>
<string>GMT</string>
<float>1420736835.67</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -99,9 +99,7 @@
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global window, rJS, RSVP, loopEventListener, URI, document */\n
<value> <string>/*global window, rJS, RSVP, loopEventListener, URI, document */\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, RSVP, loopEventListener, URI) {\n
"use strict";\n
......@@ -191,24 +189,6 @@
breadcrumb_url: all_result[4],\n
save_action: true\n
});\n
})\n
// XXX: DOM touches\n
.push(function () {\n
return form_gadget.translateHtml(form_gadget.props.element.innerHTML);\n
})\n
.push(function (my_translated_html) {\n
//Can\'t use form_gadget.props.element.innerHTML = my_translated_html\n
// which will change dom then service will not be started\n
var temp = document.createElement("div"),\n
elements1,\n
i,\n
elements2;\n
temp.innerHTML = my_translated_html;\n
elements1 = form_gadget.props.element.querySelectorAll("[data-i18n]");\n
elements2 = temp.querySelectorAll("[data-i18n]");\n
for (i = 0; i < elements1.length; i += 1) {\n
elements1[i].innerHTML = elements2[i].innerHTML;\n
}\n
});\n
})\n
\n
......@@ -250,9 +230,7 @@
);\n
});\n
\n
}(window, rJS, RSVP, loopEventListener, URI));
]]></string> </value>
}(window, rJS, RSVP, loopEventListener, URI));</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -387,7 +365,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.9016.5643.56644</string> </value>
<value> <string>940.10421.7831.40686</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -405,7 +383,7 @@
</tuple>
<state>
<tuple>
<float>1420723492.34</float>
<float>1420736076.72</float>
<string>UTC</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