Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
uiDatetimePickerConfig introduced so you can globally set datetimePicker
options
  • Loading branch information
Gillardo committed May 28, 2015
1 parent 9fcbb9c commit 9b2ac10
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 27 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": "1.0.22",
"version": "1.1.0",
"homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker",
"authors": [
"Gillardo <[email protected]>"
Expand Down
34 changes: 24 additions & 10 deletions datetime-picker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
.directive('datetimePicker', ['$compile', '$parse', '$document', '$timeout', '$position', 'dateFilter', 'dateParser', 'datepickerPopupConfig',
function ($compile, $parse, $document, $timeout, $position, dateFilter, dateParser, datepickerPopupConfig) {
.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',
enableDate: true,
enableTime: true,
todayText: 'Today',
nowText: 'Now',
clearText: 'Clear',
closeText: 'Done',
dateText: 'Date',
timeText: 'Time',
closeOnDateSelection: true,
appendToBody: false,
showButtonBar: true
})
.directive('datetimePicker', ['$compile', '$parse', '$document', '$timeout', '$position', 'dateFilter', 'dateParser', 'uiDatetimePickerConfig',
function ($compile, $parse, $document, $timeout, $position, dateFilter, dateParser, uiDatetimePickerConfig) {
return {
restrict: 'A',
require: 'ngModel',
Expand All @@ -17,15 +31,15 @@
dateDisabled: '&'
},
link: function (scope, element, attrs, ngModel) {
var dateFormat = 'dd MMM yyyy HH:mm:ss', currentDate,
closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection,
appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody;
var dateFormat = uiDatetimePickerConfig.dateFormat, currentDate,
closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : uiDatetimePickerConfig.closeOnDateSelection,
appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : uiDatetimePickerConfig.appendToBody;

scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : uiDatetimePickerConfig.showButtonBar;

// determine which pickers should be available. Defaults to date and time
scope.enableDate = !(scope.enableDate == false);
scope.enableTime = !(scope.enableTime == false);
scope.enableDate = angular.isDefined(scope.enableDate) ? scope.enableDate : uiDatetimePickerConfig.enableDate;
scope.enableTime = angular.isDefined(scope.enableTime) ? scope.enableTime : uiDatetimePickerConfig.enableTime;

// default picker view
scope.showPicker = scope.enableDate ? 'date' : 'time';
Expand All @@ -39,11 +53,11 @@
scope.timeText = scope.timeText || 'Time';

scope.getText = function (key) {
return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
return scope[key + 'Text'] || uiDatetimePickerConfig[key + 'Text'];
};

attrs.$observe('datetimePicker', function (value) {
dateFormat = value || datepickerPopupConfig.datepickerPopup;
dateFormat = value || uiDatetimePickerConfig.dateFormat;
ngModel.$render();
});

Expand Down
38 changes: 26 additions & 12 deletions dist/datetime-picker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// https://github.com/Gillardo/bootstrap-ui-datetime-picker
// Version: 1.0.22
// Released: 2015-05-27
// Version: 1.1.0
// Released: 2015-05-28
angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
.directive('datetimePicker', ['$compile', '$parse', '$document', '$timeout', '$position', 'dateFilter', 'dateParser', 'datepickerPopupConfig',
function ($compile, $parse, $document, $timeout, $position, dateFilter, dateParser, datepickerPopupConfig) {
.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',
enableDate: true,
enableTime: true,
todayText: 'Today',
nowText: 'Now',
clearText: 'Clear',
closeText: 'Done',
dateText: 'Date',
timeText: 'Time',
closeOnDateSelection: true,
appendToBody: false,
showButtonBar: true
})
.directive('datetimePicker', ['$compile', '$parse', '$document', '$timeout', '$position', 'dateFilter', 'dateParser', 'uiDatetimePickerConfig',
function ($compile, $parse, $document, $timeout, $position, dateFilter, dateParser, uiDatetimePickerConfig) {
return {
restrict: 'A',
require: 'ngModel',
Expand All @@ -20,15 +34,15 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
dateDisabled: '&'
},
link: function (scope, element, attrs, ngModel) {
var dateFormat = 'dd MMM yyyy HH:mm:ss', currentDate,
closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection,
appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody;
var dateFormat = uiDatetimePickerConfig.dateFormat, currentDate,
closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : uiDatetimePickerConfig.closeOnDateSelection,
appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : uiDatetimePickerConfig.appendToBody;

scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : uiDatetimePickerConfig.showButtonBar;

// determine which pickers should be available. Defaults to date and time
scope.enableDate = !(scope.enableDate == false);
scope.enableTime = !(scope.enableTime == false);
scope.enableDate = angular.isDefined(scope.enableDate) ? scope.enableDate : uiDatetimePickerConfig.enableDate;
scope.enableTime = angular.isDefined(scope.enableTime) ? scope.enableTime : uiDatetimePickerConfig.enableTime;

// default picker view
scope.showPicker = scope.enableDate ? 'date' : 'time';
Expand All @@ -42,11 +56,11 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
scope.timeText = scope.timeText || 'Time';

scope.getText = function (key) {
return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
return scope[key + 'Text'] || uiDatetimePickerConfig[key + 'Text'];
};

attrs.$observe('datetimePicker', function (value) {
dateFormat = value || datepickerPopupConfig.datepickerPopup;
dateFormat = value || uiDatetimePickerConfig.dateFormat;
ngModel.$render();
});

Expand Down
Loading

0 comments on commit 9b2ac10

Please sign in to comment.