fit-ui 2.19.2 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Documentation.html +1 -1
- package/dist/Fit.UI.js +146 -34
- package/dist/Fit.UI.min.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +7 -0
package/dist/Fit.UI.js
CHANGED
|
@@ -682,7 +682,7 @@ Fit._internal =
|
|
|
682
682
|
{
|
|
683
683
|
Core:
|
|
684
684
|
{
|
|
685
|
-
VersionInfo: { Major: 2, Minor:
|
|
685
|
+
VersionInfo: { Major: 2, Minor: 20, Patch: 0 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
|
|
686
686
|
}
|
|
687
687
|
};
|
|
688
688
|
|
|
@@ -14061,26 +14061,28 @@ Fit.Controls.DatePicker = function(ctlId)
|
|
|
14061
14061
|
Fit.Core.Extend(this, Fit.Controls.ControlBase).Apply(ctlId);
|
|
14062
14062
|
|
|
14063
14063
|
var me = this;
|
|
14064
|
-
var input = null;
|
|
14065
|
-
var inputTime = null;
|
|
14066
|
-
var orgVal = null;
|
|
14067
|
-
var preVal = "";
|
|
14068
|
-
var prevTimeVal = "";
|
|
14069
|
-
var locale = "en";
|
|
14070
|
-
var localeEnforced = false;
|
|
14071
|
-
var format = "MM/DD/YYYY";
|
|
14072
|
-
var formatEnforced = false;
|
|
14073
|
-
var placeholderDate = null;
|
|
14074
|
-
var placeholderTime = null;
|
|
14075
|
-
var weeks = false;
|
|
14076
|
-
var jquery = undefined;
|
|
14077
|
-
var datepicker = null;
|
|
14078
|
-
var datepickerElm = null;
|
|
14079
|
-
var
|
|
14080
|
-
var
|
|
14081
|
-
var
|
|
14082
|
-
var
|
|
14083
|
-
var
|
|
14064
|
+
var input = null; // Input field for date
|
|
14065
|
+
var inputTime = null; // Input field for time (Null if not enabled)
|
|
14066
|
+
var orgVal = null; // Date object containing control value set using Value(..) or Date(..) - used to determine Dirty state (holds both date and time portion)
|
|
14067
|
+
var preVal = ""; // Previous valid date value as string (without time portion)
|
|
14068
|
+
var prevTimeVal = ""; // Previous valid time value as string (without date portion)
|
|
14069
|
+
var locale = "en"; // Default ("", "en", and "en-US" is the same) - see this.regional[""] decleration in jquery-ui.js
|
|
14070
|
+
var localeEnforced = false; // Whether locale was set by external code which takes precedence over locale set using Fit.Internationalization.Locale(..)
|
|
14071
|
+
var format = "MM/DD/YYYY"; // Default format for "en" locale (specified using Fit.UI format - jQuery UI DataPicker uses "mm/dd/yy" - see this.regional[""] decleration in jquery-ui.js)
|
|
14072
|
+
var formatEnforced = false; // Whether format was set by external code which takes precedence over locale set using DatePicker.Locale(..) and Fit.Internationalization.Locale(..)
|
|
14073
|
+
var placeholderDate = null; // Placeholder value for date
|
|
14074
|
+
var placeholderTime = null; // Placeholder value for time
|
|
14075
|
+
var weeks = false; // Whether to display week numbers or not
|
|
14076
|
+
var jquery = undefined; // jQuery instance
|
|
14077
|
+
var datepicker = null; // jQuery UI calendar widget
|
|
14078
|
+
var datepickerElm = null; // jQuery UI calendar widget element (remains null until shown for the first time - element shared among all DatePicker instances)
|
|
14079
|
+
var datePickerYears = "c-10:c+10"; // Calendar widget's year range (from current year, going 10 years back and 10 years forward)
|
|
14080
|
+
var datepickerDate = null; // Which date to display in the calendar widget when no date is selected - null or Date
|
|
14081
|
+
var startDate = null; // Which year/month to display in calendar widget if view needs to be restored (related to restoreView variable)
|
|
14082
|
+
var open = false; // Whether calendar widget is currently open
|
|
14083
|
+
var focused = false; // Whether control is currently focused
|
|
14084
|
+
var restoreView = false; // Whether to keep calendar widget on given year/month when temporarily closing and opening it again
|
|
14085
|
+
var updateCalConf = true; // Whether to set/update calendar widget settings - true on initial load
|
|
14084
14086
|
var detectBoundaries = false; // Flag indicating whether calendar widget should detect viewport collision and open upwards when needed
|
|
14085
14087
|
var detectBoundariesRelToViewPort = false; // Flag indicating whether calendar widget should be positioned relative to viewport (true) or scroll parent (false)
|
|
14086
14088
|
|
|
@@ -14280,6 +14282,14 @@ Fit.Controls.DatePicker = function(ctlId)
|
|
|
14280
14282
|
input.onchange();
|
|
14281
14283
|
}
|
|
14282
14284
|
|
|
14285
|
+
me.OnChange(function(sender)
|
|
14286
|
+
{
|
|
14287
|
+
if (me.Value() === "") // Value reset
|
|
14288
|
+
{
|
|
14289
|
+
selectDateInMobileDatePicker(datepickerDate);
|
|
14290
|
+
}
|
|
14291
|
+
});
|
|
14292
|
+
|
|
14283
14293
|
if (Fit.Device.HasMouse === true)
|
|
14284
14294
|
{
|
|
14285
14295
|
// This might be an iPad with a pen (precision pointer) attached, or a PC/laptop with a touch screen
|
|
@@ -14336,6 +14346,61 @@ Fit.Controls.DatePicker = function(ctlId)
|
|
|
14336
14346
|
return hasFocus;
|
|
14337
14347
|
}
|
|
14338
14348
|
|
|
14349
|
+
/// <function container="Fit.Controls.DatePicker" name="CalendarStartDate" access="public" returns="Date | null">
|
|
14350
|
+
/// <description>
|
|
14351
|
+
/// Get/set calendar start date - this date is used when control has no value
|
|
14352
|
+
/// </description>
|
|
14353
|
+
/// <param name="val" type="Date | null" default="undefined">
|
|
14354
|
+
/// If defined, provided date will serve as start date for calendar view
|
|
14355
|
+
/// </param>
|
|
14356
|
+
/// </function>
|
|
14357
|
+
this.CalendarStartDate = function(val)
|
|
14358
|
+
{
|
|
14359
|
+
Fit.Validation.ExpectDate(val, true);
|
|
14360
|
+
|
|
14361
|
+
if (val !== undefined && val !== datepickerDate)
|
|
14362
|
+
{
|
|
14363
|
+
datepickerDate = val; // Used to select date in calendar widget, unless a specific date is selected in control
|
|
14364
|
+
|
|
14365
|
+
var applyDate = val || new Date();
|
|
14366
|
+
|
|
14367
|
+
if (isMobile === false)
|
|
14368
|
+
{
|
|
14369
|
+
var yearToday = (new Date()).getFullYear();
|
|
14370
|
+
var yearsApart = Math.abs(yearToday - applyDate.getFullYear());
|
|
14371
|
+
var yearRange = yearsApart < 10 ? 10 : yearsApart;
|
|
14372
|
+
|
|
14373
|
+
// A range of years relative to the current year (e.g. c-20:c+20) will continueusly adjust to the year selected
|
|
14374
|
+
// by the user, while a fixed range (e.g. 2000:2040) will not allow the user to select 2040 to extend the list further.
|
|
14375
|
+
// So, what happens when we apply the date 2040-08-01, is that we first expand the year range 2040-2024 = 16 years
|
|
14376
|
+
// (assuming current year is 2024). Once the picker is opened, 2040 will programmatically be selected in the year picker,
|
|
14377
|
+
// and the calendar widget will automatically adjust the list of years relative to the newly selected year, which is from
|
|
14378
|
+
// 2040-16=2024 to 2040+16=2056.
|
|
14379
|
+
|
|
14380
|
+
datePickerYears = "c-" + (yearRange) + ":c+" + (yearRange);
|
|
14381
|
+
|
|
14382
|
+
// If currently open, close and reopen to update calendar widget
|
|
14383
|
+
|
|
14384
|
+
if (open === true)
|
|
14385
|
+
{
|
|
14386
|
+
updateCalConf = true;
|
|
14387
|
+
|
|
14388
|
+
me.Hide();
|
|
14389
|
+
me.Show();
|
|
14390
|
+
}
|
|
14391
|
+
}
|
|
14392
|
+
else
|
|
14393
|
+
{
|
|
14394
|
+
if (me.Value() === "")
|
|
14395
|
+
{
|
|
14396
|
+
selectDateInMobileDatePicker(applyDate);
|
|
14397
|
+
}
|
|
14398
|
+
}
|
|
14399
|
+
}
|
|
14400
|
+
|
|
14401
|
+
return datepickerDate;
|
|
14402
|
+
}
|
|
14403
|
+
|
|
14339
14404
|
/// <function container="Fit.Controls.DatePicker" name="Value" access="public" returns="string">
|
|
14340
14405
|
/// <description>
|
|
14341
14406
|
/// Get/set control value in the following format: YYYY-MM-DD[ hh:mm]
|
|
@@ -15195,22 +15260,28 @@ Fit.Controls.DatePicker = function(ctlId)
|
|
|
15195
15260
|
datepicker.datepicker("option", datepicker.jq.datepicker.regional[locale]);
|
|
15196
15261
|
datepicker.datepicker("option", "dateFormat", getJqueryUiDatePickerFormat(me.Format()));
|
|
15197
15262
|
datepicker.datepicker("option", "showWeek", weeks);
|
|
15263
|
+
datepicker.datepicker("option", "yearRange", datePickerYears);
|
|
15198
15264
|
}
|
|
15199
15265
|
|
|
15200
|
-
if (
|
|
15266
|
+
if (me.Value() === "" && datepickerDate !== null) // Apply initial year and month selection
|
|
15201
15267
|
{
|
|
15202
|
-
setTimeout(function()
|
|
15268
|
+
setTimeout(function() // Postpone - selectYearMonthInCalendarWidget(..) requires calendar widget to be mounted in DOM
|
|
15203
15269
|
{
|
|
15204
|
-
var year = Fit.Date.Format(
|
|
15205
|
-
var month = Fit.Date.Format(
|
|
15270
|
+
var year = parseInt(Fit.Date.Format(datepickerDate, "YYYY"), 10);
|
|
15271
|
+
var month = parseInt(Fit.Date.Format(datepickerDate, "M"), 10);
|
|
15272
|
+
|
|
15273
|
+
selectYearMonthInCalendarWidget(year, month);
|
|
15274
|
+
}, 0);
|
|
15275
|
+
}
|
|
15206
15276
|
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15277
|
+
if (startDate !== null && restoreView === true) // Restore year and month the user previously navigated to
|
|
15278
|
+
{
|
|
15279
|
+
setTimeout(function() // Postpone - selectYearMonthInCalendarWidget(..) requires calendar widget to be mounted in DOM
|
|
15280
|
+
{
|
|
15281
|
+
var year = parseInt(Fit.Date.Format(startDate, "YYYY"), 10);
|
|
15282
|
+
var month = parseInt(Fit.Date.Format(startDate, "M"), 10);
|
|
15210
15283
|
|
|
15211
|
-
|
|
15212
|
-
monthPicker.value = (parseInt(month) - 1).toString();
|
|
15213
|
-
datepicker.jq(monthPicker).trigger("change");
|
|
15284
|
+
selectYearMonthInCalendarWidget(year, month);
|
|
15214
15285
|
}, 0);
|
|
15215
15286
|
}
|
|
15216
15287
|
|
|
@@ -15386,6 +15457,43 @@ Fit.Controls.DatePicker = function(ctlId)
|
|
|
15386
15457
|
return null;
|
|
15387
15458
|
}
|
|
15388
15459
|
|
|
15460
|
+
function selectYearMonthInCalendarWidget(year, month)
|
|
15461
|
+
{
|
|
15462
|
+
Fit.Validation.ExpectInteger(year);
|
|
15463
|
+
Fit.Validation.ExpectInteger(month);
|
|
15464
|
+
|
|
15465
|
+
var yearPicker = document.querySelector("select.fitui-datepicker-year");
|
|
15466
|
+
yearPicker.value = year.toString();
|
|
15467
|
+
datepicker.jq(yearPicker).trigger("change");
|
|
15468
|
+
|
|
15469
|
+
var monthPicker = document.querySelector("select.fitui-datepicker-month");
|
|
15470
|
+
monthPicker.value = (month - 1).toString();
|
|
15471
|
+
datepicker.jq(monthPicker).trigger("change");
|
|
15472
|
+
}
|
|
15473
|
+
|
|
15474
|
+
function selectDateInMobileDatePicker(date)
|
|
15475
|
+
{
|
|
15476
|
+
Fit.Validation.ExpectDate(date);
|
|
15477
|
+
|
|
15478
|
+
// Fix necessary to apply new value while open/focused on iPadOS - otherwise
|
|
15479
|
+
// value will not take effect until after picker has lost focus and regained
|
|
15480
|
+
// focus. This will also make picker reopen on newer versions of iPhoneOS and
|
|
15481
|
+
// iPadOS, but not on Android.
|
|
15482
|
+
var focusFix = Fit.Dom.GetFocused() === inputMobile;
|
|
15483
|
+
|
|
15484
|
+
if (focusFix)
|
|
15485
|
+
{
|
|
15486
|
+
input.focus();
|
|
15487
|
+
}
|
|
15488
|
+
|
|
15489
|
+
inputMobile.valueAsDate = date;
|
|
15490
|
+
|
|
15491
|
+
if (focusFix)
|
|
15492
|
+
{
|
|
15493
|
+
inputMobile.focus();
|
|
15494
|
+
}
|
|
15495
|
+
}
|
|
15496
|
+
|
|
15389
15497
|
function getLocales()
|
|
15390
15498
|
{
|
|
15391
15499
|
// List of locales was generated this way:
|
|
@@ -29287,7 +29395,7 @@ Fit.Controls.SoftLog = function(controlId)
|
|
|
29287
29395
|
{
|
|
29288
29396
|
me.Log(arg.toString());
|
|
29289
29397
|
}
|
|
29290
|
-
else if (arg === null || arg === undefined)
|
|
29398
|
+
else if (arg === null || arg === undefined || arg instanceof Date)
|
|
29291
29399
|
{
|
|
29292
29400
|
me.Log(arg + "");
|
|
29293
29401
|
}
|
|
@@ -29378,8 +29486,12 @@ Fit.Controls.SoftLog = function(controlId)
|
|
|
29378
29486
|
trimLog(true);
|
|
29379
29487
|
|
|
29380
29488
|
txt.value += (txt.value !== "" ? "\n" : "") + time + ": " + msg.replace(/\r/g, "").replace(/\n/g, " ");
|
|
29381
|
-
|
|
29382
|
-
|
|
29489
|
+
|
|
29490
|
+
if (Fit.Dom.GetFocused() !== txt)
|
|
29491
|
+
{
|
|
29492
|
+
txt.scrollLeft = 0;
|
|
29493
|
+
txt.scrollTop = 999999;
|
|
29494
|
+
}
|
|
29383
29495
|
}
|
|
29384
29496
|
|
|
29385
29497
|
/// <function container="Fit.Controls.SoftLog" name="Clear" access="public">
|