diff --git a/bower.json b/bower.json index c6923fa..6e8ca39 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-ui-datetime-picker", - "version": "2.5.4", + "version": "2.6.0", "homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker", "authors": [ "Gillardo " diff --git a/datetime-picker.js b/datetime-picker.js index 6a5afa9..019c4e1 100644 --- a/datetime-picker.js +++ b/datetime-picker.js @@ -44,7 +44,7 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo cls: 'btn-sm btn-default' }, cancel: { - show: true, + show: false, text: 'Cancel', cls: 'btn-sm btn-default' } diff --git a/dist/datetime-picker.js b/dist/datetime-picker.js index 0d88d85..7a20670 100644 --- a/dist/datetime-picker.js +++ b/dist/datetime-picker.js @@ -1,6 +1,6 @@ // https://github.com/Gillardo/bootstrap-ui-datetime-picker -// Version: 2.5.4 -// Released: 2017-04-18 +// Version: 2.6.0 +// Released: 2017-05-12 angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position']) .constant('uiDatetimePickerConfig', { dateFormat: 'yyyy-MM-dd HH:mm', @@ -45,6 +45,11 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo show: true, text: 'Close', cls: 'btn-sm btn-default' + }, + cancel: { + show: false, + text: 'Cancel', + cls: 'btn-sm btn-default' } }, closeOnDateSelection: true, @@ -64,7 +69,8 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo appendToBody = angular.isDefined($attrs.datepickerAppendToBody) ? $scope.$parent.$eval($attrs.datepickerAppendToBody) : uiDatetimePickerConfig.appendToBody, altInputFormats = angular.isDefined($attrs.altInputFormats) ? $scope.$parent.$eval($attrs.altInputFormats) : uiDatetimePickerConfig.altInputFormats, saveAs = angular.isDefined($attrs.saveAs) ? $scope.$parent.$eval($attrs.saveAs) || $attrs.saveAs : uiDatetimePickerConfig.saveAs, - readAs = angular.isDefined($attrs.readAs) ? $scope.$parent.$eval($attrs.readAs) : uiDatetimePickerConfig.readAs; + readAs = angular.isDefined($attrs.readAs) ? $scope.$parent.$eval($attrs.readAs) : uiDatetimePickerConfig.readAs, + currentDateTimeModelValue = null; this.init = function (_ngModel) { ngModel = _ngModel; @@ -485,12 +491,26 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo $scope.dateSelection(date, opt); }; + $scope.cancel = function (evt) { + if (angular.isDefined(evt)) { + evt.preventDefault(); + evt.stopPropagation(); + } + + $element.val(dateFilter(currentDateTimeModelValue, dateFormat)); + ngModel.$setViewValue(dateFilter(currentDateTimeModelValue, dateFormat)); + + $scope.close(false); + }; + $scope.open = function (picker, evt) { if (angular.isDefined(evt)) { evt.preventDefault(); evt.stopPropagation(); } + currentDateTimeModelValue = $element.val(); + // need to delay this, else timePicker never shown $timeout(function () { $scope.showPicker = picker; @@ -699,12 +719,12 @@ angular.module('ui.bootstrap.datetimepicker').run(['$templateCache', function($t 'use strict'; $templateCache.put('template/date-picker.html', - "" + "" ); $templateCache.put('template/time-picker.html', - "" + "" ); }]); diff --git a/dist/datetime-picker.min.js b/dist/datetime-picker.min.js index 637f3f2..8c7ac14 100644 --- a/dist/datetime-picker.min.js +++ b/dist/datetime-picker.min.js @@ -1,4 +1,4 @@ // https://github.com/Gillardo/bootstrap-ui-datetime-picker -// Version: 2.5.4 -// Released: 2017-04-18 -angular.module("ui.bootstrap.datetimepicker",["ui.bootstrap.dateparser","ui.bootstrap.position"]).constant("uiDatetimePickerConfig",{dateFormat:"yyyy-MM-dd HH:mm",defaultTime:"00:00:00",html5Types:{date:"yyyy-MM-dd","datetime-local":"yyyy-MM-ddTHH:mm:ss.sss",month:"yyyy-MM"},initialPicker:"date",reOpenDefault:!1,enableDate:!0,enableTime:!0,buttonBar:{show:!0,now:{show:!0,text:"Now",cls:"btn-sm btn-default"},today:{show:!0,text:"Today",cls:"btn-sm btn-default"},clear:{show:!0,text:"Clear",cls:"btn-sm btn-default"},date:{show:!0,text:"Date",cls:"btn-sm btn-default"},time:{show:!0,text:"Time",cls:"btn-sm btn-default"},close:{show:!0,text:"Close",cls:"btn-sm btn-default"}},closeOnDateSelection:!0,closeOnTimeNow:!0,appendToBody:!1,altInputFormats:[],ngModelOptions:{timezone:null},saveAs:!1,readAs:!1}).controller("DateTimePickerController",["$scope","$element","$attrs","$compile","$parse","$document","$timeout","$uibPosition","dateFilter","uibDateParser","uiDatetimePickerConfig","$rootScope",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(c){var d=v[0],e=b[0].contains(c.target),f=void 0!==d.contains&&d.contains(c.target);!a.isOpen||e||f||a.$apply(function(){a.close(!1)})}function n(c){27===c.which&&a.isOpen?(c.preventDefault(),c.stopPropagation(),a.$apply(function(){a.close(!1)}),b[0].focus()):40!==c.which||a.isOpen||(c.preventDefault(),c.stopPropagation(),a.$apply(function(){a.isOpen=!0}))}function o(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function p(b){var c=j.parse(b,w,a.date);if(isNaN(c))for(var d=0;da.datepickerOptions.maxDate?!1:!0}function s(a,b){var d=a||b;return c.ngRequired||c.required||d?(angular.isNumber(d)&&(d=new Date(d)),d?angular.isDate(d)&&!isNaN(d)?r(d):angular.isDate(new Date(d))&&!isNaN(new Date(d).valueOf())?r(new Date(d)):angular.isString(d)?!isNaN(p(b))&&r(p(b)):!1:!0):!0}var t,u,v,w=k.dateFormat,x={},y=[],z=angular.isDefined(c.closeOnDateSelection)?a.$parent.$eval(c.closeOnDateSelection):k.closeOnDateSelection,A=angular.isDefined(c.closeOnTimeNow)?a.$parent.$eval(c.closeOnTimeNow):k.closeOnTimeNow,B=angular.isDefined(c.datepickerAppendToBody)?a.$parent.$eval(c.datepickerAppendToBody):k.appendToBody,C=angular.isDefined(c.altInputFormats)?a.$parent.$eval(c.altInputFormats):k.altInputFormats,D=angular.isDefined(c.saveAs)?a.$parent.$eval(c.saveAs)||c.saveAs:k.saveAs,E=angular.isDefined(c.readAs)?a.$parent.$eval(c.readAs):k.readAs;this.init=function(e){function g(a){if(t.$isEmpty(a))return a;var b=new Date(a);return angular.isDate(b)&&!isNaN(b)?b:a}function h(a){return!a||angular.isString(a)||!angular.isDate(a)||isNaN(a)?a:"ISO"===D?a.toISOString():"json"===D?a.toJSON():"number"===D?a.valueOf():i?j.fromTimezone(a,u.timezone).toLocaleString():(w=w.replace(/M!/,"MM").replace(/d!/,"dd"),j.filter(j.fromTimezone(a,u.timezone),w))}if(t=e,u=t.$options||k.ngModelOptions,a.buttonBar=angular.isDefined(c.buttonBar)?a.$parent.$eval(c.buttonBar):k.buttonBar,a.enableDate=angular.isDefined(a.enableDate)?a.enableDate:k.enableDate,a.enableTime=angular.isDefined(a.enableTime)?a.enableTime:k.enableTime,a.initialPicker=angular.isDefined(c.initialPicker)?c.initialPicker:a.enableDate?k.initialPicker:"time",a.reOpenDefault=angular.isDefined(c.reOpenDefault)?c.reOpenDefault:k.reOpenDefault,"date"==a.initialPicker&&!a.enableDate)throw new Error("datetimePicker can't have initialPicker set to date and have enableDate set to false.");a.showPicker=a.enableDate?a.initialPicker:"time";var i=!1;if(k.html5Types[c.type]?(w=k.html5Types[c.type],i=!0):(w=c.datetimePicker||k.dateFormat,c.$observe("datetimePicker",function(a){var b=a||k.dateFormat;if(b!==w&&(w=b,t.$modelValue=null,!w))throw new Error("datetimePicker must have a date format specified.")})),!w)throw new Error("datetimePicker must have a date format specified.");var l=angular.element('
');a.ngModelOptions=angular.copy(u),a.ngModelOptions.updateOnDefault===!0&&(a.ngModelOptions.updateOn=a.ngModelOptions.updateOn?a.ngModelOptions.updateOn+" default":"default"),l.attr({"ng-model":"date","ng-model-options":"ngModelOptions","ng-change":"dateSelection(date)"});var m=angular.element(l.children()[0]);a.datepickerOptions||(a.datepickerOptions={}),i&&"month"===c.type&&(a.datepickerOptions.datepickerMode="month",a.datepickerOptions.minMode="month"),m.attr("datepicker-options","datepickerOptions"),angular.isDefined(a.datepickerOptions.datepickerMode)||(a.datepickerOptions.datepickerMode="day");var r=angular.element(l.children()[1]);a.timepickerOptions||(a.timepickerOptions={showMeridian:!0});for(var x in a.timepickerOptions)r.attr(o(x),"timepickerOptions."+x);angular.forEach(["minDate","maxDate","initDate"],function(b){a.datepickerOptions[b]&&("minDate"==b?a.timepickerOptions.min?r.attr("min","timepickerOptions.min"):r.attr("min","datepickerOptions.minDate"):"maxDate"==b&&(a.timepickerOptions.max?r.attr("max","timepickerOptions.max"):r.attr("max","datepickerOptions.maxDate")))}),i?t.$formatters.push(function(b){return a.date=j.fromTimezone(b,u.timezone),b}):(t.$$parserName="datetime",t.$validators.datetime=s,t.$parsers.unshift(q),t.$formatters.push(function(b){return t.$isEmpty(b)?(a.date=b,b):(a.date=j.fromTimezone(b,u.timezone),w=w.replace(/M!/,"MM").replace(/d!/,"dd"),j.filter(a.date,w))})),D&&(angular.isFunction(D)?t.$parsers.push(D):t.$parsers.push(h),angular.isFunction(E)?t.$formatters.push(E):t.$formatters.push(g)),t.$viewChangeListeners.push(function(){if(a.timepickerOptions.min){var b=new Date(a.timepickerOptions.min).getHours(),c=new Date(a.timepickerOptions.min).getMinutes(),d=new Date(a.date);d.setHours(b),d.setMinutes(c),a.timepickerOptions.min=d}if(a.timepickerOptions.max){var e=new Date(a.timepickerOptions.max).getHours(),f=new Date(a.timepickerOptions.max).getMinutes(),g=new Date(a.date);g.setHours(e),g.setMinutes(f),a.timepickerOptions.max=g}a.date=p(t.$viewValue)}),b.bind("keydown",n),v=d(l)(a),l.remove(),B?f.find("body").append(v):b.after(v)},a.getText=function(b){return a.buttonBar[b].text||k.buttonBar[b].text},a.getClass=function(b){return a.buttonBar[b].cls||k.buttonBar[b].cls},a.keydown=function(c){27===c.which&&(c.preventDefault(),c.stopPropagation(),a.close(!1),g(function(){b[0].focus()},0))},a.doShow=function(b){return angular.isDefined(a.buttonBar[b].show)?a.buttonBar[b].show:k.buttonBar[b].show},a.dateSelection=function(d,e){if(a.enableTime&&"time"===a.showPicker)if(d||null!=d){if(angular.isDefined(a.date)&&null!=a.date||(a.date=new Date),d&&null!=d){var f=new Date(a.date);f.setHours(d.getHours()),f.setMinutes(d.getMinutes()),f.setSeconds(d.getSeconds()),f.setMilliseconds(d.getMilliseconds()),d=f}}else a.oldDate=a.date;if(angular.isDefined(d)){if(!a.date){var g=angular.isDefined(c.defaultTime)?c.defaultTime:k.defaultTime,h=new Date("2001-01-01 "+g);isNaN(h)||null==d||(d.setHours(h.getHours()),d.setMinutes(h.getMinutes()),d.setSeconds(h.getSeconds()),d.setMilliseconds(h.getMilliseconds()))}a.date=d,d&&a.oldDate&&(d.setDate(a.oldDate.getDate()),d.setMonth(a.oldDate.getMonth()),d.setFullYear(a.oldDate.getFullYear()),delete a.oldDate)}var f=a.date?i(a.date,w):null;b.val(f),t.$setViewValue(f),z&&("time"!=a.showPicker&&null!=f?a.enableTime?a.open("time"):a.close(!1):A&&"time"===a.showPicker&&null!=f&&"now"===e&&a.close(!1))},a.$watch("isOpen",function(c){if(a.dropdownStyle={display:c?"block":"none"},c){x.openDate=a.date;var d=B?h.offset(b):h.position(b);B?a.dropdownStyle.top=d.top+b.prop("offsetHeight")+"px":a.dropdownStyle.top=void 0,a.dropdownStyle.left=d.left+"px",g(function(){a.$broadcast("uib:datepicker.focus"),f.bind("click",m)},0,!1),a.open(a.showPicker)}else f.unbind("click",m)}),a.isDisabled=function(b){("today"===b||"now"===b)&&(b=j.fromTimezone(new Date,u.timezone));var c={};return angular.forEach(["minDate","maxDate"],function(b){a.datepickerOptions[b]?angular.isDate(a.datepickerOptions[b])?c[b]=j.fromTimezone(new Date(a.datepickerOptions[b]),u.timezone):c[b]=new Date(i(a.datepickerOptions[b],"medium")):c[b]=null}),a.datepickerOptions&&c.minDate&&a.compare(b,c.minDate)<0||c.maxDate&&a.compare(b,c.maxDate)>0},a.compare=function(a,b){return new Date(a.getFullYear(),a.getMonth(),a.getDate())-new Date(b.getFullYear(),b.getMonth(),b.getDate())},a.select=function(b,c){angular.isDefined(c)&&(c.preventDefault(),c.stopPropagation());var d=null;if("today"===b||"now"==b){var e=new Date;angular.isDate(a.date)?(d=new Date(a.date),d.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),d.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())):d=e}a.dateSelection(d,b)},a.open=function(b,c){angular.isDefined(c)&&(c.preventDefault(),c.stopPropagation()),g(function(){a.showPicker=b},0),"time"==b&&g(function(){a.date=p(t.$viewValue)},50)},a.close=function(c,d){angular.isDefined(d)&&(d.preventDefault(),d.stopPropagation()),a.isOpen=!1,a.enableDate&&a.enableTime&&(a.showPicker=a.reOpenDefault===!1?"date":a.reOpenDefault),angular.isDefined(c)?a.whenClosed({args:{closePressed:c,openDate:x.openDate||null,closeDate:a.date}}):b[0].focus()},a.$on("$destroy",function(){a.isOpen===!0&&(l.$$phase||a.$apply(function(){a.close()})),y.forEach(function(a){a()}),v.remove(),b.unbind("keydown",n),f.unbind("click",m)})}]).directive("datetimePicker",function(){return{restrict:"A",require:["ngModel","datetimePicker"],controller:"DateTimePickerController",scope:{isOpen:"=?",datepickerOptions:"=?",timepickerOptions:"=?",enableDate:"=?",enableTime:"=?",initialPicker:"=?",reOpenDefault:"=?",whenClosed:"&"},link:function(a,b,c,d){var e=d[0],f=d[1];f.init(e)}}}).directive("datePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/date-picker.html"}}).directive("timePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/time-picker.html"}}),angular.module("ui.bootstrap.datetimepicker").run(["$templateCache",function(a){"use strict";a.put("template/date-picker.html",""),a.put("template/time-picker.html","")}]),"object"==typeof exports&&"object"==typeof module&&(module.exports="ui.bootstrap.datetimepicker"); \ No newline at end of file +// Version: 2.6.0 +// Released: 2017-05-12 +angular.module("ui.bootstrap.datetimepicker",["ui.bootstrap.dateparser","ui.bootstrap.position"]).constant("uiDatetimePickerConfig",{dateFormat:"yyyy-MM-dd HH:mm",defaultTime:"00:00:00",html5Types:{date:"yyyy-MM-dd","datetime-local":"yyyy-MM-ddTHH:mm:ss.sss",month:"yyyy-MM"},initialPicker:"date",reOpenDefault:!1,enableDate:!0,enableTime:!0,buttonBar:{show:!0,now:{show:!0,text:"Now",cls:"btn-sm btn-default"},today:{show:!0,text:"Today",cls:"btn-sm btn-default"},clear:{show:!0,text:"Clear",cls:"btn-sm btn-default"},date:{show:!0,text:"Date",cls:"btn-sm btn-default"},time:{show:!0,text:"Time",cls:"btn-sm btn-default"},close:{show:!0,text:"Close",cls:"btn-sm btn-default"},cancel:{show:!1,text:"Cancel",cls:"btn-sm btn-default"}},closeOnDateSelection:!0,closeOnTimeNow:!0,appendToBody:!1,altInputFormats:[],ngModelOptions:{timezone:null},saveAs:!1,readAs:!1}).controller("DateTimePickerController",["$scope","$element","$attrs","$compile","$parse","$document","$timeout","$uibPosition","dateFilter","uibDateParser","uiDatetimePickerConfig","$rootScope",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(c){var d=v[0],e=b[0].contains(c.target),f=void 0!==d.contains&&d.contains(c.target);!a.isOpen||e||f||a.$apply(function(){a.close(!1)})}function n(c){27===c.which&&a.isOpen?(c.preventDefault(),c.stopPropagation(),a.$apply(function(){a.close(!1)}),b[0].focus()):40!==c.which||a.isOpen||(c.preventDefault(),c.stopPropagation(),a.$apply(function(){a.isOpen=!0}))}function o(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function p(b){var c=j.parse(b,w,a.date);if(isNaN(c))for(var d=0;da.datepickerOptions.maxDate?!1:!0}function s(a,b){var d=a||b;return c.ngRequired||c.required||d?(angular.isNumber(d)&&(d=new Date(d)),d?angular.isDate(d)&&!isNaN(d)?r(d):angular.isDate(new Date(d))&&!isNaN(new Date(d).valueOf())?r(new Date(d)):angular.isString(d)?!isNaN(p(b))&&r(p(b)):!1:!0):!0}var t,u,v,w=k.dateFormat,x={},y=[],z=angular.isDefined(c.closeOnDateSelection)?a.$parent.$eval(c.closeOnDateSelection):k.closeOnDateSelection,A=angular.isDefined(c.closeOnTimeNow)?a.$parent.$eval(c.closeOnTimeNow):k.closeOnTimeNow,B=angular.isDefined(c.datepickerAppendToBody)?a.$parent.$eval(c.datepickerAppendToBody):k.appendToBody,C=angular.isDefined(c.altInputFormats)?a.$parent.$eval(c.altInputFormats):k.altInputFormats,D=angular.isDefined(c.saveAs)?a.$parent.$eval(c.saveAs)||c.saveAs:k.saveAs,E=angular.isDefined(c.readAs)?a.$parent.$eval(c.readAs):k.readAs,F=null;this.init=function(e){function g(a){if(t.$isEmpty(a))return a;var b=new Date(a);return angular.isDate(b)&&!isNaN(b)?b:a}function h(a){return!a||angular.isString(a)||!angular.isDate(a)||isNaN(a)?a:"ISO"===D?a.toISOString():"json"===D?a.toJSON():"number"===D?a.valueOf():i?j.fromTimezone(a,u.timezone).toLocaleString():(w=w.replace(/M!/,"MM").replace(/d!/,"dd"),j.filter(j.fromTimezone(a,u.timezone),w))}if(t=e,u=t.$options||k.ngModelOptions,a.buttonBar=angular.isDefined(c.buttonBar)?a.$parent.$eval(c.buttonBar):k.buttonBar,a.enableDate=angular.isDefined(a.enableDate)?a.enableDate:k.enableDate,a.enableTime=angular.isDefined(a.enableTime)?a.enableTime:k.enableTime,a.initialPicker=angular.isDefined(c.initialPicker)?c.initialPicker:a.enableDate?k.initialPicker:"time",a.reOpenDefault=angular.isDefined(c.reOpenDefault)?c.reOpenDefault:k.reOpenDefault,"date"==a.initialPicker&&!a.enableDate)throw new Error("datetimePicker can't have initialPicker set to date and have enableDate set to false.");a.showPicker=a.enableDate?a.initialPicker:"time";var i=!1;if(k.html5Types[c.type]?(w=k.html5Types[c.type],i=!0):(w=c.datetimePicker||k.dateFormat,c.$observe("datetimePicker",function(a){var b=a||k.dateFormat;if(b!==w&&(w=b,t.$modelValue=null,!w))throw new Error("datetimePicker must have a date format specified.")})),!w)throw new Error("datetimePicker must have a date format specified.");var l=angular.element('
');a.ngModelOptions=angular.copy(u),a.ngModelOptions.updateOnDefault===!0&&(a.ngModelOptions.updateOn=a.ngModelOptions.updateOn?a.ngModelOptions.updateOn+" default":"default"),l.attr({"ng-model":"date","ng-model-options":"ngModelOptions","ng-change":"dateSelection(date)"});var m=angular.element(l.children()[0]);a.datepickerOptions||(a.datepickerOptions={}),i&&"month"===c.type&&(a.datepickerOptions.datepickerMode="month",a.datepickerOptions.minMode="month"),m.attr("datepicker-options","datepickerOptions"),angular.isDefined(a.datepickerOptions.datepickerMode)||(a.datepickerOptions.datepickerMode="day");var r=angular.element(l.children()[1]);a.timepickerOptions||(a.timepickerOptions={showMeridian:!0});for(var x in a.timepickerOptions)r.attr(o(x),"timepickerOptions."+x);angular.forEach(["minDate","maxDate","initDate"],function(b){a.datepickerOptions[b]&&("minDate"==b?a.timepickerOptions.min?r.attr("min","timepickerOptions.min"):r.attr("min","datepickerOptions.minDate"):"maxDate"==b&&(a.timepickerOptions.max?r.attr("max","timepickerOptions.max"):r.attr("max","datepickerOptions.maxDate")))}),i?t.$formatters.push(function(b){return a.date=j.fromTimezone(b,u.timezone),b}):(t.$$parserName="datetime",t.$validators.datetime=s,t.$parsers.unshift(q),t.$formatters.push(function(b){return t.$isEmpty(b)?(a.date=b,b):(a.date=j.fromTimezone(b,u.timezone),w=w.replace(/M!/,"MM").replace(/d!/,"dd"),j.filter(a.date,w))})),D&&(angular.isFunction(D)?t.$parsers.push(D):t.$parsers.push(h),angular.isFunction(E)?t.$formatters.push(E):t.$formatters.push(g)),t.$viewChangeListeners.push(function(){if(a.timepickerOptions.min){var b=new Date(a.timepickerOptions.min).getHours(),c=new Date(a.timepickerOptions.min).getMinutes(),d=new Date(a.date);d.setHours(b),d.setMinutes(c),a.timepickerOptions.min=d}if(a.timepickerOptions.max){var e=new Date(a.timepickerOptions.max).getHours(),f=new Date(a.timepickerOptions.max).getMinutes(),g=new Date(a.date);g.setHours(e),g.setMinutes(f),a.timepickerOptions.max=g}a.date=p(t.$viewValue)}),b.bind("keydown",n),v=d(l)(a),l.remove(),B?f.find("body").append(v):b.after(v)},a.getText=function(b){return a.buttonBar[b].text||k.buttonBar[b].text},a.getClass=function(b){return a.buttonBar[b].cls||k.buttonBar[b].cls},a.keydown=function(c){27===c.which&&(c.preventDefault(),c.stopPropagation(),a.close(!1),g(function(){b[0].focus()},0))},a.doShow=function(b){return angular.isDefined(a.buttonBar[b].show)?a.buttonBar[b].show:k.buttonBar[b].show},a.dateSelection=function(d,e){if(a.enableTime&&"time"===a.showPicker)if(d||null!=d){if(angular.isDefined(a.date)&&null!=a.date||(a.date=new Date),d&&null!=d){var f=new Date(a.date);f.setHours(d.getHours()),f.setMinutes(d.getMinutes()),f.setSeconds(d.getSeconds()),f.setMilliseconds(d.getMilliseconds()),d=f}}else a.oldDate=a.date;if(angular.isDefined(d)){if(!a.date){var g=angular.isDefined(c.defaultTime)?c.defaultTime:k.defaultTime,h=new Date("2001-01-01 "+g);isNaN(h)||null==d||(d.setHours(h.getHours()),d.setMinutes(h.getMinutes()),d.setSeconds(h.getSeconds()),d.setMilliseconds(h.getMilliseconds()))}a.date=d,d&&a.oldDate&&(d.setDate(a.oldDate.getDate()),d.setMonth(a.oldDate.getMonth()),d.setFullYear(a.oldDate.getFullYear()),delete a.oldDate)}var f=a.date?i(a.date,w):null;b.val(f),t.$setViewValue(f),z&&("time"!=a.showPicker&&null!=f?a.enableTime?a.open("time"):a.close(!1):A&&"time"===a.showPicker&&null!=f&&"now"===e&&a.close(!1))},a.$watch("isOpen",function(c){if(a.dropdownStyle={display:c?"block":"none"},c){x.openDate=a.date;var d=B?h.offset(b):h.position(b);B?a.dropdownStyle.top=d.top+b.prop("offsetHeight")+"px":a.dropdownStyle.top=void 0,a.dropdownStyle.left=d.left+"px",g(function(){a.$broadcast("uib:datepicker.focus"),f.bind("click",m)},0,!1),a.open(a.showPicker)}else f.unbind("click",m)}),a.isDisabled=function(b){("today"===b||"now"===b)&&(b=j.fromTimezone(new Date,u.timezone));var c={};return angular.forEach(["minDate","maxDate"],function(b){a.datepickerOptions[b]?angular.isDate(a.datepickerOptions[b])?c[b]=j.fromTimezone(new Date(a.datepickerOptions[b]),u.timezone):c[b]=new Date(i(a.datepickerOptions[b],"medium")):c[b]=null}),a.datepickerOptions&&c.minDate&&a.compare(b,c.minDate)<0||c.maxDate&&a.compare(b,c.maxDate)>0},a.compare=function(a,b){return new Date(a.getFullYear(),a.getMonth(),a.getDate())-new Date(b.getFullYear(),b.getMonth(),b.getDate())},a.select=function(b,c){angular.isDefined(c)&&(c.preventDefault(),c.stopPropagation());var d=null;if("today"===b||"now"==b){var e=new Date;angular.isDate(a.date)?(d=new Date(a.date),d.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),d.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())):d=e}a.dateSelection(d,b)},a.cancel=function(c){angular.isDefined(c)&&(c.preventDefault(),c.stopPropagation()),b.val(i(F,w)),t.$setViewValue(i(F,w)),a.close(!1)},a.open=function(c,d){angular.isDefined(d)&&(d.preventDefault(),d.stopPropagation()),F=b.val(),g(function(){a.showPicker=c},0),"time"==c&&g(function(){a.date=p(t.$viewValue)},50)},a.close=function(c,d){angular.isDefined(d)&&(d.preventDefault(),d.stopPropagation()),a.isOpen=!1,a.enableDate&&a.enableTime&&(a.showPicker=a.reOpenDefault===!1?"date":a.reOpenDefault),angular.isDefined(c)?a.whenClosed({args:{closePressed:c,openDate:x.openDate||null,closeDate:a.date}}):b[0].focus()},a.$on("$destroy",function(){a.isOpen===!0&&(l.$$phase||a.$apply(function(){a.close()})),y.forEach(function(a){a()}),v.remove(),b.unbind("keydown",n),f.unbind("click",m)})}]).directive("datetimePicker",function(){return{restrict:"A",require:["ngModel","datetimePicker"],controller:"DateTimePickerController",scope:{isOpen:"=?",datepickerOptions:"=?",timepickerOptions:"=?",enableDate:"=?",enableTime:"=?",initialPicker:"=?",reOpenDefault:"=?",whenClosed:"&"},link:function(a,b,c,d){var e=d[0],f=d[1];f.init(e)}}}).directive("datePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/date-picker.html"}}).directive("timePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/time-picker.html"}}),angular.module("ui.bootstrap.datetimepicker").run(["$templateCache",function(a){"use strict";a.put("template/date-picker.html","
"),a.put("template/time-picker.html","
")}]),"object"==typeof exports&&"object"==typeof module&&(module.exports="ui.bootstrap.datetimepicker"); \ No newline at end of file diff --git a/dist/datetime-picker.tpls.js b/dist/datetime-picker.tpls.js index 2f93ce6..3a9e857 100644 --- a/dist/datetime-picker.tpls.js +++ b/dist/datetime-picker.tpls.js @@ -2,12 +2,12 @@ angular.module('ui.bootstrap.datetimepicker').run(['$templateCache', function($t 'use strict'; $templateCache.put('template/date-picker.html', - "
" + "
" ); $templateCache.put('template/time-picker.html', - "
" + "
" ); }]); diff --git a/package.json b/package.json index 17862ed..51a57ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-ui-datetime-picker", - "version": "2.5.4", + "version": "2.6.0", "url": "https://github.com/Gillardo/bootstrap-ui-datetime-picker", "authors": [ "Gillardo "