/** * angular-strap * @version v2.3.9 - 2016-06-10 * @link http://mgcrea.github.io/angular-strap * @author Olivier Louvignes (https://github.com/mgcrea) * @license MIT License, http://www.opensource.org/licenses/MIT */ 'use strict';angular.module('mgcrea.ngStrap.datepicker',['mgcrea.ngStrap.helpers.dateParser','mgcrea.ngStrap.helpers.dateFormatter','mgcrea.ngStrap.tooltip']).provider('$datepicker',function(){var e=this.defaults={animation:'am-fade',prefixClass:'datepicker',placement:'bottom-left',templateUrl:'datepicker/datepicker.tpl.html',trigger:'focus',container:!1,keyboard:!0,html:!1,delay:0,useNative:!1,dateType:'date',dateFormat:'shortDate',timezone:null,modelDateFormat:null,dayFormat:'dd',monthFormat:'MMM',yearFormat:'yyyy',monthTitleFormat:'MMMM yyyy',yearTitleFormat:'yyyy',strictFormat:!1,autoclose:!1,minDate:-(1/0),maxDate:+(1/0),startView:0,minView:0,startWeek:0,daysOfWeekDisabled:'',hasToday:!1,hasClear:!1,iconLeft:'glyphicon glyphicon-chevron-left',iconRight:'glyphicon glyphicon-chevron-right'};this.$get=['$window','$document','$rootScope','$sce','$dateFormatter','datepickerViews','$tooltip','$timeout',function(t,a,n,i,o,r,s,l){function d(t,a,n){function i(e){e.selected=d.$isSelected(e.date)}function o(){t[0].focus()}var d=s(t,angular.extend({},e,n)),g=n.scope,f=d.$options,m=d.$scope;f.startView&&(f.startView-=f.minView);var $=r(d);d.$views=$.views;var h=$.viewDate;m.$mode=f.startView,m.$iconLeft=f.iconLeft,m.$iconRight=f.iconRight,m.$hasToday=f.hasToday,m.$hasClear=f.hasClear;var D=d.$views[m.$mode];m.$select=function(e){d.select(e)},m.$selectPane=function(e){d.$selectPane(e)},m.$toggleMode=function(){d.setMode((m.$mode+1)%d.$views.length)},m.$setToday=function(){f.autoclose?(d.setMode(0),d.select(new Date)):d.select(new Date,!0)},m.$clear=function(){f.autoclose?(d.setMode(0),d.select(null)):d.select(null,!0)},d.update=function(e){angular.isDate(e)&&!isNaN(e.getTime())&&(d.$date=e,D.update.call(D,e)),d.$build(!0)},d.updateDisabledDates=function(e){f.disabledDateRanges=e;for(var t=0,a=m.rows.length;a>t;t++)angular.forEach(m.rows[t],d.$setDisabledEl)},d.select=function(e,t){angular.isDate(e)?(!angular.isDate(a.$dateValue)||isNaN(a.$dateValue.getTime()))&&(a.$dateValue=new Date(e)):a.$dateValue=null,!m.$mode||t?(a.$setViewValue(angular.copy(e)),a.$render(),f.autoclose&&!t&&l(function(){d.hide(!0)})):(angular.extend(h,{year:e.getFullYear(),month:e.getMonth(),date:e.getDate()}),d.setMode(m.$mode-1),d.$build())},d.setMode=function(e){m.$mode=e,D=d.$views[m.$mode],d.$build()},d.$build=function(e){e===!0&&D.built||(e!==!1||D.built)&&D.build.call(D)},d.$updateSelected=function(){for(var e=0,t=m.rows.length;t>e;e++)angular.forEach(m.rows[e],i)},d.$isSelected=function(e){return D.isSelected(e)},d.$setDisabledEl=function(e){e.disabled=D.isDisabled(e.date)},d.$selectPane=function(e){var t=D.steps,a=new Date(Date.UTC(h.year+(t.year||0)*e,h.month+(t.month||0)*e,1));angular.extend(h,{year:a.getUTCFullYear(),month:a.getUTCMonth(),date:a.getUTCDate()}),d.$build()},d.$onMouseDown=function(e){if(e.preventDefault(),e.stopPropagation(),c){var t=angular.element(e.target);'button'!==t[0].nodeName.toLowerCase()&&(t=t.parent()),t.triggerHandler('click')}},d.$onKeyDown=function(e){if(/(38|37|39|40|13)/.test(e.keyCode)&&!e.shiftKey&&!e.altKey){if(e.preventDefault(),e.stopPropagation(),13===e.keyCode)return void(m.$mode?m.$apply(function(){d.setMode(m.$mode-1)}):d.hide(!0));D.onKeyDown(e),g.$digest()}};var p=d.init;d.init=function(){return u&&f.useNative?(t.prop('type','date'),void t.css('-webkit-appearance','textfield')):(c&&(t.prop('type','text'),t.attr('readonly','true'),t.on('click',o)),void p())};var y=d.destroy;d.destroy=function(){u&&f.useNative&&t.off('click',o),y()};var w=d.show;d.show=function(){!c&&t.attr('readonly')||t.attr('disabled')||(w(),l(function(){d.$isShown&&(d.$element.on(c?'touchstart':'mousedown',d.$onMouseDown),f.keyboard&&t.on('keydown',d.$onKeyDown))},0,!1))};var b=d.hide;return d.hide=function(e){d.$isShown&&(d.$element.off(c?'touchstart':'mousedown',d.$onMouseDown),f.keyboard&&t.off('keydown',d.$onKeyDown),b(e))},d}var u=/(ip[ao]d|iphone|android)/gi.test(t.navigator.userAgent),c='createTouch'in t.document&&u;return e.lang||(e.lang=o.getDefaultLocale()),d.defaults=e,d}]}).directive('bsDatepicker',['$window','$parse','$q','$dateFormatter','$dateParser','$datepicker',function(e,t,a,n,i,o){var r=/(ip[ao]d|iphone|android)/gi.test(e.navigator.userAgent);return{restrict:'EAC',require:'ngModel',link:function(e,t,a,s){function l(e){return e&&e.length?e:null}function d(e){if(angular.isDate(e)){var t=isNaN(f.$options.minDate)||e.getTime()>=f.$options.minDate,a=isNaN(f.$options.maxDate)||e.getTime()<=f.$options.maxDate,n=t&&a;s.$setValidity('date',n),s.$setValidity('min',t),s.$setValidity('max',a),n&&(s.$dateValue=e)}}function u(){return!s.$dateValue||isNaN(s.$dateValue.getTime())?'':$(s.$dateValue,c.dateFormat)}var c={scope:e};angular.forEach(['template','templateUrl','controller','controllerAs','placement','container','delay','trigger','html','animation','autoclose','dateType','dateFormat','timezone','modelDateFormat','dayFormat','strictFormat','startWeek','startDate','useNative','lang','startView','minView','iconLeft','iconRight','daysOfWeekDisabled','id','prefixClass','prefixEvent','hasToday','hasClear'],function(e){angular.isDefined(a[e])&&(c[e]=a[e])});var g=/^(false|0|)$/i;angular.forEach(['html','container','autoclose','useNative','hasToday','hasClear'],function(e){angular.isDefined(a[e])&&g.test(a[e])&&(c[e]=!1)}),angular.forEach(['onBeforeShow','onShow','onBeforeHide','onHide'],function(t){var n='bs'+t.charAt(0).toUpperCase()+t.slice(1);angular.isDefined(a[n])&&(c[t]=e.$eval(a[n]))});var f=o(t,s,c);c=f.$options,r&&c.useNative&&(c.dateFormat='yyyy-MM-dd');var m=c.lang,$=function(e,t){return n.formatDate(e,t,m)},h=i({format:c.dateFormat,lang:m,strict:c.strictFormat});a.bsShow&&e.$watch(a.bsShow,function(e,t){f&&angular.isDefined(e)&&(angular.isString(e)&&(e=!!e.match(/true|,?(datepicker),?/i)),e===!0?f.show():f.hide())}),angular.forEach(['minDate','maxDate'],function(e){angular.isDefined(a[e])&&a.$observe(e,function(t){f.$options[e]=h.getDateForAttribute(e,t),isNaN(f.$options[e])||f.$build(!1),d(s.$dateValue)})}),angular.isDefined(a.dateFormat)&&a.$observe('dateFormat',function(e){f.$options.dateFormat=e}),e.$watch(a.ngModel,function(e,t){f.update(s.$dateValue)},!0),angular.isDefined(a.disabledDates)&&e.$watch(a.disabledDates,function(e,t){e=l(e),t=l(t),e&&f.updateDisabledDates(e)}),s.$parsers.unshift(function(e){var t;if(!e)return s.$setValidity('date',!0),null;var a=h.parse(e,s.$dateValue);return!a||isNaN(a.getTime())?void s.$setValidity('date',!1):(d(a),'string'===c.dateType?(t=h.timezoneOffsetAdjust(a,c.timezone,!0),$(t,c.modelDateFormat||c.dateFormat)):(t=h.timezoneOffsetAdjust(s.$dateValue,c.timezone,!0),'number'===c.dateType?t.getTime():'unix'===c.dateType?t.getTime()/1e3:'iso'===c.dateType?t.toISOString():new Date(t)))}),s.$formatters.push(function(e){var t;return t=angular.isUndefined(e)||null===e?NaN:angular.isDate(e)?e:'string'===c.dateType?h.parse(e,null,c.modelDateFormat):'unix'===c.dateType?new Date(1e3*e):new Date(e),s.$dateValue=h.timezoneOffsetAdjust(t,c.timezone),u()}),s.$render=function(){t.val(u())},e.$on('$destroy',function(){f&&f.destroy(),c=null,f=null})}}}]).provider('datepickerViews',function(){function e(e,t){for(var a=[];e.length>0;)a.push(e.splice(0,t));return a}function t(e,t){return(e%t+t)%t}this.$get=['$dateFormatter','$dateParser','$sce',function(a,n,i){return function(o){var r=o.$scope,s=o.$options,l=s.lang,d=function(e,t){return a.formatDate(e,t,l)},u=n({format:s.dateFormat,lang:l,strict:s.strictFormat}),c=a.weekdaysShort(l),g=c.slice(s.startWeek).concat(c.slice(0,s.startWeek)),f=i.trustAsHtml(''+g.join('')+''),m=o.$date||(s.startDate?u.getDateForAttribute('startDate',s.startDate):new Date),$={year:m.getFullYear(),month:m.getMonth(),date:m.getDate()},h=[{format:s.dayFormat,split:7,steps:{month:1},update:function(e,t){!this.built||t||e.getFullYear()!==$.year||e.getMonth()!==$.month?(angular.extend($,{year:o.$date.getFullYear(),month:o.$date.getMonth(),date:o.$date.getDate()}),o.$build()):(e.getDate()!==$.date||1===e.getDate())&&($.date=o.$date.getDate(),o.$updateSelected())},build:function(){var a=new Date($.year,$.month,1),n=a.getTimezoneOffset(),i=new Date(+a-864e5*t(a.getDay()-s.startWeek,7)),l=i.getTimezoneOffset(),c=u.timezoneOffsetAdjust(new Date,s.timezone).toDateString();l!==n&&(i=new Date(+i+6e4*(l-n)));for(var g,m=[],h=0;42>h;h++)g=u.daylightSavingAdjust(new Date(i.getFullYear(),i.getMonth(),i.getDate()+h)),m.push({date:g,isToday:g.toDateString()===c,label:d(g,this.format),selected:o.$date&&this.isSelected(g),muted:g.getMonth()!==$.month,disabled:this.isDisabled(g)});r.title=d(a,s.monthTitleFormat),r.showLabels=!0,r.labels=f,r.rows=e(m,this.split),r.isTodayDisabled=this.isDisabled(new Date),this.built=!0},isSelected:function(e){return o.$date&&e.getFullYear()===o.$date.getFullYear()&&e.getMonth()===o.$date.getMonth()&&e.getDate()===o.$date.getDate()},isDisabled:function(e){var t=e.getTime();if(ts.maxDate)return!0;if(-1!==s.daysOfWeekDisabled.indexOf(e.getDay()))return!0;if(s.disabledDateRanges)for(var a=0;a=s.disabledDateRanges[a].start&&t<=s.disabledDateRanges[a].end)return!0;return!1},onKeyDown:function(e){if(o.$date){var t,a=o.$date.getTime();37===e.keyCode?t=new Date(a-864e5):38===e.keyCode?t=new Date(a-6048e5):39===e.keyCode?t=new Date(a+864e5):40===e.keyCode&&(t=new Date(a+6048e5)),this.isDisabled(t)||o.select(t,!0)}}},{name:'month',format:s.monthFormat,split:4,steps:{year:1},update:function(e,t){this.built&&e.getFullYear()===$.year?e.getMonth()!==$.month&&(angular.extend($,{month:o.$date.getMonth(),date:o.$date.getDate()}),o.$updateSelected()):(angular.extend($,{year:o.$date.getFullYear(),month:o.$date.getMonth(),date:o.$date.getDate()}),o.$build())},build:function(){for(var t,a=[],n=0;12>n;n++)t=new Date($.year,n,1),a.push({date:t,label:d(t,this.format),selected:o.$isSelected(t),disabled:this.isDisabled(t)});r.title=d(t,s.yearTitleFormat),r.showLabels=!1,r.rows=e(a,this.split),this.built=!0},isSelected:function(e){return o.$date&&e.getFullYear()===o.$date.getFullYear()&&e.getMonth()===o.$date.getMonth()},isDisabled:function(e){var t=+new Date(e.getFullYear(),e.getMonth()+1,0);return ts.maxDate},onKeyDown:function(e){if(o.$date){var t=o.$date.getMonth(),a=new Date(o.$date);37===e.keyCode?a.setMonth(t-1):38===e.keyCode?a.setMonth(t-4):39===e.keyCode?a.setMonth(t+1):40===e.keyCode&&a.setMonth(t+4),this.isDisabled(a)||o.select(a,!0)}}},{name:'year',format:s.yearFormat,split:4,steps:{year:12},update:function(e,t){!this.built||t||parseInt(e.getFullYear()/20,10)!==parseInt($.year/20,10)?(angular.extend($,{year:o.$date.getFullYear(),month:o.$date.getMonth(),date:o.$date.getDate()}),o.$build()):e.getFullYear()!==$.year&&(angular.extend($,{year:o.$date.getFullYear(),month:o.$date.getMonth(),date:o.$date.getDate()}),o.$updateSelected())},build:function(){for(var t,a=$.year-$.year%(3*this.split),n=[],i=0;12>i;i++)t=new Date(a+i,0,1),n.push({date:t,label:d(t,this.format),selected:o.$isSelected(t),disabled:this.isDisabled(t)});r.title=n[0].label+'-'+n[n.length-1].label,r.showLabels=!1,r.rows=e(n,this.split),this.built=!0},isSelected:function(e){return o.$date&&e.getFullYear()===o.$date.getFullYear()},isDisabled:function(e){var t=+new Date(e.getFullYear()+1,0,0);return ts.maxDate},onKeyDown:function(e){if(o.$date){var t=o.$date.getFullYear(),a=new Date(o.$date);37===e.keyCode?a.setYear(t-1):38===e.keyCode?a.setYear(t-4):39===e.keyCode?a.setYear(t+1):40===e.keyCode&&a.setYear(t+4),this.isDisabled(a)||o.select(a,!0)}}}];return{views:s.minView?Array.prototype.slice.call(h,s.minView):h,viewDate:$}}}]}); //# sourceMappingURL=datepicker.min.js.map