Commit 039caf1e authored by Romain Courteaud's avatar Romain Courteaud

erp5_svg_editor: update gadget to match new version

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