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
# Conflicts:
#	tests/unit/editors/datePicker/tests.html
  • Loading branch information
bazal4o authored and ViktorSlavov committed Mar 8, 2018
1 parent 11472fd commit f159ec8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 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
26 changes: 25 additions & 1 deletion tests/unit/editors/datePicker/datePicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ QUnit.module("igDatePicker unit tests", {
spinDownButton: function() {
return this.editor.igDatePicker("spinDownButton");
},
beforeEach: function () { $.fx.off = true; },
beforeEach: function () {
$.fx.off = true;
if($.ig.util.regional){
$.ig.util.changeGlobalRegional('');
}
},
afterEach: function () { $.fx.off = false; }
});

Expand Down Expand Up @@ -1165,4 +1170,23 @@ QUnit.test('Change month / year event should pass values accoridngly', function(
done();
throw er;
});
});

QUnit.test('Calendar should fallback to locale settings, if no region is specified.', function (assert) {
var holder = "" + $.ig.util.regional, $editor, $currentDate;
if($.ig.util && $.ig.util.regional !== "ja"){
$.ig.util.changeGlobalRegional("ja");
}
assert.expect(1);
$editor = this.appendToFixture(this.inputTag).igDatePicker({
value: new Date("2018-03-04T00:00:00.000Z"),
dataMode: "date",
});
console.log( $.ig.util.regional );
$editor.igDatePicker("dropDownButton").click();
$currentDate = $editor.igDatePicker("getCalendar").find(".ui-datepicker-header > .ui-datepicker-title").text();
console.log($editor.igDatePicker("getCalendar").find(".ui-datepicker-header > .ui-datepicker-title").text());
console.log($editor.igDatePicker("getCalendar").find(".ui-datepicker-header > .ui-datepicker-title").text(), "2018年 3月");
assert.ok($currentDate == "2018年 3月", "Date value should be in Japanese");

});

0 comments on commit f159ec8

Please sign in to comment.