-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathangular-step-input.min.js
More file actions
6 lines (6 loc) · 1.55 KB
/
angular-step-input.min.js
File metadata and controls
6 lines (6 loc) · 1.55 KB
1
2
3
4
5
6
/*!
* angular-step-input 0.1.0
* 10KB, http://10kb.nl/
* License: MIT
*/
(function(){var a;a=angular.module("tien.stepInput",[]),a.directive("tienStepInput",["$interpolate","$sce",function(a,b){return{restrict:"AE",replace:!0,scope:{user_options:"&stepInputOptions",value:"=ngModel"},link:function(c){var d;return d={decrease:"fa fa-minus",increase:"fa fa-plus",min_value:0,max_value:999,style:"primary",view_value:!1,overrides:[]},c.$watch(c.user_options,function(){return angular.extend(d,c.user_options(c))},!0),c.value=isNaN(parseInt(c.value))?0:c.value,c.decrease=function(){return c.value=c.value-1},c.increase=function(){return c.value=c.value+1},c.$watch("value",function(e,f){var g;return c.value=isNaN(parseInt(c.value))?f:Math.min(Math.max(parseInt(e),d.min_value),d.max_value),c.property=angular.copy(d),g=d.overrides.filter(function(a){return a.value===c.value}),g.length>0&&angular.extend(c.property,g[0]),c.property.view_value=b.trustAsHtml(null!=c.property.view_value.call?""+c.property.view_value.call():a(c.property.view_value)(c))})},template:'<div class="tien-step" ng-class="property.style">\n <button ng-click="decrease()" ng-class="{disabled: value == property.min_value}"><i ng-class="property.decrease"></i></button>\n <div class="step-value" ng-show="property.view_value" ng-bind-html="property.view_value"></div>\n <input class="step-value" type="text" ng-model="value" ng-hide="property.view_value">\n <button ng-click="increase()" ng-class="{disabled: value == property.max_value}"><i ng-class="property.increase"></i></button>\n</div>'}}])}).call(this);