fit-ui 2.11.2 → 2.11.3

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: 11, Patch: 2 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 2, Minor: 11, Patch: 3 } // 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
 
@@ -13476,6 +13476,14 @@ Fit.Controls.WSContextMenu = function(controlId)
13476
13476
  init();
13477
13477
  }
13478
13478
 
13479
+
13480
+
13481
+
13482
+
13483
+
13484
+
13485
+
13486
+
13479
13487
  /// <container name="Fit.Controls.DatePicker" extends="Fit.Controls.ControlBase">
13480
13488
  /// DatePicker control allowing user to easily pick a date and optionally time.
13481
13489
  /// On mobile devices (phones and tablets) the native date and time pickers are used.
@@ -13514,7 +13522,7 @@ Fit.Controls.DatePicker = function(ctlId)
13514
13522
  var detectBoundaries = false; // Flag indicating whether calendar widget should detect viewport collision and open upwards when needed
13515
13523
  var detectBoundariesRelToViewPort = false; // Flag indicating whether calendar widget should be positioned relative to viewport (true) or scroll parent (false)
13516
13524
 
13517
- var isMobile = Fit.Browser.GetInfo().IsMobile;
13525
+ var isMobile = Fit.Browser.GetInfo().IsMobile || (Fit.Browser.GetInfo().IsTouchEnabled && Fit.Browser.GetInfo().Name === "Safari"); // More recent versions of Safari on iPad identifies as a Mac computer by default ("Request desktop website" is enabled by default)
13518
13526
  var inputMobile = null; // Native date picker on mobile devices - value selected is synchronized to input field defined above (remains Null on desktop devices)
13519
13527
  var inputTimeMobile = null; // Native time picker on mobile devices - value selected is synchronized to inputTime field defined above (remains Null on desktop devices)
13520
13528
 
@@ -13611,7 +13619,6 @@ Fit.Controls.DatePicker = function(ctlId)
13611
13619
  // Prevent OnFocus from firing when user interacts with calendar widget which
13612
13620
  // is not contained in div.FitUiControlDatePicker (changing month/year and selecting date).
13613
13621
  // Focus is returned to input almost immediately after interacting with calendar widget.
13614
- // TODO/TBD: Use FocusStateLocked instead? See https://github.com/Jemt/Fit.UI/issues/103
13615
13622
  // - Also see FireOnBlur override further down.
13616
13623
  me._internal.FireOnFocus = Fit.Core.CreateOverride(me._internal.FireOnFocus, function()
13617
13624
  {
@@ -13625,15 +13632,19 @@ Fit.Controls.DatePicker = function(ctlId)
13625
13632
  // Prevent OnBlur from firing when user interacts with calendar widget which
13626
13633
  // is not contained in div.FitUiControlDatePicker (changing month/year).
13627
13634
  // Focus is returned to input almost immediately after interacting with calendar widget.
13628
- // TODO/TBD: Use FocusStateLocked instead? See https://github.com/Jemt/Fit.UI/issues/103
13629
13635
  // - Also see FireOnFocus override above.
13630
13636
  me._internal.FireOnBlur = Fit.Core.CreateOverride(me._internal.FireOnBlur, function()
13631
13637
  {
13632
- if (open === false)
13638
+ var pointerState = Fit.Events.GetPointerState();
13639
+ var userAction = pointerState.Buttons.Primary === true || pointerState.Buttons.Touch === true;
13640
+
13641
+ if (open === true && userAction === true) // Skipping invocation of OnBlur event when user interacts with calendar widget
13633
13642
  {
13634
- focused = false;
13635
- base();
13643
+ return;
13636
13644
  }
13645
+
13646
+ focused = false;
13647
+ base();
13637
13648
  });
13638
13649
 
13639
13650
  input.onblur = function()
@@ -13679,6 +13690,11 @@ Fit.Controls.DatePicker = function(ctlId)
13679
13690
  inputTime.value = "00:00";
13680
13691
  prevTimeVal = "00:00";
13681
13692
  }
13693
+
13694
+ if (open === true) // Calendar might be left open if focus is "stolen" from control, e.g. using document.activeElement.blur(), or using datePicker.Focused(false)
13695
+ {
13696
+ me.Hide();
13697
+ }
13682
13698
  });
13683
13699
 
13684
13700
  me._internal.AddDomElement(input);
@@ -13716,24 +13732,19 @@ Fit.Controls.DatePicker = function(ctlId)
13716
13732
  {
13717
13733
  Fit.Validation.ExpectBoolean(focus, true);
13718
13734
 
13719
- var inp = ((inputMobile === null) ? input : inputMobile);
13720
-
13721
13735
  if (Fit.Validation.IsSet(focus) === true)
13722
13736
  {
13723
- if (focus === true)
13737
+ if (focus === true && me.Focused() === false)
13724
13738
  {
13725
- inp.focus();
13739
+ ((inputMobile === null) ? input : inputMobile).focus();
13726
13740
  }
13727
- else
13741
+ else if (focus === false && me.Focused() === true)
13728
13742
  {
13729
- inp.blur();
13730
-
13731
- if (isMobile === false) // Prevent infinite loop - Hide() calls Focused(false) on mobile
13732
- me.Hide();
13743
+ Fit.Dom.GetFocused().blur();
13733
13744
  }
13734
13745
  }
13735
13746
 
13736
- return Fit.Dom.GetFocused() === inp;
13747
+ return Fit.Array.Contains([input, inputTime, inputMobile, inputTimeMobile], Fit.Dom.GetFocused()) === true;
13737
13748
  }
13738
13749
 
13739
13750
  /// <function container="Fit.Controls.DatePicker" name="Value" access="public" returns="string">
@@ -14619,6 +14630,21 @@ Fit.Controls.DatePicker = function(ctlId)
14619
14630
  // the value manually and pressed ESC to close the calendar.
14620
14631
  // Calendar widget returns focus if closed using ESC key.
14621
14632
  input.onblur();
14633
+
14634
+ // Calendar remains open if control lose focus while year or month picker is open (has focus).
14635
+ // In this case OnBlur does not fire for the control since elements within the calendar
14636
+ // widget is not part of the control (it lives in the root of the document), and therefore
14637
+ // does not inherit the automatic invocation of OnBlur and OnFocus.
14638
+ // This is unlikely to happen since it would require focus to programmatically be changed
14639
+ // while user is interacting with the year or month pickers. But if it does happen, we make
14640
+ // sure to fire OnBlur when the calendar widget closes, which happens when the user interacts
14641
+ // with something else on the page.
14642
+ // If the user decides to return focus to the control, it will not cause OnFocus to fire again,
14643
+ // without firing OnBlur in-between, thanks to the 'focused' flag.
14644
+ if (focused === true && Fit.Dom.GetFocused() !== input)
14645
+ {
14646
+ me._internal.FireOnBlur();
14647
+ }
14622
14648
  }
14623
14649
  });
14624
14650