From 9715ee88df1ec9f381f235ff475d479922a29257 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 20 Dec 2015 16:28:36 +0100 Subject: [PATCH] Removed unnecessary Html model map. The Html model mapping was originally needed to support inline editing of Html elements, but that capability has been removed. --- .../LayoutEditor/Directives/Html.js | 41 ----------- .../Assets/JavaScript/Models/Html.js | 70 ------------------- .../Orchard.Layouts/Orchard.Layouts.csproj | 5 -- .../Services/DefaultModelMaps.cs | 28 -------- .../Views/LayoutEditor.Template.Html.cshtml | 11 --- 5 files changed, 155 deletions(-) delete mode 100644 src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/LayoutEditor/Directives/Html.js delete mode 100644 src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/Models/Html.js delete mode 100644 src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Html.cshtml diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/LayoutEditor/Directives/Html.js b/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/LayoutEditor/Directives/Html.js deleted file mode 100644 index 94890f1d6..000000000 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/LayoutEditor/Directives/Html.js +++ /dev/null @@ -1,41 +0,0 @@ -angular - .module("LayoutEditor") - .directive("orcLayoutHtml", ["$sce", "scopeConfigurator", "environment", - function ($sce, scopeConfigurator, environment) { - return { - restrict: "E", - scope: { element: "=" }, - controller: ["$scope", "$element", - function ($scope, $element) { - scopeConfigurator.configureForElement($scope, $element); - $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); - }); - }); - }; - $scope.updateContent = function (e) { - $scope.element.setHtml(e.target.innerHTML); - }; - - // 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; - $scope.element.htmlUnsafe = $sce.trustAsHtml(html); - }; - - $scope.element.setHtml($scope.element.html); - } - ], - templateUrl: environment.templateUrl("Html"), - replace: true, - link: function (scope, element) { - } - }; - } - ]); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/Models/Html.js b/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/Models/Html.js deleted file mode 100644 index fd62a1b3e..000000000 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Assets/JavaScript/Models/Html.js +++ /dev/null @@ -1,70 +0,0 @@ -var LayoutEditor; -(function ($, LayoutEditor) { - - LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) { - LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated, rule); - - this.contentType = contentType; - this.contentTypeLabel = contentTypeLabel; - this.contentTypeClass = contentTypeClass; - this.html = html; - this.hasEditor = hasEditor; - this.isContainable = true; - - this.getInnerText = function () { - return $($.parseHTML("
" + this.html + "
")).text(); - }; - - // This function will be overwritten by the Content directive. - this.setHtml = function (html) { - this.html = html; - this.htmlUnsafe = html; - } - - this.toObject = function () { - return { - "type": "Html" - }; - }; - - this.toObject = function () { - var result = this.elementToObject(); - result.contentType = this.contentType; - result.contentTypeLabel = this.contentTypeLabel; - result.contentTypeClass = this.contentTypeClass; - result.html = this.html; - result.hasEditor = hasEditor; - return result; - }; - - var getEditorObject = this.getEditorObject; - this.getEditorObject = function () { - var dto = getEditorObject(); - return $.extend(dto, { - Content: this.html - }); - } - - this.setHtml(html); - }; - - LayoutEditor.Html.from = function (value) { - var result = new LayoutEditor.Html( - value.data, - value.htmlId, - value.htmlClass, - value.htmlStyle, - value.isTemplated, - value.contentType, - value.contentTypeLabel, - value.contentTypeClass, - value.html, - value.hasEditor, - value.rule); - - return result; - }; - - LayoutEditor.registerFactory("Html", function(value) { return LayoutEditor.Html.from(value); }); - -})(jQuery, LayoutEditor || (LayoutEditor = {})); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj index 07dc77758..f2b68b6b3 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj @@ -94,7 +94,6 @@ - @@ -114,7 +113,6 @@ - @@ -512,9 +510,6 @@ - - - diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs index d463892ee..1eb51b9f9 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs @@ -134,34 +134,6 @@ namespace Orchard.Layouts.Services { } } - public class HtmlModelMap : ContentModelMap { - public HtmlModelMap(IShapeDisplay shapeDisplay, IElementDisplay elementDisplay) - : base(shapeDisplay, elementDisplay) { - } - - public override int Priority { - get { return 1; } - } - - public override string LayoutElementType { - get { return "Html"; } - } - - public override bool CanMap(Element element) { - return element is Html; - } - - public override Element ToElement(IElementManager elementManager, DescribeElementsContext describeContext, JToken node) { - var html = (string)node["html"]; - var element = (Html)base.ToElement(elementManager, describeContext, node); - - // To support inline editing, we need to update the element's content. - element.Content = html; - - return element; - } - } - public class RecycleBinModelMap : ILayoutModelMap { public int Priority { get { return 0; } } public string LayoutElementType { get { return "RecycleBin"; } } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Html.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Html.cshtml deleted file mode 100644 index 3c229860a..000000000 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Html.cshtml +++ /dev/null @@ -1,11 +0,0 @@ -
-
    -
  • {{::element.contentTypeLabel}}
  • -
  • - @Display(New.LayoutEditor_Template_Properties(ElementTypeName: "{{element.contentTypeLabel.toLowerCase()}}")) -
  • -
  • -
  • -
-
-
\ No newline at end of file