!function(){var t=angular.module("number-input",[]);t.directive("numberInput",function(){return{restrict:"E",template:'
{{numberInput.hint}}
',scope:{model:"=ngModel",onChange:"&ngChange",start:"=?start",min:"=?min",max:"=?max",step:"=?step",hint:"@?hint",hideHint:"=?hideHint",disableDecimal:"=?disableDecimal",decimalPlaces:"=?decimalPlaces",prefix:"@?prefix",postfix:"@?postfix",options:"=?options"},controller:["$scope",function(t){var n=null,i=48,e=57,o=190,r=189,u=32;t.$watch("model",function(){t.onChange()}),this.inc=function(){p()||null!=n||(t.model+=t.step,g())},this.dec=function(){a()||null!=n||(t.model-=t.step,g())},this.onKeyPress=function(t){t.keyCode==u&&g(),h(t.keyCode)&&(n=t.keyCode)},this.onChange=function(){s()&&(n==o||n==r||n==i&&c(t.model)||g())},this.onBlur=function(){g(),t.model||(t.model=t.start||0)},this.hasPrefix=function(){return""==!this.prefix},this.hasPostfix=function(){return""==!this.postfix},this.getWidth=function(){var t=0;return this.hasPrefix()&&this.hasPostfix()?t=$("#number-input-prefix-id").outerWidth()+$("#number-input-postfix-id").outerWidth():this.hasPrefix()?t=$("#number-input-prefix-id").outerWidth():this.hasPostfix()&&(t=$("#number-input-postfix-id").outerWidth()),{width:$("#number-input-container-id").outerWidth()-$("#number-input-btns-container-id").outerWidth()-t}};var s=function(){if(!m()||!d())return!0;if(!(t.max>=0&&t.min>=0||t.max<=0&&t.min<=0))return!0;var n=t.decimalPlaces+(t.decimalPlaces>0?1:0),i=t.max.toString().length+n,e=t.min.toString().length+n,o=i>e?i:e,r=t.model.toString(),u=P(r);return(r.length>o||u>t.decimalPlaces)&&(t.model=x(r.substring(0,r.length-1))),o==t.model.toString().length||u>0&&u==t.decimalPlaces},l=function(){return m()||d()?t.hint?t.hint:t.options.hint?t.options.hint:m()&&!d()?"Less than or equal to "+t.max:d()&&!m()?"Greater than or equal to "+t.min:m()&&d()?t.min+" to "+t.max:void 0:t.hideHint=!0},p=function(){return m()&&t.model>=t.max},a=function(){return d()&&t.model<=t.min},m=function(){return!b(t.max)},d=function(){return!b(t.min)},b=function(t){return null===t||void 0===t||NaN===t},c=function(t){return t.toString().indexOf(".")>-1},f=function(){return!d()||t.min<0},h=function(n){return n>=i&&n<=e||n==r&&f()||n==o&&!t.disableDecimal&&!(0==t.decimalPlaces)},x=function(n){return+parseFloat(n).toFixed(t.decimalPlaces)},g=function(){t.model=x(t.model),p()&&(t.model=t.max),a()&&(t.model=t.min),n=null},P=function(t){return t.indexOf(".")>=0?t.split(".")[1].length:0};t.options||(t.options={}),b(t.min)&&(t.min=t.options.min),b(t.max)&&(t.max=t.options.max),b(t.start)&&(t.start=t.options.start),b(t.start)&&(t.start=t.min),t.step=t.step||t.options.step||1,t.hint=this.hint=l(),t.hideHint=t.hideHint||t.options.hideHint||!1,t.disableDecimal=t.disableDecimal||t.options.disableDecimal||!1,t.decimalPlaces=t.decimalPlaces||t.options.decimalPlaces||P(t.step.toString()),t.model=t.start||t.model||0,t.prefix=this.prefix=t.prefix||t.options.prefix||"",t.postfix=this.postfix=t.postfix||t.options.postfix||""}],controllerAs:"numberInput"}})}();