angular-eha.counter
Advanced tools
Comparing version
@@ -10,3 +10,11 @@ ;(function () { | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', ['ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -31,7 +39,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -45,3 +57,3 @@ | ||
} | ||
}) | ||
}]) | ||
@@ -48,0 +60,0 @@ // Check for and export to commonjs environment |
@@ -10,3 +10,11 @@ ;(function () { | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', ['ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -31,7 +39,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -45,3 +57,3 @@ | ||
} | ||
}) | ||
}]) | ||
@@ -48,0 +60,0 @@ // Check for and export to commonjs environment |
@@ -20,3 +20,3 @@ angular.module('eha.counter.template', ['templates/counter.template.tpl.html']); | ||
" step=\"1\"\n" + | ||
" class=\"form-control input-lg eha-counter-input\"\n" + | ||
" class=\"form-control input-lg eha-counter-input text-center\"\n" + | ||
" ng-change=\"change\"\n" + | ||
@@ -50,3 +50,11 @@ " ng-model=\"count\"\n" + | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', ['ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -71,7 +79,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -85,3 +97,3 @@ | ||
} | ||
}) | ||
}]) | ||
@@ -88,0 +100,0 @@ // Check for and export to commonjs environment |
@@ -20,3 +20,3 @@ angular.module('eha.counter.template', ['templates/counter.template.tpl.html']); | ||
" step=\"1\"\n" + | ||
" class=\"form-control input-lg eha-counter-input\"\n" + | ||
" class=\"form-control input-lg eha-counter-input text-center\"\n" + | ||
" ng-change=\"change\"\n" + | ||
@@ -23,0 +23,0 @@ " ng-model=\"count\"\n" + |
@@ -10,3 +10,11 @@ ;(function () { | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', ['ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -31,7 +39,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -45,3 +57,3 @@ | ||
} | ||
}) | ||
}]) | ||
@@ -48,0 +60,0 @@ // Check for and export to commonjs environment |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var a=angular.module("eha.counter.directive",[]);a.directive("ehaCounter",function(){return{restrict:"E",templateUrl:function(a,b){return b.templateUrl||"templates/counter.template.tpl.html"},scope:{count:"=bind",change:"=onchange",name:"=name"},link:function(a,b){function c(a){return isNaN(a)||""===a||1>a}var d=b.find("button"),e=d.eq(0),f=d.eq(1);a.incrementTouch=function(a){return c(a)?1:parseInt(a,10)+1},a.decrementTouch=function(a){return c(a)?0:parseInt(a,10)-1},b.on("$destroy",function(){f.off("click"),e.off("click")})}}}),"undefined"!=typeof module&&module.exports&&(module.exports=a)}(),function(){"use strict";var a=angular.module("eha.counter",["eha.counter.directive"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}(); | ||
!function(){"use strict";var a=angular.module("eha.counter.directive",[]);a.provider("ehaCounter",function(){this.increment=angular.noop,this.decrement=angular.noop,this.$get=function(){return this}}),a.directive("ehaCounter",["ehaCounter",function(a){return{restrict:"E",templateUrl:function(a,b){return b.templateUrl||"templates/counter.template.tpl.html"},scope:{count:"=bind",change:"=onchange",name:"=name"},link:function(b,c){function d(a){return isNaN(a)||""===a||1>a}var e=c.find("button"),f=e.eq(0),g=e.eq(1);b.incrementTouch=function(b){var c=d(b)?1:parseInt(b,10)+1;return a.increment(c),c},b.decrementTouch=function(b){var c=d(b)?0:parseInt(b,10)-1;return a.decrement(c),c},c.on("$destroy",function(){g.off("click"),f.off("click")})}}}]),"undefined"!=typeof module&&module.exports&&(module.exports=a)}(),function(){"use strict";var a=angular.module("eha.counter",["eha.counter.directive"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}(); |
@@ -20,3 +20,3 @@ angular.module('eha.counter.template', ['templates/counter.template.tpl.html']); | ||
" step=\"1\"\n" + | ||
" class=\"form-control input-lg eha-counter-input\"\n" + | ||
" class=\"form-control input-lg eha-counter-input text-center\"\n" + | ||
" ng-change=\"change\"\n" + | ||
@@ -50,3 +50,11 @@ " ng-model=\"count\"\n" + | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', ['ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -71,7 +79,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -85,3 +97,3 @@ | ||
} | ||
}) | ||
}]) | ||
@@ -88,0 +100,0 @@ // Check for and export to commonjs environment |
@@ -1,1 +0,1 @@ | ||
angular.module("eha.counter.template",["templates/counter.template.tpl.html"]),angular.module("templates/counter.template.tpl.html",[]).run(["$templateCache",function(a){a.put("templates/counter.template.tpl.html",'<div class="input-group">\n <span class="input-group-btn">\n <button\n class="btn btn-warning eha-counter-btn"\n type="button"\n ng-click="count = decrementTouch(count)"\n >\n <i class="fa fa-minus"></i>\n </button>\n </span>\n\n <input\n type="number"\n min="0"\n step="1"\n class="form-control input-lg eha-counter-input"\n ng-change="change"\n ng-model="count"\n required\n />\n\n <span class="input-group-btn">\n <button\n class="btn btn-info eha-counter-btn"\n type="button"\n ng-click="count = incrementTouch(count)"\n >\n <i class="fa fa-plus"></i>\n </button>\n </span>\n\n</div>\n')}]),function(){"use strict";var a=angular.module("eha.counter.directive",[]);a.directive("ehaCounter",function(){return{restrict:"E",templateUrl:function(a,b){return b.templateUrl||"templates/counter.template.tpl.html"},scope:{count:"=bind",change:"=onchange",name:"=name"},link:function(a,b){function c(a){return isNaN(a)||""===a||1>a}var d=b.find("button"),e=d.eq(0),f=d.eq(1);a.incrementTouch=function(a){return c(a)?1:parseInt(a,10)+1},a.decrementTouch=function(a){return c(a)?0:parseInt(a,10)-1},b.on("$destroy",function(){f.off("click"),e.off("click")})}}}),"undefined"!=typeof module&&module.exports&&(module.exports=a)}(),function(){"use strict";var a=angular.module("eha.counter",["eha.counter.directive","eha.counter.template"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}(); | ||
angular.module("eha.counter.template",["templates/counter.template.tpl.html"]),angular.module("templates/counter.template.tpl.html",[]).run(["$templateCache",function(a){a.put("templates/counter.template.tpl.html",'<div class="input-group">\n <span class="input-group-btn">\n <button\n class="btn btn-warning eha-counter-btn"\n type="button"\n ng-click="count = decrementTouch(count)"\n >\n <i class="fa fa-minus"></i>\n </button>\n </span>\n\n <input\n type="number"\n min="0"\n step="1"\n class="form-control input-lg eha-counter-input text-center"\n ng-change="change"\n ng-model="count"\n required\n />\n\n <span class="input-group-btn">\n <button\n class="btn btn-info eha-counter-btn"\n type="button"\n ng-click="count = incrementTouch(count)"\n >\n <i class="fa fa-plus"></i>\n </button>\n </span>\n\n</div>\n')}]),function(){"use strict";var a=angular.module("eha.counter.directive",[]);a.provider("ehaCounter",function(){this.increment=angular.noop,this.decrement=angular.noop,this.$get=function(){return this}}),a.directive("ehaCounter",["ehaCounter",function(a){return{restrict:"E",templateUrl:function(a,b){return b.templateUrl||"templates/counter.template.tpl.html"},scope:{count:"=bind",change:"=onchange",name:"=name"},link:function(b,c){function d(a){return isNaN(a)||""===a||1>a}var e=c.find("button"),f=e.eq(0),g=e.eq(1);b.incrementTouch=function(b){var c=d(b)?1:parseInt(b,10)+1;return a.increment(c),c},b.decrementTouch=function(b){var c=d(b)?0:parseInt(b,10)-1;return a.decrement(c),c},c.on("$destroy",function(){g.off("click"),f.off("click")})}}}]),"undefined"!=typeof module&&module.exports&&(module.exports=a)}(),function(){"use strict";var a=angular.module("eha.counter",["eha.counter.directive","eha.counter.template"]);"undefined"!=typeof module&&module.exports&&(module.exports=a)}(); |
@@ -10,3 +10,4 @@ { | ||
"presemantic-release": "npm run build", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"watch": "onchange src -- npm run build" | ||
}, | ||
@@ -41,2 +42,3 @@ "repository": { | ||
"load-grunt-tasks": "^3.1.0", | ||
"onchange": "^2.0.0", | ||
"semantic-release": "^4.3.4", | ||
@@ -54,3 +56,3 @@ "standard": "^5.2.1" | ||
}, | ||
"version": "1.1.1" | ||
"version": "1.2.0" | ||
} |
@@ -20,4 +20,8 @@ # angular-eha.counter | ||
Optionally, pass in a path to a custom template: | ||
## Options | ||
### `template-url` | ||
A custom template can be used with the `template-url` attribute: | ||
```html | ||
@@ -30,3 +34,3 @@ <eha-counter | ||
The default template assumes a mobile UI and depends on [Bootstrap][] and | ||
Note, the default template assumes a mobile UI and depends on [Bootstrap][] and | ||
[font-awesome][]. | ||
@@ -37,2 +41,17 @@ | ||
### `ehaCounterProvider` | ||
Exposes the `increment` and `decrement` callbacks (both `angular.noop` by | ||
default), which are passed corresponding count on change. Can be overridden in | ||
an `angular.config` block, for example: | ||
```js | ||
angular.module('myApp') | ||
.config(function (ehaCounterProvider) { | ||
ehaCounterProvider.increment = function (count) { | ||
console.log('The count is', count) | ||
} | ||
}) | ||
``` | ||
## Installation | ||
@@ -39,0 +58,0 @@ |
@@ -10,3 +10,11 @@ ;(function () { | ||
ngModule.directive('ehaCounter', function () { | ||
ngModule.provider('ehaCounter', function () { | ||
this.increment = angular.noop | ||
this.decrement = angular.noop | ||
this.$get = function () { | ||
return this | ||
} | ||
}) | ||
ngModule.directive('ehaCounter', function (ehaCounter) { | ||
return { | ||
@@ -31,7 +39,11 @@ restrict: 'E', | ||
scope.incrementTouch = function (count) { | ||
return isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
var res = isInvalid(count) ? 1 : (parseInt(count, 10) + 1) | ||
ehaCounter.increment(res) | ||
return res | ||
} | ||
scope.decrementTouch = function (count) { | ||
return isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
var res = isInvalid(count) ? 0 : (parseInt(count, 10) - 1) | ||
ehaCounter.decrement(res) | ||
return res | ||
} | ||
@@ -38,0 +50,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
37602
8.3%672
10.89%77
32.76%14
7.69%