diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs index 50f0aa89b..b4698ad9a 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs @@ -1,9 +1,17 @@ -using Orchard.Layouts.Elements; +using System.Collections.Generic; +using System.Linq; +using Orchard.Layouts.Elements; +using Orchard.Layouts.Framework.Display; using Orchard.Layouts.Framework.Drivers; using Orchard.Layouts.ViewModels; +using Orchard.Services; namespace Orchard.Layouts.Drivers { public class HtmlElementDriver : ElementDriver { + private readonly IEnumerable _htmlFilters; + public HtmlElementDriver(IEnumerable htmlFilters) { + _htmlFilters = htmlFilters; + } protected override EditorResult OnBuildEditor(Html element, ElementEditorContext context) { var viewModel = new HtmlEditorViewModel { @@ -18,5 +26,17 @@ namespace Orchard.Layouts.Drivers { return Editor(context, editor); } + + protected override void OnDisplaying(Html element, ElementDisplayContext context) { + var text = element.Content; + var flavor = "html"; + var processedText = ApplyHtmlFilters(text, flavor); + + context.ElementShape.ProcessedText = processedText; + } + + private string ApplyHtmlFilters(string content, string flavor) { + return _htmlFilters.Aggregate(content, (t, filter) => filter.ProcessContent(t, flavor)); + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ParagraphElementDriver.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ParagraphElementDriver.cs index 09a2c51c1..67b440537 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ParagraphElementDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ParagraphElementDriver.cs @@ -1,9 +1,17 @@ -using Orchard.Layouts.Elements; +using System.Collections.Generic; +using System.Linq; +using Orchard.Layouts.Elements; +using Orchard.Layouts.Framework.Display; using Orchard.Layouts.Framework.Drivers; using Orchard.Layouts.ViewModels; +using Orchard.Services; namespace Orchard.Layouts.Drivers { public class ParagraphElementDriver : ElementDriver { + private readonly IEnumerable _htmlFilters; + public ParagraphElementDriver(IEnumerable htmlFilters) { + _htmlFilters = htmlFilters; + } protected override EditorResult OnBuildEditor(Paragraph element, ElementEditorContext context) { var viewModel = new ParagraphEditorViewModel { @@ -18,5 +26,17 @@ namespace Orchard.Layouts.Drivers { return Editor(context, editor); } + + protected override void OnDisplaying(Paragraph element, ElementDisplayContext context) { + var text = element.Content; + var flavor = "html"; + var processedText = ApplyHtmlFilters(text, flavor); + + context.ElementShape.ProcessedText = processedText; + } + + private string ApplyHtmlFilters(string content, string flavor) { + return _htmlFilters.Aggregate(content, (t, filter) => filter.ProcessContent(t, flavor)); + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/TextElementDriver.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/TextElementDriver.cs index feb1a7ea9..e4d6f0500 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/TextElementDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/TextElementDriver.cs @@ -14,17 +14,14 @@ namespace Orchard.Layouts.Drivers { } protected override EditorResult OnBuildEditor(Text element, ElementEditorContext context) { - var flavor = GetFlavor(); - var viewModel = new TextEditorViewModel { - Flavor = flavor, - Text = element.Content + Content = element.Content }; var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Text", Model: viewModel); if (context.Updater != null) { context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null); - element.Content = viewModel.Text; + element.Content = viewModel.Content; } return Editor(context, editor); @@ -32,18 +29,14 @@ namespace Orchard.Layouts.Drivers { protected override void OnDisplaying(Text element, ElementDisplayContext context) { var text = element.Content; - var flavor = GetFlavor(); - var processedText = ToHtml(text, flavor); + var flavor = "textarea"; + var processedText = ApplyHtmlFilters(text, flavor); context.ElementShape.ProcessedText = processedText; } - private string ToHtml(string content, string flavor) { + private string ApplyHtmlFilters(string content, string flavor) { return _htmlFilters.Aggregate(content, (t, filter) => filter.ProcessContent(t, flavor)); } - - private static string GetFlavor() { - return "textarea"; - } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/ContentElement.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/ContentElement.cs similarity index 61% rename from src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/ContentElement.cs rename to src/Orchard.Web/Modules/Orchard.Layouts/Elements/ContentElement.cs index b6a54f1f4..e554f9a17 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/ContentElement.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/ContentElement.cs @@ -1,7 +1,8 @@ -using Orchard.Layouts.Helpers; +using Orchard.Layouts.Framework.Elements; +using Orchard.Layouts.Helpers; -namespace Orchard.Layouts.Framework.Elements { - public abstract class ContentElement : Element, IContentElement { +namespace Orchard.Layouts.Elements { + public abstract class ContentElement : Element { public override string Category { get { return "Content"; } } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Html.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Html.cs index 4cbcce954..17edf5806 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Html.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Html.cs @@ -1,4 +1,3 @@ -using Orchard.Layouts.Framework.Elements; using Orchard.Localization; namespace Orchard.Layouts.Elements { diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Paragraph.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Paragraph.cs index 54e728c7e..663efb027 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Paragraph.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Paragraph.cs @@ -1,5 +1,3 @@ -using Orchard.Layouts.Framework.Elements; - namespace Orchard.Layouts.Elements { public class Paragraph : ContentElement { public override string ToolboxIcon { diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Text.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Text.cs index a46d6fd85..3abfa7e05 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Text.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Text.cs @@ -1,5 +1,3 @@ -using Orchard.Layouts.Framework.Elements; - namespace Orchard.Layouts.Elements { public class Text : ContentElement { public override string ToolboxIcon { diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/IContentElement.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/IContentElement.cs deleted file mode 100644 index 62653182a..000000000 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Elements/IContentElement.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Orchard.Layouts.Framework.Elements { - public interface IContentElement { - string Content { get; set; } - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Module.txt b/src/Orchard.Web/Modules/Orchard.Layouts/Module.txt index 1f5447874..b128089f6 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Module.txt @@ -29,6 +29,6 @@ Features: Dependencies: Orchard.Layouts, Orchard.Projections Orchard.Layouts.Tokens: Name: Element Tokens - Description: Provides an element token provider, enabling elements to be rendered using a token. + Description: Provides an element token provider that enables elements to be rendered using a token and enables tokens to be used inside of various elements such as Html, Text and Paragraph. Category: Layout Dependencies: Orchard.Layouts, Orchard.Tokens diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj index 8f354889d..b428dc728 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj @@ -99,6 +99,7 @@ LayoutEditor.js + @@ -130,6 +131,7 @@ + @@ -419,6 +421,7 @@ + @@ -437,8 +440,6 @@ - - @@ -612,6 +613,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js index b329d6bb1..48d076f9f 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutDesignerHost.js @@ -63,42 +63,6 @@ return deferred.promise(); }; - //this.addElement = function (contentType) { - // var elementType = contentType.id; - // var deferred = new $.Deferred(); - // var dialog = new window.Orchard.Layouts.Dialog(".dialog-template." + self.settings.editorDialogName); - - // if (contentType.hasEditor) { - // var url = self.settings.endpoints.add + "&typeName=" + elementType; - - // dialog.show(); - // dialog.load(url); - - // dialog.element.on("command", function(e, args) { - // if (args.command == "add" || args.command == "save") { - // deferred.resolve(args); - // dialog.close(); - // } - // }); - // } else { - // var url = self.settings.endpoints.addDirect; - - // $.ajax(url, { - // data: { - // typeName: elementType, - // __RequestVerificationToken: self.settings.antiForgeryToken - // }, - // type: "POST" - // }).then(function(response) { - // deferred.resolve({ - // element: response - // }); - // }); - // } - - // return deferred.promise(); - //}; - var serializeCanvas = function () { var layoutData = self.editor.canvas.toObject(); return JSON.stringify(layoutData, null, "\t"); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js index ae606092e..1831ba8de 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js @@ -430,7 +430,7 @@ angular if (!$scope.element.inlineEditingIsActive) { $scope.element.inlineEditingIsActive = true; $element.find(".layout-toolbar-container").show(); - var selector = "#layout-editor-" + $scope.$id + " .layout-content-h-t-m-l .layout-content-markup[data-templated=false]"; + var selector = "#layout-editor-" + $scope.$id + " .layout-html .layout-content-markup[data-templated=false]"; var firstContentEditorId = $(selector).first().attr("id"); tinymce.init({ selector: selector, @@ -631,6 +631,42 @@ angular angular .module("LayoutEditor") .directive("orcLayoutContent", ["$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); + }); + }); + }; + + // 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("Content"), + replace: true + }; + } + ]); +angular + .module("LayoutEditor") + .directive("orcLayoutHtml", ["$sce", "scopeConfigurator", "environment", function ($sce, scopeConfigurator, environment) { return { restrict: "E", @@ -662,7 +698,7 @@ angular $scope.element.setHtml($scope.element.html); } ], - templateUrl: environment.templateUrl("Content"), + templateUrl: environment.templateUrl("Html"), replace: true, link: function (scope, element) { // Mouse down events must not be intercepted by drag and drop while inline editing is active, diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js.bundle b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js.bundle index dbbfb14f1..0d21a726a 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js.bundle +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.js.bundle @@ -18,6 +18,7 @@ LayoutEditor/Directives/Child.js LayoutEditor/Directives/Column.js LayoutEditor/Directives/Content.js + LayoutEditor/Directives/Html.js LayoutEditor/Directives/Grid.js LayoutEditor/Directives/Row.js LayoutEditor/Directives/Popup.js diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.min.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.min.js index f474f0923..a03872e11 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.min.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor.min.js @@ -1 +1 @@ -angular.module("LayoutEditor",["ngSanitize","ngResource","ui.sortable"]);var LayoutEditor;(function(n){var t=function(){var n=this;this.clipboardData={};this.setData=function(t,i){n.clipboardData[t]=i};this.getData=function(t){return n.clipboardData[t]};this.disable=function(){this.disabled=!0}};n.Clipboard=new t;angular.module("LayoutEditor").factory("clipboard",[function(){return{setData:n.Clipboard.setData,getData:n.Clipboard.getData,disable:n.Clipboard.disable}}])})(LayoutEditor||(LayoutEditor={}));angular.module("LayoutEditor").factory("scopeConfigurator",["$timeout","clipboard",function(n,t){return{configureForElement:function(n,i){i.find(".layout-panel").click(function(n){n.stopPropagation()});i.parent().keydown(function(r){var f=!1,s=!1,u=n.element,e,o;if(!u.editor.isDragging&&!u.editor.inlineEditingIsActive){if(!t.disabled&&(e=u.editor.focusedElement,!!e&&r.ctrlKey))switch(r.which){case 67:e.copy(t);break;case 88:e.cut(t);break;case 86:e.paste(t)}r.ctrlKey||r.shiftKey||r.altKey||r.which!=46?r.ctrlKey||r.shiftKey||r.altKey||r.which!=32&&r.which!=27||(i.find(".layout-panel-action-properties").first().click(),f=!0):(n.delete(u),f=!0);u.type=="Content"&&(r.ctrlKey||r.shiftKey||r.altKey||r.which!=13||(i.find(".layout-panel-action-edit").first().click(),f=!0));!u.children||(r.ctrlKey||r.shiftKey||!r.altKey||r.which!=40||(u.children.length>0&&u.children[0].setIsFocused(),f=!0),u.type=="Column"&&(o=!r.ctrlKey,r.which==37?(r.altKey&&u.expandLeft(o),r.shiftKey&&u.contractRight(o),f=!0):r.which==39&&(r.altKey&&u.contractLeft(o),r.shiftKey&&u.expandRight(o),f=!0)));!u.parent||(r.altKey&&r.which==38&&(u.parent.setIsFocused(),f=!0),u.parent.type=="Row"?r.ctrlKey||r.shiftKey||r.altKey||r.which!=37?r.ctrlKey||r.shiftKey||r.altKey||r.which!=39?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=37?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=39||(u.moveDown(),f=!0):(u.moveUp(),s=!0,f=!0):(u.parent.moveFocusNextChild(u),f=!0):(u.parent.moveFocusPrevChild(u),f=!0):r.ctrlKey||r.shiftKey||r.altKey||r.which!=38?r.ctrlKey||r.shiftKey||r.altKey||r.which!=40?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=38?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=40||(u.moveDown(),f=!0):(u.moveUp(),s=!0,f=!0):(u.parent.moveFocusNextChild(u),f=!0):(u.parent.moveFocusPrevChild(u),f=!0));f&&r.preventDefault();r.stopPropagation();n.$apply();s&&window.setTimeout(function(){n.$apply(function(){u.editor.focusedElement.setIsFocused()})},100)}});n.element.setIsFocusedEventHandlers.push(function(){i.parent().focus()});n.delete=function(n){n.delete()}},configureForContainer:function(t,r){var u=t.element;t.getShowChildrenPlaceholder=function(){return t.element.children.length===0&&!t.element.getIsDropTarget()};t.sortableOptions={cursor:"move",delay:150,disabled:u.getIsSealed(),distance:5,start:function(n,i){t.$apply(function(){u.setIsDropTarget(!0);u.editor.isDragging=!0});i.placeholder.height(i.item.height()-4);i.placeholder.css("min-height",0)},stop:function(){t.$apply(function(){u.editor.isDragging=!1;u.setIsDropTarget(!1)})},over:function(t,f){!f.sender||!f.sender[0].isToolbox||(!f.sender[0].dropTargetTimeout||(n.cancel(f.sender[0].dropTargetTimeout),f.sender[0].dropTargetTimeout=null),n(function(){if(u.type=="Row"){var n=u.editor.dropTargetElement;!n||n.type!="Row"||n.rollbackAddColumn()}u.setIsDropTarget(!1)}),f.sender[0].dropTargetTimeout=n(function(){var n,t,e;if(u.type=="Row"){for(n=f.item.sortable.model,t=Math.floor(12/(u.children.length+1)),n.width=t,n.offset=0,u.beginAddColumn(t),e=_.max(_(r.find("> .layout-children > .layout-column:not(.ui-sortable-placeholder)")).map(function(n){return $(n).height()})),i=1;i<=12;i++)f.placeholder.removeClass("col-xs-"+i);f.placeholder.addClass("col-xs-"+n.width);e>0?(f.placeholder.height(e),f.placeholder.css("min-height",0)):(f.placeholder.height(0),f.placeholder.css("min-height",""))}u.setIsDropTarget(!0)},150))},receive:function(i,r){!r.sender||!r.sender[0].isToolbox||t.$apply(function(){var i=r.item.sortable.model;!i||(u.type=="Row"&&u.commitAddColumn(),i.setEditor(u.editor),i.setParent(u),i.type!="Content"||!i.hasEditor||t.$root.editElement(i).then(function(t){t.cancel||(i.data=t.element.data,i.setHtml(t.element.html));n(function(){t.cancel?i.delete():i.setIsFocused();u.setIsDropTarget(!1)});return}));n(function(){u.setIsDropTarget(!1);!i||i.setIsFocused()})})}};t.click=function(n,t){n.editor.isDragging||n.setIsFocused();t.stopPropagation()};t.getClasses=function(n){var t=["layout-element"];return!n.children||(t.push("layout-container"),n.getIsSealed()&&t.push("layout-container-sealed")),t.push("layout-"+n.type.toLowerCase()),!n.dropTargetClass||t.push(n.dropTargetClass),n.type=="Row"&&(t.push("row"),n.canAddColumn()||t.push("layout-row-full")),n.type=="Column"&&(t.push("col-xs-"+n.width),t.push("col-xs-offset-"+n.offset)),n.type=="Content"&&t.push("layout-content-"+n.contentTypeClass),n.getIsActive()&&t.push("layout-element-active"),n.getIsFocused()&&t.push("layout-element-focused"),n.getIsSelected()&&t.push("layout-element-selected"),n.getIsDropTarget()&&t.push("layout-element-droptarget"),n.isTemplated&&t.push("layout-element-templated"),t}}}}]);angular.module("LayoutEditor").directive("orcLayoutEditor",["environment",function(n){return{restrict:"E",scope:{},controller:["$scope","$element","$attrs","$compile","clipboard",function($scope,$element,$attrs,$compile,clipboard){if(!$attrs.model)throw new Error("The 'model' attribute must evaluate to a LayoutEditor.Editor object.");else $scope.element=eval($attrs.model);$scope.click=function(n,t){n.editor.isDragging||n.setIsFocused();t.stopPropagation()};$scope.getClasses=function(n){var t=["layout-element","layout-container","layout-canvas"];return n.getIsActive()&&t.push("layout-element-active"),n.getIsFocused()&&t.push("layout-element-focused"),n.getIsSelected()&&t.push("layout-element-selected"),n.getIsDropTarget()&&t.push("layout-element-droptarget"),n.isTemplated&&t.push("layout-element-templated"),t};var layoutDesignerHost=$(".layout-designer").data("layout-designer-host");$scope.$root.layoutDesignerHost=layoutDesignerHost;layoutDesignerHost.element.on("replacecanvas",function(n,t){var u=$scope.element,f={data:t.canvas.data,htmlId:t.canvas.htmlId,htmlClass:t.canvas.htmlClass,htmlStyle:t.canvas.htmlStyle,isTemplated:t.canvas.isTemplated,children:t.canvas.children},i,r;layoutDesignerHost.editor=window.layoutEditor=new LayoutEditor.Editor(u.config,f);i="";r=$compile(i)($scope);$(".layout-editor-holder").html(r)});$scope.$root.editElement=function(n){var t=$scope.$root.layoutDesignerHost;return t.editElement(n)};$scope.$root.addElement=function(n){var t=$scope.$root.layoutDesignerHost;return t.addElement(n)};$scope.toggleInlineEditing=function(){if($scope.element.inlineEditingIsActive)tinymce.remove("#layout-editor-"+$scope.$id+" .layout-content-markup"),$element.find(".layout-toolbar-container").hide(),$scope.element.inlineEditingIsActive=!1;else{$scope.element.inlineEditingIsActive=!0;$element.find(".layout-toolbar-container").show();var n="#layout-editor-"+$scope.$id+" .layout-content-h-t-m-l .layout-content-markup[data-templated=false]",t=$(n).first().attr("id");tinymce.init({selector:n,theme:"modern",schema:"html5",plugins:["advlist autolink lists link image charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime media nonbreaking table contextmenu directionality","emoticons template paste textcolor colorpicker textpattern","fullscreen autoresize"],toolbar:"undo redo cut copy paste | bold italic | bullist numlist outdent indent formatselect | alignleft aligncenter alignright alignjustify ltr rtl | link unlink charmap | code fullscreen close",convert_urls:!1,valid_elements:"*[*]",extended_valid_elements:"script[type|defer|src|language]",statusbar:!1,skin:"orchardlightgray",inline:!0,fixed_toolbar_container:"#layout-editor-"+$scope.$id+" .layout-toolbar-container",init_instance_callback:function(n){n.id==t&&tinymce.execCommand("mceFocus",!1,n.id)}})}};$(document).on("cut copy paste",function(n){clipboard.disable();var t=$scope.element.focusedElement;!t||($scope.$apply(function(){switch(n.type){case"copy":t.copy(n.originalEvent.clipboardData);break;case"cut":t.cut(n.originalEvent.clipboardData);break;case"paste":t.paste(n.originalEvent.clipboardData)}}),window.setTimeout(function(){$scope.$apply(function(){!$scope.element.focusedElement||$scope.element.focusedElement.setIsFocused()})},100),n.preventDefault())})}],templateUrl:n.templateUrl("Editor"),replace:!0,link:function(n,t){t.find(".layout-toolbar-container").click(function(n){n.stopPropagation()});t.mousedown(function(t){n.element.inlineEditingIsActive&&(t.preventDefault(),t.stopPropagation())});$(window).click(function(){n.element.inlineEditingIsActive||n.$apply(function(){n.element.activeElement=null;n.element.focusedElement=null})})}}}]);angular.module("LayoutEditor").directive("orcLayoutCanvas",["scopeConfigurator","environment",function(n,t){return{restrict:"E",scope:{element:"="},controller:["$scope","$element","$attrs",function(t,i){n.configureForElement(t,i);n.configureForContainer(t,i);t.sortableOptions.axis="y"}],templateUrl:t.templateUrl("Canvas"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutChild",["$compile",function(n){return{restrict:"E",scope:{element:"="},link:function(t,i){var r="",u=n(r)(t);$(i).replaceWith(u)}}}]);angular.module("LayoutEditor").directive("orcLayoutColumn",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y"}],templateUrl:i.templateUrl("Column"),replace:!0,link:function(n,t){t.find(".layout-column-resize-bar").draggable({axis:"x",helper:"clone",revert:!0,start:function(){n.$apply(function(){n.element.editor.isResizing=!0})},drag:function(i,r){var e=t.parent(),o=e.width()/n.element.width,u=!i.ctrlKey,f;$(i.target).hasClass("layout-column-resize-bar-left")?(f=r.offset.left-e.offset().left,f<-o&&n.element.canExpandLeft(u)?n.$apply(function(){n.element.expandLeft(u)}):f>o&&n.element.canContractLeft(u)&&n.$apply(function(){n.element.contractLeft(u)})):$(i.target).hasClass("layout-column-resize-bar-right")&&(f=r.offset.left-e.width()-e.offset().left,f>o&&n.element.canExpandRight(u)?n.$apply(function(){n.element.expandRight(u)}):f<-o&&n.element.canContractRight(u)&&n.$apply(function(){n.element.contractRight(u)}))},stop:function(){n.$apply(function(){n.element.editor.isResizing=!1})}})}}}]);angular.module("LayoutEditor").directive("orcLayoutContent",["$sce","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(i,r){t.configureForElement(i,r);i.edit=function(){i.$root.editElement(i.element).then(function(n){i.$apply(function(){n.cancel||(i.element.data=n.element.data,i.element.setHtml(n.element.html))})})};i.updateContent=function(n){i.element.setHtml(n.target.innerHTML)};i.element.setHtml=function(t){i.element.html=t;i.element.htmlUnsafe=n.trustAsHtml(t)};i.element.setHtml(i.element.html)}],templateUrl:i.templateUrl("Content"),replace:!0,link:function(n,t){t.find(".layout-content-markup").mousedown(function(t){n.element.editor.inlineEditingIsActive&&t.stopPropagation()})}}}]);angular.module("LayoutEditor").directive("orcLayoutGrid",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y"}],templateUrl:i.templateUrl("Grid"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutRow",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="x";n.sortableOptions["ui-floating"]=!0}],templateUrl:i.templateUrl("Row"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutPopup",[function(){return{restrict:"A",link:function(n,t,i){var r=$(t),u=r.closest(".layout-popup-trigger"),f=r.closest(".layout-element");u.click(function(){r.toggle();r.is(":visible")&&(r.position({my:i.orcLayoutPopupMy||"left top",at:i.orcLayoutPopupAt||"left bottom+4px",of:u}),r.find("input").first().focus())});r.click(function(n){n.stopPropagation()});f.click(function(){r.hide()});r.keydown(function(n){n.ctrlKey||n.shiftKey||n.altKey||n.which!=27||r.hide();n.stopPropagation()})}}}]);angular.module("LayoutEditor").directive("orcLayoutToolbox",["$compile","environment",function(n,t){return{restrict:"E",controller:["$scope","$element",function(n,t){n.resetElements=function(){n.gridElements=[LayoutEditor.Grid.from({toolboxIcon:"",toolboxLabel:"Grid",toolboxDescription:"Empty grid.",children:[]})];n.rowElements=[LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (1 column)",toolboxDescription:"Row with 1 column.",children:LayoutEditor.Column.times(1)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (2 columns)",toolboxDescription:"Row with 2 columns.",children:LayoutEditor.Column.times(2)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (3 columns)",toolboxDescription:"Row with 3 columns.",children:LayoutEditor.Column.times(3)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (4 columns)",toolboxDescription:"Row with 4 columns.",children:LayoutEditor.Column.times(4)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (6 columns)",toolboxDescription:"Row with 6 columns.",children:LayoutEditor.Column.times(6)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (12 columns)",toolboxDescription:"Row with 12 columns.",children:LayoutEditor.Column.times(12)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (empty)",toolboxDescription:"Empty row.",children:[]})];n.columnElements=[LayoutEditor.Column.from({toolboxIcon:"",toolboxLabel:"Column",toolboxDescription:"Empty column.",width:1,offset:0,children:[]})];n.contentElementCategories=_(n.element.config.categories).map(function(n){return{name:n.name,elements:_(n.contentTypes).map(function(n){var i=n.type,r=LayoutEditor.factories[i]||LayoutEditor.factories.Content,u={isTemplated:!1,contentType:n.id,contentTypeLabel:n.label,contentTypeClass:n.typeClass,data:null,hasEditor:n.hasEditor,html:n.html},t=r(u);return t.toolboxIcon=n.icon||"",t.toolboxLabel=n.label,t.toolboxDescription=n.description,t})}})};n.resetElements();n.getSortableOptions=function(i){var e=t.closest(".layout-editor").attr("id"),r,u,f=!1;switch(i){case"Grid":r=[".layout-canvas",".layout-column",".layout-common-holder"];u="layout-element layout-container layout-grid ui-sortable-placeholder";break;case"Row":r=[".layout-grid"];u="layout-element layout-container layout-row row ui-sortable-placeholder";break;case"Column":r=[".layout-row:not(.layout-row-full)"];u="layout-element layout-container layout-column ui-sortable-placeholder";f=!0;break;case"Content":r=[".layout-canvas",".layout-column",".layout-common-holder"];u="layout-element layout-content ui-sortable-placeholder"}return{cursor:"move",connectWith:_(r).map(function(n){return"#"+e+" "+n+":not(.layout-container-sealed) > .layout-element-wrapper > .layout-children"}).join(", "),placeholder:u,"ui-floating":f,create:function(n){n.target.isToolbox=!0},start:function(){n.$apply(function(){n.element.isDragging=!0})},stop:function(){n.$apply(function(){n.element.isDragging=!1;n.resetElements()})},over:function(){n.$apply(function(){n.element.canvas.setIsDropTarget(!1)})}}};var i="layoutToolboxCategory_Layout_IsCollapsed";n.layoutIsCollapsed=$.cookie(i)==="true";n.toggleLayoutIsCollapsed=function(t){n.layoutIsCollapsed=!n.layoutIsCollapsed;$.cookie(i,n.layoutIsCollapsed,{expires:365});t.preventDefault();t.stopPropagation()}}],templateUrl:t.templateUrl("Toolbox"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutToolboxGroup",["$compile","environment",function(n,t){return{restrict:"E",scope:{category:"="},controller:["$scope","$element",function(n){var t="layoutToolboxCategory_"+n.category.name+"_IsCollapsed";n.isCollapsed=$.cookie(t)==="true";n.toggleIsCollapsed=function(i){n.isCollapsed=!n.isCollapsed;$.cookie(t,n.isCollapsed,{expires:365});i.preventDefault();i.stopPropagation()}}],templateUrl:t.templateUrl("ToolboxGroup"),replace:!0}}]); \ No newline at end of file +angular.module("LayoutEditor",["ngSanitize","ngResource","ui.sortable"]);var LayoutEditor;(function(n){var t=function(){var n=this;this.clipboardData={};this.setData=function(t,i){n.clipboardData[t]=i};this.getData=function(t){return n.clipboardData[t]};this.disable=function(){this.disabled=!0}};n.Clipboard=new t;angular.module("LayoutEditor").factory("clipboard",[function(){return{setData:n.Clipboard.setData,getData:n.Clipboard.getData,disable:n.Clipboard.disable}}])})(LayoutEditor||(LayoutEditor={}));angular.module("LayoutEditor").factory("scopeConfigurator",["$timeout","clipboard",function(n,t){return{configureForElement:function(n,i){i.find(".layout-panel").click(function(n){n.stopPropagation()});i.parent().keydown(function(r){var f=!1,s=!1,u=n.element,e,o;if(!u.editor.isDragging&&!u.editor.inlineEditingIsActive){if(!t.disabled&&(e=u.editor.focusedElement,!!e&&r.ctrlKey))switch(r.which){case 67:e.copy(t);break;case 88:e.cut(t);break;case 86:e.paste(t)}r.ctrlKey||r.shiftKey||r.altKey||r.which!=46?r.ctrlKey||r.shiftKey||r.altKey||r.which!=32&&r.which!=27||(i.find(".layout-panel-action-properties").first().click(),f=!0):(n.delete(u),f=!0);u.type=="Content"&&(r.ctrlKey||r.shiftKey||r.altKey||r.which!=13||(i.find(".layout-panel-action-edit").first().click(),f=!0));!u.children||(r.ctrlKey||r.shiftKey||!r.altKey||r.which!=40||(u.children.length>0&&u.children[0].setIsFocused(),f=!0),u.type=="Column"&&(o=!r.ctrlKey,r.which==37?(r.altKey&&u.expandLeft(o),r.shiftKey&&u.contractRight(o),f=!0):r.which==39&&(r.altKey&&u.contractLeft(o),r.shiftKey&&u.expandRight(o),f=!0)));!u.parent||(r.altKey&&r.which==38&&(u.parent.setIsFocused(),f=!0),u.parent.type=="Row"?r.ctrlKey||r.shiftKey||r.altKey||r.which!=37?r.ctrlKey||r.shiftKey||r.altKey||r.which!=39?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=37?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=39||(u.moveDown(),f=!0):(u.moveUp(),s=!0,f=!0):(u.parent.moveFocusNextChild(u),f=!0):(u.parent.moveFocusPrevChild(u),f=!0):r.ctrlKey||r.shiftKey||r.altKey||r.which!=38?r.ctrlKey||r.shiftKey||r.altKey||r.which!=40?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=38?!r.ctrlKey||r.shiftKey||r.altKey||r.which!=40||(u.moveDown(),f=!0):(u.moveUp(),s=!0,f=!0):(u.parent.moveFocusNextChild(u),f=!0):(u.parent.moveFocusPrevChild(u),f=!0));f&&r.preventDefault();r.stopPropagation();n.$apply();s&&window.setTimeout(function(){n.$apply(function(){u.editor.focusedElement.setIsFocused()})},100)}});n.element.setIsFocusedEventHandlers.push(function(){i.parent().focus()});n.delete=function(n){n.delete()}},configureForContainer:function(t,r){var u=t.element;t.getShowChildrenPlaceholder=function(){return t.element.children.length===0&&!t.element.getIsDropTarget()};t.sortableOptions={cursor:"move",delay:150,disabled:u.getIsSealed(),distance:5,start:function(n,i){t.$apply(function(){u.setIsDropTarget(!0);u.editor.isDragging=!0});i.placeholder.height(i.item.height()-4);i.placeholder.css("min-height",0)},stop:function(){t.$apply(function(){u.editor.isDragging=!1;u.setIsDropTarget(!1)})},over:function(t,f){!f.sender||!f.sender[0].isToolbox||(!f.sender[0].dropTargetTimeout||(n.cancel(f.sender[0].dropTargetTimeout),f.sender[0].dropTargetTimeout=null),n(function(){if(u.type=="Row"){var n=u.editor.dropTargetElement;!n||n.type!="Row"||n.rollbackAddColumn()}u.setIsDropTarget(!1)}),f.sender[0].dropTargetTimeout=n(function(){var n,t,e;if(u.type=="Row"){for(n=f.item.sortable.model,t=Math.floor(12/(u.children.length+1)),n.width=t,n.offset=0,u.beginAddColumn(t),e=_.max(_(r.find("> .layout-children > .layout-column:not(.ui-sortable-placeholder)")).map(function(n){return $(n).height()})),i=1;i<=12;i++)f.placeholder.removeClass("col-xs-"+i);f.placeholder.addClass("col-xs-"+n.width);e>0?(f.placeholder.height(e),f.placeholder.css("min-height",0)):(f.placeholder.height(0),f.placeholder.css("min-height",""))}u.setIsDropTarget(!0)},150))},receive:function(i,r){!r.sender||!r.sender[0].isToolbox||t.$apply(function(){var i=r.item.sortable.model;!i||(u.type=="Row"&&u.commitAddColumn(),i.setEditor(u.editor),i.setParent(u),i.type!="Content"||!i.hasEditor||t.$root.editElement(i).then(function(t){t.cancel||(i.data=t.element.data,i.setHtml(t.element.html));n(function(){t.cancel?i.delete():i.setIsFocused();u.setIsDropTarget(!1)});return}));n(function(){u.setIsDropTarget(!1);!i||i.setIsFocused()})})}};t.click=function(n,t){n.editor.isDragging||n.setIsFocused();t.stopPropagation()};t.getClasses=function(n){var t=["layout-element"];return!n.children||(t.push("layout-container"),n.getIsSealed()&&t.push("layout-container-sealed")),t.push("layout-"+n.type.toLowerCase()),!n.dropTargetClass||t.push(n.dropTargetClass),n.type=="Row"&&(t.push("row"),n.canAddColumn()||t.push("layout-row-full")),n.type=="Column"&&(t.push("col-xs-"+n.width),t.push("col-xs-offset-"+n.offset)),n.type=="Content"&&t.push("layout-content-"+n.contentTypeClass),n.getIsActive()&&t.push("layout-element-active"),n.getIsFocused()&&t.push("layout-element-focused"),n.getIsSelected()&&t.push("layout-element-selected"),n.getIsDropTarget()&&t.push("layout-element-droptarget"),n.isTemplated&&t.push("layout-element-templated"),t}}}}]);angular.module("LayoutEditor").directive("orcLayoutEditor",["environment",function(n){return{restrict:"E",scope:{},controller:["$scope","$element","$attrs","$compile","clipboard",function($scope,$element,$attrs,$compile,clipboard){if(!$attrs.model)throw new Error("The 'model' attribute must evaluate to a LayoutEditor.Editor object.");else $scope.element=eval($attrs.model);$scope.click=function(n,t){n.editor.isDragging||n.setIsFocused();t.stopPropagation()};$scope.getClasses=function(n){var t=["layout-element","layout-container","layout-canvas"];return n.getIsActive()&&t.push("layout-element-active"),n.getIsFocused()&&t.push("layout-element-focused"),n.getIsSelected()&&t.push("layout-element-selected"),n.getIsDropTarget()&&t.push("layout-element-droptarget"),n.isTemplated&&t.push("layout-element-templated"),t};var layoutDesignerHost=$(".layout-designer").data("layout-designer-host");$scope.$root.layoutDesignerHost=layoutDesignerHost;layoutDesignerHost.element.on("replacecanvas",function(n,t){var u=$scope.element,f={data:t.canvas.data,htmlId:t.canvas.htmlId,htmlClass:t.canvas.htmlClass,htmlStyle:t.canvas.htmlStyle,isTemplated:t.canvas.isTemplated,children:t.canvas.children},i,r;layoutDesignerHost.editor=window.layoutEditor=new LayoutEditor.Editor(u.config,f);i="";r=$compile(i)($scope);$(".layout-editor-holder").html(r)});$scope.$root.editElement=function(n){var t=$scope.$root.layoutDesignerHost;return t.editElement(n)};$scope.$root.addElement=function(n){var t=$scope.$root.layoutDesignerHost;return t.addElement(n)};$scope.toggleInlineEditing=function(){if($scope.element.inlineEditingIsActive)tinymce.remove("#layout-editor-"+$scope.$id+" .layout-content-markup"),$element.find(".layout-toolbar-container").hide(),$scope.element.inlineEditingIsActive=!1;else{$scope.element.inlineEditingIsActive=!0;$element.find(".layout-toolbar-container").show();var n="#layout-editor-"+$scope.$id+" .layout-html .layout-content-markup[data-templated=false]",t=$(n).first().attr("id");tinymce.init({selector:n,theme:"modern",schema:"html5",plugins:["advlist autolink lists link image charmap print preview hr anchor pagebreak","searchreplace wordcount visualblocks visualchars code fullscreen","insertdatetime media nonbreaking table contextmenu directionality","emoticons template paste textcolor colorpicker textpattern","fullscreen autoresize"],toolbar:"undo redo cut copy paste | bold italic | bullist numlist outdent indent formatselect | alignleft aligncenter alignright alignjustify ltr rtl | link unlink charmap | code fullscreen close",convert_urls:!1,valid_elements:"*[*]",extended_valid_elements:"script[type|defer|src|language]",statusbar:!1,skin:"orchardlightgray",inline:!0,fixed_toolbar_container:"#layout-editor-"+$scope.$id+" .layout-toolbar-container",init_instance_callback:function(n){n.id==t&&tinymce.execCommand("mceFocus",!1,n.id)}})}};$(document).on("cut copy paste",function(n){clipboard.disable();var t=$scope.element.focusedElement;!t||($scope.$apply(function(){switch(n.type){case"copy":t.copy(n.originalEvent.clipboardData);break;case"cut":t.cut(n.originalEvent.clipboardData);break;case"paste":t.paste(n.originalEvent.clipboardData)}}),window.setTimeout(function(){$scope.$apply(function(){!$scope.element.focusedElement||$scope.element.focusedElement.setIsFocused()})},100),n.preventDefault())})}],templateUrl:n.templateUrl("Editor"),replace:!0,link:function(n,t){t.find(".layout-toolbar-container").click(function(n){n.stopPropagation()});t.mousedown(function(t){n.element.inlineEditingIsActive&&(t.preventDefault(),t.stopPropagation())});$(window).click(function(){n.element.inlineEditingIsActive||n.$apply(function(){n.element.activeElement=null;n.element.focusedElement=null})})}}}]);angular.module("LayoutEditor").directive("orcLayoutCanvas",["scopeConfigurator","environment",function(n,t){return{restrict:"E",scope:{element:"="},controller:["$scope","$element","$attrs",function(t,i){n.configureForElement(t,i);n.configureForContainer(t,i);t.sortableOptions.axis="y"}],templateUrl:t.templateUrl("Canvas"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutChild",["$compile",function(n){return{restrict:"E",scope:{element:"="},link:function(t,i){var r="",u=n(r)(t);$(i).replaceWith(u)}}}]);angular.module("LayoutEditor").directive("orcLayoutColumn",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y"}],templateUrl:i.templateUrl("Column"),replace:!0,link:function(n,t){t.find(".layout-column-resize-bar").draggable({axis:"x",helper:"clone",revert:!0,start:function(){n.$apply(function(){n.element.editor.isResizing=!0})},drag:function(i,r){var e=t.parent(),o=e.width()/n.element.width,u=!i.ctrlKey,f;$(i.target).hasClass("layout-column-resize-bar-left")?(f=r.offset.left-e.offset().left,f<-o&&n.element.canExpandLeft(u)?n.$apply(function(){n.element.expandLeft(u)}):f>o&&n.element.canContractLeft(u)&&n.$apply(function(){n.element.contractLeft(u)})):$(i.target).hasClass("layout-column-resize-bar-right")&&(f=r.offset.left-e.width()-e.offset().left,f>o&&n.element.canExpandRight(u)?n.$apply(function(){n.element.expandRight(u)}):f<-o&&n.element.canContractRight(u)&&n.$apply(function(){n.element.contractRight(u)}))},stop:function(){n.$apply(function(){n.element.editor.isResizing=!1})}})}}}]);angular.module("LayoutEditor").directive("orcLayoutContent",["$sce","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(i,r){t.configureForElement(i,r);i.edit=function(){i.$root.editElement(i.element).then(function(n){i.$apply(function(){n.cancel||(i.element.data=n.element.data,i.element.setHtml(n.element.html))})})};i.element.setHtml=function(t){i.element.html=t;i.element.htmlUnsafe=n.trustAsHtml(t)};i.element.setHtml(i.element.html)}],templateUrl:i.templateUrl("Content"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutHtml",["$sce","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(i,r){t.configureForElement(i,r);i.edit=function(){i.$root.editElement(i.element).then(function(n){i.$apply(function(){n.cancel||(i.element.data=n.element.data,i.element.setHtml(n.element.html))})})};i.updateContent=function(n){i.element.setHtml(n.target.innerHTML)};i.element.setHtml=function(t){i.element.html=t;i.element.htmlUnsafe=n.trustAsHtml(t)};i.element.setHtml(i.element.html)}],templateUrl:i.templateUrl("Html"),replace:!0,link:function(n,t){t.find(".layout-content-markup").mousedown(function(t){n.element.editor.inlineEditingIsActive&&t.stopPropagation()})}}}]);angular.module("LayoutEditor").directive("orcLayoutGrid",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="y"}],templateUrl:i.templateUrl("Grid"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutRow",["$compile","scopeConfigurator","environment",function(n,t,i){return{restrict:"E",scope:{element:"="},controller:["$scope","$element",function(n,i){t.configureForElement(n,i);t.configureForContainer(n,i);n.sortableOptions.axis="x";n.sortableOptions["ui-floating"]=!0}],templateUrl:i.templateUrl("Row"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutPopup",[function(){return{restrict:"A",link:function(n,t,i){var r=$(t),u=r.closest(".layout-popup-trigger"),f=r.closest(".layout-element");u.click(function(){r.toggle();r.is(":visible")&&(r.position({my:i.orcLayoutPopupMy||"left top",at:i.orcLayoutPopupAt||"left bottom+4px",of:u}),r.find("input").first().focus())});r.click(function(n){n.stopPropagation()});f.click(function(){r.hide()});r.keydown(function(n){n.ctrlKey||n.shiftKey||n.altKey||n.which!=27||r.hide();n.stopPropagation()})}}}]);angular.module("LayoutEditor").directive("orcLayoutToolbox",["$compile","environment",function(n,t){return{restrict:"E",controller:["$scope","$element",function(n,t){n.resetElements=function(){n.gridElements=[LayoutEditor.Grid.from({toolboxIcon:"",toolboxLabel:"Grid",toolboxDescription:"Empty grid.",children:[]})];n.rowElements=[LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (1 column)",toolboxDescription:"Row with 1 column.",children:LayoutEditor.Column.times(1)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (2 columns)",toolboxDescription:"Row with 2 columns.",children:LayoutEditor.Column.times(2)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (3 columns)",toolboxDescription:"Row with 3 columns.",children:LayoutEditor.Column.times(3)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (4 columns)",toolboxDescription:"Row with 4 columns.",children:LayoutEditor.Column.times(4)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (6 columns)",toolboxDescription:"Row with 6 columns.",children:LayoutEditor.Column.times(6)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (12 columns)",toolboxDescription:"Row with 12 columns.",children:LayoutEditor.Column.times(12)}),LayoutEditor.Row.from({toolboxIcon:"",toolboxLabel:"Row (empty)",toolboxDescription:"Empty row.",children:[]})];n.columnElements=[LayoutEditor.Column.from({toolboxIcon:"",toolboxLabel:"Column",toolboxDescription:"Empty column.",width:1,offset:0,children:[]})];n.contentElementCategories=_(n.element.config.categories).map(function(n){return{name:n.name,elements:_(n.contentTypes).map(function(n){var i=n.type,r=LayoutEditor.factories[i]||LayoutEditor.factories.Content,u={isTemplated:!1,contentType:n.id,contentTypeLabel:n.label,contentTypeClass:n.typeClass,data:null,hasEditor:n.hasEditor,html:n.html},t=r(u);return t.toolboxIcon=n.icon||"",t.toolboxLabel=n.label,t.toolboxDescription=n.description,t})}})};n.resetElements();n.getSortableOptions=function(i){var e=t.closest(".layout-editor").attr("id"),r,u,f=!1;switch(i){case"Grid":r=[".layout-canvas",".layout-column",".layout-common-holder"];u="layout-element layout-container layout-grid ui-sortable-placeholder";break;case"Row":r=[".layout-grid"];u="layout-element layout-container layout-row row ui-sortable-placeholder";break;case"Column":r=[".layout-row:not(.layout-row-full)"];u="layout-element layout-container layout-column ui-sortable-placeholder";f=!0;break;case"Content":r=[".layout-canvas",".layout-column",".layout-common-holder"];u="layout-element layout-content ui-sortable-placeholder"}return{cursor:"move",connectWith:_(r).map(function(n){return"#"+e+" "+n+":not(.layout-container-sealed) > .layout-element-wrapper > .layout-children"}).join(", "),placeholder:u,"ui-floating":f,create:function(n){n.target.isToolbox=!0},start:function(){n.$apply(function(){n.element.isDragging=!0})},stop:function(){n.$apply(function(){n.element.isDragging=!1;n.resetElements()})},over:function(){n.$apply(function(){n.element.canvas.setIsDropTarget(!1)})}}};var i="layoutToolboxCategory_Layout_IsCollapsed";n.layoutIsCollapsed=$.cookie(i)==="true";n.toggleLayoutIsCollapsed=function(t){n.layoutIsCollapsed=!n.layoutIsCollapsed;$.cookie(i,n.layoutIsCollapsed,{expires:365});t.preventDefault();t.stopPropagation()}}],templateUrl:t.templateUrl("Toolbox"),replace:!0}}]);angular.module("LayoutEditor").directive("orcLayoutToolboxGroup",["$compile","environment",function(n,t){return{restrict:"E",scope:{category:"="},controller:["$scope","$element",function(n){var t="layoutToolboxCategory_"+n.category.name+"_IsCollapsed";n.isCollapsed=$.cookie(t)==="true";n.toggleIsCollapsed=function(i){n.isCollapsed=!n.isCollapsed;$.cookie(t,n.isCollapsed,{expires:365});i.preventDefault();i.stopPropagation()}}],templateUrl:t.templateUrl("ToolboxGroup"),replace:!0}}]); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Content.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Content.js index a1d78faf8..ce96c7f1e 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Content.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Content.js @@ -19,9 +19,6 @@ }); }); }; - $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) { @@ -33,16 +30,7 @@ } ], templateUrl: environment.templateUrl("Content"), - replace: true, - link: function (scope, element) { - // Mouse down events must not be intercepted by drag and drop while inline editing is active, - // otherwise clicks in inline editors will have no effect. - element.find(".layout-content-markup").mousedown(function (e) { - if (scope.element.editor.inlineEditingIsActive) { - e.stopPropagation(); - } - }); - } + replace: true }; } ]); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Editor.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Editor.js index 1daeaa8f9..43207591e 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Editor.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Editor.js @@ -78,7 +78,7 @@ if (!$scope.element.inlineEditingIsActive) { $scope.element.inlineEditingIsActive = true; $element.find(".layout-toolbar-container").show(); - var selector = "#layout-editor-" + $scope.$id + " .layout-content-h-t-m-l .layout-content-markup[data-templated=false]"; + var selector = "#layout-editor-" + $scope.$id + " .layout-html .layout-content-markup[data-templated=false]"; var firstContentEditorId = $(selector).first().attr("id"); tinymce.init({ selector: selector, diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Html.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Html.js new file mode 100644 index 000000000..4dc6a4f1e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/LayoutEditor/Directives/Html.js @@ -0,0 +1,48 @@ +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) { + // Mouse down events must not be intercepted by drag and drop while inline editing is active, + // otherwise clicks in inline editors will have no effect. + element.find(".layout-content-markup").mousedown(function (e) { + if (scope.element.editor.inlineEditingIsActive) { + e.stopPropagation(); + } + }); + } + }; + } + ]); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js index 7f6dafe8a..d8dd4ba15 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js @@ -898,14 +898,6 @@ var LayoutEditor; return result; }; - var getEditorObject = this.getEditorObject; - this.getEditorObject = function () { - var dto = getEditorObject(); - return $.extend(dto, { - Content: this.html - }); - } - this.setHtml(html); }; @@ -926,3 +918,71 @@ var LayoutEditor; }; })(LayoutEditor || (LayoutEditor = {})); +var LayoutEditor; +(function ($, LayoutEditor) { + + LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) { + LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated); + + this.contentType = contentType; + this.contentTypeLabel = contentTypeLabel; + this.contentTypeClass = contentTypeClass; + this.html = html; + this.hasEditor = hasEditor; + + 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); + + return result; + }; + + LayoutEditor.registerFactory("Html", function(value) { return LayoutEditor.Html.from(value); }); + +})(jQuery, LayoutEditor || (LayoutEditor = {})); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js.bundle b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js.bundle index 6938f2dcc..8f3f02515 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js.bundle +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js.bundle @@ -19,5 +19,6 @@ Models/Row.js Models/Column.js Models/Content.js + Models/Html.js \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.min.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.min.js index c9c2f1fe4..4e7e8b253 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.min.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.min.js @@ -1 +1 @@ -var LayoutEditor;(function(n){Array.prototype.move=function(n,t){this.splice(t,0,this.splice(n,1)[0])};n.childrenFrom=function(t){return _(t).map(function(t){return n.elementFrom(t)})};var t=n.registerFactory=function(t,i){var r=n.factories=n.factories||{};r[t]=i};t("Grid",function(t){return n.Grid.from(t)});t("Row",function(t){return n.Row.from(t)});t("Column",function(t){return n.Column.from(t)});t("Content",function(t){return n.Content.from(t)});n.elementFrom=function(t){var i=n.factories[t.type];if(!i)throw new Error('No element with type "'+t.type+'" was found.');return i(t)};n.setModel=function(n,t){$(n).scope().element=t};n.getModel=function(n){return $(n).scope().element}})(LayoutEditor||(LayoutEditor={})),function(n){n.Editor=function(t,i){this.config=t;this.canvas=n.Canvas.from(i);this.initialState=JSON.stringify(this.canvas.toObject());this.activeElement=null;this.focusedElement=null;this.dropTargetElement=null;this.isDragging=!1;this.inlineEditingIsActive=!1;this.isResizing=!1;this.resetToolboxElements=function(){this.toolboxElements=[n.Row.from({children:[]})]};this.isDirty=function(){var n=JSON.stringify(this.canvas.toObject());return this.initialState!=n};this.resetToolboxElements();this.canvas.setEditor(this)}}(LayoutEditor||(LayoutEditor={})),function(n){n.Element=function(n,t,i,r,u,f){if(!n)throw new Error("Parameter 'type' is required.");this.type=n;this.data=t;this.htmlId=i;this.htmlClass=r;this.htmlStyle=u;this.isTemplated=f;this.editor=null;this.parent=null;this.setIsFocusedEventHandlers=[];this.setEditor=function(n){this.editor=n;!!this.children&&_.isArray(this.children)&&_(this.children).each(function(t){t.setEditor(n)})};this.setParent=function(n){this.parent=n;!this.parent.linkChild||this.parent.linkChild(this)};this.setIsTemplated=function(n){this.isTemplated=n;!!this.children&&_.isArray(this.children)&&_(this.children).each(function(t){t.setIsTemplated(n)})};this.getIsActive=function(){return this.editor?this.editor.activeElement===this&&!this.getIsFocused():!1};this.setIsActive=function(n){this.editor&&(this.editor.isDragging||this.editor.inlineEditingIsActive||this.editor.isResizing||(this.editor.activeElement=n?this:this.parent))};this.getIsFocused=function(){return this.editor?this.editor.focusedElement===this:!1};this.setIsFocused=function(){this.editor&&(this.isTemplated||this.editor.isDragging||this.editor.inlineEditingIsActive||this.editor.isResizing||(this.editor.focusedElement=this,_(this.setIsFocusedEventHandlers).each(function(n){try{n()}catch(t){}})))};this.getIsSelected=function(){return this.getIsFocused()?!0:!!this.children&&_.isArray(this.children)?_(this.children).any(function(n){return n.getIsSelected()}):!1};this.getIsDropTarget=function(){return this.editor?this.editor.dropTargetElement===this:!1};this.setIsDropTarget=function(n){this.editor&&(this.editor.dropTargetElement=n?this:null)};this.delete=function(){!this.parent||this.parent.deleteChild(this)};this.canMoveUp=function(){return this.parent?this.parent.canMoveChildUp(this):!1};this.moveUp=function(){!this.parent||this.parent.moveChildUp(this)};this.canMoveDown=function(){return this.parent?this.parent.canMoveChildDown(this):!1};this.moveDown=function(){!this.parent||this.parent.moveChildDown(this)};this.elementToObject=function(){return{type:this.type,data:this.data,htmlId:this.htmlId,htmlClass:this.htmlClass,htmlStyle:this.htmlStyle,isTemplated:this.isTemplated}};this.getEditorObject=function(){return{}};this.copy=function(n){var t=this.getInnerText(),i,r;n.setData("text/plain",t);console.log(t);i=this.toObject();r=JSON.stringify(i,null,"\t");n.setData("text/json",r)};this.cut=function(n){this.copy(n);this.delete()};this.paste=function(n){!this.parent||this.parent.paste(n)}}}(LayoutEditor||(LayoutEditor={})),function(n){n.Container=function(t,i){this.allowedChildTypes=t;this.children=i;this.isContainer=!0;var r=this;this.setChildren=function(n){this.children=n;_(this.children).each(function(n){n.parent=r})};this.setChildren(i);this.getIsSealed=function(){return _(this.children).any(function(n){return n.isTemplated})};this.addChild=function(n){!_(this.children).contains(n)&&(_(this.allowedChildTypes).contains(n.type)||n.isContainable)&&this.children.push(n);n.setEditor(this.editor);n.setIsTemplated(!1);n.parent=this};this.deleteChild=function(n){var t=_(this.children).indexOf(n);t>=0&&(this.children.splice(t,1),n.getIsActive()&&(this.editor.activeElement=null),n.getIsFocused()&&(this.children.length>t?this.children[t].setIsFocused():t>0?this.children[t-1].setIsFocused():this.setIsFocused()))};this.moveFocusPrevChild=function(n){if(!(this.children.length<2)){var t=_(this.children).indexOf(n);t>0&&this.children[t-1].setIsFocused()}};this.moveFocusNextChild=function(n){if(!(this.children.length<2)){var t=_(this.children).indexOf(n);t0};this.canMoveChildDown=function(n){var t=_(this.children).indexOf(n);return t0?n.width<12:t<0?n.width>1:!1}var t,f,r,u;if(n==0)return!0;for(t=n,t<0&&(f=12-l(),t+=f,t>0&&(t=0));t<0&&_(s.children).any(function(n){return n.offset>0});)for(i=0;i0&&(r.offset--,t++);while(t!=0){if(!_(s.children).any(e))break;for(i=0;i=0?n.width>1:!1};this.contractColumnRight=function(n,t){var i,r;this.canContractColumnRight(n,t)&&(i=_(this.children).indexOf(n),i>=0&&n.width>1&&(n.width--,this.children.length>i+1&&(r=this.children[i+1],t&&r.offset==0?r.width++:r.offset++)))};this.canExpandColumnRight=function(n,t){var r=_(this.children).indexOf(n),i;return r>=0?n.width>=12?!1:this.children.length>r+1?(i=this.children[r+1],t&&i.offset==0?i.width>1:i.offset>0):l()<12:!1};this.expandColumnRight=function(n,t){var i,r;this.canExpandColumnRight(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(this.children.length>i+1&&(r=this.children[i+1],t&&r.offset==0?r.width--:r.offset--),n.width++))};this.canExpandColumnLeft=function(n,t){var i=_(this.children).indexOf(n),r;return i>=0?n.width>=12?!1:i>0&&(r=this.children[i-1],t&&n.offset==0)?r.width>1:n.offset>0:!1};this.expandColumnLeft=function(n,t){var i,r;this.canExpandColumnLeft(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(i>0?(r=this.children[i-1],t&&n.offset==0?r.width--:n.offset--):n.offset--,n.width++))};this.canContractColumnLeft=function(n){var t=_(this.children).indexOf(n);return t>=0?n.width>1:!1};this.contractColumnLeft=function(n,t){var i,r;this.canContractColumnLeft(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(i>0?(r=this.children[i-1],t&&n.offset==0?r.width++:n.offset++):n.offset++,n.width--))};this.evenColumns=function(){var t,n;this.children.length!=0&&(t=Math.floor(12/this.children.length),_(this.children).each(function(n){n.width=t;n.offset=0}),n=12%this.children.length,n>0&&c(n))};v=this.pasteChild;this.pasteChild=function(n){n.type=="Column"?this.beginAddColumn(n.width)&&(this.commitAddColumn(),v.call(this,n)):!this.parent||this.parent.pasteChild(n)};this.toObject=function(){var n=this.elementToObject();return n.children=this.childrenToObject(),n}};n.Row.from=function(t){var i=new n.Row(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,n.childrenFrom(t.children));return i.toolboxIcon=t.toolboxIcon,i.toolboxLabel=t.toolboxLabel,i.toolboxDescription=t.toolboxDescription,i}}(LayoutEditor||(LayoutEditor={})),function(n){n.Column=function(t,i,r,u,f,e,o,s){n.Element.call(this,"Column",t,i,r,u,f);n.Container.call(this,["Grid","Content"],s);this.width=e;this.offset=o;var h=!1,c=0,l=0;this.beginChange=function(){if(!!h)throw new Error("Column already has a pending change.");h=!0;c=this.width;l=this.offset};this.commitChange=function(){if(!h)throw new Error("Column has no pending change.");c=0;l=0;h=!1};this.rollbackChange=function(){if(!h)throw new Error("Column has no pending change.");this.width=c;this.offset=l;c=0;l=0;h=!1};this.canSplit=function(){return this.width>1};this.split=function(){if(this.canSplit()){var t=Math.floor(this.width/2),i=n.Column.from({data:null,htmlId:null,htmlClass:null,htmlStyle:null,width:t,offset:0,children:[]});this.width=this.width-t;this.parent.insertChild(i,this);i.setIsFocused()}};this.canContractRight=function(n){return this.parent.canContractColumnRight(this,n)};this.contractRight=function(n){this.parent.contractColumnRight(this,n)};this.canExpandRight=function(n){return this.parent.canExpandColumnRight(this,n)};this.expandRight=function(n){this.parent.expandColumnRight(this,n)};this.canExpandLeft=function(n){return this.parent.canExpandColumnLeft(this,n)};this.expandLeft=function(n){this.parent.expandColumnLeft(this,n)};this.canContractLeft=function(n){return this.parent.canContractColumnLeft(this,n)};this.contractLeft=function(n){this.parent.contractColumnLeft(this,n)};this.toObject=function(){var n=this.elementToObject();return n.width=this.width,n.offset=this.offset,n.children=this.childrenToObject(),n}};n.Column.from=function(t){var i=new n.Column(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,t.width,t.offset,n.childrenFrom(t.children));return i.toolboxIcon=t.toolboxIcon,i.toolboxLabel=t.toolboxLabel,i.toolboxDescription=t.toolboxDescription,i};n.Column.times=function(t){return _.times(t,function(){return n.Column.from({data:null,htmlId:null,htmlClass:null,isTemplated:!1,width:12/t,offset:0,children:[]})})}}(LayoutEditor||(LayoutEditor={})),function(n){n.Content=function(t,i,r,u,f,e,o,s,h,c){n.Element.call(this,"Content",t,i,r,u,f);this.contentType=e;this.contentTypeLabel=o;this.contentTypeClass=s;this.html=h;this.hasEditor=c;this.getInnerText=function(){return $($.parseHTML("
"+this.html+"<\/div>")).text()};this.setHtml=function(n){this.html=n;this.htmlUnsafe=n};this.toObject=function(){return{type:"Content"}};this.toObject=function(){var n=this.elementToObject();return n.contentType=this.contentType,n.contentTypeLabel=this.contentTypeLabel,n.contentTypeClass=this.contentTypeClass,n.html=this.html,n.hasEditor=c,n};var l=this.getEditorObject;this.getEditorObject=function(){var n=l();return $.extend(n,{Content:this.html})};this.setHtml(h)};n.Content.from=function(t){return new n.Content(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,t.contentType,t.contentTypeLabel,t.contentTypeClass,t.html,t.hasEditor)}}(LayoutEditor||(LayoutEditor={})); \ No newline at end of file +var LayoutEditor;(function(n){Array.prototype.move=function(n,t){this.splice(t,0,this.splice(n,1)[0])};n.childrenFrom=function(t){return _(t).map(function(t){return n.elementFrom(t)})};var t=n.registerFactory=function(t,i){var r=n.factories=n.factories||{};r[t]=i};t("Grid",function(t){return n.Grid.from(t)});t("Row",function(t){return n.Row.from(t)});t("Column",function(t){return n.Column.from(t)});t("Content",function(t){return n.Content.from(t)});n.elementFrom=function(t){var i=n.factories[t.type];if(!i)throw new Error('No element with type "'+t.type+'" was found.');return i(t)};n.setModel=function(n,t){$(n).scope().element=t};n.getModel=function(n){return $(n).scope().element}})(LayoutEditor||(LayoutEditor={})),function(n){n.Editor=function(t,i){this.config=t;this.canvas=n.Canvas.from(i);this.initialState=JSON.stringify(this.canvas.toObject());this.activeElement=null;this.focusedElement=null;this.dropTargetElement=null;this.isDragging=!1;this.inlineEditingIsActive=!1;this.isResizing=!1;this.resetToolboxElements=function(){this.toolboxElements=[n.Row.from({children:[]})]};this.isDirty=function(){var n=JSON.stringify(this.canvas.toObject());return this.initialState!=n};this.resetToolboxElements();this.canvas.setEditor(this)}}(LayoutEditor||(LayoutEditor={})),function(n){n.Element=function(n,t,i,r,u,f){if(!n)throw new Error("Parameter 'type' is required.");this.type=n;this.data=t;this.htmlId=i;this.htmlClass=r;this.htmlStyle=u;this.isTemplated=f;this.editor=null;this.parent=null;this.setIsFocusedEventHandlers=[];this.setEditor=function(n){this.editor=n;!!this.children&&_.isArray(this.children)&&_(this.children).each(function(t){t.setEditor(n)})};this.setParent=function(n){this.parent=n;!this.parent.linkChild||this.parent.linkChild(this)};this.setIsTemplated=function(n){this.isTemplated=n;!!this.children&&_.isArray(this.children)&&_(this.children).each(function(t){t.setIsTemplated(n)})};this.getIsActive=function(){return this.editor?this.editor.activeElement===this&&!this.getIsFocused():!1};this.setIsActive=function(n){this.editor&&(this.editor.isDragging||this.editor.inlineEditingIsActive||this.editor.isResizing||(this.editor.activeElement=n?this:this.parent))};this.getIsFocused=function(){return this.editor?this.editor.focusedElement===this:!1};this.setIsFocused=function(){this.editor&&(this.isTemplated||this.editor.isDragging||this.editor.inlineEditingIsActive||this.editor.isResizing||(this.editor.focusedElement=this,_(this.setIsFocusedEventHandlers).each(function(n){try{n()}catch(t){}})))};this.getIsSelected=function(){return this.getIsFocused()?!0:!!this.children&&_.isArray(this.children)?_(this.children).any(function(n){return n.getIsSelected()}):!1};this.getIsDropTarget=function(){return this.editor?this.editor.dropTargetElement===this:!1};this.setIsDropTarget=function(n){this.editor&&(this.editor.dropTargetElement=n?this:null)};this.delete=function(){!this.parent||this.parent.deleteChild(this)};this.canMoveUp=function(){return this.parent?this.parent.canMoveChildUp(this):!1};this.moveUp=function(){!this.parent||this.parent.moveChildUp(this)};this.canMoveDown=function(){return this.parent?this.parent.canMoveChildDown(this):!1};this.moveDown=function(){!this.parent||this.parent.moveChildDown(this)};this.elementToObject=function(){return{type:this.type,data:this.data,htmlId:this.htmlId,htmlClass:this.htmlClass,htmlStyle:this.htmlStyle,isTemplated:this.isTemplated}};this.getEditorObject=function(){return{}};this.copy=function(n){var t=this.getInnerText(),i,r;n.setData("text/plain",t);console.log(t);i=this.toObject();r=JSON.stringify(i,null,"\t");n.setData("text/json",r)};this.cut=function(n){this.copy(n);this.delete()};this.paste=function(n){!this.parent||this.parent.paste(n)}}}(LayoutEditor||(LayoutEditor={})),function(n){n.Container=function(t,i){this.allowedChildTypes=t;this.children=i;this.isContainer=!0;var r=this;this.setChildren=function(n){this.children=n;_(this.children).each(function(n){n.parent=r})};this.setChildren(i);this.getIsSealed=function(){return _(this.children).any(function(n){return n.isTemplated})};this.addChild=function(n){!_(this.children).contains(n)&&(_(this.allowedChildTypes).contains(n.type)||n.isContainable)&&this.children.push(n);n.setEditor(this.editor);n.setIsTemplated(!1);n.parent=this};this.deleteChild=function(n){var t=_(this.children).indexOf(n);t>=0&&(this.children.splice(t,1),n.getIsActive()&&(this.editor.activeElement=null),n.getIsFocused()&&(this.children.length>t?this.children[t].setIsFocused():t>0?this.children[t-1].setIsFocused():this.setIsFocused()))};this.moveFocusPrevChild=function(n){if(!(this.children.length<2)){var t=_(this.children).indexOf(n);t>0&&this.children[t-1].setIsFocused()}};this.moveFocusNextChild=function(n){if(!(this.children.length<2)){var t=_(this.children).indexOf(n);t0};this.canMoveChildDown=function(n){var t=_(this.children).indexOf(n);return t0?n.width<12:t<0?n.width>1:!1}var t,f,r,u;if(n==0)return!0;for(t=n,t<0&&(f=12-l(),t+=f,t>0&&(t=0));t<0&&_(s.children).any(function(n){return n.offset>0});)for(i=0;i0&&(r.offset--,t++);while(t!=0){if(!_(s.children).any(e))break;for(i=0;i=0?n.width>1:!1};this.contractColumnRight=function(n,t){var i,r;this.canContractColumnRight(n,t)&&(i=_(this.children).indexOf(n),i>=0&&n.width>1&&(n.width--,this.children.length>i+1&&(r=this.children[i+1],t&&r.offset==0?r.width++:r.offset++)))};this.canExpandColumnRight=function(n,t){var r=_(this.children).indexOf(n),i;return r>=0?n.width>=12?!1:this.children.length>r+1?(i=this.children[r+1],t&&i.offset==0?i.width>1:i.offset>0):l()<12:!1};this.expandColumnRight=function(n,t){var i,r;this.canExpandColumnRight(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(this.children.length>i+1&&(r=this.children[i+1],t&&r.offset==0?r.width--:r.offset--),n.width++))};this.canExpandColumnLeft=function(n,t){var i=_(this.children).indexOf(n),r;return i>=0?n.width>=12?!1:i>0&&(r=this.children[i-1],t&&n.offset==0)?r.width>1:n.offset>0:!1};this.expandColumnLeft=function(n,t){var i,r;this.canExpandColumnLeft(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(i>0?(r=this.children[i-1],t&&n.offset==0?r.width--:n.offset--):n.offset--,n.width++))};this.canContractColumnLeft=function(n){var t=_(this.children).indexOf(n);return t>=0?n.width>1:!1};this.contractColumnLeft=function(n,t){var i,r;this.canContractColumnLeft(n,t)&&(i=_(this.children).indexOf(n),i>=0&&(i>0?(r=this.children[i-1],t&&n.offset==0?r.width++:n.offset++):n.offset++,n.width--))};this.evenColumns=function(){var t,n;this.children.length!=0&&(t=Math.floor(12/this.children.length),_(this.children).each(function(n){n.width=t;n.offset=0}),n=12%this.children.length,n>0&&c(n))};v=this.pasteChild;this.pasteChild=function(n){n.type=="Column"?this.beginAddColumn(n.width)&&(this.commitAddColumn(),v.call(this,n)):!this.parent||this.parent.pasteChild(n)};this.toObject=function(){var n=this.elementToObject();return n.children=this.childrenToObject(),n}};n.Row.from=function(t){var i=new n.Row(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,n.childrenFrom(t.children));return i.toolboxIcon=t.toolboxIcon,i.toolboxLabel=t.toolboxLabel,i.toolboxDescription=t.toolboxDescription,i}}(LayoutEditor||(LayoutEditor={})),function(n){n.Column=function(t,i,r,u,f,e,o,s){n.Element.call(this,"Column",t,i,r,u,f);n.Container.call(this,["Grid","Content"],s);this.width=e;this.offset=o;var h=!1,c=0,l=0;this.beginChange=function(){if(!!h)throw new Error("Column already has a pending change.");h=!0;c=this.width;l=this.offset};this.commitChange=function(){if(!h)throw new Error("Column has no pending change.");c=0;l=0;h=!1};this.rollbackChange=function(){if(!h)throw new Error("Column has no pending change.");this.width=c;this.offset=l;c=0;l=0;h=!1};this.canSplit=function(){return this.width>1};this.split=function(){if(this.canSplit()){var t=Math.floor(this.width/2),i=n.Column.from({data:null,htmlId:null,htmlClass:null,htmlStyle:null,width:t,offset:0,children:[]});this.width=this.width-t;this.parent.insertChild(i,this);i.setIsFocused()}};this.canContractRight=function(n){return this.parent.canContractColumnRight(this,n)};this.contractRight=function(n){this.parent.contractColumnRight(this,n)};this.canExpandRight=function(n){return this.parent.canExpandColumnRight(this,n)};this.expandRight=function(n){this.parent.expandColumnRight(this,n)};this.canExpandLeft=function(n){return this.parent.canExpandColumnLeft(this,n)};this.expandLeft=function(n){this.parent.expandColumnLeft(this,n)};this.canContractLeft=function(n){return this.parent.canContractColumnLeft(this,n)};this.contractLeft=function(n){this.parent.contractColumnLeft(this,n)};this.toObject=function(){var n=this.elementToObject();return n.width=this.width,n.offset=this.offset,n.children=this.childrenToObject(),n}};n.Column.from=function(t){var i=new n.Column(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,t.width,t.offset,n.childrenFrom(t.children));return i.toolboxIcon=t.toolboxIcon,i.toolboxLabel=t.toolboxLabel,i.toolboxDescription=t.toolboxDescription,i};n.Column.times=function(t){return _.times(t,function(){return n.Column.from({data:null,htmlId:null,htmlClass:null,isTemplated:!1,width:12/t,offset:0,children:[]})})}}(LayoutEditor||(LayoutEditor={})),function(n){n.Content=function(t,i,r,u,f,e,o,s,h,c){n.Element.call(this,"Content",t,i,r,u,f);this.contentType=e;this.contentTypeLabel=o;this.contentTypeClass=s;this.html=h;this.hasEditor=c;this.getInnerText=function(){return $($.parseHTML("
"+this.html+"<\/div>")).text()};this.setHtml=function(n){this.html=n;this.htmlUnsafe=n};this.toObject=function(){return{type:"Content"}};this.toObject=function(){var n=this.elementToObject();return n.contentType=this.contentType,n.contentTypeLabel=this.contentTypeLabel,n.contentTypeClass=this.contentTypeClass,n.html=this.html,n.hasEditor=c,n};this.setHtml(h)};n.Content.from=function(t){return new n.Content(t.data,t.htmlId,t.htmlClass,t.htmlStyle,t.isTemplated,t.contentType,t.contentTypeLabel,t.contentTypeClass,t.html,t.hasEditor)}}(LayoutEditor||(LayoutEditor={})),function(n,t){t.Html=function(i,r,u,f,e,o,s,h,c,l){t.Element.call(this,"Html",i,r,u,f,e);this.contentType=o;this.contentTypeLabel=s;this.contentTypeClass=h;this.html=c;this.hasEditor=l;this.getInnerText=function(){return n(n.parseHTML("
"+this.html+"<\/div>")).text()};this.setHtml=function(n){this.html=n;this.htmlUnsafe=n};this.toObject=function(){return{type:"Html"}};this.toObject=function(){var n=this.elementToObject();return n.contentType=this.contentType,n.contentTypeLabel=this.contentTypeLabel,n.contentTypeClass=this.contentTypeClass,n.html=this.html,n.hasEditor=l,n};var a=this.getEditorObject;this.getEditorObject=function(){var t=a();return n.extend(t,{Content:this.html})};this.setHtml(c)};t.Html.from=function(n){return new t.Html(n.data,n.htmlId,n.htmlClass,n.htmlStyle,n.isTemplated,n.contentType,n.contentTypeLabel,n.contentTypeClass,n.html,n.hasEditor)};t.registerFactory("Html",function(n){return t.Html.from(n)})}(jQuery,LayoutEditor||(LayoutEditor={})); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Content.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Content.js index 83b3310cc..a6f921994 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Content.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Content.js @@ -36,14 +36,6 @@ return result; }; - var getEditorObject = this.getEditorObject; - this.getEditorObject = function () { - var dto = getEditorObject(); - return $.extend(dto, { - Content: this.html - }); - } - this.setHtml(html); }; diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Html.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Html.js new file mode 100644 index 000000000..94ec2ccd9 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Html.js @@ -0,0 +1,68 @@ +var LayoutEditor; +(function ($, LayoutEditor) { + + LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor) { + LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated); + + this.contentType = contentType; + this.contentTypeLabel = contentTypeLabel; + this.contentTypeClass = contentTypeClass; + this.html = html; + this.hasEditor = hasEditor; + + 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); + + 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/Services/DefaultModelMaps.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs index 526922ad5..ed631cfbc 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs @@ -1,5 +1,4 @@ -using System.Web.Mvc; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Orchard.DisplayManagement; using Orchard.Layouts.Elements; using Orchard.Layouts.Framework.Display; @@ -8,7 +7,11 @@ using Orchard.Layouts.Helpers; using Orchard.Utility.Extensions; namespace Orchard.Layouts.Services { - public abstract class LayoutModelMapBase : ILayoutModelMap where T:Element { + public abstract class LayoutModelMapBase : ILayoutModelMap where T : Element { + public int Priority { + get { return 10; } + } + public virtual string LayoutElementType { get { return typeof(T).Name; } } public virtual bool CanMap(Element element) { @@ -43,9 +46,9 @@ namespace Orchard.Layouts.Services { } } - public class CanvasModelMap : LayoutModelMapBase {} - public class GridModelMap : LayoutModelMapBase {} - public class RowModelMap : LayoutModelMapBase {} + public class CanvasModelMap : LayoutModelMapBase { } + public class GridModelMap : LayoutModelMapBase { } + public class RowModelMap : LayoutModelMapBase { } public class ColumnModelMap : LayoutModelMapBase { protected override void ToElement(Column element, JToken node) { @@ -64,20 +67,22 @@ namespace Orchard.Layouts.Services { public class ContentModelMap : ILayoutModelMap { private readonly IShapeDisplay _shapeDisplay; private readonly IElementDisplay _elementDisplay; - private readonly UrlHelper _urlHelper; - public ContentModelMap(IShapeDisplay shapeDisplay, IElementDisplay elementDisplay, UrlHelper urlHelper) { + public ContentModelMap(IShapeDisplay shapeDisplay, IElementDisplay elementDisplay) { _shapeDisplay = shapeDisplay; _elementDisplay = elementDisplay; - _urlHelper = urlHelper; } - public string LayoutElementType { get { return "Content"; } } - public bool CanMap(Element element) { + public virtual int Priority { + get { return 0; } + } + + public virtual string LayoutElementType { get { return "Content"; } } + public virtual bool CanMap(Element element) { return !(element is Container); } - public Element ToElement(IElementManager elementManager, DescribeElementsContext describeContext, JToken node) { + public virtual Element ToElement(IElementManager elementManager, DescribeElementsContext describeContext, JToken node) { var elementTypeName = (string)node["contentType"]; var descriptor = elementManager.GetElementDescriptorByTypeName(describeContext, elementTypeName); var element = elementManager.ActivateElement(descriptor); @@ -88,13 +93,6 @@ namespace Orchard.Layouts.Services { element.HtmlStyle = (string)node["htmlStyle"]; element.IsTemplated = (bool)(node["isTemplated"] ?? false); - // To support inline editing, we need to tell the element to update its content. - var contentElement = element as IContentElement; - if (contentElement != null) { - var html = (string)node["html"]; - contentElement.Content = html; - } - return element; } @@ -112,4 +110,32 @@ namespace Orchard.Layouts.Services { node["html"] = _shapeDisplay.Display(_elementDisplay.DisplayElement(element, content: describeContext.Content, displayType: "Design")); } } + + 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; + } + } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutModelMap.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutModelMap.cs index 9ef1b6f30..301752ec5 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutModelMap.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutModelMap.cs @@ -3,6 +3,7 @@ using Orchard.Layouts.Framework.Elements; namespace Orchard.Layouts.Services { public interface ILayoutModelMap : IDependency { + int Priority { get; } string LayoutElementType { get; } bool CanMap(Element element); Element ToElement(IElementManager elementManager, DescribeElementsContext describeContext, JToken node); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutEditorFactory.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutEditorFactory.cs index 00c885c7c..56849f50d 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutEditorFactory.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutEditorFactory.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using System.Web.UI.WebControls.WebParts; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Orchard.ContentManagement; diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutModelMapper.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutModelMapper.cs index cdc5f9f06..8d05c73f2 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutModelMapper.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutModelMapper.cs @@ -59,7 +59,7 @@ namespace Orchard.Layouts.Services { } public ILayoutModelMap GetMapFor(Element element) { - return _maps.Value.Single(x => x.CanMap(element)); + return SelectMap(x => x.CanMap(element)); } private Element ParseEditorNode(JToken node, Container parent, int index, DescribeElementsContext describeContext) { @@ -77,7 +77,7 @@ namespace Orchard.Layouts.Services { private Element LoadElement(JToken node, Container parent, int index, DescribeElementsContext describeContext) { var type = (string)node["type"]; - var map = _maps.Value.Single(x => x.LayoutElementType == type); + var map = SelectMap(x => x.LayoutElementType == type); var element = map.ToElement(_elementManager, describeContext, node); element.Container = parent; @@ -85,5 +85,9 @@ namespace Orchard.Layouts.Services { return element; } + + private ILayoutModelMap SelectMap(Func predicate) { + return _maps.Value.OrderByDescending(x => x.Priority).FirstOrDefault(predicate); + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Tokens/ElementTokens.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Tokens/ElementTokens.cs index 5d8173b3f..d5d80aca8 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Tokens/ElementTokens.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Tokens/ElementTokens.cs @@ -8,11 +8,11 @@ using Orchard.Tokens; namespace Orchard.Layouts.Tokens { [OrchardFeature("Orchard.Layouts.Tokens")] public class ElementTokens : Component, ITokenProvider { - private readonly ElementManager _elementManager; - private readonly ElementDisplay _elementDisplay; + private readonly IElementManager _elementManager; + private readonly IElementDisplay _elementDisplay; private readonly IShapeDisplay _shapeDisplay; - public ElementTokens(ElementManager elementManager, ElementDisplay elementDisplay, IShapeDisplay shapeDisplay) { + public ElementTokens(IElementManager elementManager, IElementDisplay elementDisplay, IShapeDisplay shapeDisplay) { _elementManager = elementManager; _elementDisplay = elementDisplay; _shapeDisplay = shapeDisplay; diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/TextEditorViewModel.cs b/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/TextEditorViewModel.cs index 4069a0bd6..5d8b37abb 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/TextEditorViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/TextEditorViewModel.cs @@ -1,6 +1,5 @@ namespace Orchard.Layouts.ViewModels { public class TextEditorViewModel { - public string Text { get; set; } - public string Flavor { get; set; } + public string Content { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Paragraph.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Paragraph.cshtml index 7cb98ba63..9b1588dd5 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Paragraph.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Paragraph.cshtml @@ -4,5 +4,6 @@ }
@Html.LabelFor(m => m.Text, T("Body")) - @Html.TextAreaFor(m => m.Text, new { @class = "text large", rows = 10, autofocus = "autofocus" }) + @Html.TextAreaFor(m => m.Text, 25, 80, new { @class = "text large tokenized", autofocus = "autofocus" }) + @Html.Hint(T("Note: HTML markup will be rendered unencoded."))
\ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Text.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Text.cshtml index f2bbd4255..3a9627a87 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Text.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Text.cshtml @@ -3,6 +3,7 @@ Script.Include("AutoFocus.js"); }
- @Html.LabelFor(m => m.Text, T("Body")) - @Display.Body_Editor(EditorFlavor: Model.Flavor, Text: Model.Text, AutoFocus: true) + @Html.LabelFor(m => m.Content, T("Body")) + @Html.TextAreaFor(m => m.Content, 25, 80, new { @class = "text large tokenized", autofocus = "autofocus" }) + @Html.Hint(T("Note: HTML markup will be rendered encoded."))
\ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml index 59bd542b8..aa80bdee5 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/ElementEditor.cshtml @@ -40,7 +40,7 @@ typeLabel: "@Model.DisplayText.Text", typeClass: "@Model.DisplayText.Text.HtmlClassify()", data: LayoutEditor.decode("@Url.Encode(Model.ElementData)"), - html: "@Url.Encode(Model.ElementHtml)", + html: LayoutEditor.decode("@Url.Encode(Model.ElementHtml)"), isTemplated: false }, elementEditorModel: @Html.Raw(Model.ElementEditorModel.ToJson()) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Html.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Html.cshtml index 3e65b63b5..08f04fdb4 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Html.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Html.cshtml @@ -1,11 +1,8 @@ @using Orchard.DisplayManagement.Shapes -@using Orchard.Layouts.Elements @using Orchard.Layouts.Helpers @{ - var element = (Html)Model.Element; var tagBuilder = TagBuilderExtensions.AddCommonElementAttributes(new OrchardTagBuilder("div"), Model); - var text = element.Content; } @tagBuilder.StartElement -@Html.Raw(text) -@tagBuilder.EndElement +@Html.Raw(Model.ProcessedText) +@tagBuilder.EndElement \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Paragraph.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Paragraph.cshtml index 87cd41316..515f54a7e 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Paragraph.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Paragraph.cshtml @@ -1,10 +1,8 @@ @using Orchard.DisplayManagement.Shapes -@using Orchard.Layouts.Elements @using Orchard.Layouts.Helpers @{ var tagBuilder = TagBuilderExtensions.AddCommonElementAttributes(new OrchardTagBuilder("p"), Model); - var element = (Paragraph) Model.Element; } @tagBuilder.StartElement -@Html.Raw(element.Content) +@Html.Raw(Model.ProcessedText) @tagBuilder.EndElement diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Text.Design.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Text.Design.cshtml index 859a020c5..c96c6cffd 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Text.Design.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Text.Design.cshtml @@ -1 +1 @@ -@Html.Raw((string)Model.ProcessedText) \ No newline at end of file +@Model.Element.Content \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Content.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Content.cshtml index e812b1046..c5599aa98 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Content.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Content.cshtml @@ -1,5 +1,4 @@ -@using Orchard.Layouts.ViewModels; -
+
  • {{::element.contentTypeLabel}}
  • @@ -8,5 +7,5 @@
-
+
\ No newline at end of file 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 new file mode 100644 index 000000000..fe336ae2f --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Html.cshtml @@ -0,0 +1,11 @@ +
+
    +
  • {{::element.contentTypeLabel}}
  • +
  • + @Display(New.LayoutEditor_Template_Properties(ElementTypeName: "{{element.contentTypeLabel.toLowerCase()}}")) +
  • +
  • +
  • +
+
+
\ No newline at end of file