[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/tinymce/plugins/tabfocus/ -> plugin.js (source)

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


Generated : Thu Dec 26 08:20:01 2024 Cross-referenced by PHPXref