mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Implemented blended positioned rendering.
This commit is contained in:
@@ -20,11 +20,11 @@ namespace Orchard.Layouts.Drivers {
|
||||
if (column.Collapsible == true && IsEmpty(columnShape)) {
|
||||
columnShape.Collapsed = true;
|
||||
|
||||
// Get the first non-collapsed sibling column so we can increase its width with the width of the current column being collapsed.
|
||||
var sibling = GetNonCollapsedSibling(columnShapes, columnIndex);
|
||||
if (sibling != null) {
|
||||
// Increase the width of the sibling by the width of the current column.
|
||||
sibling.Width += columnShape.Width;
|
||||
//sibling.Width += GetAvailableWidth(columnShapes.Skip(columnIndex));
|
||||
}
|
||||
else {
|
||||
// The row has only one column, which is collapsed, so we hide the row entirely.
|
||||
@@ -41,10 +41,6 @@ namespace Orchard.Layouts.Drivers {
|
||||
return siblings.FirstOrDefault(x => x.Collapsed == false);
|
||||
}
|
||||
|
||||
private int GetAvailableWidth(IEnumerable<dynamic> columnShapes) {
|
||||
return columnShapes.Where(x => IsEmpty(x)).Sum(x => (int) x.Width);
|
||||
}
|
||||
|
||||
private static bool IsEmpty(dynamic shape) {
|
||||
return shape.Items.Count == 0;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Shapes;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
@@ -65,10 +66,11 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
|
||||
if (container != null) {
|
||||
if (container.Elements.Any()) {
|
||||
var childIndex = 0;
|
||||
foreach (var child in container.Elements) {
|
||||
var childShape = DisplayElement(child, content, displayType: displayType, updater: updater);
|
||||
childShape.Parent = elementShape;
|
||||
elementShape.Add(childShape);
|
||||
elementShape.Add(childShape, childIndex++.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,10 +94,11 @@ namespace Orchard.Layouts.Framework.Display {
|
||||
|
||||
public dynamic DisplayElements(IEnumerable<Element> elements, IContent content, string displayType = null, IUpdateModel updater = null) {
|
||||
var layoutRoot = (dynamic)_shapeFactory.Create("LayoutRoot");
|
||||
var index = 0;
|
||||
|
||||
foreach (var element in elements) {
|
||||
var elementShape = DisplayElement(element, content, displayType, updater);
|
||||
layoutRoot.Add(elementShape);
|
||||
layoutRoot.Add(elementShape, index++.ToString());
|
||||
}
|
||||
|
||||
return layoutRoot;
|
||||
|
@@ -33,13 +33,12 @@ namespace Orchard.Layouts.Shapes {
|
||||
public void Discover(ShapeTableBuilder builder) {
|
||||
builder.Describe("Element").OnDisplaying(context => {
|
||||
var element = (Element)context.Shape.Element;
|
||||
|
||||
// Tokenize common settings
|
||||
var content = (ContentItem)context.Shape.ContentItem;
|
||||
var htmlId = element.HtmlId;
|
||||
var htmlClass = element.HtmlClass;
|
||||
var htmlStyle = element.HtmlStyle;
|
||||
|
||||
// Provide tokenizer functions.
|
||||
context.Shape.TokenizeHtmlId = (Func<string>)(() => _tokenizer.Value.Replace(htmlId, new { Content = content }));
|
||||
context.Shape.TokenizeHtmlClass = (Func<string>)(() => _tokenizer.Value.Replace(htmlClass, new { Content = content }));
|
||||
context.Shape.TokenizeHtmlStyle = (Func<string>)(() => _tokenizer.Value.Replace(htmlStyle, new { Content = content }));
|
||||
@@ -70,6 +69,7 @@ namespace Orchard.Layouts.Shapes {
|
||||
}
|
||||
|
||||
private static void DisplayChildren(dynamic shape, dynamic display, TextWriter output) {
|
||||
shape = CoreShapes.Order(shape);
|
||||
foreach (var child in shape) {
|
||||
output.Write(display(child));
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@using Orchard.DisplayManagement.Shapes
|
||||
@using Orchard.Core.Shapes
|
||||
@using Orchard.DisplayManagement.Shapes
|
||||
@using Orchard.Layouts.Helpers
|
||||
@{
|
||||
var columnSpan = (int?)Model.Width;
|
||||
@@ -12,6 +13,8 @@
|
||||
}
|
||||
@if (!Model.Collapsed) {
|
||||
@tagBuilder.StartElement
|
||||
@DisplayChildren(Model)
|
||||
foreach (var item in CoreShapes.Order(Model)) {
|
||||
@Display(item)
|
||||
}
|
||||
@tagBuilder.EndElement
|
||||
}
|
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Shapes;
|
||||
using Orchard.Layouts.Elements;
|
||||
using Orchard.Layouts.Framework.Display;
|
||||
using Orchard.Layouts.Framework.Drivers;
|
||||
|
Reference in New Issue
Block a user