mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
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:
@@ -1,34 +1,10 @@
|
||||
var LayoutEditor;
|
||||
(function ($, LayoutEditor) {
|
||||
|
||||
var decode = function(value) {
|
||||
var decode = function (value) {
|
||||
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 = {}));
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user