diff --git a/bower.json b/bower.json index 2783739..105c009 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "bootstrap-ui-datetime-picker", - "version": "1.1.2", + "version": "1.1.3", "homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker", "authors": [ "Gillardo " diff --git a/datetime-picker.js b/datetime-picker.js index 0de165b..9191a93 100644 --- a/datetime-picker.js +++ b/datetime-picker.js @@ -131,7 +131,7 @@ ngModel.$setValidity('date', true); return viewValue; } else if (angular.isString(viewValue)) { - var date = dateParser.parse(viewValue, dateFormat); + var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); if (isNaN(date)) { ngModel.$setValidity('date', false); diff --git a/dist/datetime-picker.js b/dist/datetime-picker.js index ee5b9ec..594f279 100644 --- a/dist/datetime-picker.js +++ b/dist/datetime-picker.js @@ -1,6 +1,6 @@ // https://github.com/Gillardo/bootstrap-ui-datetime-picker -// Version: 1.1.2 -// Released: 2015-07-07 +// Version: 1.1.3 +// Released: 2015-07-08 angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position']) .constant('uiDatetimePickerConfig', { dateFormat: 'yyyy-MM-dd HH:mm', @@ -134,7 +134,7 @@ angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bo ngModel.$setValidity('date', true); return viewValue; } else if (angular.isString(viewValue)) { - var date = dateParser.parse(viewValue, dateFormat); + var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); if (isNaN(date)) { ngModel.$setValidity('date', false); diff --git a/dist/datetime-picker.min.js b/dist/datetime-picker.min.js index c3e1538..28de874 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: 1.1.2 -// Released: 2015-07-07 -angular.module("ui.bootstrap.datetimepicker",["ui.bootstrap.dateparser","ui.bootstrap.position"]).constant("uiDatetimePickerConfig",{dateFormat:"yyyy-MM-dd HH:mm",enableDate:!0,enableTime:!0,todayText:"Today",nowText:"Now",clearText:"Clear",closeText:"Done",dateText:"Date",timeText:"Time",closeOnDateSelection:!0,appendToBody:!1,showButtonBar:!0}).directive("datetimePicker",["$compile","$parse","$document","$timeout","$position","dateFilter","dateParser","uiDatetimePickerConfig",function(a,b,c,d,e,f,g,h){return{restrict:"A",require:"ngModel",scope:{isOpen:"=?",enableDate:"=?",enableTime:"=?",todayText:"@",nowText:"@",dateText:"@",timeText:"@",clearText:"@",closeText:"@",dateDisabled:"&"},link:function(d,i,j,k){function l(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function m(a){return j.dateDisabled&&angular.isDefined(a)&&d.dateDisabled({date:a,mode:d.watchData.datepickerMode})}function n(a){if(a){if(angular.isDate(a)&&!isNaN(a))return k.$setValidity("date",!0),a;if(angular.isString(a)){var b=g.parse(a,p);return isNaN(b)?void k.$setValidity("date",!1):(k.$setValidity("date",!0),b)}return void k.$setValidity("date",!1)}return k.$setValidity("date",!0),null}var o,p=h.dateFormat,q=angular.isDefined(j.closeOnDateSelection)?d.$parent.$eval(j.closeOnDateSelection):h.closeOnDateSelection,r=angular.isDefined(j.datepickerAppendToBody)?d.$parent.$eval(j.datepickerAppendToBody):h.appendToBody;d.showButtonBar=angular.isDefined(j.showButtonBar)?d.$parent.$eval(j.showButtonBar):h.showButtonBar,d.enableDate=angular.isDefined(d.enableDate)?d.enableDate:h.enableDate,d.enableTime=angular.isDefined(d.enableTime)?d.enableTime:h.enableTime,d.showPicker=d.enableDate?"date":"time",d.getText=function(a){return d[a+"Text"]||h[a+"Text"]},j.$observe("datetimePicker",function(a){p=a||h.dateFormat,k.$render()});var s=angular.element('
');s.attr({"ng-model":"date","ng-change":"dateSelection()"});var t=angular.element(s.children()[0]);j.datepickerOptions&&angular.forEach(d.$parent.$eval(j.datepickerOptions),function(a,b){t.attr(l(b),a)});var u=angular.element(s.children()[1]);j.timepickerOptions&&angular.forEach(d.$parent.$eval(j.timepickerOptions),function(a,b){u.attr(l(b),a)}),j.datepickerMode||(j.datepickerMode="day"),d.watchData={},angular.forEach(["minDate","maxDate","datepickerMode"],function(a){if(j[a]){var c=b(j[a]);if(d.$parent.$watch(c,function(b){d.watchData[a]=b}),t.attr(l(a),"watchData."+a),"datepickerMode"===a){var e=c.assign;d.$watch("watchData."+a,function(a,b){a!==b&&e(d.$parent,a)})}}}),j.dateDisabled&&t.attr("date-disabled","dateDisabled({ date: date, mode: mode })"),k.$parsers.unshift(n),d.dateSelection=function(a){d.enableDate&&d.enableTime&&"time"===d.showPicker&&o&&null!==o&&(null!==d.date||a||null!=a)&&(a&&null!=a?(o.setHours(a.getHours()),o.setMinutes(a.getMinutes()),o.setSeconds(a.getSeconds()),o.setMilliseconds(a.getMilliseconds()),a=new Date(o)):(o.setHours(d.date.getHours()),o.setMinutes(d.date.getMinutes()),o.setSeconds(d.date.getSeconds()),o.setMilliseconds(d.date.getMilliseconds()))),angular.isDefined(a)&&(d.date=a),o=d.date,k.$setViewValue(d.date),k.$render(),q&&"time"!=d.showPicker&&(d.enableTime?d.showPicker="time":(d.isOpen=!1,i[0].focus()))},i.bind("input change keyup",function(){d.$apply(function(){d.date=k.$modelValue})}),k.$render=function(){var a=k.$viewValue?n(k.$viewValue):null,b=a?f(a,p):"";i.val(b),d.date=a};var v=function(a){d.isOpen&&a.target!==i[0]&&d.$apply(function(){d.isOpen=!1})},w=function(a){d.keydown(a)};i.bind("keydown",w),d.keydown=function(a){27===a.which?(a.preventDefault(),d.isOpen&&a.stopPropagation(),d.close()):40!==a.which||d.isOpen||(d.isOpen=!0)},d.$watch("isOpen",function(a){a?(d.$broadcast("datepicker.focus"),d.position=r?e.offset(i):e.position(i),d.position.top=d.position.top+i.prop("offsetHeight"),c.bind("mousedown",v)):c.unbind("mousedown",v)}),d.isTodayDisabled=function(){return m(new Date)},d.select=function(a){if("today"===a||"now"==a){var b=new Date;angular.isDate(k.$modelValue)?(a=new Date(k.$modelValue),a.setFullYear(b.getFullYear(),b.getMonth(),b.getDate()),a.setHours(b.getHours(),b.getMinutes(),b.getSeconds(),b.getMilliseconds())):a=b}d.dateSelection(a)},d.close=function(){d.isOpen=!1,i[0].focus()},d.changePicker=function(a){d.showPicker=a};var x=a(s)(d);s.remove(),r?c.find("body").append(x):i.after(x),d.$on("$destroy",function(){x.remove(),i.unbind("keydown",w),c.unbind("mousedown",v)})}}}]).directive("datePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/datetime-picker.html",link:function(a,b){b.bind("mousedown",function(a){a.preventDefault(),a.stopPropagation()})}}}).directive("timePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/datetime-picker.html",link:function(a,b){b.bind("mousedown",function(a){a.preventDefault(),a.stopPropagation()})}}}),angular.module("ui.bootstrap.datetimepicker").run(["$templateCache",function(a){"use strict";a.put("template/datetime-picker.html","")}]); \ No newline at end of file +// Version: 1.1.3 +// Released: 2015-07-08 +angular.module("ui.bootstrap.datetimepicker",["ui.bootstrap.dateparser","ui.bootstrap.position"]).constant("uiDatetimePickerConfig",{dateFormat:"yyyy-MM-dd HH:mm",enableDate:!0,enableTime:!0,todayText:"Today",nowText:"Now",clearText:"Clear",closeText:"Done",dateText:"Date",timeText:"Time",closeOnDateSelection:!0,appendToBody:!1,showButtonBar:!0}).directive("datetimePicker",["$compile","$parse","$document","$timeout","$position","dateFilter","dateParser","uiDatetimePickerConfig",function(a,b,c,d,e,f,g,h){return{restrict:"A",require:"ngModel",scope:{isOpen:"=?",enableDate:"=?",enableTime:"=?",todayText:"@",nowText:"@",dateText:"@",timeText:"@",clearText:"@",closeText:"@",dateDisabled:"&"},link:function(d,i,j,k){function l(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function m(a){return j.dateDisabled&&angular.isDefined(a)&&d.dateDisabled({date:a,mode:d.watchData.datepickerMode})}function n(a){if(a){if(angular.isDate(a)&&!isNaN(a))return k.$setValidity("date",!0),a;if(angular.isString(a)){var b=g.parse(a,p)||new Date(a);return isNaN(b)?void k.$setValidity("date",!1):(k.$setValidity("date",!0),b)}return void k.$setValidity("date",!1)}return k.$setValidity("date",!0),null}var o,p=h.dateFormat,q=angular.isDefined(j.closeOnDateSelection)?d.$parent.$eval(j.closeOnDateSelection):h.closeOnDateSelection,r=angular.isDefined(j.datepickerAppendToBody)?d.$parent.$eval(j.datepickerAppendToBody):h.appendToBody;d.showButtonBar=angular.isDefined(j.showButtonBar)?d.$parent.$eval(j.showButtonBar):h.showButtonBar,d.enableDate=angular.isDefined(d.enableDate)?d.enableDate:h.enableDate,d.enableTime=angular.isDefined(d.enableTime)?d.enableTime:h.enableTime,d.showPicker=d.enableDate?"date":"time",d.getText=function(a){return d[a+"Text"]||h[a+"Text"]},j.$observe("datetimePicker",function(a){p=a||h.dateFormat,k.$render()});var s=angular.element('
');s.attr({"ng-model":"date","ng-change":"dateSelection()"});var t=angular.element(s.children()[0]);j.datepickerOptions&&angular.forEach(d.$parent.$eval(j.datepickerOptions),function(a,b){t.attr(l(b),a)});var u=angular.element(s.children()[1]);j.timepickerOptions&&angular.forEach(d.$parent.$eval(j.timepickerOptions),function(a,b){u.attr(l(b),a)}),j.datepickerMode||(j.datepickerMode="day"),d.watchData={},angular.forEach(["minDate","maxDate","datepickerMode"],function(a){if(j[a]){var c=b(j[a]);if(d.$parent.$watch(c,function(b){d.watchData[a]=b}),t.attr(l(a),"watchData."+a),"datepickerMode"===a){var e=c.assign;d.$watch("watchData."+a,function(a,b){a!==b&&e(d.$parent,a)})}}}),j.dateDisabled&&t.attr("date-disabled","dateDisabled({ date: date, mode: mode })"),k.$parsers.unshift(n),d.dateSelection=function(a){d.enableDate&&d.enableTime&&"time"===d.showPicker&&o&&null!==o&&(null!==d.date||a||null!=a)&&(a&&null!=a?(o.setHours(a.getHours()),o.setMinutes(a.getMinutes()),o.setSeconds(a.getSeconds()),o.setMilliseconds(a.getMilliseconds()),a=new Date(o)):(o.setHours(d.date.getHours()),o.setMinutes(d.date.getMinutes()),o.setSeconds(d.date.getSeconds()),o.setMilliseconds(d.date.getMilliseconds()))),angular.isDefined(a)&&(d.date=a),o=d.date,k.$setViewValue(d.date),k.$render(),q&&"time"!=d.showPicker&&(d.enableTime?d.showPicker="time":(d.isOpen=!1,i[0].focus()))},i.bind("input change keyup",function(){d.$apply(function(){d.date=k.$modelValue})}),k.$render=function(){var a=k.$viewValue?n(k.$viewValue):null,b=a?f(a,p):"";i.val(b),d.date=a};var v=function(a){d.isOpen&&a.target!==i[0]&&d.$apply(function(){d.isOpen=!1})},w=function(a){d.keydown(a)};i.bind("keydown",w),d.keydown=function(a){27===a.which?(a.preventDefault(),d.isOpen&&a.stopPropagation(),d.close()):40!==a.which||d.isOpen||(d.isOpen=!0)},d.$watch("isOpen",function(a){a?(d.$broadcast("datepicker.focus"),d.position=r?e.offset(i):e.position(i),d.position.top=d.position.top+i.prop("offsetHeight"),c.bind("mousedown",v)):c.unbind("mousedown",v)}),d.isTodayDisabled=function(){return m(new Date)},d.select=function(a){if("today"===a||"now"==a){var b=new Date;angular.isDate(k.$modelValue)?(a=new Date(k.$modelValue),a.setFullYear(b.getFullYear(),b.getMonth(),b.getDate()),a.setHours(b.getHours(),b.getMinutes(),b.getSeconds(),b.getMilliseconds())):a=b}d.dateSelection(a)},d.close=function(){d.isOpen=!1,i[0].focus()},d.changePicker=function(a){d.showPicker=a};var x=a(s)(d);s.remove(),r?c.find("body").append(x):i.after(x),d.$on("$destroy",function(){x.remove(),i.unbind("keydown",w),c.unbind("mousedown",v)})}}}]).directive("datePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/datetime-picker.html",link:function(a,b){b.bind("mousedown",function(a){a.preventDefault(),a.stopPropagation()})}}}).directive("timePickerWrap",function(){return{restrict:"EA",replace:!0,transclude:!0,templateUrl:"template/datetime-picker.html",link:function(a,b){b.bind("mousedown",function(a){a.preventDefault(),a.stopPropagation()})}}}),angular.module("ui.bootstrap.datetimepicker").run(["$templateCache",function(a){"use strict";a.put("template/datetime-picker.html","")}]); \ No newline at end of file diff --git a/package.json b/package.json index 5223d1a..47b62a7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "bootstrap-ui-datetime-picker", "url": "https://github.com/Gillardo/bootstrap-ui-datetime-picker", - "version": "1.1.2", + "version": "1.1.3", "devDependencies": { "grunt": "^0.4.5", "grunt-angular-templates": "^0.5.7",