vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.0.0 vs vendor/assets/javascripts/bootstrap-datetimepicker.js in bootstrap3-datetimepicker-rails-3.0.0.1

- old
+ new

@@ -193,14 +193,12 @@ update(); showMode(); attachDatePickerEvents(); if (picker.options.defaultDate !== "" && getPickerInput().val() == "") picker.setValue(picker.options.defaultDate); if (picker.options.minuteStepping !== 1) { - var rMinutes = picker.date.minutes(); var rInterval = picker.options.minuteStepping; - picker.date.minutes((Math.round(rMinutes / rInterval) * rInterval) % 60) - .seconds(0); + picker.date.minutes((Math.round(picker.date.minutes() / rInterval) * rInterval) % 60).seconds(0); } }, getPickerInput = function () { if (picker.isInput) { @@ -363,10 +361,11 @@ month = picker.viewDate.month(), startYear = picker.options.minDate.year(), startMonth = picker.options.minDate.month(), endYear = picker.options.maxDate.year(), endMonth = picker.options.maxDate.month(), + currentDate, prevMonth, nextMonth, html = [], row, clsName, i, days, yearCont, currentYear, months = pMoment.months(); picker.widget.find('.datepicker-days').find('.disabled').removeClass('disabled'); picker.widget.find('.datepicker-months').find('.disabled').removeClass('disabled'); picker.widget.find('.datepicker-years').find('.disabled').removeClass('disabled'); @@ -414,11 +413,17 @@ break; } } } row.append('<td class="day' + clsName + '">' + prevMonth.date() + '</td>'); + + currentDate = prevMonth.date(); prevMonth.add(1, "d"); + + if (currentDate == prevMonth.date()) { + prevMonth.add(1, "d"); + } } picker.widget.find('.datepicker-days tbody').empty().append(html); currentYear = picker.date.year(), months = picker.widget.find('.datepicker-months') .find('th:eq(1)').text(year).end().find('span').removeClass('active'); if (currentYear === year) { @@ -487,11 +492,11 @@ }, fillMinutes = function () { var table = picker.widget.find('.timepicker .timepicker-minutes table'), html = '', current = 0, i, j, step = picker.options.minuteStepping; table.parent().hide(); - if (step = 1) step = 5; + if (step == 1) step = 5; for (i = 0; i < Math.ceil(60 / step / 4) ; i++) { html += '<tr>'; for (j = 0; j < 4; j += 1) { if (current < 60) { html += '<td class="minute">' + padLeft(current.toString()) + '</td>'; @@ -1035,16 +1040,31 @@ if (picker.component) picker.component.removeData('DateTimePicker'); }; picker.show = function (e) { - if (picker.options.useCurrent === true) { + if (picker.options.useCurrent) { if (getPickerInput().val() == '') { - picker.setValue(pMoment().format(picker.format)) + if (picker.options.minuteStepping !== 1) { + var mDate = pMoment(), + rInterval = picker.options.minuteStepping; + mDate.minutes((Math.round(mDate.minutes() / rInterval) * rInterval) % 60) + .seconds(0); + picker.setValue(mDate.format(picker.format)) + } else { + picker.setValue(pMoment().format(picker.format)) + } }; } - picker.widget.show(); + if (picker.widget.hasClass("picker-open")) { + picker.widget.hide(); + picker.widget.removeClass("picker-open"); + } + else { + picker.widget.show(); + picker.widget.addClass("picker-open"); + } picker.height = picker.component ? picker.component.outerHeight() : picker.element.outerHeight(); place(); picker.element.trigger({ type: 'dp.show', date: pMoment(picker.date) @@ -1097,10 +1117,10 @@ picker.unset = true; set(); } else { picker.unset = false; } - if (!pMoment.isMoment(newDate)) newDate = pMoment(newDate); + if (!pMoment.isMoment(newDate)) newDate = pMoment(newDate, picker.format); if (newDate.isValid()) { picker.date = newDate; set(); picker.viewDate = pMoment({ y: picker.date.year(), M: picker.date.month() }); fillDate();