From cd0ffd9924401740375690585dadbace1da204a0 Mon Sep 17 00:00:00 2001 From: Denis Lins Date: Mon, 15 Jun 2015 16:53:57 -0300 Subject: [PATCH] Version 0.2.3 --- bower.json | 2 +- paDatepicker.js | 38 +++++++++++++++++++------------------- paDatepicker.min.js | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bower.json b/bower.json index c9909fc..0e5d0aa 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,7 @@ "license": "MIT", "ignore": [], "description": "A complete datepicker written from scratch built on top of AngularJS", - "version": "0.2.2", + "version": "0.2.3", "main": [ "./paDatepicker.min.js", "./paDatepicker.tpls.js" diff --git a/paDatepicker.js b/paDatepicker.js index 1d32fb6..3759eed 100644 --- a/paDatepicker.js +++ b/paDatepicker.js @@ -304,7 +304,6 @@ init: function() { this.selections = {}; - this.initConfig(); this.initToday(); this.initCurrentPeriod(); this.initModel(); @@ -321,17 +320,6 @@ }.bind(this)); }, - initConfig: function() { - this.config = angular.copy(paDatepickerConfig); - - angular.forEach(this.config, function(value, option) { - if (typeof this[option] !== 'undefined') { - var newValue = this[option] !== 'false' ? this[option] : false; - this.config[option] = newValue; - } - }.bind(this)); - }, - initToday: function() { this.today = new Date(); this.today.setHours(0, 0, 0, 0); @@ -340,7 +328,7 @@ initPanels: function() { this.datePanels = []; - var numberOfPanels = parseInt(this.config.panels, 10); + var numberOfPanels = parseInt(this.getConfig('panels'), 10); var base = this.getPanelStart(); for (var i = 0; i < numberOfPanels; i++) { @@ -370,6 +358,11 @@ } }, + getConfig: function(config) { + var value = this[config] || paDatepickerConfig[config]; + return value !== 'false' ? value : false; + }, + getPanelStart: function() { if (this.isRange()) { return this.getRangePanelStart(); @@ -426,7 +419,10 @@ }, startSelection: function(date) { - this.selections[this.currentPeriod] = { selected: date, start: date, end: date }; + this.selections[this.currentPeriod] = { + selected: date, start: date, end: date + }; + $rootScope.$broadcast('paDatepicker.selection.started'); }, @@ -464,13 +460,16 @@ }, isRange: function() { - return this.config.mode === 'range'; + return this.getConfig('mode') === 'range'; }, isDateEnabled: function(date) { - if (this.config.minDate && this.compare(date, this.config.minDate) < 0) { + var minDate = this.getConfig('minDate'); + var maxDate = this.getConfig('maxDate'); + + if (minDate && this.compare(date, minDate) < 0) { return false; - } else if (this.config.maxDate && this.compare(date, this.config.maxDate) > 0) { + } else if (maxDate && this.compare(date, maxDate) > 0) { return false; } else { return true; @@ -483,7 +482,8 @@ this.isDateWithinComparisonPeriod(date); } - return this.ngModel instanceof Date && date.getTime() === this.ngModel.getTime(); + return this.ngModel instanceof Date && + date.getTime() === this.ngModel.getTime(); }, isDateWithinBasePeriod: function(date) { @@ -523,7 +523,7 @@ }, getStartingDay: function() { - return (parseInt(this.config.startingDay, 10) % 7) || 0; + return (parseInt(this.getConfig('startingDay'), 10) % 7) || 0; }, closePopup: function() { diff --git a/paDatepicker.min.js b/paDatepicker.min.js index 2bea160..567e3ec 100644 --- a/paDatepicker.min.js +++ b/paDatepicker.min.js @@ -1 +1 @@ -!function(){"use strict";angular.module("pa-datepicker",[])}(),function(){"use strict";angular.module("pa-datepicker").directive("paDateInput",["$filter","DateParser",function(t,e){var i=function(e){return function(i){var n=new Date(i);return isNaN(n.getTime())?null:t("date")(n,e)}},n=function(t){return function(i){return e.parse(i,t)}};return{require:"ngModel",template:'',replace:!0,scope:{format:"@"},link:function(t,e,o,r){var s=t.format||"shortDate";r.$formatters.unshift(i(s)),r.$parsers.unshift(n(s))}}}])}(),function(){"use strict";angular.module("pa-datepicker").directive("paDatepicker",function(){return{restrict:"E",controller:"DatepickerContainerCtrl",controllerAs:"container",bindToController:!0,require:["^ngModel","^paDatepicker","?^paDatepickerPopup"],templateUrl:"templates/pa-datepicker/container.html",scope:{panels:"@",mode:"@",currentPeriod:"=?",startingDay:"@",showOutliers:"@",minDate:"=",maxDate:"=",ngModel:"="},link:function(t,e,i,n){n[1].popup=n[2],n[1].init()}}})}(),function(){"use strict";angular.module("pa-datepicker").directive("paPanel",function(){return{restrict:"E",controller:"DatepickerPanelCtrl",controllerAs:"panel",bindToController:!0,require:["^paDatepicker","^paPanel"],templateUrl:"templates/pa-datepicker/panel.html",scope:{config:"=",period:"@"},link:function(t,e,i,n){n[1].container=n[0],n[1].init()}}})}(),function(){"use strict";angular.module("pa-datepicker").directive("paDatepickerPopup",function(){return{restrict:"E",controller:"DatepickerPopupCtrl",controllerAs:"popup",bindToController:!0,templateUrl:"templates/pa-datepicker/popup.html",transclude:!0,replace:!0,scope:{isOpen:"=",closeAfterSelection:"@"},link:function(t,e,i,n){n.container=e[0],n.init()}}})}(),function(){"use strict";angular.module("pa-datepicker").constant("paDatepickerConfig",{panels:1,mode:"single",startingDay:0,showOutliers:!0,minDate:null,maxDate:null,popup:{closeAfterSelection:!0}})}(),function(){"use strict";angular.module("pa-datepicker").service("DateParser",function(t,e){function i(t){var i=[],n=t.split("");return angular.forEach(o,function(e,o){var r=t.indexOf(o);if(r>-1){t=t.split(""),n[r]="("+e.regex+")",t[r]="$";for(var s=r+1,a=r+o.length;a>s;s++)n[s]="",t[s]="$";t=t.join(""),i.push({index:r,apply:e.apply})}}),{regex:new RegExp("^"+n.join("")+"$"),map:e(i,"index")}}function n(t,e,i){return 1===e&&i>28?29===i&&(t%4===0&&t%100!==0||t%400===0):3===e||5===e||8===e||10===e?31>i:!0}this.parsers={};var o={yyyy:{regex:"\\d{4}",apply:function(t){this.year=+t}},yy:{regex:"\\d{2}",apply:function(t){this.year=+t+2e3}},y:{regex:"\\d{1,4}",apply:function(t){this.year=+t}},MMMM:{regex:t.DATETIME_FORMATS.MONTH.join("|"),apply:function(e){this.month=t.DATETIME_FORMATS.MONTH.indexOf(e)}},MMM:{regex:t.DATETIME_FORMATS.SHORTMONTH.join("|"),apply:function(e){this.month=t.DATETIME_FORMATS.SHORTMONTH.indexOf(e)}},MM:{regex:"0?[1-9]|1[0-2]",apply:function(t){this.month=t-1}},M:{regex:"0?[1-9]|1[0-2]",apply:function(t){this.month=t-1}},dd:{regex:"0?[1-9]|[12][0-9]|3[01]",apply:function(t){this.date=+t}},d:{regex:"0?[1-9]|[12][0-9]|3[01]",apply:function(t){this.date=+t}},EEEE:{regex:t.DATETIME_FORMATS.DAY.join("|")},EEE:{regex:t.DATETIME_FORMATS.SHORTDAY.join("|")}};this.parse=function(e,o){if(!angular.isString(e)||!o)return e;o=t.DATETIME_FORMATS[o]||o,this.parsers[o]||(this.parsers[o]=i(o));var r=this.parsers[o],s=r.regex,a=r.map,c=e.match(s);if(c&&c.length){for(var l,h={year:1900,month:0,date:1,hours:0},u=1,p=c.length;p>u;u++){var d=a[u-1];d.apply&&d.apply.call(h,c[u])}return n(h.year,h.month,h.date)&&(l=new Date(h.year,h.month,h.date,h.hours)),l}}})}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerContainerCtrl",["$rootScope","$scope","paDatepickerConfig",function(t,e,i){angular.extend(this,{init:function(){this.selections={},this.initConfig(),this.initToday(),this.initCurrentPeriod(),this.initModel(),this.initPanels(),this.initMonitorWatcher()},initMonitorWatcher:function(){e.$watch(function(){return this.ngModel}.bind(this),function(){this.initModel(),this.initPanels()}.bind(this))},initConfig:function(){this.config=angular.copy(i),angular.forEach(this.config,function(t,e){if("undefined"!=typeof this[e]){var i="false"!==this[e]?this[e]:!1;this.config[e]=i}}.bind(this))},initToday:function(){this.today=new Date,this.today.setHours(0,0,0,0)},initPanels:function(){this.datePanels=[];for(var t=parseInt(this.config.panels,10),e=this.getPanelStart(),i=0;t>i;i++)this.datePanels[i]={first:0===i,last:i===t-1,year:e.getFullYear(),month:e.getMonth()+i-t+1}},initCurrentPeriod:function(){this.currentPeriod=this.currentPeriod||"base"},initModel:function(){this.isRange()&&"object"!=typeof this.ngModel?this.ngModel={}:this.ngModel instanceof Date?this.ngModel.setHours(0,0,0,0):"string"==typeof this.ngModel||this.ngModel instanceof String?(this.ngModel=new Date(this.ngModel),this.ngModel.setHours(0,0,0,0)):this.isRange()||(this.ngModel=void 0)},getPanelStart:function(){return this.isRange()?this.getRangePanelStart():this.ngModel||this.today},getRangePanelStart:function(){return this.ngModel.base&&this.ngModel.base.end instanceof Date?this.ngModel.comparison&&this.ngModel.comparison.end instanceof Date?this.getFurtherDate():this.ngModel.base.end:this.today},getFurtherDate:function(){return this.compare(this.ngModel.comparison.end,this.ngModel.base.end)>0?this.ngModel.comparison.end:this.ngModel.base.end},updatePanels:function(t,e){e.preventDefault(),this.datePanels.forEach(function(e){e.month+=t})},selectDate:function(t){this.isRange()?this.handleDateSelection(t):(this.ngModel=t,this.closePopup())},handleDateSelection:function(t){this.isSelecting()?(this.stopSelection(t),this.closePopup()):this.startSelection(t)},isSelecting:function(){return!!this.selections[this.currentPeriod]},startSelection:function(e){this.selections[this.currentPeriod]={selected:e,start:e,end:e},t.$broadcast("paDatepicker.selection.started")},previewSelection:function(t){if(!this.isSelecting())return!1;var e=this.selections[this.currentPeriod];t>=e.selected?(e.start=e.selected,e.end=t):(e.start=t,e.end=e.selected)},stopSelection:function(e){var i=this.selections[this.currentPeriod];e>i.selected?this.updateCurrentPeriod(i.selected,e):this.updateCurrentPeriod(e,i.selected),this.selections[this.currentPeriod]=null,t.$broadcast("paDatepicker.selection.ended")},updateCurrentPeriod:function(t,e){this.ngModel[this.currentPeriod]={start:t,end:e}},isRange:function(){return"range"===this.config.mode},isDateEnabled:function(t){return this.config.minDate&&this.compare(t,this.config.minDate)<0?!1:this.config.maxDate&&this.compare(t,this.config.maxDate)>0?!1:!0},isDateSelected:function(t){return this.isRange()?this.isDateWithinBasePeriod(t)||this.isDateWithinComparisonPeriod(t):this.ngModel instanceof Date&&t.getTime()===this.ngModel.getTime()},isDateWithinBasePeriod:function(t){return this.isDateWithinPeriod("base",t)},isDateWithinComparisonPeriod:function(t){return this.isDateWithinPeriod("comparison",t)},isDateWithinPeriod:function(t,e){if(!this.isRange())return!1;if(this.isSelecting()&&this.currentPeriod===t)return this.isDateWithinSelection(e);var i=this.ngModel[t];return i&&i.start&&i.end?i&&this.compare(e,i.start)>=0&&this.compare(e,i.end)<=0:!1},isDateWithinSelection:function(t){var e=this.selections[this.currentPeriod];return e&&this.compare(t,e.start)>=0&&this.compare(t,e.end)<=0},isToday:function(t){return 0===this.compare(t,this.today)},getStartingDay:function(){return parseInt(this.config.startingDay,10)%7||0},closePopup:function(){this.popup&&this.popup.close()},compare:function(t,e){var i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i-n}})}])}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerPanelCtrl",["$scope",function(t){angular.extend(this,{init:function(){this.initConfigWatcher()},updatePanel:function(){this.setBoundaries(),this.separateRows()},initConfigWatcher:function(){t.$watch(function(){return this.config}.bind(this),this.updatePanel.bind(this),!0)},setBoundaries:function(){this.start=new Date(this.config.year,this.config.month,1),this.end=new Date(this.config.year,1+parseInt(this.config.month,10),0)},separateRows:function(){var t=1-this.start.getDay()+this.container.getStartingDay(),e=new Date(this.config.year,this.config.month,t),i=(this.end-e)/6048e5;i=i%1===0?i+1:Math.ceil(i),this.fillRows(i,e)},fillRows:function(t,e){this.rows=[];for(var i=0;t>i;i++){this.rows[i]=[];for(var n=0;7>n;n++)this.rows[i][n]=new Date(e.getTime()),e.setDate(e.getDate()+1)}},selectDate:function(t){this.isEnabled(t)&&this.container.selectDate(t)},previewSelection:function(t){this.isEnabled(t)&&this.container.previewSelection(t)},isEnabled:function(t){return this.container.isDateEnabled(t)&&this.isDateInsideMonth(t)},isDisabled:function(t){return!this.isEnabled(t)},isDateInsideMonth:function(t){return this.container.compare(t,this.start)>=0&&this.container.compare(this.end,t)>=0},isDateSelected:function(t){return this.isEnabled(t)&&this.container.isDateSelected(t)},isDateWithinBasePeriod:function(t){return this.isEnabled(t)&&this.container.isDateWithinBasePeriod(t)},isDateWithinComparisonPeriod:function(t){return this.isEnabled(t)&&this.container.isDateWithinComparisonPeriod(t)}})}])}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerPopupCtrl",["$rootScope","$scope","$document","$timeout","paDatepickerConfig",function(t,e,i,n,o){angular.extend(this,{init:function(){this.initOpeningWatcher(),this.initConfig(),this.initSelectionHandlers(),this.initClickHandler(),this.openingHandler()},initOpeningWatcher:function(){e.$watch(function(){return this.isOpen}.bind(this),this.openingHandler.bind(this))},initConfig:function(){this.config=angular.copy(o.popup),void 0!==this.closeAfterSelection&&(this.config.closeAfterSelection="true"===this.closeAfterSelection)},initSelectionHandlers:function(){t.$on("paDatepicker.selection.started",function(){this.isSelectingPeriod=!0}.bind(this)),t.$on("paDatepicker.selection.ended",function(){this.isSelectingPeriod=!1}.bind(this))},initClickHandler:function(){this.clickHandler=this.onClickOutside.bind(this)},openingHandler:function(){var t=function(){this.isOpen?i.bind("click",this.clickHandler):i.unbind("click",this.clickHandler)};n(t.bind(this),200)},onClickOutside:function(){e.$apply(function(){this.isSelectingPeriod!==!0?this.closePopup():t.$broadcast("paDatepicker.popup.unfinishedSelection")}.bind(this))},preventClosing:function(t){t.stopPropagation()},close:function(){this.config.closeAfterSelection&&this.closePopup()},closePopup:function(){this.isOpen=!1,this.openingHandler()}})}])}(); \ No newline at end of file +!function(){"use strict";angular.module("pa-datepicker",[])}(),function(){"use strict";angular.module("pa-datepicker").directive("paDateInput",["$filter","DateParser",function(t,e){var i=function(e){return function(i){var n=new Date(i);return isNaN(n.getTime())?null:t("date")(n,e)}},n=function(t){return function(i){return e.parse(i,t)}};return{require:"ngModel",template:'',replace:!0,scope:{format:"@"},link:function(t,e,r,o){var s=t.format||"shortDate";o.$formatters.unshift(i(s)),o.$parsers.unshift(n(s))}}}])}(),function(){"use strict";angular.module("pa-datepicker").directive("paDatepicker",function(){return{restrict:"E",controller:"DatepickerContainerCtrl",controllerAs:"container",bindToController:!0,require:["^ngModel","^paDatepicker","?^paDatepickerPopup"],templateUrl:"templates/pa-datepicker/container.html",scope:{panels:"@",mode:"@",currentPeriod:"=?",startingDay:"@",showOutliers:"@",minDate:"=",maxDate:"=",ngModel:"="},link:function(t,e,i,n){n[1].popup=n[2],n[1].init()}}})}(),function(){"use strict";angular.module("pa-datepicker").directive("paPanel",function(){return{restrict:"E",controller:"DatepickerPanelCtrl",controllerAs:"panel",bindToController:!0,require:["^paDatepicker","^paPanel"],templateUrl:"templates/pa-datepicker/panel.html",scope:{config:"=",period:"@"},link:function(t,e,i,n){n[1].container=n[0],n[1].init()}}})}(),function(){"use strict";angular.module("pa-datepicker").directive("paDatepickerPopup",function(){return{restrict:"E",controller:"DatepickerPopupCtrl",controllerAs:"popup",bindToController:!0,templateUrl:"templates/pa-datepicker/popup.html",transclude:!0,replace:!0,scope:{isOpen:"=",closeAfterSelection:"@"},link:function(t,e,i,n){n.container=e[0],n.init()}}})}(),function(){"use strict";angular.module("pa-datepicker").constant("paDatepickerConfig",{panels:1,mode:"single",startingDay:0,showOutliers:!0,minDate:null,maxDate:null,popup:{closeAfterSelection:!0}})}(),function(){"use strict";angular.module("pa-datepicker").service("DateParser",function(t,e){function i(t){var i=[],n=t.split("");return angular.forEach(r,function(e,r){var o=t.indexOf(r);if(o>-1){t=t.split(""),n[o]="("+e.regex+")",t[o]="$";for(var s=o+1,a=o+r.length;a>s;s++)n[s]="",t[s]="$";t=t.join(""),i.push({index:o,apply:e.apply})}}),{regex:new RegExp("^"+n.join("")+"$"),map:e(i,"index")}}function n(t,e,i){return 1===e&&i>28?29===i&&(t%4===0&&t%100!==0||t%400===0):3===e||5===e||8===e||10===e?31>i:!0}this.parsers={};var r={yyyy:{regex:"\\d{4}",apply:function(t){this.year=+t}},yy:{regex:"\\d{2}",apply:function(t){this.year=+t+2e3}},y:{regex:"\\d{1,4}",apply:function(t){this.year=+t}},MMMM:{regex:t.DATETIME_FORMATS.MONTH.join("|"),apply:function(e){this.month=t.DATETIME_FORMATS.MONTH.indexOf(e)}},MMM:{regex:t.DATETIME_FORMATS.SHORTMONTH.join("|"),apply:function(e){this.month=t.DATETIME_FORMATS.SHORTMONTH.indexOf(e)}},MM:{regex:"0?[1-9]|1[0-2]",apply:function(t){this.month=t-1}},M:{regex:"0?[1-9]|1[0-2]",apply:function(t){this.month=t-1}},dd:{regex:"0?[1-9]|[12][0-9]|3[01]",apply:function(t){this.date=+t}},d:{regex:"0?[1-9]|[12][0-9]|3[01]",apply:function(t){this.date=+t}},EEEE:{regex:t.DATETIME_FORMATS.DAY.join("|")},EEE:{regex:t.DATETIME_FORMATS.SHORTDAY.join("|")}};this.parse=function(e,r){if(!angular.isString(e)||!r)return e;r=t.DATETIME_FORMATS[r]||r,this.parsers[r]||(this.parsers[r]=i(r));var o=this.parsers[r],s=o.regex,a=o.map,c=e.match(s);if(c&&c.length){for(var l,u={year:1900,month:0,date:1,hours:0},h=1,p=c.length;p>h;h++){var d=a[h-1];d.apply&&d.apply.call(u,c[h])}return n(u.year,u.month,u.date)&&(l=new Date(u.year,u.month,u.date,u.hours)),l}}})}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerContainerCtrl",["$rootScope","$scope","paDatepickerConfig",function(t,e,i){angular.extend(this,{init:function(){this.selections={},this.initToday(),this.initCurrentPeriod(),this.initModel(),this.initPanels(),this.initMonitorWatcher()},initMonitorWatcher:function(){e.$watch(function(){return this.ngModel}.bind(this),function(){this.initModel(),this.initPanels()}.bind(this))},initToday:function(){this.today=new Date,this.today.setHours(0,0,0,0)},initPanels:function(){this.datePanels=[];for(var t=parseInt(this.getConfig("panels"),10),e=this.getPanelStart(),i=0;t>i;i++)this.datePanels[i]={first:0===i,last:i===t-1,year:e.getFullYear(),month:e.getMonth()+i-t+1}},initCurrentPeriod:function(){this.currentPeriod=this.currentPeriod||"base"},initModel:function(){this.isRange()&&"object"!=typeof this.ngModel?this.ngModel={}:this.ngModel instanceof Date?this.ngModel.setHours(0,0,0,0):"string"==typeof this.ngModel||this.ngModel instanceof String?(this.ngModel=new Date(this.ngModel),this.ngModel.setHours(0,0,0,0)):this.isRange()||(this.ngModel=void 0)},getConfig:function(t){var e=this[t]||i[t];return"false"!==e?e:!1},getPanelStart:function(){return this.isRange()?this.getRangePanelStart():this.ngModel||this.today},getRangePanelStart:function(){return this.ngModel.base&&this.ngModel.base.end instanceof Date?this.ngModel.comparison&&this.ngModel.comparison.end instanceof Date?this.getFurtherDate():this.ngModel.base.end:this.today},getFurtherDate:function(){return this.compare(this.ngModel.comparison.end,this.ngModel.base.end)>0?this.ngModel.comparison.end:this.ngModel.base.end},updatePanels:function(t,e){e.preventDefault(),this.datePanels.forEach(function(e){e.month+=t})},selectDate:function(t){this.isRange()?this.handleDateSelection(t):(this.ngModel=t,this.closePopup())},handleDateSelection:function(t){this.isSelecting()?(this.stopSelection(t),this.closePopup()):this.startSelection(t)},isSelecting:function(){return!!this.selections[this.currentPeriod]},startSelection:function(e){this.selections[this.currentPeriod]={selected:e,start:e,end:e},t.$broadcast("paDatepicker.selection.started")},previewSelection:function(t){if(!this.isSelecting())return!1;var e=this.selections[this.currentPeriod];t>=e.selected?(e.start=e.selected,e.end=t):(e.start=t,e.end=e.selected)},stopSelection:function(e){var i=this.selections[this.currentPeriod];e>i.selected?this.updateCurrentPeriod(i.selected,e):this.updateCurrentPeriod(e,i.selected),this.selections[this.currentPeriod]=null,t.$broadcast("paDatepicker.selection.ended")},updateCurrentPeriod:function(t,e){this.ngModel[this.currentPeriod]={start:t,end:e}},isRange:function(){return"range"===this.getConfig("mode")},isDateEnabled:function(t){var e=this.getConfig("minDate"),i=this.getConfig("maxDate");return e&&this.compare(t,e)<0?!1:i&&this.compare(t,i)>0?!1:!0},isDateSelected:function(t){return this.isRange()?this.isDateWithinBasePeriod(t)||this.isDateWithinComparisonPeriod(t):this.ngModel instanceof Date&&t.getTime()===this.ngModel.getTime()},isDateWithinBasePeriod:function(t){return this.isDateWithinPeriod("base",t)},isDateWithinComparisonPeriod:function(t){return this.isDateWithinPeriod("comparison",t)},isDateWithinPeriod:function(t,e){if(!this.isRange())return!1;if(this.isSelecting()&&this.currentPeriod===t)return this.isDateWithinSelection(e);var i=this.ngModel[t];return i&&i.start&&i.end?i&&this.compare(e,i.start)>=0&&this.compare(e,i.end)<=0:!1},isDateWithinSelection:function(t){var e=this.selections[this.currentPeriod];return e&&this.compare(t,e.start)>=0&&this.compare(t,e.end)<=0},isToday:function(t){return 0===this.compare(t,this.today)},getStartingDay:function(){return parseInt(this.getConfig("startingDay"),10)%7||0},closePopup:function(){this.popup&&this.popup.close()},compare:function(t,e){var i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i-n}})}])}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerPanelCtrl",["$scope",function(t){angular.extend(this,{init:function(){this.initConfigWatcher()},updatePanel:function(){this.setBoundaries(),this.separateRows()},initConfigWatcher:function(){t.$watch(function(){return this.config}.bind(this),this.updatePanel.bind(this),!0)},setBoundaries:function(){this.start=new Date(this.config.year,this.config.month,1),this.end=new Date(this.config.year,1+parseInt(this.config.month,10),0)},separateRows:function(){var t=1-this.start.getDay()+this.container.getStartingDay(),e=new Date(this.config.year,this.config.month,t),i=(this.end-e)/6048e5;i=i%1===0?i+1:Math.ceil(i),this.fillRows(i,e)},fillRows:function(t,e){this.rows=[];for(var i=0;t>i;i++){this.rows[i]=[];for(var n=0;7>n;n++)this.rows[i][n]=new Date(e.getTime()),e.setDate(e.getDate()+1)}},selectDate:function(t){this.isEnabled(t)&&this.container.selectDate(t)},previewSelection:function(t){this.isEnabled(t)&&this.container.previewSelection(t)},isEnabled:function(t){return this.container.isDateEnabled(t)&&this.isDateInsideMonth(t)},isDisabled:function(t){return!this.isEnabled(t)},isDateInsideMonth:function(t){return this.container.compare(t,this.start)>=0&&this.container.compare(this.end,t)>=0},isDateSelected:function(t){return this.isEnabled(t)&&this.container.isDateSelected(t)},isDateWithinBasePeriod:function(t){return this.isEnabled(t)&&this.container.isDateWithinBasePeriod(t)},isDateWithinComparisonPeriod:function(t){return this.isEnabled(t)&&this.container.isDateWithinComparisonPeriod(t)}})}])}(),function(){"use strict";angular.module("pa-datepicker").controller("DatepickerPopupCtrl",["$rootScope","$scope","$document","$timeout","paDatepickerConfig",function(t,e,i,n,r){angular.extend(this,{init:function(){this.initOpeningWatcher(),this.initConfig(),this.initSelectionHandlers(),this.initClickHandler(),this.openingHandler()},initOpeningWatcher:function(){e.$watch(function(){return this.isOpen}.bind(this),this.openingHandler.bind(this))},initConfig:function(){this.config=angular.copy(r.popup),void 0!==this.closeAfterSelection&&(this.config.closeAfterSelection="true"===this.closeAfterSelection)},initSelectionHandlers:function(){t.$on("paDatepicker.selection.started",function(){this.isSelectingPeriod=!0}.bind(this)),t.$on("paDatepicker.selection.ended",function(){this.isSelectingPeriod=!1}.bind(this))},initClickHandler:function(){this.clickHandler=this.onClickOutside.bind(this)},openingHandler:function(){var t=function(){this.isOpen?i.bind("click",this.clickHandler):i.unbind("click",this.clickHandler)};n(t.bind(this),200)},onClickOutside:function(){e.$apply(function(){this.isSelectingPeriod!==!0?this.closePopup():t.$broadcast("paDatepicker.popup.unfinishedSelection")}.bind(this))},preventClosing:function(t){t.stopPropagation()},close:function(){this.config.closeAfterSelection&&this.closePopup()},closePopup:function(){this.isOpen=!1,this.openingHandler()}})}])}(); \ No newline at end of file