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