From 0184c64c5a004148895fd6b3be0f6ebd086de7f2 Mon Sep 17 00:00:00 2001 From: isaacws Date: Mon, 16 Feb 2015 14:48:56 -0600 Subject: [PATCH] Fixed IE8 Issues when textbox is empty and navigation buttons are clicked --- jquery.datetimepicker.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index 71d23e3..e299a15 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -791,6 +791,11 @@ event.preventDefault(); }) .on('mousedown.xdsoft', '.xdsoft_option', function (event) { + + if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) { + _xdsoft_datetime.currentTime = _xdsoft_datetime.now(); + } + var year = _xdsoft_datetime.currentTime.getFullYear(); if (_xdsoft_datetime && _xdsoft_datetime.currentTime) { _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value')); @@ -1110,6 +1115,11 @@ }; _this.nextMonth = function () { + + if (_this.currentTime === undefined || _this.currentTime === null) { + _this.currentTime = _this.now(); + } + var month = _this.currentTime.getMonth() + 1, year; if (month === 12) { @@ -1140,6 +1150,11 @@ }; _this.prevMonth = function () { + + if (_this.currentTime === undefined || _this.currentTime === null) { + _this.currentTime = _this.now(); + } + var month = _this.currentTime.getMonth() - 1; if (month === -1) { _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1); @@ -1238,7 +1253,7 @@ stop = false; (function arguments_callee1(v) { - var month = _xdsoft_datetime.currentTime.getMonth(); + //var month = _xdsoft_datetime.currentTime.getMonth(); if ($this.hasClass(options.next)) { _xdsoft_datetime.nextMonth(); } else if ($this.hasClass(options.prev)) { @@ -1294,7 +1309,12 @@ .on('xchange.xdsoft', function (event) { clearTimeout(xchangeTimer); xchangeTimer = setTimeout(function () { - var table = '', + + if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) { + _xdsoft_datetime.currentTime = _xdsoft_datetime.now(); + } + + var table = '', start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0), i = 0, j,