mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Further Layouts client-side scripting improvements.
- Pushed the editElement function further down from Content to Element, which means even less code for custom container elements. - Fixed a bug where client-side element editor state would not be applied after editing that element. - Pushed down the toObject function from Content to Element, which means less code is necessary for custom container elements. -
This commit is contained in:
@@ -8,20 +8,7 @@
|
||||
controller: ["$scope", "$element",
|
||||
function ($scope, $element) {
|
||||
scopeConfigurator.configureForElement($scope, $element);
|
||||
if ($scope.element.hasEditor) {
|
||||
$scope.edit = function () {
|
||||
$scope.$root.editElement($scope.element).then(function (args) {
|
||||
$scope.$apply(function () {
|
||||
if (args.cancel)
|
||||
return;
|
||||
|
||||
$scope.element.data = args.element.data;
|
||||
$scope.element.setHtml(args.element.html);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Overwrite the setHtml function so that we can use the $sce service to trust the html (and not have the html binding strip certain tags).
|
||||
$scope.element.setHtml = function (html) {
|
||||
$scope.element.html = html;
|
||||
|
@@ -159,6 +159,10 @@
|
||||
return;
|
||||
|
||||
$scope.element.data = args.element.data;
|
||||
$scope.element.applyElementEditorModel(args.elementEditorModel);
|
||||
|
||||
if (!!$scope.element.setHtml)
|
||||
$scope.element.setHtml(args.element.html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@@ -20,19 +20,12 @@
|
||||
this.htmlUnsafe = html;
|
||||
}
|
||||
|
||||
var baseToObject = this.toObject;
|
||||
this.toObject = function () {
|
||||
return {
|
||||
"type": "Content"
|
||||
};
|
||||
};
|
||||
|
||||
this.toObject = function () {
|
||||
var result = this.elementToObject();
|
||||
result.contentType = this.contentType;
|
||||
var result = baseToObject();
|
||||
result.contentTypeLabel = this.contentTypeLabel;
|
||||
result.contentTypeClass = this.contentTypeClass;
|
||||
result.html = this.html;
|
||||
result.hasEditor = hasEditor;
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
if (!type)
|
||||
throw new Error("Parameter 'type' is required.");
|
||||
|
||||
var self = this;
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
this.htmlId = htmlId;
|
||||
@@ -164,7 +165,9 @@
|
||||
htmlClass: this.htmlClass,
|
||||
htmlStyle: this.htmlStyle,
|
||||
isTemplated: this.isTemplated,
|
||||
rule: this.rule
|
||||
rule: this.rule,
|
||||
contentType: this.contentType,
|
||||
hasEditor: this.hasEditor
|
||||
};
|
||||
};
|
||||
|
||||
@@ -172,6 +175,10 @@
|
||||
return {};
|
||||
};
|
||||
|
||||
this.toObject = function () {
|
||||
return self.elementToObject();
|
||||
};
|
||||
|
||||
this.copy = function (clipboardData) {
|
||||
var text = this.getInnerText();
|
||||
clipboardData.setData("text/plain", text);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user