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 @@
<title>Text editor gadget</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_global.js"></script>
<script src="gadget_editor.js"></script>
</head>
<body>
......
/*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, FileReader, Blob*/
(function (window, rJS, RSVP, document, FileReader, Blob) {
/*global window, rJS, RSVP, document, FileReader, Blob,
lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(function (window, rJS, RSVP, document, FileReader, Blob,
lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue) {
"use strict";
/*
......@@ -55,7 +57,7 @@
url,
div = document.createElement('div'),
div_max = document.createElement('div'),
queue = new RSVP.Queue();
queue = lockGadgetInQueue(gadget)();
if ((modification_dict.hasOwnProperty('editable')) ||
(modification_dict.hasOwnProperty('editor'))) {
......@@ -139,18 +141,24 @@
} else {
element.querySelector('pre').textContent = gadget.state.value;
}
return queue;
return queue
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
})
.declareMethod('getContent', function () {
var argument_list = arguments,
gadget = this,
result;
if (this.state.editable &&
((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) {
return editor_gadget.getContent.apply(editor_gadget, argument_list);
});
})
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
/*
.push(function (result) {
var value = result[context.state.key] || '';
......@@ -171,4 +179,5 @@
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