fit-ui 3.4.2 → 3.4.4

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: 4, Patch: 2 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 3, Minor: 4, Patch: 4 } // 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
 
@@ -14746,12 +14746,14 @@ Fit.Controls.DatePicker = function(ctlId)
14746
14746
 
14747
14747
  if (Fit.Validation.IsSet(val) === true)
14748
14748
  {
14749
- localeEnforced = true;
14750
- setLocale(val);
14751
-
14752
- if (selectWeek === true)
14749
+ if (setLocale(val) === true)
14753
14750
  {
14754
- selectFirstDayOfWeek(middleOfWeek);
14751
+ localeEnforced = true;
14752
+
14753
+ if (selectWeek === true)
14754
+ {
14755
+ selectFirstDayOfWeek(middleOfWeek);
14756
+ }
14755
14757
  }
14756
14758
  }
14757
14759
 
@@ -15908,7 +15910,10 @@ Fit.Controls.DatePicker = function(ctlId)
15908
15910
  var loc = getJqueryDateFormatFromLocale(val); // Null if locale does not exist
15909
15911
 
15910
15912
  if (loc === null)
15911
- Fit.Validation.ThrowError("Unknown locale '" + val + "'");
15913
+ {
15914
+ console.warn("Unknown locale '" + val + "'");
15915
+ return false;
15916
+ }
15912
15917
 
15913
15918
  var newFormat = loc.format;
15914
15919
 
@@ -15933,6 +15938,8 @@ Fit.Controls.DatePicker = function(ctlId)
15933
15938
  me.Show();
15934
15939
  restoreView = false;
15935
15940
  }
15941
+
15942
+ return true;
15936
15943
  }
15937
15944
 
15938
15945
  function setFormat(val)
@@ -16020,7 +16027,7 @@ Fit.Controls.DatePicker = function(ctlId)
16020
16027
 
16021
16028
  // Update locale
16022
16029
 
16023
- // Make sure locale exists - otherwise setLocale throws an error
16030
+ // Make sure locale exists - otherwise setLocale emits a warning
16024
16031
  if (Fit.Array.Contains(Fit.Array.GetKeys(getLocales()), key) === true)
16025
16032
  {
16026
16033
  setLocale(key);
@@ -26930,76 +26937,47 @@ Fit.Controls.Input = function(ctlId)
26930
26937
  }
26931
26938
  }
26932
26939
 
26933
- // Register necessary events with emoji panel when opened
26934
-
26935
- var emojiButton = designEditor.container.$.querySelector("a.cke_button__emojipanel");
26940
+ // Register necessary events with color panel when opened
26936
26941
 
26937
- if (emojiButton !== null) // Better safe than sorry
26942
+ Fit.Array.ForEach(designEditor.container.$.querySelectorAll("a.cke_button__textcolor, a.cke_button__bgcolor"), function(button)
26938
26943
  {
26939
- Fit.Events.AddHandler(emojiButton, "click", function(e)
26944
+ lockDesignEditorDialogButtonToFocusState(button, function() // Callback invoked to get panel associated with button
26940
26945
  {
26941
- // Make sure OnFocus fires before locking focus state
26942
-
26943
- if (me.Focused() === false)
26944
- {
26945
- // Control not focused - make sure OnFocus fires when emoji button is clicked,
26946
- // and make sure ControlBase internally considers itself focused, so there is
26947
- // no risk of OnFocus being fired twice without OnBlur firing in between,
26948
- // when focus state is unlocked, and focus is perhaps re-assigned to another
26949
- // DOM element within the control, which will be the case if the design editor
26950
- // is switched back to an ordinary input field (e.g. using DesignMode(false)).
26951
- me.Focused(true);
26952
- }
26953
-
26954
- // Prevent control from firing OnBlur when emoji dialog is opened.
26955
- // Notice that locking the focus state will also prevent OnFocus
26956
- // from being fired automatically.
26957
- me._internal.FocusStateLocked(true);
26946
+ var panel = null;
26958
26947
 
26959
- setTimeout(function() // Postpone - emoji panel is made visible after click event
26948
+ // Color panel has no color plugin identifier, so we need to inspect all panel iframes to look for a plugin identifier inside
26949
+ Fit.Array.ForEach(document.querySelectorAll("div.cke_panel > iframe"), function(iframe)
26960
26950
  {
26961
- // Allow light dismissable panels/callouts to prevent close/dismiss
26962
- // when interacting with emoji widget hosted outside of panels/callouts,
26963
- // by detecting the presence of a data-disable-light-dismiss="true" attribute.
26964
- var emojiPanel = document.querySelector("div.cke_emoji-panel"); // Shared among instances
26965
-
26966
- if (emojiPanel !== null) // Better safe than sorry
26951
+ if (iframe.contentDocument !== null) // Null if hosted on foreign domain
26967
26952
  {
26968
- Fit.Dom.Data(emojiPanel, "disable-light-dismiss", "true");
26969
-
26970
- emojiPanel._associatedFitUiControl = me;
26953
+ var colorBlock = iframe.contentDocument.querySelector("div.cke_colorblock");
26971
26954
 
26972
- designEditorActiveToolbarPanel =
26955
+ if (colorBlock !== null)
26973
26956
  {
26974
- DomElement: emojiPanel,
26975
- UnlockFocusStateIfEmojiPanelIsClosed: function() // Function called regularly via interval timer while emoji panel is open to make sure focus state is unlocked when emoji panel is closed, e.g. by pressing ESC, clicking outside of emoji panel, or by choosing an emoji
26976
- {
26977
- if (designModeEnabledAndReady() === false /* No longer in DesignMode */ || Fit.Dom.IsVisible(emojiPanel) === false /* Emoji panel closed */ || emojiPanel._associatedFitUiControl !== me /* Emoji panel now opened from another editor */)
26978
- {
26979
- designEditorActiveToolbarPanel = null;
26980
-
26981
- // Disable focus lock - let ControlBase handle OnFocus and OnBlur automatically again
26982
- me._internal.FocusStateLocked(false);
26983
-
26984
- // Fire OnBlur in case user changed focus while emoji panel was open.
26985
- // OnBlur does not fire automatically when focus state is locked.
26986
- if (me.Focused() === false)
26987
- {
26988
- me._internal.FireOnBlur();
26989
- }
26990
- }
26991
- },
26992
- CloseEmojiPanel: function()
26993
- {
26994
- if (emojiPanel._associatedFitUiControl === me && Fit.Dom.IsVisible(emojiPanel) === true && Fit.Dom.Contained(emojiPanel, Fit.Dom.GetFocused()) === true)
26995
- {
26996
- designEditor.focus();
26997
- designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed();
26998
- }
26999
- }
26957
+ // Color panel found. Panel is shared between instances and used for both the
26958
+ // text color and back color. We know parentElement exists because of the query selector.
26959
+ panel = iframe.parentElement;
26960
+ return false; // Break loop
27000
26961
  }
27001
26962
  }
26963
+ });
26964
+
26965
+ return panel;
26966
+ });
26967
+ });
27002
26968
 
26969
+ // Register necessary events with emoji panel when opened
26970
+
26971
+ var emojiButton = designEditor.container.$.querySelector("a.cke_button__emojipanel");
26972
+
26973
+ if (emojiButton !== null) // Button might not be enabled
26974
+ {
26975
+ lockDesignEditorDialogButtonToFocusState(emojiButton, function() // Callback invoked to get panel associated with button
26976
+ {
26977
+ var emojiPanel = document.querySelector("div.cke_emoji-panel"); // Shared among instances
26978
+
26979
+ if (emojiPanel !== null) // Better safe than sorry
26980
+ {
27003
26981
  // Hide status bar in emoji dialog
27004
26982
  var emojiFrame = emojiPanel.querySelector("iframe");
27005
26983
  var emojiContent = emojiFrame && emojiFrame.contentDocument;
@@ -27007,31 +26985,9 @@ Fit.Controls.Input = function(ctlId)
27007
26985
  var emojiContentStatus = emojiContent && emojiContent.querySelector(".cke_emoji-status_bar");
27008
26986
  emojiContentBlock && (emojiContentBlock.style.height = "220px");
27009
26987
  emojiContentStatus && (emojiContentStatus.style.display = "none");
26988
+ }
27010
26989
 
27011
- var checkClosedId = setInterval(function()
27012
- {
27013
- // Invoke cleanup function regularly to make sure
27014
- // focus lock is relased when emoji panel is closed,
27015
- // and to fire OnBlur if another control was focused
27016
- // while emoji panel was open.
27017
-
27018
- if (me === null)
27019
- {
27020
- clearInterval(checkClosedId);
27021
- return;
27022
- }
27023
-
27024
- if (designEditorActiveToolbarPanel !== null)
27025
- {
27026
- designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed(); // Nullfies designEditorActiveToolbarPanel if emoji panel is closed
27027
- }
27028
-
27029
- if (designEditorActiveToolbarPanel === null)
27030
- {
27031
- clearInterval(checkClosedId);
27032
- }
27033
- }, 250);
27034
- }, 0);
26990
+ return emojiPanel;
27035
26991
  });
27036
26992
  }
27037
26993
 
@@ -27500,7 +27456,105 @@ Fit.Controls.Input = function(ctlId)
27500
27456
 
27501
27457
  designEditorRestoreButtonState = null;
27502
27458
  }
27503
- };
27459
+ }
27460
+
27461
+ function lockDesignEditorDialogButtonToFocusState(button, getPanelCallback)
27462
+ {
27463
+ Fit.Validation.ExpectElement(button);
27464
+ Fit.Validation.ExpectFunction(getPanelCallback);
27465
+
27466
+ Fit.Events.AddHandler(button, "click", function(e)
27467
+ {
27468
+ // Make sure OnFocus fires before locking focus state
27469
+
27470
+ if (me.Focused() === false)
27471
+ {
27472
+ // Control not focused - make sure OnFocus fires when emoji button is clicked,
27473
+ // and make sure ControlBase internally considers itself focused, so there is
27474
+ // no risk of OnFocus being fired twice without OnBlur firing in between,
27475
+ // when focus state is unlocked, and focus is perhaps re-assigned to another
27476
+ // DOM element within the control, which will be the case if the design editor
27477
+ // is switched back to an ordinary input field (e.g. using DesignMode(false)).
27478
+ me.Focused(true);
27479
+ }
27480
+
27481
+ // Prevent control from firing OnBlur when emoji dialog is opened.
27482
+ // Notice that locking the focus state will also prevent OnFocus
27483
+ // from being fired automatically.
27484
+ me._internal.FocusStateLocked(true);
27485
+
27486
+ setTimeout(function() // Postpone - wait for dialog to be mounted in DOM
27487
+ {
27488
+ var panel = getPanelCallback(); // Panel is shared among instances
27489
+
27490
+ if (panel === null)
27491
+ {
27492
+ return;
27493
+ }
27494
+
27495
+ // Allow light dismissable panels/callouts to prevent close/dismiss
27496
+ // when interacting with emoji widget hosted outside of panels/callouts,
27497
+ // by detecting the presence of a data-disable-light-dismiss="true" attribute.
27498
+ Fit.Dom.Data(panel, "disable-light-dismiss", "true");
27499
+
27500
+ panel._associatedFitUiControl = me;
27501
+
27502
+ designEditorActiveToolbarPanel =
27503
+ {
27504
+ DomElement: panel,
27505
+ UnlockFocusStateIfEmojiPanelIsClosed: function() // Function called regularly via interval timer while emoji panel is open to make sure focus state is unlocked when emoji panel is closed, e.g. by pressing ESC, clicking outside of emoji panel, or by choosing an emoji
27506
+ {
27507
+ if (designModeEnabledAndReady() === false /* No longer in DesignMode */ || Fit.Dom.IsVisible(panel) === false /* Emoji panel closed */ || panel._associatedFitUiControl !== me /* Emoji panel now opened from another editor */)
27508
+ {
27509
+ designEditorActiveToolbarPanel = null;
27510
+
27511
+ // Disable focus lock - let ControlBase handle OnFocus and OnBlur automatically again
27512
+ me._internal.FocusStateLocked(false);
27513
+
27514
+ // Fire OnBlur in case user changed focus while emoji panel was open.
27515
+ // OnBlur does not fire automatically when focus state is locked.
27516
+ if (me.Focused() === false)
27517
+ {
27518
+ me._internal.FireOnBlur();
27519
+ }
27520
+ }
27521
+ },
27522
+ CloseEmojiPanel: function()
27523
+ {
27524
+ if (panel._associatedFitUiControl === me && Fit.Dom.IsVisible(panel) === true && Fit.Dom.Contained(panel, Fit.Dom.GetFocused()) === true)
27525
+ {
27526
+ designEditor.focus();
27527
+ designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed();
27528
+ }
27529
+ }
27530
+ };
27531
+
27532
+ var checkClosedId = setInterval(function()
27533
+ {
27534
+ // Invoke cleanup function regularly to make sure
27535
+ // focus lock is relased when emoji panel is closed,
27536
+ // and to fire OnBlur if another control was focused
27537
+ // while emoji panel was open.
27538
+
27539
+ if (me === null)
27540
+ {
27541
+ clearInterval(checkClosedId);
27542
+ return;
27543
+ }
27544
+
27545
+ if (designEditorActiveToolbarPanel !== null)
27546
+ {
27547
+ designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed(); // Nullfies designEditorActiveToolbarPanel if emoji panel is closed
27548
+ }
27549
+
27550
+ if (designEditorActiveToolbarPanel === null)
27551
+ {
27552
+ clearInterval(checkClosedId);
27553
+ }
27554
+ }, 250);
27555
+ }, 0);
27556
+ });
27557
+ }
27504
27558
 
27505
27559
  function updateDesignEditorSize()
27506
27560
  {