fit-ui 3.2.10 → 3.2.12

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: 3, Minor: 2, Patch: 10 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 3, Minor: 2, Patch: 12 } // 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
 
@@ -11908,7 +11908,16 @@ Fit.Controls.Button = function(controlId)
11908
11908
  Fit.Events.AddHandler(element, Fit.Browser.IsTouchEnabled() === true ? "touchend" : "click", function(e)
11909
11909
  {
11910
11910
  if (invokeClick === true && me.Enabled() === true)
11911
+ {
11912
+ // On computers the button would have gained focus by now, before triggering the OnClick callback,
11913
+ // but not on touch devices, where the button receives focus after the OnTouchEnd event finishes.
11914
+ // To ensure consistent behaviour across devices, we force focus the button on touch devices so that
11915
+ // external code is able to determine focused state for the button, and return focus to the button later.
11916
+ // See https://github.com/Jemt/Fit.UI/issues/214 for details.
11917
+ me.Focused(true);
11918
+
11911
11919
  me.Click();
11920
+ }
11912
11921
 
11913
11922
  if (focusedBeforeClick !== null)
11914
11923
  {
@@ -14059,11 +14068,21 @@ Fit.Controls.DatePicker = function(ctlId)
14059
14068
  input.placeholder = getDatePlaceholder();
14060
14069
  input.tabIndex = ((isMobile === true) ? -1 : 0);
14061
14070
 
14062
- // Prevent jQuery UI from focusing input field when calendar is opened (brings up virtual keyboard on touch devices).
14071
+ // Prevent jQuery UI from focusing input field on touch devices when calendar is opened or when changing year/month (brings up virtual keyboard).
14063
14072
  // https://github.com/Jemt/Fit.UI/blob/5e8f2183d75ae17ddb8086ebbe39025a7a7c98bb/Resources/JqueryUI-1.11.4.custom/jquery-ui.js#L1090
14064
14073
  // => https://github.com/Jemt/Fit.UI/blob/5e8f2183d75ae17ddb8086ebbe39025a7a7c98bb/Resources/JqueryUI-1.11.4.custom/external/jquery/jquery.js#L5268
14065
14074
  input._focus = input.focus;
14066
- input.focus = function() { console.debug("focus() disabled for this input field"); };
14075
+ input.focus = function()
14076
+ {
14077
+ if (Fit.Device.OptimizeForTouch === true && me.TriggerIcon() === true)
14078
+ {
14079
+ icon.focus();
14080
+ }
14081
+ else
14082
+ {
14083
+ input._focus();
14084
+ }
14085
+ };
14067
14086
 
14068
14087
  input.onkeydown = function(e)
14069
14088
  {
@@ -14242,12 +14261,13 @@ Fit.Controls.DatePicker = function(ctlId)
14242
14261
 
14243
14262
  icon = document.createElement("span");
14244
14263
  icon.className = "fa fa-calendar";
14264
+ icon.style.outline = "none"; // Avoid outline when focused
14245
14265
  icon.tabIndex = -1;
14246
14266
  icon.onclick = function(e)
14247
14267
  {
14248
14268
  me.Show();
14249
14269
 
14250
- if (me.TriggerIcon() === false) // Focus input if icon is hidden
14270
+ if (me.TriggerIcon() === false) // Focus input if icon is hidden (using opacity:0)
14251
14271
  {
14252
14272
  input._focus();
14253
14273
  }
@@ -14330,7 +14350,7 @@ Fit.Controls.DatePicker = function(ctlId)
14330
14350
  }
14331
14351
  }
14332
14352
 
14333
- var hasFocus = Fit.Array.Contains([input, inputTime, inputMobile, inputTimeMobile], Fit.Dom.GetFocused()) === true;
14353
+ var hasFocus = Fit.Array.Contains([icon, input, inputTime, inputMobile, inputTimeMobile], Fit.Dom.GetFocused()) === true;
14334
14354
 
14335
14355
  if (hasFocus === false && isMobile === false)
14336
14356
  {
@@ -15287,16 +15307,18 @@ Fit.Controls.DatePicker = function(ctlId)
15287
15307
  {
15288
15308
  // Retain focus when changing month or year using calendar
15289
15309
  // widget, which causes its DOM to be removed and replaced.
15290
- // Focus is later returned to DatePicker, but not in time for
15310
+ // Focus is later returned to input field, but not in time for
15291
15311
  // OnFocusOut. Related issue: https://github.com/Jemt/Fit.UI/issues/194
15292
- if (Fit.Device.OptimizeForTouch === true && me.TriggerIcon() === true)
15312
+ // DISABLED: Logic moved to input.focus override.
15313
+ /*if (Fit.Device.OptimizeForTouch === true && me.TriggerIcon() === true)
15293
15314
  {
15294
15315
  icon.focus(); // Focusing icon to prevent virtual keyboard from being shown on touch devices
15295
15316
  }
15296
15317
  else
15297
15318
  {
15298
15319
  input._focus(); // Do not use Focused(true) as it will not re-focus input, since control is already considered focused
15299
- }
15320
+ }*/
15321
+ input.focus();
15300
15322
 
15301
15323
  if (open === true) // Remember which year and month the user navigated to
15302
15324
  {
@@ -15314,14 +15336,16 @@ Fit.Controls.DatePicker = function(ctlId)
15314
15336
  {
15315
15337
  startDate = null;
15316
15338
 
15317
- if (Fit.Device.OptimizeForTouch === true && me.TriggerIcon() === true)
15339
+ // DISABLED: Logic moved to input.focus override
15340
+ /*if (Fit.Device.OptimizeForTouch === true && me.TriggerIcon() === true)
15318
15341
  {
15319
15342
  icon.focus(); // Focusing icon to prevent virtual keyboard from being shown on touch devices
15320
15343
  }
15321
15344
  else
15322
15345
  {
15323
15346
  input._focus(); // Do not use Focused(true) as it will not re-focus input, since control is already considered focused
15324
- }
15347
+ }*/
15348
+ input.focus();
15325
15349
 
15326
15350
  input.onchange();
15327
15351
  },
@@ -16045,6 +16069,25 @@ Fit.Controls.Dialog = function(controlId)
16045
16069
  }
16046
16070
  }
16047
16071
  });
16072
+
16073
+ if (Fit.Browser.IsTouchEnabled() === true)
16074
+ {
16075
+ // Prevent invocation of OnMouseUp, OnMouseDown, and OnClick on elements behind the dialog
16076
+ // on touch devices, if the dialog is disposed during invocation of OnTouchStart or OnTouchEnd.
16077
+ // This will also prevent a UI control from receiving focus if positioned behind the dialog.
16078
+ // See https://github.com/Jemt/Fit.UI/issues/215 for more information.
16079
+
16080
+ var stopEventIfDialogIsDisposed = function(e)
16081
+ {
16082
+ if (me === null)
16083
+ {
16084
+ Fit.Events.PreventDefault(e); // Dialog was disposed as a result of event - halt event
16085
+ }
16086
+ };
16087
+
16088
+ Fit.Events.AddHandler(me.GetDomElement(), "touchstart", stopEventIfDialogIsDisposed);
16089
+ Fit.Events.AddHandler(me.GetDomElement(), "touchend", stopEventIfDialogIsDisposed);
16090
+ }
16048
16091
  }
16049
16092
 
16050
16093
  // ============================================