Commit 56297366 authored by Jérome Perrin's avatar Jérome Perrin

xhtml_style: expose methods from interface_translation.html

This way we can use gadgets using of ERP5JS translation API in xhtml
style.
This is really minimal compatibility layer and translation is not
actually performed.
parent d1313878
...@@ -5,11 +5,22 @@ ...@@ -5,11 +5,22 @@
rJS(window) rJS(window)
.declareAcquiredMethod('notifyChange', 'notifyChange') .declareAcquiredMethod('notifyChange', 'notifyChange')
.declareAcquiredMethod('translateHtml', 'translateHtml')
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
this.element.firstChild.value = options.value || ""; var form_gadget = this;
this.element.firstChild.title = options.key; // gadgets can use translation methods also in xhtml style,
this.element.firstChild.setAttribute('data-name', // this test gadget also exercise this.
options.key || ""); return form_gadget
.translateHtml(form_gadget.element.innerHtml)
.push(function (html) {
form_gadget.element.innerHtml = html;
form_gadget.element.firstChild.value = options.value || "";
form_gadget.element.firstChild.title = options.key;
form_gadget.element.firstChild.setAttribute(
"data-name",
options.key || ""
);
});
}) })
.onEvent('change', function () { .onEvent('change', function () {
return this.notifyChange(); return this.notifyChange();
......
...@@ -88,6 +88,17 @@ ...@@ -88,6 +88,17 @@
return this.element.querySelector('form').querySelector('[type="submit"]').click(); return this.element.querySelector('form').querySelector('[type="submit"]').click();
}) })
// Comply to interface_translation.html, but without actually translating.
.allowPublicAcquisition('translate', function (argument_list) {
return argument_list[0];
})
.allowPublicAcquisition('getTranslationList', function (argument_list) {
return argument_list[0];
})
.allowPublicAcquisition('translateHtml', function (argument_list) {
return argument_list[0];
})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
......
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