[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/tinymce/plugins/tabfocus/ -> plugin.js (source)

   1  /**
   2   * Copyright (c) Tiny Technologies, Inc. All rights reserved.
   3   * Licensed under the LGPL or a commercial license.
   4   * For LGPL see License.txt in the project root for license information.
   5   * For commercial licenses see https://www.tiny.cloud/
   6   *
   7   * Version: 5.10.5 (2022-05-25)
   8   */
   9  (function () {
  10      'use strict';
  11  
  12      var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
  13  
  14      var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
  15  
  16      var global$4 = tinymce.util.Tools.resolve('tinymce.EditorManager');
  17  
  18      var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
  19  
  20      var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
  21  
  22      var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
  23  
  24      var global = tinymce.util.Tools.resolve('tinymce.util.VK');
  25  
  26      var getTabFocusElements = function (editor) {
  27        return editor.getParam('tabfocus_elements', ':prev,:next');
  28      };
  29      var getTabFocus = function (editor) {
  30        return editor.getParam('tab_focus', getTabFocusElements(editor));
  31      };
  32  
  33      var DOM = global$5.DOM;
  34      var tabCancel = function (e) {
  35        if (e.keyCode === global.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) {
  36          e.preventDefault();
  37        }
  38      };
  39      var setup = function (editor) {
  40        var tabHandler = function (e) {
  41          var x;
  42          if (e.keyCode !== global.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
  43            return;
  44          }
  45          var find = function (direction) {
  46            var el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
  47            var canSelectRecursive = function (e) {
  48              var castElem = e;
  49              return e.nodeName === 'BODY' || castElem.type !== 'hidden' && castElem.style.display !== 'none' && castElem.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode);
  50            };
  51            var canSelect = function (el) {
  52              return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$4.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el);
  53            };
  54            global$1.each(el, function (e, i) {
  55              if (e.id === editor.id) {
  56                x = i;
  57                return false;
  58              }
  59            });
  60            if (direction > 0) {
  61              for (var i = x + 1; i < el.length; i++) {
  62                if (canSelect(el[i])) {
  63                  return el[i];
  64                }
  65              }
  66            } else {
  67              for (var i = x - 1; i >= 0; i--) {
  68                if (canSelect(el[i])) {
  69                  return el[i];
  70                }
  71              }
  72            }
  73            return null;
  74          };
  75          var v = global$1.explode(getTabFocus(editor));
  76          if (v.length === 1) {
  77            v[1] = v[0];
  78            v[0] = ':prev';
  79          }
  80          var el;
  81          if (e.shiftKey) {
  82            if (v[0] === ':prev') {
  83              el = find(-1);
  84            } else {
  85              el = DOM.get(v[0]);
  86            }
  87          } else {
  88            if (v[1] === ':next') {
  89              el = find(1);
  90            } else {
  91              el = DOM.get(v[1]);
  92            }
  93          }
  94          if (el) {
  95            var focusEditor = global$4.get(el.id || el.name);
  96            if (el.id && focusEditor) {
  97              focusEditor.focus();
  98            } else {
  99              global$2.setTimeout(function () {
 100                if (!global$3.webkit) {
 101                  window.focus();
 102                }
 103                el.focus();
 104              }, 10);
 105            }
 106            e.preventDefault();
 107          }
 108        };
 109        editor.on('init', function () {
 110          if (editor.inline) {
 111            DOM.setAttrib(editor.getBody(), 'tabIndex', null);
 112          }
 113          editor.on('keyup', tabCancel);
 114          if (global$3.gecko) {
 115            editor.on('keypress keydown', tabHandler);
 116          } else {
 117            editor.on('keydown', tabHandler);
 118          }
 119        });
 120      };
 121  
 122      function Plugin () {
 123        global$6.add('tabfocus', function (editor) {
 124          setup(editor);
 125        });
 126      }
 127  
 128      Plugin();
 129  
 130  }());


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer