Skip to content

Commit

Permalink
Merge pull request #1643 from IgniteUI/VSlavov/1358-igDatePicker-regi…
Browse files Browse the repository at this point in the history
…onal-fallback-18.1

#1358 - igDatePicker regional fallback to global regional
  • Loading branch information
bazal4o authored Mar 8, 2018
2 parents 9379fd1 + 72a2657 commit d39d86c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/js/modules/infragistics.ui.editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11095,10 +11095,19 @@
this._attachButtonsEvents("dropdown", dropDownButton);
},
_dpRegion: function () {
var reg = this.options.regional, lastRegional, regional;
regional = ($.datepicker && typeof reg === "string") ?
$.datepicker.regional[ (reg === "defaults" || reg === "en-US") ? "" : reg ] :
null;
var reg = this.options.regional, lastRegional, regional = null, abbreviation = "";

//V.S. March 7th 2018 - #1358 if no regional option is provided and a global regional is set, uses the global one
if ($.datepicker && typeof reg === "string") {
if (reg === "defaults" || reg === "en-US") {
if (typeof $.ig.util.regional === "string" && $.ig.util.regional) {
abbreviation = $.ig.util.regional;
}
} else {
abbreviation = reg;
}
regional = $.datepicker.regional[ abbreviation ] || $.datepicker.regional[ "" ];
}
if (regional === null && $.datepicker) {
for (lastRegional in $.datepicker.regional) { }
if ($.datepicker.regional[ lastRegional ]) {
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/editors/datePicker/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,24 @@
},100);

});
//$.ig.util.regional
testId = 'Calendar should fallback to locale settings, if no region is specified.';
QUnit.test(testId, function (assert) {
assert.expect(1);
var holder = "" + $.ig.util.regional;
if($.ig.util && $.ig.util.regional != "ja"){
$.ig.util.changeGlobalRegional("ja");
}
var $editor, $currentDate;
$editor = $('<input id="datePickerLocale"/>').appendTo("#testBedContainer").igDatePicker({
value: new Date("2018-03-04T00:00:00.000Z"),
dataMode: "date",
});
$editor.igDatePicker("dropDownButton").click();
$currentDate = $editor.igDatePicker("getCalendar").find(".ui-datepicker-header > .ui-datepicker-title").text();
assert.ok($currentDate === "2018年 3月", "Test values are undefined by default.");
$.ig.util.changeGlobalRegional(holder);
});
});

function mouseInteraction(type, element) {
Expand Down

0 comments on commit d39d86c

Please sign in to comment.