Simplified URL encoding/decoding of layout editor data.

This also fixes an issue with certain rendered HTML as part of he element editor model object.
This commit is contained in:
Sipke Schoorstra
2015-04-10 17:38:48 +02:00
parent 05faccd722
commit 1f3c5cc1a4
3 changed files with 4 additions and 31 deletions

View File

@@ -5,30 +5,6 @@
return !!value ? decodeURIComponent(value.replace(/\+/g, "%20")) : null;
};
var decodeGraph = function (graph) {
if (!!graph.html) {
graph.html = decode(graph.html);
}
if (!!graph.data) {
var items = $.deserialize(graph.data);
for (var i = 0; i < items.length; i++) {
items[i] = decode(items[i]);
}
graph.data = $.param(items);
}
if (!!graph.children) {
for (var i = 0; i < graph.children.length; i++) {
decodeGraph(graph.children[i]);
}
}
};
LayoutEditor.decode = decode;
LayoutEditor.decodeLayoutGraph = decodeGraph;
})(jQuery, LayoutEditor || (LayoutEditor = {}));

View File

@@ -43,10 +43,9 @@
}
});
(function() {
var editorConfig = @Html.Raw(Model.ConfigurationData);
var editorCanvasData = @Html.Raw(Model.Data);
var editorConfig = JSON.parse(LayoutEditor.decode("@Html.Raw(Url.Encode(Model.ConfigurationData))"));
var editorCanvasData = JSON.parse(LayoutEditor.decode("@Html.Raw(Url.Encode(Model.Data))"));
LayoutEditor.decodeLayoutGraph(editorCanvasData);
window.layoutEditor = new LayoutEditor.Editor(editorConfig, editorCanvasData);
})(jQuery);
</script>

View File

@@ -43,11 +43,9 @@
html: LayoutEditor.decode("@Url.Encode(Model.ElementHtml)"),
isTemplated: false
},
elementEditorModel: @Html.Raw(Model.ElementEditorModel.ToJson())
elementEditorModel: LayoutEditor.decode("@Html.Raw(Url.Encode(Model.ElementEditorModel.ToJson()))")
};
LayoutEditor.decodeLayoutGraph(payload.element);
LayoutEditor.decodeLayoutGraph(payload.elementEditorModel);
window.parent.currentDialog.trigger("command", payload);
});
</script>