Skip to content

Commit

Permalink
Merged into master and updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Gillardo committed Jun 3, 2016
1 parent 958543b commit 6bf5c38
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 69 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.3.1",
"version": "2.4.0",
"homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker",
"authors": [
"Gillardo <[email protected]>"
Expand Down
41 changes: 17 additions & 24 deletions datetime-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
ngModel.$parsers.push(saveAsParser);

// Assuming if saveAs is !false, we'll want to convert, either pass the function, or the stock str/num -> Date obj formatter.
if (angular.isFunction(readAs))
if (angular.isFunction(readAs))
ngModel.$formatters.push(readAs);
else
ngModel.$formatters.push(readAsFormatter);
Expand All @@ -237,28 +237,28 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
$element.after($popup);
}

function readAsFormatter(value) {
if (ngModel.$isEmpty(value))
return value;

var d = new Date(value);
if (angular.isDate(d) && !isNaN(d))
return d;

return value;
}
function readAsFormatter(value) {
if (ngModel.$isEmpty(value))
return value;

var d = new Date(value);
if (angular.isDate(d) && !isNaN(d))
return d;

return value;
}

function saveAsParser(value) {
if (!value || angular.isString(value) || !angular.isDate(value) || isNaN(value))
return value;

if (saveAs === 'ISO')
return value.toISOString();

if (saveAs === 'json')
return value.toJSON();

if (saveAs === 'number')
return value.toISOString();

if (saveAs === 'json')
return value.toJSON();

if (saveAs === 'number')
return value.valueOf();

if (!isHtml5DateInput) {
Expand Down Expand Up @@ -347,13 +347,6 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo

};

$scope.keydown = function(evt) {
if (evt.which === 27) {
$scope.close(false);
$element[0].focus();
}
};

$scope.$watch('isOpen', function (value) {
$scope.dropdownStyle = {
display: value ? 'block' : 'none'
Expand Down
49 changes: 21 additions & 28 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.3.1
// Released: 2016-05-27
// Version: 2.4.0
// Released: 2016-06-03
angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
.constant('uiDatetimePickerConfig', {
dateFormat: 'yyyy-MM-dd HH:mm',
Expand Down Expand Up @@ -218,7 +218,7 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
ngModel.$parsers.push(saveAsParser);

// Assuming if saveAs is !false, we'll want to convert, either pass the function, or the stock str/num -> Date obj formatter.
if (angular.isFunction(readAs))
if (angular.isFunction(readAs))
ngModel.$formatters.push(readAs);
else
ngModel.$formatters.push(readAsFormatter);
Expand All @@ -240,28 +240,28 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo
$element.after($popup);
}

function readAsFormatter(value) {
if (ngModel.$isEmpty(value))
return value;

var d = new Date(value);
if (angular.isDate(d) && !isNaN(d))
return d;

return value;
}
function readAsFormatter(value) {
if (ngModel.$isEmpty(value))
return value;

var d = new Date(value);
if (angular.isDate(d) && !isNaN(d))
return d;

return value;
}

function saveAsParser(value) {
if (!value || angular.isString(value) || !angular.isDate(value) || isNaN(value))
return value;

if (saveAs === 'ISO')
return value.toISOString();

if (saveAs === 'json')
return value.toJSON();

if (saveAs === 'number')
return value.toISOString();

if (saveAs === 'json')
return value.toJSON();

if (saveAs === 'number')
return value.valueOf();

if (!isHtml5DateInput) {
Expand Down Expand Up @@ -350,13 +350,6 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo

};

$scope.keydown = function(evt) {
if (evt.which === 27) {
$scope.close(false);
$element[0].focus();
}
};

$scope.$watch('isOpen', function (value) {
$scope.dropdownStyle = {
display: value ? 'block' : 'none'
Expand Down Expand Up @@ -635,12 +628,12 @@ angular.module('ui.bootstrap.datetimepicker').run(['$templateCache', function($t
'use strict';

$templateCache.put('template/date-picker.html',
"<ul class=\"dropdown-menu dropdown-menu-left datetime-picker-dropdown\" ng-if=\"isOpen && showPicker == 'date'\" ng-style=dropdownStyle style=left:inherit ng-keydown=keydown($event) ng-click=$event.stopPropagation()><li style=\"padding:0 5px 5px 5px\" class=date-picker-menu><div ng-transclude></div></li><li style=padding:5px ng-if=buttonBar.show><span class=\"btn-group pull-left\" style=margin-right:10px ng-if=\"doShow('today') || doShow('clear')\"><button type=button class=\"btn btn-sm btn-info\" ng-if=\"doShow('today')\" ng-click=\"select('today')\" ng-disabled=\"isDisabled('today')\">{{ getText('today') }}</button> <button type=button class=\"btn btn-sm btn-danger\" ng-if=\"doShow('clear')\" ng-click=\"select('clear')\">{{ getText('clear') }}</button></span> <span class=\"btn-group pull-right\" ng-if=\"(doShow('time') && enableTime) || doShow('close')\"><button type=button class=\"btn btn-sm btn-default\" ng-if=\"doShow('time') && enableTime\" ng-click=\"open('time', $event)\">{{ getText('time')}}</button> <button type=button class=\"btn btn-sm btn-success\" ng-if=\"doShow('close')\" ng-click=close(true)>{{ getText('close') }}</button></span> <span class=clearfix></span></li></ul>"
"<ul class=\"dropdown-menu dropdown-menu-left datetime-picker-dropdown\" ng-if=\"isOpen && showPicker == 'date'\" ng-style=dropdownStyle style=left:inherit ng-click=$event.stopPropagation()><li style=\"padding:0 5px 5px 5px\" class=date-picker-menu><div ng-transclude></div></li><li style=padding:5px ng-if=buttonBar.show><span class=\"btn-group pull-left\" style=margin-right:10px ng-if=\"doShow('today') || doShow('clear')\"><button type=button class=\"btn btn-sm btn-info\" ng-if=\"doShow('today')\" ng-click=\"select('today')\" ng-disabled=\"isDisabled('today')\">{{ getText('today') }}</button> <button type=button class=\"btn btn-sm btn-danger\" ng-if=\"doShow('clear')\" ng-click=\"select('clear')\">{{ getText('clear') }}</button></span> <span class=\"btn-group pull-right\" ng-if=\"(doShow('time') && enableTime) || doShow('close')\"><button type=button class=\"btn btn-sm btn-default\" ng-if=\"doShow('time') && enableTime\" ng-click=\"open('time', $event)\">{{ getText('time')}}</button> <button type=button class=\"btn btn-sm btn-success\" ng-if=\"doShow('close')\" ng-click=close(true)>{{ getText('close') }}</button></span> <span class=clearfix></span></li></ul>"
);


$templateCache.put('template/time-picker.html',
"<ul class=\"dropdown-menu dropdown-menu-left datetime-picker-dropdown\" ng-if=\"isOpen && showPicker == 'time'\" ng-style=dropdownStyle style=left:inherit ng-keydown=keydown($event) ng-click=$event.stopPropagation()><li style=\"padding:0 5px 5px 5px\" class=time-picker-menu><div ng-transclude></div></li><li style=padding:5px ng-if=buttonBar.show><span class=\"btn-group pull-left\" style=margin-right:10px ng-if=\"doShow('now') || doShow('clear')\"><button type=button class=\"btn btn-sm btn-info\" ng-if=\"doShow('now')\" ng-click=\"select('now')\" ng-disabled=\"isDisabled('now')\">{{ getText('now') }}</button> <button type=button class=\"btn btn-sm btn-danger\" ng-if=\"doShow('clear')\" ng-click=\"select('clear')\">{{ getText('clear') }}</button></span> <span class=\"btn-group pull-right\" ng-if=\"(doShow('date') && enableDate) || doShow('close')\"><button type=button class=\"btn btn-sm btn-default\" ng-if=\"doShow('date') && enableDate\" ng-click=\"open('date', $event)\">{{ getText('date')}}</button> <button type=button class=\"btn btn-sm btn-success\" ng-if=\"doShow('close')\" ng-click=close(true)>{{ getText('close') }}</button></span> <span class=clearfix></span></li></ul>"
"<ul class=\"dropdown-menu dropdown-menu-left datetime-picker-dropdown\" ng-if=\"isOpen && showPicker == 'time'\" ng-style=dropdownStyle style=left:inherit ng-click=$event.stopPropagation()><li style=\"padding:0 5px 5px 5px\" class=time-picker-menu><div ng-transclude></div></li><li style=padding:5px ng-if=buttonBar.show><span class=\"btn-group pull-left\" style=margin-right:10px ng-if=\"doShow('now') || doShow('clear')\"><button type=button class=\"btn btn-sm btn-info\" ng-if=\"doShow('now')\" ng-click=\"select('now')\" ng-disabled=\"isDisabled('now')\">{{ getText('now') }}</button> <button type=button class=\"btn btn-sm btn-danger\" ng-if=\"doShow('clear')\" ng-click=\"select('clear')\">{{ getText('clear') }}</button></span> <span class=\"btn-group pull-right\" ng-if=\"(doShow('date') && enableDate) || doShow('close')\"><button type=button class=\"btn btn-sm btn-default\" ng-if=\"doShow('date') && enableDate\" ng-click=\"open('date', $event)\">{{ getText('date')}}</button> <button type=button class=\"btn btn-sm btn-success\" ng-if=\"doShow('close')\" ng-click=close(true)>{{ getText('close') }}</button></span> <span class=clearfix></span></li></ul>"
);

}]);
Loading

0 comments on commit 6bf5c38

Please sign in to comment.