Merge branch '7.0.0' of https://github.com/umbraco/Umbraco-CMS into 7.0.0

This commit is contained in:
perploug
2013-08-23 12:10:56 +02:00
15 changed files with 118 additions and 26 deletions

View File

@@ -0,0 +1,30 @@
/**
* @ngdoc directive
* @name umbraco.directives.directive:valHighlight
* @restrict A
* @description Used on input fields when you want to signal that they are in error, this will highlight the item for 1 second
**/
function valHighlight($timeout) {
return {
restrict: "A",
link: function (scope, element, attrs, ctrl) {
scope.$watch(function() {
return scope.$eval(attrs.valHighlight);
}, function(newVal, oldVal) {
if (newVal === true) {
element.addClass("highlight-error");
$timeout(function () {
//set the bound scope property to false
scope[attrs.valHighlight] = false;
}, 1000);
}
else {
element.removeClass("highlight-error");
}
});
}
};
}
angular.module('umbraco.directives').directive("valHighlight", valHighlight);

View File

@@ -399,6 +399,16 @@ input[type="checkbox"][readonly] {
}
input.highlight-error,
select.highlight-error,
textarea.highlight-error {
border-color: #953b39 !important;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
}
// FORM ACTIONS
// ------------

View File

@@ -198,9 +198,6 @@
}
}
// CSS3 PROPERTIES
// --------------------------------------------------

View File

@@ -8,12 +8,14 @@ angular.module("umbraco").controller("Umbraco.Editors.DropdownController",
keyName: "alias",
valueName: "name"
};
//map the user config
angular.extend(config, $scope.model.config);
//map back to the model
$scope.model.config = config;
$scope.selectExpression = "e." + config.keyName + " as e." + config.valueName + " for e in model.config.items";
//now we need to format the items in the array because we always want to have a dictionary
for (var i = 0; i < $scope.model.config.items.length; i++) {
if (angular.isString($scope.model.config.items[i])) {

View File

@@ -1,7 +1,6 @@
<div ng-controller="Umbraco.Editors.DropdownController">
<select name="dropDownList"
ng-model="model.value"
required
ng-options="e.alias as e.name for e in model.config.items"></select>
ng-options="{{selectExpression}}"></select>
</div>

View File

@@ -0,0 +1,33 @@
angular.module("umbraco").controller("Umbraco.Editors.DropdownPreValueController",
function ($scope, $timeout) {
$scope.newItem = "";
$scope.hasError = false;
$scope.remove = function(item, evt) {
evt.preventDefault();
$scope.model.value = _.reject($scope.model.value, function(i) {
return i === item;
});
};
$scope.add = function (evt) {
evt.preventDefault();
if (!_.contains($scope.model.value, $scope.newItem)) {
if ($scope.newItem) {
$scope.model.value.push($scope.newItem);
$scope.newItem = "";
$scope.hasError = false;
return;
}
}
//there was an error, do the highlight (will be set back by the directive)
$scope.hasError = true;
};
});

View File

@@ -1,5 +1,13 @@
<div>
<input type="text" ng-model="model.value" />
<div ng-controller="Umbraco.Editors.DropdownPreValueController">
<ul class="unstyled">
<li>
<input name="newItem" type="text" ng-model="newItem" val-highlight="hasError" />
<button class="btn" ng-click="add($event)">Add</button>
</li>
<li ng-repeat="item in model.value">
<input type="text" ng-model="item" />
<button class="btn" ng-click="remove(item, $event)">Remove</button>
</li>
</ul>
</div>