Skip to content

Commit 7585466

Browse files
author
User Jenkins
committed
Sync with Kendo UI Professional
1 parent 792fcd4 commit 7585466

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

src/kendo.datepicker.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,12 @@ var __meta__ = { // jshint ignore:line
541541

542542
that._old = that._update(value);
543543

544-
if (that._old === null && !that._dateInput) {
545-
that.element.val("");
544+
if (that._old === null) {
545+
if (that._dateInput) {
546+
that._dateInput.value(that._old);
547+
} else {
548+
that.element.val("");
549+
}
546550
}
547551

548552
that._oldText = that.element.val();

src/kendo.datetimepicker.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,11 @@ var __meta__ = { // jshint ignore:line
444444

445445
that._old = that._update(value);
446446
if (that._old === null) {
447-
that.element.val("");
447+
if (that._dateInput) {
448+
that._dateInput.value(that._old);
449+
} else {
450+
that.element.val("");
451+
}
448452
}
449453

450454
that._oldText = that.element.val();
@@ -624,8 +628,10 @@ var __meta__ = { // jshint ignore:line
624628
timeView.bind();
625629
}
626630
}
627-
if (that._dateInput && date) {
628-
that._dateInput.value(date || value);
631+
if (that._dateInput) {
632+
if (date) {
633+
that._dateInput.value(date);
634+
}
629635
} else {
630636
that.element.val(kendo.toString(date || value, options.format, options.culture));
631637
}

tests/datepicker/api.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ it("empty input if set value ot null", function() {
211211
assert.equal(datepicker._value, null);
212212
});
213213

214+
it("mask is shown if set value ot null", function() {
215+
datepicker = input.kendoDatePicker({ dateInput: true }).data("kendoDatePicker");
216+
217+
datepicker.value(null);
218+
219+
assert.isOk(input.val());
220+
assert.equal(input.val(), "month/day/year");
221+
assert.equal(datepicker._value, null);
222+
});
223+
214224
it("value method should call dateview.value()", function() {
215225
datepicker = input.kendoDatePicker().data("kendoDatePicker");
216226
stub(datepicker.dateView, "value");

tests/datetimepicker/api.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@
125125
assert.equal(+datetimepicker.value(), +value);
126126
});
127127

128+
it("value method should not clear DateInput format", function() {
129+
var datetimepicker = new DateTimePicker(input, {
130+
dateInput: true
131+
});
132+
datetimepicker.value(null);
133+
assert.isOk(datetimepicker.element.val());
134+
})
135+
136+
it("value method should not clear DateInput format if initial value was provided", function() {
137+
var datetimepicker = new DateTimePicker(input, {
138+
dateInput: true,
139+
value: new Date()
140+
});
141+
datetimepicker.value(null);
142+
assert.equal(datetimepicker.element.val(), "month/day/year hours:minutes AM/PM");
143+
assert.isOk(datetimepicker.element.val());
144+
})
145+
128146
it("value method sets null if date is out of range", function() {
129147
var datetimepicker = new DateTimePicker(input, {
130148
min: new Date(2000, 10, 10)

0 commit comments

Comments
 (0)