forked from fragaria/angular-daterangepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-daterangepicker.min.js
2 lines (2 loc) · 2.97 KB
/
angular-daterangepicker.min.js
1
2
(function(){var a;a=angular.module("daterangepicker",[]),a.constant("dateRangePickerConfig",{clearLabel:"Clear",locale:{separator:" - ",format:"YYYY-MM-DD"}}),a.directive("dateRangePicker",["$compile","$timeout","$parse","dateRangePickerConfig",function(a,b,c,d){return{require:"ngModel",restrict:"A",scope:{min:"=",max:"=",model:"=ngModel",opts:"=options",clearable:"="},link:function(a,b,c,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s;return i=function(){var a,b;return b=angular.extend.apply(angular,Array.prototype.slice.call(arguments).map(function(a){return null!=a?a.locale:void 0}).filter(function(a){return!!a})),a=angular.extend.apply(angular,arguments),a.locale=b,a},r=$(b),q=a.opts,s=i({},d,q),j=null,f=function(){return j.setStartDate(),j.setEndDate()},k=function(a){return function(b){return j&&b?a(moment(b)):void 0}},m=k(function(a){return j.endDate<a&&j.setEndDate(a),s.startDate=a,j.setStartDate(a)}),l=k(function(a){return j.startDate>a&&j.setStartDate(a),s.endDate=a,j.setEndDate(a)}),n=function(a){return function(b,c){return b&&c?a(moment(b),moment(c)):!0}},p=n(function(a,b){return a.isBefore(b)||a.isSame(b,"day")}),o=n(function(a,b){return a.isAfter(b)||a.isSame(b,"day")}),e.$formatters.push(function(a){var b;return b=function(a){return moment.isMoment(a)?a.format(s.locale.format):moment(a).format(s.locale.format)},s.singleDatePicker&&a?b(a):a.startDate?[b(a.startDate),b(a.endDate)].join(s.locale.separator):""}),e.$render=function(){return e.$modelValue&&e.$modelValue.startDate?(m(e.$modelValue.startDate),l(e.$modelValue.endDate)):f(),r.val(e.$viewValue)},e.$parsers.push(function(a){var b,c,d;return b=function(a){return moment(a,s.locale.format)},c={startDate:null,endDate:null},angular.isString(a)&&a.length>0&&(s.singleDatePicker?c=b(a):(d=a.split(s.locale.separator).map(b),c.startDate=d[0],c.endDate=d[1])),c}),e.$isEmpty=function(a){return!(angular.isString(a)&&a.length>0)},g=function(){var b,c;r.daterangepicker(angular.extend(s,{autoUpdateInput:!1}),function(b,c){return a.$apply(function(){return a.model=s.singleDatePicker?b:{startDate:b,endDate:c}})}),j=r.data("daterangepicker"),c=[];for(b in s.eventHandlers)c.push(r.on(b,function(b){var c;return c=b.type+"."+b.namespace,a.$evalAsync(s.eventHandlers[c])}));return c},g(),a.$watch("model.startDate",function(a){return m(a)}),a.$watch("model.endDate",function(a){return l(a)}),h=function(b,d,f,h){return c[b]?(e.$validators[b]=function(a){return a&&d(s[h],a[f])},a.$watch(b,function(a){return s[h]=a?moment(a):!1,g()})):void 0},h("min",p,"startDate","minDate"),h("max",o,"endDate","maxDate"),c.options&&a.$watch("opts",function(a){return s=i(s,a),g()},!0),c.clearable&&a.$watch("clearable",function(b){return b&&(s=i(s,{locale:{cancelLabel:s.clearLabel}})),g(),b?r.on("cancel.daterangepicker",function(){return a.$apply(function(){return a.model=s.singleDatePicker?null:{startDate:null,endDate:null}})}):void 0}),a.$on("$destroy",function(){return null!=j?j.remove():void 0})}}}])}).call(this);
//# sourceMappingURL=angular-daterangepicker.min.js.map