mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Improved handling of layout editor data encoding/decoding.
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
var LayoutEditor;
|
||||
(function (LayoutEditor) {
|
||||
(function ($, LayoutEditor) {
|
||||
|
||||
var decode = function(value) {
|
||||
return !!value ? decodeURIComponent(value.replace(/\+/g, "%20")) : null;
|
||||
};
|
||||
|
||||
var decodeGraph = function (graph) {
|
||||
var propertiesToDecode = ["data", "html"];
|
||||
|
||||
for (var i = 0; i < propertiesToDecode.length; i++) {
|
||||
var prop = propertiesToDecode[i];
|
||||
var propVal = graph[prop];
|
||||
if (!!graph.html) {
|
||||
graph.html = decode(graph.html);
|
||||
}
|
||||
|
||||
if(!!propVal)
|
||||
graph[prop] = decode(propVal);
|
||||
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) {
|
||||
@@ -23,6 +28,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
LayoutEditor.decode = decode;
|
||||
LayoutEditor.decodeLayoutGraph = decodeGraph;
|
||||
|
||||
})(LayoutEditor || (LayoutEditor = {}));
|
||||
})(jQuery, LayoutEditor || (LayoutEditor = {}));
|
@@ -33,14 +33,14 @@
|
||||
if (!element.isTemplated) {
|
||||
var elementType = element.contentType;
|
||||
var elementData = element.data;
|
||||
var elementEditorData = element.getEditorObject();
|
||||
var elementEditorData = $.param(element.getEditorObject());
|
||||
var dialog = new window.Orchard.Layouts.Dialog(".dialog-template." + self.settings.editorDialogName);
|
||||
|
||||
dialog.show();
|
||||
dialog.load(self.settings.endpoints.edit, {
|
||||
typeName: elementType,
|
||||
elementData: elementData,
|
||||
elementEditorData: $.param(elementEditorData),
|
||||
elementEditorData: elementEditorData,
|
||||
__RequestVerificationToken: self.settings.antiForgeryToken
|
||||
}, "post");
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
@{
|
||||
Style.Include("element-editor.css");
|
||||
Script.Require("jQuery");
|
||||
Script.Include("jquery.deserialize.js");
|
||||
Script.Include("LayoutDecoder.js");
|
||||
Script.Include("element-editor.js");
|
||||
Layout.LocalNavigation.Add(New.ElementEditor_LocalNav(Tabs: Model.Tabs));
|
||||
@@ -38,7 +39,7 @@
|
||||
typeName: "@Model.TypeName",
|
||||
typeLabel: "@Model.DisplayText.Text",
|
||||
typeClass: "@Model.DisplayText.Text.HtmlClassify()",
|
||||
data: "@Url.Encode(Model.ElementData)",
|
||||
data: LayoutEditor.decode("@Url.Encode(Model.ElementData)"),
|
||||
html: "@Url.Encode(Model.ElementHtml)",
|
||||
isTemplated: false
|
||||
},
|
||||
|
Reference in New Issue
Block a user