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:
per ploug
2014-11-06 22:58:35 +01:00
parent 9cd8ce5626
commit ed8cccdf5a
8 changed files with 238 additions and 166 deletions

View File

@@ -18,7 +18,7 @@
width: 160px !important;
overflow: hidden;
padding: 5px;
border-radius:50px;
border-radius:5px;
-webkit-box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
-moz-box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
@@ -149,6 +149,7 @@
right: 0;
width: 150px;
opacity: 0.3;
z-index: 50;
}
.usky-grid .cell-tools:hover{
@@ -158,11 +159,9 @@
.usky-grid .cell-tools-add {
position: absolute;
text-align: center;
bottom: -20px;
bottom: 0px;
left: 0;
right: 0;
z-index: 500;
opacity: 0.3;
}
.usky-grid .usky-control:hover .cell-tools-add{
@@ -480,7 +479,7 @@
/**************************************************************************************************/
.usky-grid .usky-cell{
padding-bottom: 20px;
}
.usky-grid .usky-row{
@@ -569,29 +568,52 @@
vertical-align: middle;
}
.usky-grid .usky-templates-columns .td i{
.usky-grid .usky-templates-columns .td i{
color: @gray;
opacity: 0.8
}
}
.usky-grid .mainTbpt:hover {
.usky-grid .mainTbpt:hover {
border-color:@blue;
}
}
.usky-grid .mainTbpt {
.usky-grid .mainTbpt {
cursor:pointer;
border-collapse: separate;
min-height: 35px;
border: 2px solid @grayLight;
margin:0px;
padding: 1px;
background-color: @grayLighter;
}
}
.usky-grid .mainTdpt {
.usky-grid .mainTdpt {
padding: 1px;
}
}
.usky-grid .mainTbpt {
height: auto;
}
.usky-grid .mainTdpt {
height: 11px;
margin: 0;
overflow: hidden;
border: 1px dashed #d9d9d9;
display: block;
float: left;
}
.mainTdpt span{
width: 100%;
display: block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0 1px;
height: 10px;
background: @grayLight
}
/**************************************************************************************************/
@@ -603,14 +625,13 @@
height: 380px;
overflow: auto;
border: 1px solid #ccc;
margin-top: -190px;
margin-top: -270px;
margin-left: -150px;
background: white;
padding: 7px;
top: 0;
left: 50%;
z-index: 666;
z-index: 6660;
-webkit-box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
-moz-box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
box-shadow: 3px 3px 12px 0px rgba(50, 50, 50, 0.45);
@@ -677,14 +698,21 @@
.usky-grid-configuration .uSky-templates .uSky-templates-template{
margin: 0px 20px 20px 0px;
width: 60px;
width: 80px;
}
.usky-grid-configuration .uSky-templates .uSky-templates-template .tb{
height: 50px;
max-height: 50px;
border-width: 2px !important;
padding: 0px;
border-spacing:2px;
overflow: hidden;
}
.usky-grid-configuration .uSky-templates .uSky-templates-template span{
background: @grayLight;
display: inline-block;
}
.usky-grid-configuration .uSky-templates .uSky-templates-template .tb:hover{
@@ -695,6 +723,8 @@
display: block;
float: left;
margin-left: -1px;
border: 1px white solid !important;
background: @grayLighter;
}
.usky-grid-configuration .uSky-templates-column.last{
@@ -706,9 +736,14 @@
font-size: 20px;
line-height: 70px;
color: #ccc;
text-decoration: none
text-decoration: none;
background: white;
}
.usky-grid-configuration .mainTdpt{
height: initial;
border: none;
}
.usky-grid-configuration .uSky-templates-rows .uSky-templates-row{
margin: 0px 50px 20px 0px;

View File

@@ -1,5 +1,6 @@
<div ng-controller="Umbraco.PropertyEditors.Grid.TextStringController">
<textarea
rows="1"
class="textstring input-block-level" id="{{control.uniqueId}}_text"
ng-keyup="adjustSize($event)" ng-model="control.value"
ng-attr-style="{{control.editor.config.style}}" placeholder="Write here..."></textarea>

View File

@@ -8,7 +8,7 @@ angular.module("umbraco")
$scope.currentToolsControl = null;
$scope.currentControl = null;
$scope.openRTEToolbarId = null;
$scope.hasSettings = false;
// *********************************************
// Sortable options
@@ -385,6 +385,11 @@ angular.module("umbraco")
$scope.initContent = function() {
var clear = true;
//settings indicator shortcut
if($scope.model.config.items.config || $scope.model.config.items.styles){
$scope.hasSettings = true;
}
if ($scope.model.value && $scope.model.value.sections && $scope.model.value.sections.length > 0) {
_.forEach($scope.model.value.sections, function(section){
@@ -453,9 +458,14 @@ angular.module("umbraco")
//sync area configuration
_.each(original.areas, function(area, areaIndex){
var currentArea = row.areas[areaIndex];
area.config = currentArea.config;
area.styles = currentArea.styles;
//copy over existing controls into the new areas
if(row.areas.length > areaIndex && row.areas[areaIndex].controls){
area.controls = row.areas[areaIndex].controls;
area.controls = currentArea.controls;
_.forEach(area.controls, function(control, controlIndex){
$scope.initControl(control, controlIndex);

View File

@@ -71,9 +71,9 @@
</a>
</div>
<div class="cell-tools-edit">
<div class="cell-tools-edit" ng-if="hasSettings">
<a href class="iconBox" ng-click="editGridItemSettings(row)">
<i class="icon icon-settings-alt"></i>
<i class="icon icon-settings"></i>
</a>
</div>
@@ -93,51 +93,6 @@
class="td mainTd usky-cell"
ng-repeat="area in row.areas" ui-sortable="sortableOptionsCell" ng-model="area.controls">
<!-- if area is empty tools -->
<div class="usky-control usky-control-placeholder"
ng-if="area.controls.length == 0">
<div ng-if="area.allowed && area.allowed.length === 1"
ng-init="singleEditor = area.$allowedEditors[0]"
class="cell-tools-add-single single-editor-{{singleEditor.alias}}">
<div class="help-text" style="margin-bottom: 15px">
To start, click the <i class=" icon {{singleEditor.icon}} blue">
</i> below and add your first {{singleEditor.name}}
</div><br />
<div class="iconBox">
<a href ng-click="addControl(singleEditor, area)">
<i class="icon {{singleEditor.icon}}"></i>
</a>
</div>
</div>
<div ng-if="!area.allowed || area.allowed.length > 1">
<div class="help-text" style="margin-bottom: 15px">
To start, click the <i class=" icon icon-add blue">
</i> below and add your first element
</div><br />
<div class="cell-tools-add"
ng-if="!currentToolsControl"
ng-animate="'fade'">
<div class="iconBox">
<a href ng-click="addItemOverlay($event, area, 0, area.$uniqueId);">
<i class=" icon icon-add"></i>
</a>
</div>
<div ng-if="overlayMenu.show && overlayMenu.key == area.$uniqueId" ng-include="'views/propertyeditors/grid/dialogs/additem.html'"></div>
</div>
</div>
</div>
<!-- Controls in cell -->
<div ng-repeat="control in area.controls"
ng-mouseover="setCurrentControl(control)"
@@ -174,6 +129,12 @@
<i class="icon icon-navigation"></i>
</div>
</div>
<div class="cell-tools-edit" ng-if="hasSettings && $first">
<a href class="iconBox" ng-click="editGridItemSettings(area)">
<i class="icon icon-settings"></i>
</a>
</div>
</div>
<div class="usky-control-inner" ng-class="{last:$last,
@@ -186,24 +147,31 @@
class="usky-cell usky-cell-{{control.editor.view}}">
</div>
</div>
<!-- add stuff -->
<div class="cell-tools-add"
ng-show="!currentToolsControl && control===currentControl && (area.max === undefined || area.max < area.controls.length)"
ng-animate="'fade'">
<div class="iconBox">
<a href ng-click="addItemOverlay($event, area, control.$index, control.$uniqueId)">
<i class=" icon icon-add"></i>
</a>
</div>
<div ng-show="overlayMenu.show && overlayMenu.key == control.$uniqueId" ng-include="'views/propertyeditors/grid/dialogs/additem.html'"></div>
</div>
</div>
<!-- Controls repeat end -->
<!-- if area is empty tools -->
<div class="usky-control usky-control-placeholder"
ng-if="area.controls.length == 0">
<div class="help-text" style="margin-bottom: 15px">
To start, click the <i class=" icon icon-add blue">
</i> below and add your first element
</div><br />
</div>
<div class="cell-tools-add"
ng-if="!currentToolsControl"
ng-animate="'fade'">
<div class="iconBox">
<a href ng-click="addItemOverlay($event, area, 0, area.$uniqueId);">
<i class=" icon icon-add"></i>
</a>
</div>
<div ng-if="overlayMenu.show && overlayMenu.key == area.$uniqueId" ng-include="'views/propertyeditors/grid/dialogs/additem.html'"></div>
</div>
</div>
<!-- cells repeat end -->
</div>
@@ -231,10 +199,11 @@
<div ng-style="{width: percentage(area.grid) + '%'}"
class="mainTdpt td"
ng-repeat="area in layout.areas">
<span></span>
<span></span>
</div>
</div>
</div>
<small>{{layout.name}}</small>
</li>
</ul>
@@ -256,4 +225,4 @@
</div>
</div>
</div>
</div>

View File

@@ -179,10 +179,17 @@ angular.module("umbraco")
delete $scope.currentArea;
}else{
if(area === undefined){
var space = ($scope.availableLayoutSpace > 4) ? 4 : $scope.availableLayoutSpace;
var available = $scope.availableLayoutSpace;
var space = 4;
if(available < 4 && available > 0){
space = available;
}
area = {
grid: space
};
layout.areas.push(area);
}
$scope.currentArea = area;
@@ -199,9 +206,13 @@ angular.module("umbraco")
/****************
utillities
*****************/
$scope.scaleUp = function(section, max){
$scope.scaleUp = function(section, max, overflow){
var add = 1;
if(overflow !== true){
add = (max > 1) ? 1 : max;
}
//var add = (max > 1) ? 1 : max;
section.grid = section.grid+1;
section.grid = section.grid+add;
};
$scope.scaleDown = function(section){
var remove = (section.grid > 1) ? 1 : section.grid;

View File

@@ -11,18 +11,18 @@
<li ng-repeat="template in model.value.templates">
<div class="uSky-templates-template" style="float: left">
<a href class="tb" ng-click="configureTemplate(template)">
<div class="tr">
<div class="td uSky-templates-column"
ng-class="{last:$last}"
ng-repeat="section in template.sections"
style="width:{{ percentage(section.grid) }}%">
</div>
<a class="uSky-templates-template tb mainTbpt" style="float: left"
ng-click="configureTemplate(template)">
<div class="tr">
<div
ng-style="{width: percentage(section.grid) + '%'}"
class="mainTdpt td"
ng-class="{last:$last}"
ng-repeat="section in template.sections">
<span style="height: 50px"></span>
</div>
</a>
</div>
</div>
</a>
<div>
<a ng-click="configureTemplate(template)" href>{{template.name}}</a><br />
@@ -175,15 +175,20 @@
<li ng-repeat="layout in model.value.layouts">
<div class="uSky-templates-row" style="float: left">
<a href class="tb mainTbpt" ng-click="configureLayout(layout)">
<div class="tr">
<div style="width:{{ percentage(area.grid); }}%" class="middle mainTdpt td" ng-repeat="area in layout.areas">
<i class="icon {{areaPreview(area)}}"></i>
</div>
<a class="uSky-templates-template tb mainTbpt" style="float: left"
ng-click="configureLayout(layout)">
<div class="tr">
<div
ng-style="{width: percentage(area.grid) + '%'}"
class="mainTdpt td"
ng-class="{last:$last}"
ng-repeat="area in layout.areas">
<span style="height: 20px"></span>
</div>
</a>
</div>
</div>
</a>
<div>
<a ng-click="configureLayout(layout)" href>{{layout.name}}</a><br />
@@ -214,10 +219,13 @@
</umb-control-group>
<umb-control-group label="Layout areas" hide-label="false" description="Choose a cell from the row to edit">
<div class="uSky-templates-template"
style="margin: 0; width: 350px; position: relative;">
<div class="tb" style="height: 70px; border-width: 2px; padding: 2px">
<div class="tb" style="height: auto; border: none !important; background: none">
<div class="tr">
<a class="td uSky-templates-column"
ng-class="{last:$last, selected:area==currentArea}"
ng-repeat="area in currentLayout.areas"
@@ -225,7 +233,7 @@
style="width:{{ percentage(area.grid) }}%">
</a>
<a class="td uSky-templates-column add" ng-if="availableLayoutSpace > 0"
<a class="td uSky-templates-column add"
ng-click="configureArea(undefined, currentLayout)"
style="width:{{ percentage(availableLayoutSpace) }}%">
<i class="icon icon-add"></i>
@@ -241,7 +249,7 @@
<i class="icon icon-remove"></i>
</a>
{{currentArea.grid}}
<a href ng-click="scaleUp(currentArea, availableLayoutSpace)">
<a href ng-click="scaleUp(currentArea, availableLayoutSpace, true)">
<i class="icon icon-add"></i>
</a>
</div>

View File

@@ -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>
}

View File

@@ -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>
}