From 195d8711f9b8773d3bba8c5d8286c51118f4d65c Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 19 Apr 2015 21:18:31 +0200 Subject: [PATCH] Removed Zones integration. --- .../Orchard.Layouts/Elements/Column.cs | 5 -- .../Handlers/LayoutPartHandler.cs | 5 -- .../Modules/Orchard.Layouts/Scripts/Models.js | 6 +- .../Orchard.Layouts/Scripts/Models.min.js | 2 +- .../Orchard.Layouts/Scripts/Models/Column.js | 6 +- .../Services/DefaultModelMaps.cs | 2 - .../Services/ILayoutManager.cs | 10 --- .../Orchard.Layouts/Services/LayoutManager.cs | 63 ++----------------- .../Modules/Orchard.Layouts/Signals.cs | 1 - .../Views/LayoutEditor.Template.Column.cshtml | 4 -- 10 files changed, 8 insertions(+), 96 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Column.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Column.cs index eb84dcd87..7f87b3e0d 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Column.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Elements/Column.cs @@ -34,11 +34,6 @@ namespace Orchard.Layouts.Elements { get { return Width.GetValueOrDefault() + Offset.GetValueOrDefault(); } } - public string ZoneName { - get { return this.Retrieve(x => x.ZoneName); } - set { this.Store(x => x.ZoneName, value); } - } - public bool? Collapsible { get { return this.Retrieve(x => x.Collapsible); } set { this.Store(x => x.Collapsible, value); } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Handlers/LayoutPartHandler.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Handlers/LayoutPartHandler.cs index 53530f962..d95eb9abf 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Handlers/LayoutPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Handlers/LayoutPartHandler.cs @@ -33,7 +33,6 @@ namespace Orchard.Layouts.Handlers { Filters.Add(StorageFilter.For(repository)); OnPublished(UpdateTemplateClients); - OnPublished(InvalidateLayoutZones); OnIndexing(IndexLayout); } @@ -50,10 +49,6 @@ namespace Orchard.Layouts.Handlers { UpdateTemplateClients(part); } - private void InvalidateLayoutZones(PublishContentContext context, LayoutPart part) { - _signals.Trigger(Signals.LayoutZones); - } - /// /// Recursively updates all layouts that use the specified layout as its template. /// diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js index 93fd82db7..672029ad4 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models.js @@ -731,13 +731,12 @@ var LayoutEditor; })(LayoutEditor || (LayoutEditor = {})); var LayoutEditor; (function (LayoutEditor) { - LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) { + LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, collapsible, rule, children) { LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule); LayoutEditor.Container.call(this, ["Grid", "Content"], children); this.width = width; this.offset = offset; - this.zoneName = zoneName; this.collapsible = collapsible; var _hasPendingChange = false; @@ -830,7 +829,6 @@ var LayoutEditor; var result = this.elementToObject(); result.width = this.width; result.offset = this.offset; - result.zoneName = this.zoneName; result.collapsible = this.collapsible; result.children = this.childrenToObject(); return result; @@ -846,7 +844,6 @@ var LayoutEditor; value.isTemplated, value.width, value.offset, - value.zoneName, value.collapsible, value.rule, LayoutEditor.childrenFrom(value.children)); @@ -865,7 +862,6 @@ var LayoutEditor; isTemplated: false, width: 12 / value, offset: 0, - zoneName: null, collapsible: null, children: [] }); 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 7f48cd8de..f464adb1b 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};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.isContainable=!0;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 +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,e){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.rule=e;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,rule:this.rule}};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-a(),t+=f,t>0&&(t=0));t<0&&_(h.children).any(function(n){return n.offset>0});)for(i=0;i0&&(r.offset--,t++);while(t!=0){if(!_(h.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):a()<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&&l(n))};y=this.pasteChild;this.pasteChild=function(n){n.type=="Column"?this.beginAddColumn(n.width)&&(this.commitAddColumn(),y.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,t.rule,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,h,c){n.Element.call(this,"Column",t,i,r,u,f,h);n.Container.call(this,["Grid","Content"],c);this.width=e;this.offset=o;this.collapsible=s;var l=!1,a=0,v=0;this.beginChange=function(){if(!!l)throw new Error("Column already has a pending change.");l=!0;a=this.width;v=this.offset};this.commitChange=function(){if(!l)throw new Error("Column has no pending change.");a=0;v=0;l=!1};this.rollbackChange=function(){if(!l)throw new Error("Column has no pending change.");this.width=a;this.offset=v;a=0;v=0;l=!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.collapsible=this.collapsible,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,t.collapsible,t.rule,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,collapsible:null,children:[]})})}}(LayoutEditor||(LayoutEditor={})),function(n){n.Content=function(t,i,r,u,f,e,o,s,h,c,l){n.Element.call(this,"Content",t,i,r,u,f,l);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,t.rule)}}(LayoutEditor||(LayoutEditor={})),function(n,t){t.Html=function(i,r,u,f,e,o,s,h,c,l,a){t.Element.call(this,"Html",i,r,u,f,e,a);this.contentType=o;this.contentTypeLabel=s;this.contentTypeClass=h;this.html=c;this.hasEditor=l;this.isContainable=!0;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 v=this.getEditorObject;this.getEditorObject=function(){var t=v();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,n.rule)};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/Column.js b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Column.js index 5bdf51acb..a4c6d8fa3 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Column.js +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Scripts/Models/Column.js @@ -1,12 +1,11 @@ var LayoutEditor; (function (LayoutEditor) { - LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, zoneName, collapsible, rule, children) { + LayoutEditor.Column = function (data, htmlId, htmlClass, htmlStyle, isTemplated, width, offset, collapsible, rule, children) { LayoutEditor.Element.call(this, "Column", data, htmlId, htmlClass, htmlStyle, isTemplated, rule); LayoutEditor.Container.call(this, ["Grid", "Content"], children); this.width = width; this.offset = offset; - this.zoneName = zoneName; this.collapsible = collapsible; var _hasPendingChange = false; @@ -99,7 +98,6 @@ var result = this.elementToObject(); result.width = this.width; result.offset = this.offset; - result.zoneName = this.zoneName; result.collapsible = this.collapsible; result.children = this.childrenToObject(); return result; @@ -115,7 +113,6 @@ value.isTemplated, value.width, value.offset, - value.zoneName, value.collapsible, value.rule, LayoutEditor.childrenFrom(value.children)); @@ -134,7 +131,6 @@ isTemplated: false, width: 12 / value, offset: 0, - zoneName: null, collapsible: null, children: [] }); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs index ca532d6c9..51391b64a 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DefaultModelMaps.cs @@ -74,7 +74,6 @@ namespace Orchard.Layouts.Services { base.ToElement(element, node); element.Width = (int?)node["width"]; element.Offset = (int?)node["offset"]; - element.ZoneName = (string) node["zoneName"]; element.Collapsible = ReadBoolean(node["collapsible"]); } @@ -82,7 +81,6 @@ namespace Orchard.Layouts.Services { base.FromElement(element, describeContext, node); node["width"] = element.Width; node["offset"] = element.Offset; - node["zoneName"] = element.ZoneName; node["collapsible"] = element.Collapsible; } } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutManager.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutManager.cs index ebf7985e6..2eac8b64d 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ILayoutManager.cs @@ -55,15 +55,5 @@ namespace Orchard.Layouts.Services { IEnumerable CreateDefaultLayout(); void Exporting(ExportLayoutContext context); void Importing(ImportLayoutContext context); - - /// - /// Collects all zones as defined in all layouts in the system. - /// - IEnumerable GetZones(); - - /// - /// Recursively collects all zones of the specified layout and of its selected template, if any. - /// - IEnumerable GetZones(ILayoutAspect layout); } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutManager.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutManager.cs index 34c4cd622..4e65ded44 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/LayoutManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Orchard.Caching; using Orchard.ContentManagement; using Orchard.Layouts.Elements; using Orchard.Layouts.Framework.Display; @@ -10,7 +9,6 @@ using Orchard.Layouts.Framework.Elements; using Orchard.Layouts.Helpers; using Orchard.Layouts.Models; using Orchard.Layouts.Settings; -using Orchard.Validation; namespace Orchard.Layouts.Services { public class LayoutManager : ILayoutManager { @@ -18,23 +16,17 @@ namespace Orchard.Layouts.Services { private readonly ILayoutSerializer _serializer; private readonly IElementDisplay _elementDisplay; private readonly IElementManager _elementManager; - private readonly ICacheManager _cacheManager; - private readonly ISignals _signals; public LayoutManager( - IContentManager contentManager, - ILayoutSerializer serializer, - IElementDisplay elementDisplay, - IElementManager elementManager, - ICacheManager cacheManager, - ISignals signals) { + IContentManager contentManager, + ILayoutSerializer serializer, + IElementDisplay elementDisplay, + IElementManager elementManager) { _contentManager = contentManager; _serializer = serializer; _elementDisplay = elementDisplay; _elementManager = elementManager; - _cacheManager = cacheManager; - _signals = signals; } public IEnumerable GetTemplates() { @@ -83,37 +75,6 @@ namespace Orchard.Layouts.Services { context.Layout.LayoutData = _serializer.Serialize(elementTree); } - public IEnumerable GetZones() { - return _cacheManager.Get("LayoutZones", context => { - context.Monitor(_signals.When(Signals.LayoutZones)); - return GetZones(GetLayouts()); - }); - } - - public IEnumerable GetZones(ILayoutAspect layout) { - Argument.ThrowIfNull(layout, "layout"); - - var key = String.Format("LayoutZones-{0}", layout.Id); - return _cacheManager.Get(key, context => { - context.Monitor(_signals.When(Signals.LayoutZones)); - - var layouts = new List(); - var currentTemplate = layout.TemplateId != null ? GetLayout(layout.TemplateId.Value) : default(LayoutPart); - - // Add the layout itself to the chain of layouts to harvest zones from. - layouts.Add(layout); - - // Walk up the chain of templates and collect each one for zone harvesting. - while (currentTemplate != null) { - layouts.Add(currentTemplate); - currentTemplate = currentTemplate.TemplateId != null ? GetLayout(currentTemplate.TemplateId.Value) : default(LayoutPart); - } - - // Harvest the zones from the chain of layouts. - return GetZones(layouts); - }); - } - public dynamic RenderLayout(string data, string displayType = null, IContent content = null) { var elements = _serializer.Deserialize(data, new DescribeElementsContext { Content = content }); var layoutRoot = _elementDisplay.DisplayElements(elements, content, displayType); @@ -138,7 +99,7 @@ namespace Orchard.Layouts.Services { var nonTemplatedElements = ExtractNonTemplatedElements(layout).ToList(); foreach (var element in nonTemplatedElements) { - + // Move the element to the template and try to maintain its index. var column = element.Container as Column; var indexInTemplate = templateColumns.Any() ? 0 : -1; @@ -213,19 +174,5 @@ namespace Orchard.Layouts.Services { } } } - - private IEnumerable GetZones(IEnumerable layouts) { - var zoneNames = new HashSet(); - - foreach (var layoutPart in layouts) { - var elements = LoadElements(layoutPart).Flatten(); - var columns = elements.Where(x => x is Column).Cast().Where(x => !String.IsNullOrWhiteSpace(x.ZoneName)).ToList(); - - foreach (var column in columns) - zoneNames.Add(column.ZoneName); - } - - return zoneNames.OrderBy(x => x); - } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Signals.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Signals.cs index b2f23982a..6ea01ffa8 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Signals.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Signals.cs @@ -1,6 +1,5 @@ namespace Orchard.Layouts { public static class Signals { public static readonly object ElementDescriptors = new object(); - public static readonly object LayoutZones = new object(); } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Column.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Column.cshtml index 0e8d7a831..c7214ce40 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Column.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/LayoutEditor.Template.Column.cshtml @@ -1,10 +1,6 @@ @using Orchard.Layouts.ViewModels @{ var additionalItems = new[] { - new LayoutEditorPropertiesItem { - Label = "Zone Name:", - Model = "element.zoneName" - }, new LayoutEditorPropertiesItem { Label = "Collapsible", Model = "element.collapsible",