Commit bb044324 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Simplify editor panel implementation

parent 658ccb01
...@@ -13,6 +13,5 @@ ...@@ -13,6 +13,5 @@
<script src="gadget_erp5_editor_panel.js"></script> <script src="gadget_erp5_editor_panel.js"></script>
</head> </head>
<body> <body>
<div class="jqm-navmenu-panel"></div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>954.34618.13218.7202</string> </value> <value> <string>954.35607.14703.35106</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1476258673.41</float> <float>1476258994.21</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*jslint indent: 2, maxerr: 3, nomen: true */ /*jslint indent: 2, maxerr: 3, nomen: true, maxlen: 80 */
/*global window, rJS, RSVP */ /*global window, rJS */
(function (window, rJS, RSVP) { (function (window, rJS) {
"use strict"; "use strict";
rJS(window) rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Init local properties
.ready(function (g) {
g.props = {};
})
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
g.props.container = element.querySelector(".jqm-navmenu-panel");
});
})
.allowPublicAcquisition('trigger', function () {
this.props.element.classList.toggle('visible');
// return this.props.jelement.panel("toggle");
})
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
////////////////////////////////////////////// //////////////////////////////////////////////
//local method .allowPublicAcquisition('trigger', function () {
this.element.classList.toggle('visible');
})
.declareMethod('close', function () { .declareMethod('close', function () {
var container = this.props.container; var element = this.element;
while (container.firstChild) { while (element.firstChild) {
container.removeChild(container.firstChild); element.removeChild(element.firstChild);
} }
if (this.props.element.classList.contains('visible')) { if (element.classList.contains('visible')) {
this.props.element.classList.remove('visible'); element.classList.remove('visible');
} }
}) })
.declareMethod('render', function (url, options) { .declareMethod('render', function (url, options) {
this.element.classList.toggle('visible');
return this.changeState({
url: url,
options: JSON.stringify(options)
});
})
.onStateChange(function (modification_dict) {
var gadget = this, var gadget = this,
declared_gadget; declared_gadget;
if (url && JSON.stringify(gadget.props.options) !== JSON.stringify(options)) { if (gadget.state.url && modification_dict.hasOwnProperty('options')) {
gadget.props.options = options; return gadget.declareGadget(gadget.state.url,
return new RSVP.Queue() {scope: "declared_gadget"})
.push(function () {
return gadget.declareGadget(url, {scope: "declared_gadget"});
})
.push(function (result) { .push(function (result) {
declared_gadget = result; declared_gadget = result;
return declared_gadget.render(options); return declared_gadget.render(JSON.parse(gadget.state.options));
}) })
.push(function () { .push(function () {
return RSVP.all([ return gadget.close();
gadget.close(),
declared_gadget.getElement()
]);
}) })
.push(function (result) { .push(function () {
var fragment = result[1]; gadget.element.appendChild(declared_gadget.element);
gadget.props.container.appendChild(fragment); gadget.element.classList.toggle('visible');
gadget.props.element.classList.toggle('visible');
}); });
} }
gadget.props.element.classList.toggle('visible');
}); });
}(window, rJS, RSVP)); }(window, rJS));
\ No newline at end of file \ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>953.42201.31550.52070</string> </value> <value> <string>954.35625.39214.6929</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1472808729.65</float> <float>1476259803.78</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