mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixed url encoding / decoding issues.
This change consistifies when and where data and html properties are being URL decoded.
This commit is contained in:
@@ -133,7 +133,7 @@
|
||||
<Content Include="Scripts\Models\Grid.js" />
|
||||
<Content Include="Scripts\Models\Helpers.js" />
|
||||
<Content Include="Scripts\Models\Row.js" />
|
||||
<Content Include="Scripts\serializer.js" />
|
||||
<Content Include="Scripts\LayoutDecoder.js" />
|
||||
<Content Include="Scripts\dialog.js" />
|
||||
<Content Include="Scripts\designer.canvas.js" />
|
||||
<Content Include="Data\Canvas.json" />
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
var 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(!!propVal)
|
||||
graph[prop] = decode(propVal);
|
||||
}
|
||||
|
||||
if (!!graph.children) {
|
||||
for (var i = 0; i < graph.children.length; i++) {
|
||||
decodeGraph(graph.children[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LayoutEditor.DecodeLayoutGraph = decodeGraph;
|
||||
|
||||
})(LayoutEditor || (LayoutEditor = {}));
|
||||
@@ -273,8 +273,8 @@ angular
|
||||
if (receivedElement.type == "Content" && !!receivedElement.hasEditor) {
|
||||
$scope.$root.editElement(receivedElement).then(function (args) {
|
||||
if (!args.cancel) {
|
||||
receivedElement.data = decodeURIComponent(args.element.data);
|
||||
receivedElement.setHtml(decodeURIComponent(args.element.html.replace(/\+/g, "%20")));
|
||||
receivedElement.data = args.element.data;
|
||||
receivedElement.setHtml(args.element.html);
|
||||
}
|
||||
$timeout(function () {
|
||||
if (!!args.cancel)
|
||||
@@ -644,8 +644,8 @@ angular
|
||||
if (args.cancel)
|
||||
return;
|
||||
|
||||
$scope.element.data = decodeURIComponent(args.element.data);
|
||||
$scope.element.setHtml(decodeURIComponent(args.element.html.replace(/\+/g, "%20")));
|
||||
$scope.element.data = args.element.data;
|
||||
$scope.element.setHtml(args.element.html);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -659,7 +659,7 @@ angular
|
||||
$scope.element.htmlUnsafe = $sce.trustAsHtml(html);
|
||||
};
|
||||
|
||||
$scope.element.setHtml(decodeURIComponent($scope.element.html.replace(/\+/g, "%20")));
|
||||
$scope.element.setHtml($scope.element.html);
|
||||
}
|
||||
],
|
||||
templateUrl: environment.templateUrl("Content"),
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -14,8 +14,8 @@
|
||||
if (args.cancel)
|
||||
return;
|
||||
|
||||
$scope.element.data = decodeURIComponent(args.element.data);
|
||||
$scope.element.setHtml(decodeURIComponent(args.element.html.replace(/\+/g, "%20")));
|
||||
$scope.element.data = args.element.data;
|
||||
$scope.element.setHtml(args.element.html);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -29,7 +29,7 @@
|
||||
$scope.element.htmlUnsafe = $sce.trustAsHtml(html);
|
||||
};
|
||||
|
||||
$scope.element.setHtml(decodeURIComponent($scope.element.html.replace(/\+/g, "%20")));
|
||||
$scope.element.setHtml($scope.element.html);
|
||||
}
|
||||
],
|
||||
templateUrl: environment.templateUrl("Content"),
|
||||
|
||||
+2
-2
@@ -240,8 +240,8 @@
|
||||
if (receivedElement.type == "Content" && !!receivedElement.hasEditor) {
|
||||
$scope.$root.editElement(receivedElement).then(function (args) {
|
||||
if (!args.cancel) {
|
||||
receivedElement.data = decodeURIComponent(args.element.data);
|
||||
receivedElement.setHtml(decodeURIComponent(args.element.html.replace(/\+/g, "%20")));
|
||||
receivedElement.data = args.element.data;
|
||||
receivedElement.setHtml(args.element.html);
|
||||
}
|
||||
$timeout(function () {
|
||||
if (!!args.cancel)
|
||||
|
||||
@@ -919,7 +919,7 @@ var LayoutEditor;
|
||||
value.contentType,
|
||||
value.contentTypeLabel,
|
||||
value.contentTypeClass,
|
||||
decodeURIComponent(value.html.replace(/\+/g, "%20")),
|
||||
value.html,
|
||||
value.hasEditor);
|
||||
|
||||
return result;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -57,7 +57,7 @@
|
||||
value.contentType,
|
||||
value.contentTypeLabel,
|
||||
value.contentTypeClass,
|
||||
decodeURIComponent(value.html.replace(/\+/g, "%20")),
|
||||
value.html,
|
||||
value.hasEditor);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
elements: [
|
||||
{
|
||||
typeName: data.element.typeName,
|
||||
data: data.element.data ? decodeURIComponent(data.element.data) : null
|
||||
data: data.element.data
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
this.refreshElement = function (elementUI, elementData) {
|
||||
// Serialize the element UI into an object graph.
|
||||
var graph = {};
|
||||
var data = elementData ? decodeURIComponent(elementData) : null;
|
||||
var data = elementData;
|
||||
var stateFormValues = data ? $.deserialize(data) : null;
|
||||
var formData = $.extend({}, stateFormValues);
|
||||
window.Orchard.Layouts.Serializer.serialize(graph, elementUI);
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
(function ($) {
|
||||
|
||||
var serializer = {
|
||||
serialize: function (graph, scope) {
|
||||
scope = scope.wrap("<div></div>").parent();
|
||||
serializeInternal(graph, scope);
|
||||
return graph;
|
||||
},
|
||||
|
||||
deserialize: function() {
|
||||
var layoutEditor = $(".layout-editor");
|
||||
var form = layoutEditor.closest("form");
|
||||
var stateFieldName = layoutEditor.data("Data-field-name");
|
||||
var stateField = form.find("input[name=\"" + stateFieldName + "\"]");
|
||||
return JSON.parse(stateField.val());
|
||||
}
|
||||
};
|
||||
|
||||
var serializeInternal = function (graph, scope) {
|
||||
var children = scope.children();
|
||||
var index = 0;
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = $(children.get(i));
|
||||
var isElement = child.hasClass("x-element");
|
||||
var subGraph = graph;
|
||||
|
||||
if (isElement) {
|
||||
var elementData = child.data("element");
|
||||
var elements = graph.elements = graph.elements || [];
|
||||
var element = {
|
||||
typeName: elementData.typeName,
|
||||
state: elementData.state,
|
||||
settings: elementData.settings,
|
||||
index: elementData.index || index,
|
||||
isTemplated: elementData.isTemplated || false
|
||||
};
|
||||
elements.push(element);
|
||||
subGraph = element;
|
||||
index++;
|
||||
}
|
||||
|
||||
serializeInternal(subGraph, child);
|
||||
}
|
||||
}
|
||||
|
||||
// Export types.
|
||||
window.Orchard = window.Orchard || {};
|
||||
window.Orchard.Layouts = window.Orchard.Layouts || {};
|
||||
window.Orchard.Layouts.Serializer = serializer;
|
||||
})(jQuery);
|
||||
@@ -21,7 +21,7 @@
|
||||
Style.Include("dialog.css");
|
||||
Script.Include("dialog.js");
|
||||
Script.Include("frame.js");
|
||||
Script.Include("serializer.js");
|
||||
Script.Include("LayoutDecoder.js");
|
||||
|
||||
// The actual layout editor.
|
||||
Style.Include("LayoutEditor.css", "LayoutEditor.min.css");
|
||||
@@ -39,6 +39,8 @@
|
||||
(function() {
|
||||
var editorConfig = @Html.Raw(Model.ConfigurationData);
|
||||
var editorCanvasData = @Html.Raw(Model.Data);
|
||||
|
||||
LayoutEditor.DecodeLayoutGraph(editorCanvasData);
|
||||
window.layoutEditor = new LayoutEditor.Editor(editorConfig, editorCanvasData);
|
||||
})(jQuery);
|
||||
</script>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@{
|
||||
Style.Include("element-editor.css");
|
||||
Script.Require("jQuery");
|
||||
Script.Include("LayoutDecoder.js");
|
||||
Script.Include("element-editor.js");
|
||||
Layout.LocalNavigation.Add(New.ElementEditor_LocalNav(Tabs: Model.Tabs));
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
window.parent.currentDialog.trigger("command", {
|
||||
var payload = {
|
||||
command: "@command",
|
||||
element: {
|
||||
typeName: "@Model.TypeName",
|
||||
@@ -42,7 +43,11 @@
|
||||
isTemplated: false
|
||||
},
|
||||
elementEditorModel: @Html.Raw(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