Skip to content

Commit

Permalink
Fixes #96 and #101
Browse files Browse the repository at this point in the history
  • Loading branch information
Gillardo committed Mar 4, 2016
1 parent ae0a3ea commit f386d88
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-ui-datetime-picker",
"version": "2.2.1",
"version": "2.2.2",
"homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker",
"authors": [
"Gillardo <[email protected]>"
Expand Down
6 changes: 6 additions & 0 deletions datetime-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
$timeout(function() {
scope.showPicker = 'time';
}, 0);

// in order to update the timePicker, we need to update the model reference!
// as found here https://angular-ui.github.io/bootstrap/#/timepicker
$timeout(function() {
scope.date = new Date(scope.date);
}, 100);
} else {
scope.close(false);
}
Expand Down
29 changes: 25 additions & 4 deletions dist/datetime-picker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/Gillardo/bootstrap-ui-datetime-picker
// Version: 2.2.1
// Released: 2016-03-03
// Version: 2.2.2
// Released: 2016-03-04
angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',
Expand All @@ -10,6 +10,8 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',
'month': 'yyyy-MM'
},
initialPicker: 'date',
reOpenDefault: false,
enableDate: true,
enableTime: true,
buttonBar: {
Expand Down Expand Up @@ -63,8 +65,19 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
scope.enableDate = angular.isDefined(scope.enableDate) ? scope.enableDate : uiDatetimePickerConfig.enableDate;
scope.enableTime = angular.isDefined(scope.enableTime) ? scope.enableTime : uiDatetimePickerConfig.enableTime;

// determine default picker
scope.initialPicker = angular.isDefined(attrs.initialPicker) ? attrs.initialPicker : (scope.enableDate ? uiDatetimePickerConfig.initialPicker : 'time');

// determine the picker to open when control is re-opened
scope.reOpenDefault = angular.isDefined(attrs.reOpenDefault) ? attrs.reOpenDefault : uiDatetimePickerConfig.reOpenDefault;

// check if an illegal combination of options exists
if (scope.initialPicker == 'date' && !scope.enableDate) {
throw new Error("datetimePicker can't have initialPicker set to date and have enableDate set to false.");
}

// default picker view
scope.showPicker = scope.enableDate ? 'date' : 'time';
scope.showPicker = !scope.enableDate ? 'time' : scope.initialPicker;

var isHtml5DateInput = false;

Expand Down Expand Up @@ -315,6 +328,12 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
$timeout(function() {
scope.showPicker = 'time';
}, 0);

// in order to update the timePicker, we need to update the model reference!
// as found here https://angular-ui.github.io/bootstrap/#/timepicker
$timeout(function() {
scope.date = new Date(scope.date);
}, 100);
} else {
scope.close(false);
}
Expand Down Expand Up @@ -397,7 +416,7 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo

// if enableDate and enableTime are true, reopen the picker in date mode first
if (scope.enableDate && scope.enableTime)
scope.showPicker = 'date';
scope.showPicker = scope.reOpenDefault === false ? 'date' : scope.reOpenDefault;

// if a on-close-fn has been defined, lets call it
// we only call this if closePressed is defined!
Expand Down Expand Up @@ -534,6 +553,8 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
isOpen: '=?',
enableDate: '=?',
enableTime: '=?',
initialPicker: '=?',
reOpenDefault: '=?',
dateDisabled: '&',
customClass: '&',
whenClosed: '&'
Expand Down
Loading

0 comments on commit f386d88

Please sign in to comment.