Minor visual annoyances + changed output html
changes made due to feedback from Adam, Rune and Simon on how to make the grid as flexible as possible
This commit is contained in:
@@ -1,47 +1,78 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
@using Newtonsoft.Json.Linq;
|
||||
@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-fluid" : "")">
|
||||
<div class="row-fluid clearfix">
|
||||
@foreach (var s in Model.sections)
|
||||
{
|
||||
<div class="@("span" + s.grid)">
|
||||
@foreach (var row in s.rows)
|
||||
{
|
||||
<div class="gridrow_@row.uniqueId" >
|
||||
<div>
|
||||
<div class="row-fluid clearfix">
|
||||
<div class="uSky-grid @(onlyOneColumn > 1 ? "container-fluid" : "")">
|
||||
<div class="row-fluid clearfix">
|
||||
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="@("span" + area.grid)">
|
||||
@foreach (var s in Model.sections){
|
||||
<div class="@("span" + s.grid) column"> <!-- section -->
|
||||
<div class="grid-section">
|
||||
<div @RenderElementAttributes(s)>
|
||||
<div class="@(onlyOneColumn == 1 ? "container-fluid" : "")"><!-- remove container class -->
|
||||
|
||||
<!-- foreach row in section -->
|
||||
@foreach (var row in s.rows){
|
||||
<div class="row-fluid clearfix">
|
||||
<div class="grid-row grid-row-@row.uniqueId">
|
||||
<div @RenderElementAttributes(row)>
|
||||
@foreach (var area in row.areas){
|
||||
<div class="@("span" + 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>
|
||||
@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>
|
||||
}
|
||||
@@ -32,40 +32,47 @@
|
||||
{
|
||||
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">
|
||||
@foreach (var row in s.rows)
|
||||
{
|
||||
<div class="gridrow_@row.uniqueId" @RenderElementAttributes(row)>
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
<div class="uSky-grid @(onlyOneColumn > 1 ? "container" : "")">
|
||||
<div class="row clearfix">
|
||||
|
||||
@foreach (var area in row.areas)
|
||||
{
|
||||
<div class="col-md-@area.grid column">
|
||||
@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>
|
||||
@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>
|
||||
}
|
||||
Reference in New Issue
Block a user