fit-ui 2.16.4 → 2.16.6

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/Fit.UI.js CHANGED
@@ -682,7 +682,7 @@ Fit._internal =
682
682
  {
683
683
  Core:
684
684
  {
685
- VersionInfo: { Major: 2, Minor: 16, Patch: 4 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 2, Minor: 16, Patch: 6 } // 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
 
@@ -14034,6 +14034,7 @@ Fit.Controls.DatePicker = function(ctlId)
14034
14034
  var weeks = false; // Whether to display week numbers or not
14035
14035
  var jquery = undefined; // jQuery instance
14036
14036
  var datepicker = null; // jQuery UI calendar widget
14037
+ var datepickerElm = null; // jQuery UI calendar widget element (remains null until shown for the first time - element shared among all DatePicker instances)
14037
14038
  var startDate = null; // Which year/month to display in calendar widget if view needs to be restored (related to restoreView variable)
14038
14039
  var open = false; // Whether calendar widget is currently open
14039
14040
  var focused = false; // Whether control is currently focused
@@ -14287,7 +14288,7 @@ Fit.Controls.DatePicker = function(ctlId)
14287
14288
  if (hasFocus === false && isMobile === false)
14288
14289
  {
14289
14290
  // Make sure Focused() returns true while interacting with calendar widget - https://github.com/Jemt/Fit.UI/issues/194
14290
- var calendarWidget = document.getElementById("fitui-datepicker-div"); // Null if not loaded yet
14291
+ var calendarWidget = datepickerElm; // Null if not loaded yet
14291
14292
  hasFocus = calendarWidget !== null && calendarWidget.style.display === "block" && calendarWidget._associatedFitUiControl === me.GetId();
14292
14293
  }
14293
14294
 
@@ -14502,7 +14503,7 @@ Fit.Controls.DatePicker = function(ctlId)
14502
14503
 
14503
14504
  Fit.Internationalization.RemoveOnLocaleChanged(localize);
14504
14505
 
14505
- me = input = inputTime = orgVal = preVal = prevTimeVal = locale = localeEnforced = format = formatEnforced = placeholderDate = placeholderTime = weeks = jquery = datepicker = startDate = open = focused = restoreView = updateCalConf = detectBoundaries = detectBoundariesRelToViewPort = isMobile = inputMobile = inputTimeMobile = null;
14506
+ me = input = inputTime = orgVal = preVal = prevTimeVal = locale = localeEnforced = format = formatEnforced = placeholderDate = placeholderTime = weeks = jquery = datepicker = datepickerElm = startDate = open = focused = restoreView = updateCalConf = detectBoundaries = detectBoundariesRelToViewPort = isMobile = inputMobile = inputTimeMobile = null;
14506
14507
  base();
14507
14508
  });
14508
14509
 
@@ -14940,7 +14941,7 @@ Fit.Controls.DatePicker = function(ctlId)
14940
14941
 
14941
14942
  datepicker.datepicker("show"); // Fails if not visible (part of render tree)
14942
14943
 
14943
- var calendarWidget = document.getElementById("fitui-datepicker-div");
14944
+ var calendarWidget = datepickerElm;
14944
14945
  calendarWidget._associatedFitUiControl = me.GetId();
14945
14946
 
14946
14947
  // Allow light dismissable panels/callouts to prevent close/dismiss
@@ -15107,6 +15108,8 @@ Fit.Controls.DatePicker = function(ctlId)
15107
15108
  },
15108
15109
  beforeShow: function(elm, dp)
15109
15110
  {
15111
+ datepickerElm = dp.dpDiv[0] || null;
15112
+
15110
15113
  // Load locale if not already loaded
15111
15114
 
15112
15115
  if (datepicker.jq.datepicker.regional[locale] === null)
@@ -15226,7 +15229,7 @@ Fit.Controls.DatePicker = function(ctlId)
15226
15229
 
15227
15230
  function moveCalenderWidgetLocally()
15228
15231
  {
15229
- if (Fit._internal.ControlBase.ReduceDocumentRootPollution !== true)
15232
+ if (me._internal.ReduceDocumentRootPollution !== true && Fit._internal.ControlBase.ReduceDocumentRootPollution !== true)
15230
15233
  {
15231
15234
  return;
15232
15235
  }
@@ -15241,7 +15244,7 @@ Fit.Controls.DatePicker = function(ctlId)
15241
15244
  // For more details see https://github.com/Jemt/Fit.UI/issues/116
15242
15245
 
15243
15246
  var selfDom = me.GetDomElement();
15244
- var calendarWidget = document.getElementById("fitui-datepicker-div");
15247
+ var calendarWidget = datepickerElm;
15245
15248
 
15246
15249
  Fit.Dom.InsertAfter(selfDom, calendarWidget);
15247
15250
 
@@ -15306,12 +15309,12 @@ Fit.Controls.DatePicker = function(ctlId)
15306
15309
 
15307
15310
  function moveCalenderWidgetGlobally() // Undo everything done in moveCalenderWidgetLocally()
15308
15311
  {
15309
- if (Fit._internal.ControlBase.ReduceDocumentRootPollution !== true)
15312
+ if (me._internal.ReduceDocumentRootPollution !== true && Fit._internal.ControlBase.ReduceDocumentRootPollution !== true)
15310
15313
  {
15311
15314
  return;
15312
15315
  }
15313
15316
 
15314
- var calendarWidget = document.getElementById("fitui-datepicker-div");
15317
+ var calendarWidget = datepickerElm;
15315
15318
  Fit.Dom.Add(document.body, calendarWidget);
15316
15319
 
15317
15320
  calendarWidget.style.position = ""; // "absolute"
@@ -17329,6 +17332,7 @@ Fit.Controls.DropDown = function(ctlId)
17329
17332
  var searchModeOnFocus = false; // Flag indicating whether control goes into search mode when it is focused (search mode clears input field and displays "search.." placeholder)
17330
17333
  var onScrollElement = null; // Holds control's scroll parent when drop down is open
17331
17334
  var onScrollEventId = -1; // Holds ID of OnScroll event handler registered when drop down is open
17335
+ var cancelEventRegistrationOnOpen = null; // Holds function reference which cancels event registration if no longer needed (related to onScrollElement and onScrollEventId)
17332
17336
 
17333
17337
  var onInputChangedHandlers = []; // Invoked when input value is changed - takes two arguments (sender (this), text value)
17334
17338
  var onPasteHandlers = []; // Invoked when a value is pasted - takes two arguments (sender (this), text value)
@@ -17535,30 +17539,37 @@ Fit.Controls.DropDown = function(ctlId)
17535
17539
 
17536
17540
  me.OnOpen(function()
17537
17541
  {
17538
- postpone(function() // Postpone to avoid auto closing drop down if browser scrolls control into view when it receives focus
17542
+ cancelEventRegistrationOnOpen = postpone(function() // Postpone to avoid auto closing drop down if browser scrolls control into view when it receives focus
17539
17543
  {
17540
- if (me.IsDropDownOpen() === true) // Might have been closed while waiting
17541
- {
17542
- onScrollElement = Fit.Dom.GetScrollParent(me.GetDomElement());
17544
+ cancelEventRegistrationOnOpen = null;
17543
17545
 
17544
- if (onScrollElement === document.documentElement)
17545
- {
17546
- onScrollElement = window;
17547
- }
17546
+ onScrollElement = Fit.Dom.GetScrollParent(me.GetDomElement());
17548
17547
 
17549
- if (onScrollElement !== null)
17548
+ if (onScrollElement === document.documentElement)
17549
+ {
17550
+ onScrollElement = window;
17551
+ }
17552
+
17553
+ if (onScrollElement !== null)
17554
+ {
17555
+ onScrollEventId = Fit.Events.AddHandler(onScrollElement, "scroll", function(e)
17550
17556
  {
17551
- onScrollEventId = Fit.Events.AddHandler(onScrollElement, "scroll", function(e)
17552
- {
17553
- me.CloseDropDown();
17554
- });
17555
- }
17557
+ me.CloseDropDown();
17558
+ });
17556
17559
  }
17557
17560
  });
17558
17561
  });
17559
17562
 
17560
17563
  me.OnClose(function()
17561
17564
  {
17565
+ // Cancel postponed operation in case dropdown is opened and closed multiple times to
17566
+ // avoid multiple OnScroll event registrations (https://github.com/Jemt/Fit.UI/issues/195).
17567
+ if (cancelEventRegistrationOnOpen !== null)
17568
+ {
17569
+ cancelEventRegistrationOnOpen();
17570
+ cancelEventRegistrationOnOpen = null;
17571
+ }
17572
+
17562
17573
  if (onScrollElement !== null)
17563
17574
  {
17564
17575
  Fit.Events.RemoveHandler(onScrollElement, onScrollEventId);
@@ -17897,7 +17908,7 @@ Fit.Controls.DropDown = function(ctlId)
17897
17908
  Fit.Events.RemoveHandler(onScrollElement, onScrollEventId);
17898
17909
  }
17899
17910
 
17900
- me = itemContainer = itemCollection = itemDropZones = arrow = txtPrimary = txtActive = txtEnabled = dropDownMenu = picker = orgSelections = invalidMessage = invalidMessageChanged = initialFocus = maxHeight = prevValue = focusAssigned = closeHandlers = dropZone = isMobile = focusInputOnMobile = detectBoundaries = detectBoundariesRelToViewPort = persistView = highlightFirst = searchModeOnFocus = onScrollElement = onScrollEventId = onInputChangedHandlers = onPasteHandlers = onOpenHandlers = onCloseHandlers = suppressUpdateItemSelectionState = suppressOnItemSelectionChanged = clearTextSelectionOnInputChange = prevTextSelection = textSelectionCallback = cmdToggleTextMode = null;
17911
+ me = itemContainer = itemCollection = itemDropZones = arrow = txtPrimary = txtActive = txtEnabled = dropDownMenu = picker = orgSelections = invalidMessage = invalidMessageChanged = initialFocus = maxHeight = prevValue = focusAssigned = closeHandlers = dropZone = isMobile = focusInputOnMobile = detectBoundaries = detectBoundariesRelToViewPort = persistView = highlightFirst = searchModeOnFocus = onScrollElement = onScrollEventId = cancelEventRegistrationOnOpen = onInputChangedHandlers = onPasteHandlers = onOpenHandlers = onCloseHandlers = suppressUpdateItemSelectionState = suppressOnItemSelectionChanged = clearTextSelectionOnInputChange = prevTextSelection = textSelectionCallback = cmdToggleTextMode = null;
17901
17912
 
17902
17913
  base();
17903
17914
  });
@@ -20338,13 +20349,15 @@ Fit.Controls.DropDown = function(ctlId)
20338
20349
  Fit.Validation.ExpectFunction(cb);
20339
20350
  Fit.Validation.ExpectInteger(timeout, true)
20340
20351
 
20341
- setTimeout(function()
20352
+ var toId = setTimeout(function()
20342
20353
  {
20343
20354
  if (me !== null) // Make sure control has not been disposed
20344
20355
  {
20345
20356
  cb();
20346
20357
  }
20347
20358
  }, timeout || 0);
20359
+
20360
+ return function() { clearTimeout(toId); };
20348
20361
  }
20349
20362
 
20350
20363
  init();