diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDecoder.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDecoder.js index 0c15288cc..4338cc231 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDecoder.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDecoder.js @@ -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 = {})); \ No newline at end of file +})(jQuery, LayoutEditor || (LayoutEditor = {})); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js index 8bd1b1dd6..b329d6bb1 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js @@ -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"); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml index f76b63940..59bd542b8 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml @@ -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 },