Commit 52e8b364 authored by Vincent Bechu's avatar Vincent Bechu

[erp5_core][erp5_web_renderjs_ui] lock editor gadget on render and get content

And move gadget global
parent ef4e6927
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<title>Text editor gadget</title> <title>Text editor gadget</title>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="gadget_global.js"></script>
<script src="gadget_editor.js"></script> <script src="gadget_editor.js"></script>
</head> </head>
<body> <body>
......
/*jslint nomen: true, indent: 2 */ /*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, FileReader, Blob*/ /*global window, rJS, RSVP, document, FileReader, Blob,
(function (window, rJS, RSVP, document, FileReader, Blob) { lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(function (window, rJS, RSVP, document, FileReader, Blob,
lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue) {
"use strict"; "use strict";
/* /*
...@@ -55,7 +57,7 @@ ...@@ -55,7 +57,7 @@
url, url,
div = document.createElement('div'), div = document.createElement('div'),
div_max = document.createElement('div'), div_max = document.createElement('div'),
queue = new RSVP.Queue(); queue = lockGadgetInQueue(gadget)();
if ((modification_dict.hasOwnProperty('editable')) || if ((modification_dict.hasOwnProperty('editable')) ||
(modification_dict.hasOwnProperty('editor'))) { (modification_dict.hasOwnProperty('editor'))) {
...@@ -139,18 +141,24 @@ ...@@ -139,18 +141,24 @@
} else { } else {
element.querySelector('pre').textContent = gadget.state.value; element.querySelector('pre').textContent = gadget.state.value;
} }
return queue; return queue
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var argument_list = arguments, var argument_list = arguments,
gadget = this,
result; result;
if (this.state.editable && if (this.state.editable &&
((this.state.editor === 'codemirror') || (this.state.editor === 'fck_editor'))) { ((this.state.editor === 'codemirror') || (this.state.editor === 'fck_editor'))) {
return this.getDeclaredGadget('editor') return lockGadgetInQueue(gadget)()
.push(function () {
return gadget.getDeclaredGadget('editor');
})
.push(function (editor_gadget) { .push(function (editor_gadget) {
return editor_gadget.getContent.apply(editor_gadget, argument_list); return editor_gadget.getContent.apply(editor_gadget, argument_list);
}); })
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
/* /*
.push(function (result) { .push(function (result) {
var value = result[context.state.key] || ''; var value = result[context.state.key] || '';
...@@ -171,4 +179,5 @@ ...@@ -171,4 +179,5 @@
return {}; return {};
}); });
}(window, rJS, RSVP, document, FileReader, Blob)); }(window, rJS, RSVP, document, FileReader, Blob,
lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue));
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>gadget_global.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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