Skip to content

Commit 93d856c

Browse files
committed
Version 2.1.30
Important! build.less file name has been been changed to bootstrap-datetimepicker-build.less to prevent collisions Fix for Eonasdan#135: setStartDate and setEndDate should now properly set. Fix for Eonasdan#133: Typed in date now respects en/disabled dates Fix for Eonasdan#132: En/disable picker function works again Fix for Eonasdan#117, Eonasdan#119, Eonasdan#128, Eonasdan#121: double event change event issues should be fixed Fix for Eonasdan#112: change function no longer sets the input to a blank value if the passed in date is invalid Enhancement for Eonasdan#103: Increated the z-index of the widget
1 parent da354a5 commit 93d856c

8 files changed

+34
-29
lines changed

build/css/bootstrap-datetimepicker.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
width: 250px;
1616
padding: 4px;
1717
margin-top: 1px;
18-
z-index: 9999;
18+
z-index: 99999;
1919
border-radius: 4px;
2020
/*.dow {
2121
border-top: 1px solid #ddd !important;

build/css/bootstrap-datetimepicker.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/js/bootstrap-datetimepicker.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-datetimepicker",
3-
"version": "2.1.20",
3+
"version": "2.1.30",
44
"main": ["build/css/bootstrap-datetimepicker.min.css","build/js/bootstrap-datetimepicker.min.js"],
55
"dependencies": {
66
"jquery" : ">=1.8.3",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-datetimepicker",
3-
"version": "2.1.20",
3+
"version": "2.1.30",
44
"repository": {
55
"type": "git",
66
"url": "git://github.com/eonasdan/bootstrap-datetimepicker.git"

src/js/bootstrap-datetimepicker.js

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* version 2.1.20
2+
* version 2.1.30
33
* @license
44
* =========================================================
55
* bootstrap-datetimepicker.js
@@ -67,7 +67,8 @@
6767
disabledDates: [],
6868
enabledDates: false,
6969
icons: {},
70-
useStrict: false
70+
useStrict: false,
71+
direction: "auto"
7172
},
7273

7374
icons = {
@@ -225,8 +226,14 @@
225226
offset = picker.component ? picker.component.offset() : picker.element.offset(), $window = $(window);
226227
picker.width = picker.component ? picker.component.outerWidth() : picker.element.outerWidth();
227228
offset.top = offset.top + picker.element.outerHeight();
228-
229-
//if (offset.top + picker.widget.height() > $window.height()) offset.top = offset.top - (picker.widget.height() + picker.height + 10);
229+
230+
// if (picker.options.direction === 'up' || picker.options.direction === 'auto' && offset.top + picker.widget.height() > $window.height()) {
231+
// offset.top -= picker.widget.height() + picker.element.outerHeight();
232+
// picker.widget.addClass('up');
233+
// } else if (picker.options.direction === 'down' || picker.options.direction === 'auto' && offset.top + picker.widget.height() <= $window.height()) {
234+
// offset.top += picker.element.outerHeight();
235+
// picker.widget.addClass('down');
236+
// }
230237

231238
if (picker.options.width !== undefined) {
232239
picker.widget.width(picker.options.width);
@@ -365,7 +372,7 @@
365372
if (prevMonth.isSame(pMoment({ y: picker.date.year(), M: picker.date.month(), d: picker.date.date() }))) {
366373
clsName += ' active';
367374
}
368-
if ((pMoment(prevMonth).add(1, "d") <= picker.options.startDate) || (prevMonth > picker.options.endDate) || isInDisableDates(prevMonth) || !isInEnableDates(prevMonth)) {
375+
if (isInDisableDates(prevMonth) || !isInEnableDates(prevMonth)) {
369376
clsName += ' disabled';
370377
}
371378
row.append('<td class="day' + clsName + '">' + prevMonth.date() + '</td>');
@@ -652,20 +659,20 @@
652659

653660
change = function (e) {
654661
pMoment.lang(picker.options.language);
655-
var input = $(e.target), oldDate = pMoment(picker.date), d = pMoment(input.val(), picker.format, picker.options.useStrict);
656-
if (d.isValid()) {
662+
var input = $(e.target), oldDate = pMoment(picker.date), newDate = pMoment(input.val(), picker.format, picker.options.useStrict);
663+
if (newDate.isValid() && !isInDisableDates(newDate) && isInEnableDates(newDate)) {
657664
update();
658-
picker.setValue(d);
665+
picker.setValue(newDate);
659666
notifyChange(oldDate, e.type);
660667
set();
661668
}
662669
else {
663670
picker.viewDate = oldDate;
671+
input.val(pMoment(oldDate).format(picker.format));
664672
//picker.setValue(""); // unset the date when the input is erased
665673
notifyChange(oldDate, e.type);
666-
notifyError(d);
674+
notifyError(newDate);
667675
picker.unset = true;
668-
input.val('');
669676
}
670677
},
671678

@@ -801,7 +808,7 @@
801808
else {
802809
newDate = pMoment(picker.date).subtract(amount, unit);
803810
}
804-
if (newDate.isAfter(picker.options.endDate) || pMoment(newDate.subtract(amount, unit)).isBefore(picker.options.startDate) || isInDisableDates(newDate)) {
811+
if (isInDisableDates(pMoment(newDate.subtract(amount, unit))) || isInDisableDates(newDate)) {
805812
notifyError(newDate.format(picker.format));
806813
return;
807814
}
@@ -812,10 +819,12 @@
812819
else {
813820
picker.date.subtract(amount, unit);
814821
}
822+
picker.unset = false;
815823
},
816824

817825
isInDisableDates = function (date) {
818826
pMoment.lang(picker.options.language);
827+
if (date.isAfter(picker.options.endDate) || date.isBefore(picker.options.startDate)) return true;
819828
var disabled = picker.options.disabledDates, i;
820829
for (i in disabled) {
821830
if (disabled[i] == pMoment(date).format("L")) {
@@ -985,7 +994,7 @@
985994

986995
picker.disable = function () {
987996
var input = picker.element.find('input');
988-
if(!input.prop('disabled')) return;
997+
if(input.prop('disabled')) return;
989998

990999
input.prop('disabled', true);
9911000
detachDatePickerEvents();
@@ -995,7 +1004,7 @@
9951004
var input = picker.element.find('input');
9961005
if(!input.prop('disabled')) return;
9971006

998-
input.prop('disabled', true);
1007+
input.prop('disabled', false);
9991008
attachDatePickerEvents();
10001009
},
10011010

@@ -1057,18 +1066,14 @@
10571066
},
10581067

10591068
picker.setEndDate = function (date) {
1069+
if (date == undefined) return;
10601070
picker.options.endDate = pMoment(date);
1061-
if (!picker.options.endDate.isValid()) {
1062-
picker.options.endDate = pMoment().add(50, "y");
1063-
}
10641071
if (picker.viewDate) update();
10651072
},
10661073

10671074
picker.setStartDate = function (date) {
1075+
if (date == undefined) return;
10681076
picker.options.startDate = pMoment(date);
1069-
if (!picker.options.startDate.isValid()) {
1070-
picker.options.startDate = pMoment({ y: 1970 });
1071-
}
10721077
if (picker.viewDate) update();
10731078
};
10741079

@@ -1081,4 +1086,4 @@
10811086
if (!data) $this.data('DateTimePicker', new DateTimePicker(this, options));
10821087
});
10831088
};
1084-
}));
1089+
}));
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import boostrap variables including default color palette and fonts
2-
@import "../../bootstrap/less/variables";
2+
@import "../bootstrap/variables.less";
33

44
// Import datepicker component
5-
@import "bootstrap-datetimepicker";
5+
@import "bootstrap-datetimepicker.less";

src/less/bootstrap-datetimepicker.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
width: 250px;
1414
padding: 4px;
1515
margin-top: 1px;
16-
z-index: 9999;
16+
z-index: 99999;
1717
border-radius: 4px;
1818

1919
.btn {

0 commit comments

Comments
 (0)