changes made due to feedback from Adam, Rune and Simon on how to make the grid as flexible as possible
78 lines
3.0 KiB
Plaintext
78 lines
3.0 KiB
Plaintext
@inherits UmbracoViewPage<dynamic>
|
|
@using Umbraco.Web.Templates
|
|
@using Newtonsoft.Json.Linq
|
|
|
|
@functions {
|
|
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
|
|
{
|
|
var attrs = new List<string>();
|
|
JObject cfg = contentItem.config;
|
|
|
|
if(cfg != null)
|
|
foreach (JProperty property in cfg.Properties())
|
|
attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
|
|
|
|
JObject style = contentItem.styles;
|
|
|
|
if (style != null) {
|
|
var cssVals = new List<string>();
|
|
foreach (JProperty property in style.Properties())
|
|
cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
|
|
|
|
if (cssVals.Any())
|
|
attrs.Add("style='" + string.Join(" ", cssVals) + "'");
|
|
}
|
|
|
|
return new MvcHtmlString(string.Join(" ", attrs));
|
|
}
|
|
}
|
|
|
|
|
|
@if (Model != null && !string.IsNullOrEmpty(Model.ToString()))
|
|
{
|
|
var onlyOneColumn = Model.sections != null ? ((System.Collections.ICollection)Model.sections).Count : 0;
|
|
|
|
<div class="uSky-grid @(onlyOneColumn > 1 ? "container" : "")">
|
|
<div class="row clearfix">
|
|
|
|
@foreach (var s in Model.sections){
|
|
<div class="col-md-@s.grid column"> <!-- section -->
|
|
<div class="grid-section">
|
|
<div @RenderElementAttributes(s)>
|
|
<div class="@(onlyOneColumn == 1 ? "container" : "")"><!-- remove container class -->
|
|
|
|
<!-- foreach row in section -->
|
|
@foreach (var row in s.rows){
|
|
<div class="row clearfix">
|
|
<div class="grid-row grid-row-@row.uniqueId">
|
|
<div @RenderElementAttributes(row)>
|
|
@foreach (var area in row.areas){
|
|
<div class="col-md-@area.grid column">
|
|
<div class="grid-cell">
|
|
<div @RenderElementAttributes(area)>
|
|
|
|
@foreach (var control in area.controls){
|
|
if (control != null && control.editor != null && control.editor.view != null){
|
|
string editor = "grid/editors/" + control.editor.view.ToString();
|
|
<text>@Html.Partial(editor, (object)control)</text>
|
|
}
|
|
}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
</div>
|
|
</div>
|
|
} |