Skip to content

Commit

Permalink
Merge pull request #1901 from steffendietz/keepEmptyValues_followup
Browse files Browse the repository at this point in the history
keepEmptyValues followup
  • Loading branch information
acrobat committed May 25, 2016
2 parents d7ac9b1 + 23bfd6c commit 07cc339
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
17 changes: 9 additions & 8 deletions docs/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,6 @@ Boolean. Default: false
If true, selecting a year or month in the datepicker will update the input value immediately. Otherwise, only selecting a day of the month will update the input value immediately.


keepEmptyValues
---------------

Boolean. Default: false

Only effective in a range picker. If true, the selected value does not get propagated to other, currently empty, pickers in the range.


inputs
------

Expand All @@ -313,6 +305,14 @@ A list of inputs to be used in a range picker, which will be attached to the sel
});


keepEmptyValues
---------------

Boolean. Default: false

Only effective in a range picker. If true, the selected value does not get propagated to other, currently empty, pickers in the range.


keyboardNavigation
------------------

Expand Down Expand Up @@ -519,6 +519,7 @@ assumeNearbyYear false
format 'mm/dd/yyyy'
immediateUpdates false
inputs
keepEmptyValues false
keyboardNavigation true
language 'en'
maxViewMode 4 'centuries'
Expand Down
3 changes: 2 additions & 1 deletion js/bootstrap-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@
});
delete options.inputs;

this.keepEmptyValues = options.keepEmptyValues || false;
this.keepEmptyValues = options.keepEmptyValues;
delete options.keepEmptyValues;

datepickerPlugin.call($(this.inputs), options)
Expand Down Expand Up @@ -1755,6 +1755,7 @@
endDate: Infinity,
forceParse: true,
format: 'mm/dd/yyyy',
keepEmptyValues: false,
keyboardNavigation: true,
language: 'en',
minViewMode: 0,
Expand Down
26 changes: 16 additions & 10 deletions tests/suites/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1515,29 +1515,35 @@ test('date cells', function(){

test('keepEmptyValues: none (default is false)', function() {
var proxy_element = $('<div />').appendTo('#qunit-fixture'),
input_from = $('<input />').appendTo('#qunit-fixture'),
input_from = $('<input />').val('2016-04-01').appendTo('#qunit-fixture'),
input_to = $('<input />').appendTo('#qunit-fixture'),
dp = proxy_element.datepicker({
format: 'yyyy-mm-dd',
inputs: [input_from, input_to]
});
}),
input_from_dp = input_from.data('datepicker');

input_from.val('2012-03-05');
input_from.datepicker('setValue');
input_from.focus();
input_from_dp.picker.find('.old.day').eq(0).click();

equal(input_to.val(), input_from.val(), 'Input_from value should be distributed.');
equal(input_from.val(), '2016-03-27');
equal(input_to.val(), '2016-03-27', 'Input_from value should be distributed.');
});

test('keepEmptyValues: true', function() {
var proxy_element = $('<div />').appendTo('#qunit-fixture'),
input_from = $('<input />').appendTo('#qunit-fixture'),
input_from = $('<input />').val('2016-04-01').appendTo('#qunit-fixture'),
input_to = $('<input />').appendTo('#qunit-fixture'),
dp = proxy_element.datepicker({
format: 'yyyy-mm-dd',
inputs: [input_from, input_to],
keepEmptyValues: true
});
}),
input_from_dp = input_from.data('datepicker');

input_from.val('2012-03-05');
input_from.datepicker('setValue');
input_from.focus();
input_from_dp.picker.find('.old.day').eq(0).click();

equal(input_to.val(), '', 'Input_from value should NOT be distributed.');
equal(input_from.val(), '2016-03-27');
equal(input_to.val(), '', 'Input_from value should not be distributed.');
});

0 comments on commit 07cc339

Please sign in to comment.