Commit 534cfe50 authored by Romain Courteaud's avatar Romain Courteaud

erp5_svg_editor: update gadget to match new version

parent c68eb814
/*jslint indent: 2 */ /*jslint indent: 2 */
/*global window, rJS, RSVP, curConfig, svgCanvas */ /*global window, rJS, RSVP, svgCanvas */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP) {
"use strict"; "use strict";
curConfig.jGraduatePath = "lib/jgraduate/images/"; // XXX images are not loaded at the good place
rJS(window) rJS(window)
.ready(function (g) {
g.props = {};
var deferred = RSVP.defer();
svgCanvas.ready(function () {
deferred.resolve();
});
return deferred.promise;
})
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
[].forEach.call(window.document.head.querySelectorAll("base"), function (el) { return this.changeState({
// XXX GadgetField adds <base> tag to fit to the parent page location, it's BAD to remove them. key: options.key,
// In the case of method-draw, all component are loaded dynamicaly through ajax requests in value: options.value
// method-draw "folder". By setting a <base> tag, we change the url resolution behavior, and
// we break all dynamic links. So, deleting <base> is required.
window.document.head.removeChild(el);
}); });
this.props.key = options.key; })
svgCanvas.setSvgString(options.value); .onStateChange(function () {
svgCanvas.setSvgString(this.state.value);
}) })
.declareService(function () { .declareService(function () {
if (/(?:^\?|&)auto_focus=(true|1)(?:&|$)/.test(window.location.search)) { if (/(?:^\?|&)auto_focus=(true|1)(?:&|$)/.test(window.location.search)) {
...@@ -32,8 +20,9 @@ ...@@ -32,8 +20,9 @@
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var form_data = {}; var form_data = {};
form_data[this.props.key] = svgCanvas.getSvgString(); form_data[this.state.key] = svgCanvas.getSvgString();
this.state.value = form_data[this.state.key]
return form_data; return form_data;
}); }, {mutex: 'statechange'});
}(window, rJS, RSVP)); }(window, rJS, RSVP));
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