Ming He 6e01037e55 fix gitignroe so bower_components are included in target folder
Change-Id: I97a6ec0d4584b821970bc0fbedf3c9b898773688
2015-12-21 10:19:15 -08:00

2 lines
2.9 KiB
JavaScript

(function(){var a;a=angular.module("daterangepicker",[]),a.constant("dateRangePickerConfig",{separator:" - ",format:"YYYY-MM-DD",clearLabel:"Clear"}),a.directive("dateRangePicker",["$compile","$timeout","$parse","dateRangePickerConfig",function(a,b,c,d){return{require:"ngModel",restrict:"A",scope:{dateMin:"=min",dateMax:"=max",model:"=ngModel",opts:"=options",clearable:"="},link:function(a,c,e,f){var g,h,i,j,k,l,m,n,o,p,q;return i=$(c),h=a.opts,j=angular.extend({},d,h),m=null,g=function(){return m.setStartDate(),m.setEndDate(),i.val("")},o=function(a){return b(function(){var b;return m?a?(b=moment(a),m.endDate<b&&m.setEndDate(b),m.setStartDate(b)):g():void 0})},n=function(a){return b(function(){var b;return m?a?(b=moment(a),m.startDate>b&&m.setStartDate(b),m.setEndDate(b)):g():void 0})},a.$watch("model.startDate",function(a){return o(a)}),a.$watch("model.endDate",function(a){return n(a)}),k=function(a){var b;return b=function(a){return moment.isMoment(a)?a.format(j.format):moment(a).format(j.format)},j.singleDatePicker?b(a.startDate):[b(a.startDate),b(a.endDate)].join(j.separator)},q=function(a,b){var c;return a=moment(a),b=moment(b),c=a.isBefore(b)||a.isSame(b,"day"),f.$setValidity("min",c),c},p=function(a,b){var c;return a=moment(a),b=moment(b),c=a.isAfter(b)||a.isSame(b,"day"),f.$setValidity("max",c),c},f.$formatters.push(function(a){return a&&a.startDate&&a.endDate?(o(a.startDate),n(a.endDate),a):""}),f.$parsers.push(function(b){return angular.isObject(b)&&b.hasOwnProperty("startDate")&&b.hasOwnProperty("endDate")?(a.dateMin&&b.startDate?q(a.dateMin,b.startDate):f.$setValidity("min",!0),a.dateMax&&b.endDate?p(a.dateMax,b.endDate):f.$setValidity("max",!0),b):f.$modelValue}),f.$isEmpty=function(a){return!a||null===a.startDate||null===a.endDate},f.$render=function(){return i.val(f.$modelValue?null===f.$modelValue.startDate?"":k(f.$modelValue):"")},l=function(){var a,c,d,g;i.daterangepicker(j,function(a,c){return b(function(){return f.$setViewValue({startDate:a,endDate:c})}),f.$render()}),m=i.data("daterangepicker"),g=j.eventHandlers;for(c in g)a=g[c],i.on(c,a);e.clearable&&(d=j.locale||{},d.cancelLabel=j.clearLabel,j.locale=d,i.on("cancel.daterangepicker",function(){return f.$setViewValue({startDate:null,endDate:null}),f.$render(),i.trigger("change")}))},l(),i.change(function(){return""===$.trim(i.val())?b(function(){return f.$setViewValue({startDate:null,endDate:null})}):void 0}),e.min&&a.$watch("dateMin",function(a){return a?(f.$isEmpty(f.$modelValue)||q(a,f.$modelValue.startDate),j.minDate=moment(a)):j.minDate=!1,l()}),e.max&&a.$watch("dateMax",function(a){return a?(f.$isEmpty(f.$modelValue)||p(a,f.$modelValue.endDate),j.maxDate=moment(a)):j.maxDate=!1,l()}),e.options&&a.$watch("opts",function(a){return j=angular.extend(j,a),l()}),a.$on("$destroy",function(){return null!=m?m.remove():void 0})}}}])}).call(this);
//# sourceMappingURL=angular-daterangepicker.min.map