Commit bb044324 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Simplify editor panel implementation

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