diff --git a/dist/ionic-datepicker.bundle.min.js b/dist/ionic-datepicker.bundle.min.js
index 27b42917..767f02bb 100644
--- a/dist/ionic-datepicker.bundle.min.js
+++ b/dist/ionic-datepicker.bundle.min.js
@@ -1 +1 @@
-!function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,"/**/\n.padding_zero {\n padding: 0;\n}\n\n.ionic_datepicker_popup .font_bold {\n font-weight: bold;\n}\n\n.ionic_datepicker_popup .padding_top_zero {\n padding-top: 0;\n}\n\n.ionic_datepicker_popup .padding_left_5px {\n padding-left: 5px;\n}\n\n.ionic_datepicker_popup .padding_right_5px {\n padding-right: 5px;\n}\n\n.ionic_datepicker_popup .month_year_section {\n padding: 5px 0;\n}\n\n.ionic_datepicker_popup .calendar_grid {\n height: 215px;\n}\n\n.ionic_datepicker_popup .calendar_grid .weeks_row {\n padding: 0;\n}\n\n.ionic_datepicker_popup .today {\n border: 1px solid #009688;\n border-radius: 50%;\n}\n\n.ionic_datepicker_popup .selected_date {\n background-color: #009688;\n border-radius: 50%;\n color: #ffffff;\n font-weight: bold;\n}\n\n.ionic_datepicker_popup .popup-head {\n background-color: #009688;\n display: none;\n}\n\n.ionic_datepicker_popup .popup-head .popup-title {\n color: #ffffff;\n}\n\n.ionic_datepicker_popup .popup-head .popup-sub-title {\n color: #ffffff;\n}\n\n.ionic_datepicker_popup .popup-body {\n background-color: #ffffff;\n}\n\n.ionic_datepicker_popup .popup-body .selected_date_full {\n background-color: #009688;\n margin: -10px -10px 0 -10px;\n height: 45px;\n text-align: center;\n font-weight: bold;\n color: #ffffff;\n line-height: 45px;\n font-size: 18px;\n}\n\n.ionic_datepicker_popup .popup-body .select_section {\n padding: 1px 5px;\n}\n\n.ionic_datepicker_popup .popup-body .pointer_events_none {\n pointer-events: none;\n color: #aaaaaa !important;\n}\n\n.ionic_datepicker_popup .popup-body .month_select, .ionic_datepicker_popup .popup-body .year_select {\n border: none;\n border-bottom: 1px solid #009688;\n padding: 0;\n}\n\n.ionic_datepicker_popup .popup-body .month_select .input-label, .ionic_datepicker_popup .popup-body .year_select .input-label {\n padding: 2px 0;\n width: 0;\n}\n\n.ionic_datepicker_popup .popup-body .month_select select, .ionic_datepicker_popup .popup-body .year_select select {\n left: 10px;\n border: none;\n padding: 0;\n}\n\n.ionic_datepicker_popup .popup-body .month_select:after, .ionic_datepicker_popup .popup-body .year_select:after {\n right: 5px;\n color: #009688;\n}\n\n.ionic_datepicker_popup .popup-body .show_nav {\n padding: 5px 0 0 0;\n}\n\n.ionic_datepicker_popup .popup-body .show_nav .prev_btn_section {\n padding: 5px 0;\n text-align: left;\n}\n\n.ionic_datepicker_popup .popup-body .show_nav .prev_btn_section button {\n padding: 0;\n}\n\n.ionic_datepicker_popup .popup-body .show_nav .next_btn_section {\n padding: 5px 0;\n text-align: right;\n}\n\n.ionic_datepicker_popup .popup-body .show_nav .next_btn_section button {\n padding: 0;\n}\n\n.ionic_datepicker_popup .popup-body .button-clear {\n color: #009688;\n}\n\n.ionic_datepicker_popup .popup-buttons {\n padding: 0;\n min-height: 45px;\n}\n\n.ionic_datepicker_popup .popup-buttons button {\n background-color: #009688;\n border-radius: 0;\n margin-right: 1px;\n color: #ffffff;\n}\n\n.ionic_datepicker_popup .row + .row {\n padding: 0;\n}\n\n.ionic_datepicker_modal .header, .ionic_datepicker_modal .footer {\n background-color: #009688;\n}\n\n.ionic_datepicker_modal .header .title, .ionic_datepicker_modal .header .button, .ionic_datepicker_modal .footer .title, .ionic_datepicker_modal .footer .button {\n color: #ffffff;\n}\n\n.ionic_datepicker_modal .footer .button-block {\n margin: 0;\n}\n\n.ionic_datepicker_modal .today {\n border: 1px solid #009688;\n}\n\n.ionic_datepicker_modal .selected_date {\n background-color: #009688;\n color: #ffffff;\n font-weight: bold;\n}\n\n.ionic_datepicker_modal .pointer_events_none {\n pointer-events: none;\n color: #aaaaaa !important;\n}\n\n.ionic_datepicker_modal .select_section {\n padding: 1px 5px;\n}\n\n.ionic_datepicker_modal .button-clear {\n color: #009688;\n}\n\n.ionic_datepicker_modal .month_select, .ionic_datepicker_modal .year_select {\n border: none;\n border-bottom: 1px solid #009688;\n padding: 0;\n}\n\n.ionic_datepicker_modal .month_select .input-label, .ionic_datepicker_modal .year_select .input-label {\n padding: 2px 0;\n width: 0;\n}\n\n.ionic_datepicker_modal .month_select select, .ionic_datepicker_modal .year_select select {\n left: 10px;\n border: none;\n padding: 0 10px;\n}\n\n.ionic_datepicker_modal .month_select:after, .ionic_datepicker_modal .year_select:after {\n right: 5px;\n color: #009688;\n}\n\n.ionic_datepicker_modal .padding_left_5px {\n padding-left: 5px;\n}\n\n.ionic_datepicker_modal .padding_right_5px {\n padding-right: 5px;\n}\n\n.ionic_datepicker_modal .date_col {\n height: 50px;\n line-height: 50px;\n}\n\n.ionic_datepicker_modal .font_bold {\n font-weight: bold;\n}\n\n.ionic_datepicker_modal .font_22px {\n font-size: 22px;\n}\n\n.platform-android .ionic_datepicker_modal .bar .title.title-left {\n text-align: center;\n}\n\n.platform-android .ionic_datepicker_modal select {\n left: 25%;\n}\n\n.platform-ios .ionic_datepicker_modal select {\n left: 5%;\n}"),function(e){try{e=angular.module("ionic-datepicker.templates")}catch(t){e=angular.module("ionic-datepicker.templates",[])}e.run(["$templateCache",function(e){e.put("ionic-datepicker-modal.html",'{{dayList[row + col].date}}
')}])}(),function(e){try{e=angular.module("ionic-datepicker.templates")}catch(t){e=angular.module("ionic-datepicker.templates",[])}e.run(["$templateCache",function(e){e.put("ionic-datepicker-popup.html",'
{{mainObj.titleLabel || selctedDateEpoch | date : mainObj.dateFormat}}
{{dayList[row + col].date}}
')}])}(),angular.module("ionic-datepicker",["ionic","ionic-datepicker.service","ionic-datepicker.provider","ionic-datepicker.templates"]),angular.module("ionic-datepicker.provider",[]).provider("ionicDatePicker",function(){var e={titleLabel:null,setLabel:"Set",todayLabel:"Today",closeLabel:"Close",inputDate:new Date,mondayFirst:!0,weeksList:["S","M","T","W","T","F","S"],monthsList:["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"],templateType:"popup",showTodayButton:!1,closeOnSelect:!1,disableWeekdays:[]};this.configDatePicker=function(t){angular.extend(e,t)},this.$get=["$rootScope","$ionicPopup","$ionicModal","IonicDatepickerService",function(t,n,a,o){function i(e){return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e}function c(e){e.disabledDates&&0!==e.disabledDates.length?(u.disabledDates=[],angular.forEach(e.disabledDates,function(e,t){e=i(new Date(e)),u.disabledDates.push(e.getTime())})):u.disabledDates=[]}function d(e){e=i(e),u.currentDate=angular.copy(e);var t=new Date(e.getFullYear(),e.getMonth(),1).getDate(),n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();u.monthsList=[],u.mainObj.monthsList&&12===u.mainObj.monthsList.length?u.monthsList=u.mainObj.monthsList:u.monthsList=o.monthsList,u.yearsList=o.getYearsList(u.mainObj.from,u.mainObj.to),u.dayList=[];var a,c;u.firstDayEpoch=i(new Date(e.getFullYear(),e.getMonth(),t)).getTime(),u.lastDayEpoch=i(new Date(e.getFullYear(),e.getMonth(),n)).getTime();for(var d=t;d<=n;d++)a=new Date(e.getFullYear(),e.getMonth(),d),c=a.getTime()u.toDate||u.mainObj.disableWeekdays.indexOf(a.getDay())>=0,u.dayList.push({date:a.getDate(),month:a.getMonth(),year:a.getFullYear(),day:a.getDay(),epoch:a.getTime(),disabled:c});var r=u.dayList[0].day-u.mainObj.mondayFirst;r=r<0?6:r;for(var l=0;l{{dayList[row + col].date}}
')}])}(),function(e){try{e=angular.module("ionic-datepicker.templates")}catch(t){e=angular.module("ionic-datepicker.templates",[])}e.run(["$templateCache",function(e){e.put("ionic-datepicker-popup.html",'{{mainObj.titleLabel || selctedDateEpoch | date : mainObj.dateFormat}}
{{dayList[row + col].date}}
')}])}(),angular.module("ionic-datepicker",["ionic","ionic-datepicker.service","ionic-datepicker.provider","ionic-datepicker.templates"]),angular.module("ionic-datepicker.provider",[]).provider("ionicDatePicker",function(){var e={titleLabel:null,setLabel:"Set",todayLabel:"Today",closeLabel:"Close",inputDate:new Date,mondayFirst:!0,weeksList:["S","M","T","W","T","F","S"],monthsList:["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"],templateType:"popup",showTodayButton:!1,closeOnSelect:!1,disableWeekdays:[]};this.configDatePicker=function(t){angular.extend(e,t)},this.$get=["$rootScope","$ionicPopup","$ionicModal","IonicDatepickerService",function(t,n,a,o){function i(e){return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e}function c(e){var t=e.getTime()<_.fromDate||e.getTime()>_.toDate||_.mainObj.disableWeekdays.indexOf(e.getDay())>=0;return{date:e.getDate(),month:e.getMonth(),year:e.getFullYear(),day:e.getDay(),epoch:e.getTime(),disabled:t}}function d(e){e.disabledDates&&0!==e.disabledDates.length?(_.disabledDates=[],angular.forEach(e.disabledDates,function(e,t){e=i(new Date(e)),_.disabledDates.push(e.getTime())})):_.disabledDates=[]}function r(e){e=i(e),_.currentDate=angular.copy(e);var t=new Date(e.getFullYear(),e.getMonth(),1).getDate(),n=new Date(e.getFullYear(),e.getMonth()+1,0).getDate();_.monthsList=[],_.mainObj.monthsList&&12===_.mainObj.monthsList.length?_.monthsList=_.mainObj.monthsList:_.monthsList=o.monthsList,_.yearsList=o.getYearsList(_.mainObj.from,_.mainObj.to),_.dayList=[];var a;_.firstDayEpoch=i(new Date(e.getFullYear(),e.getMonth(),t)).getTime(),_.lastDayEpoch=i(new Date(e.getFullYear(),e.getMonth(),n)).getTime();for(var d=t;d<=n;d++)a=new Date(e.getFullYear(),e.getMonth(),d),_.dayList.push(c(a));var r=_.dayList[0].day-_.mainObj.mondayFirst;r=r<0?6:r;for(var l=0;l{{mainObj.titleLabel || selctedDateEpoch | date : mainObj.date
diff --git a/src/ionic-datepicker-popup.html b/src/ionic-datepicker-popup.html
index 70b13867..f1f941d9 100644
--- a/src/ionic-datepicker-popup.html
+++ b/src/ionic-datepicker-popup.html
@@ -30,7 +30,7 @@
diff --git a/src/ionic-datepicker.provider.js b/src/ionic-datepicker.provider.js
index 43ecd7b0..380b3aa2 100644
--- a/src/ionic-datepicker.provider.js
+++ b/src/ionic-datepicker.provider.js
@@ -26,7 +26,6 @@ angular.module('ionic-datepicker.provider', [])
var provider = {};
var $scope = $rootScope.$new();
- $scope.today = resetHMSM(new Date()).getTime();
$scope.disabledDates = [];
$scope.data = {};
@@ -39,6 +38,19 @@ angular.module('ionic-datepicker.provider', [])
return currentDate;
}
+ function getDatePickerDay(dateObj) {
+ var disabled = (dateObj.getTime() < $scope.fromDate) || (dateObj.getTime() > $scope.toDate) || $scope.mainObj.disableWeekdays.indexOf(dateObj.getDay()) >= 0;
+
+ return {
+ date: dateObj.getDate(),
+ month: dateObj.getMonth(),
+ year: dateObj.getFullYear(),
+ day: dateObj.getDay(),
+ epoch: dateObj.getTime(),
+ disabled: disabled
+ };
+ }
+
//Previous month
$scope.prevMonth = function () {
if ($scope.currentDate.getMonth() === 1) {
@@ -56,21 +68,18 @@ angular.module('ionic-datepicker.provider', [])
if ($scope.currentDate.getMonth() === 11) {
$scope.currentDate.setFullYear($scope.currentDate.getFullYear());
}
- $scope.currentDate.setDate(1);
$scope.currentDate.setMonth($scope.currentDate.getMonth() + 1);
$scope.data.currentMonth = $scope.mainObj.monthsList[$scope.currentDate.getMonth()];
$scope.data.currentYear = $scope.currentDate.getFullYear();
- $scope.monthChanged($scope.currentDate.getMonth());
- refreshDateList(new Date());
+ refreshDateList($scope.currentDate);
changeDaySelected();
};
- var changeDaySelected = function() {
+ var changeDaySelected = function () {
var newSelectedDate = new Date($scope.selctedDateEpoch);
newSelectedDate.setMonth($scope.currentDate.getMonth());
newSelectedDate.setYear($scope.currentDate.getFullYear());
$scope.selctedDateEpoch = newSelectedDate.getTime();
- $scope.mainObj.callback($scope.selctedDateEpoch);
}
//Date selected
@@ -87,9 +96,10 @@ angular.module('ionic-datepicker.provider', [])
}
};
- //Set today as date for the modal
+ //Set today as date for the modal and popup
$scope.setIonicDatePickerTodayDate = function () {
- $scope.dateSelected($scope.today);
+ refreshDateList(new Date($scope.today));
+ $scope.dateSelected(getDatePickerDay(new Date($scope.today)));
};
//Set date for the modal
@@ -136,16 +146,7 @@ angular.module('ionic-datepicker.provider', [])
for (var i = firstDay; i <= lastDay; i++) {
tempDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), i);
- disabled = (tempDate.getTime() < $scope.fromDate) || (tempDate.getTime() > $scope.toDate) || $scope.mainObj.disableWeekdays.indexOf(tempDate.getDay()) >= 0;
-
- $scope.dayList.push({
- date: tempDate.getDate(),
- month: tempDate.getMonth(),
- year: tempDate.getFullYear(),
- day: tempDate.getDay(),
- epoch: tempDate.getTime(),
- disabled: disabled
- });
+ $scope.dayList.push(getDatePickerDay(tempDate));
}
//To set Monday as the first day of the week.
@@ -231,6 +232,7 @@ angular.module('ionic-datepicker.provider', [])
delete $scope.fromDate;
delete $scope.toDate;
+ $scope.today = resetHMSM(new Date()).getTime();
$scope.mainObj = angular.extend({}, config, ipObj);
if ($scope.mainObj.from) {
$scope.fromDate = resetHMSM(new Date($scope.mainObj.from)).getTime();
@@ -259,23 +261,8 @@ angular.module('ionic-datepicker.provider', [])
text: $scope.mainObj.todayLabel,
type: 'button_today',
onTap: function (e) {
- var today = new Date($scope.today);
- var today_obj = {
- date: today.getDate(),
- month: today.getMonth(),
- year: today.getFullYear(),
- day: today.getDay(),
- epoch: today.getTime(),
- disabled: false
- };
- $scope.dateSelected(today_obj);
-
- refreshDateList(new Date());
- $scope.selctedDateEpoch = resetHMSM(today).getTime();
- $scope.mainObj.callback($scope.selctedDateEpoch);
- if (!$scope.mainObj.closeOnSelect) {
- e.preventDefault();
- }
+ e.preventDefault();
+ $scope.setIonicDatePickerTodayDate();
}
});
}