2017-05-08 01:32:46 -04:00
|
|
|
(function () {
|
2018-04-25 18:35:21 -04:00
|
|
|
var tabfocus = (function () {
|
|
|
|
'use strict';
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var getTabFocusElements = function (editor) {
|
|
|
|
return editor.getParam('tabfocus_elements', ':prev,:next');
|
|
|
|
};
|
|
|
|
var getTabFocus = function (editor) {
|
|
|
|
return editor.getParam('tab_focus', getTabFocusElements(editor));
|
|
|
|
};
|
2018-07-16 04:07:26 -04:00
|
|
|
var $_8rita4kwjjgwed4m = { getTabFocus: getTabFocus };
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
var DOM = global$1.DOM;
|
|
|
|
var tabCancel = function (e) {
|
|
|
|
if (e.keyCode === global$6.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
|
|
function tabHandler(e) {
|
|
|
|
var x, el, v, i;
|
|
|
|
if (e.keyCode !== global$6.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
|
|
|
|
return;
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
function find(direction) {
|
|
|
|
el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
|
|
|
|
function canSelectRecursive(e) {
|
|
|
|
return e.nodeName === 'BODY' || e.type !== 'hidden' && e.style.display !== 'none' && e.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode);
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
function canSelect(el) {
|
|
|
|
return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$2.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el);
|
|
|
|
}
|
|
|
|
global$5.each(el, function (e, i) {
|
|
|
|
if (e.id === editor.id) {
|
|
|
|
x = i;
|
|
|
|
return false;
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
});
|
|
|
|
if (direction > 0) {
|
|
|
|
for (i = x + 1; i < el.length; i++) {
|
|
|
|
if (canSelect(el[i])) {
|
|
|
|
return el[i];
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = x - 1; i >= 0; i--) {
|
|
|
|
if (canSelect(el[i])) {
|
|
|
|
return el[i];
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
return null;
|
|
|
|
}
|
2018-07-16 04:07:26 -04:00
|
|
|
v = global$5.explode($_8rita4kwjjgwed4m.getTabFocus(editor));
|
2018-04-25 18:35:21 -04:00
|
|
|
if (v.length === 1) {
|
|
|
|
v[1] = v[0];
|
|
|
|
v[0] = ':prev';
|
|
|
|
}
|
|
|
|
if (e.shiftKey) {
|
|
|
|
if (v[0] === ':prev') {
|
|
|
|
el = find(-1);
|
2017-05-08 01:32:46 -04:00
|
|
|
} else {
|
2018-04-25 18:35:21 -04:00
|
|
|
el = DOM.get(v[0]);
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
} else {
|
|
|
|
if (v[1] === ':next') {
|
|
|
|
el = find(1);
|
|
|
|
} else {
|
|
|
|
el = DOM.get(v[1]);
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
if (el) {
|
|
|
|
var focusEditor = global$2.get(el.id || el.name);
|
|
|
|
if (el.id && focusEditor) {
|
|
|
|
focusEditor.focus();
|
2017-05-08 01:32:46 -04:00
|
|
|
} else {
|
2018-04-25 18:35:21 -04:00
|
|
|
global$4.setTimeout(function () {
|
|
|
|
if (!global$3.webkit) {
|
|
|
|
window.focus();
|
|
|
|
}
|
|
|
|
el.focus();
|
|
|
|
}, 10);
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
editor.on('init', function () {
|
|
|
|
if (editor.inline) {
|
|
|
|
DOM.setAttrib(editor.getBody(), 'tabIndex', null);
|
|
|
|
}
|
|
|
|
editor.on('keyup', tabCancel);
|
|
|
|
if (global$3.gecko) {
|
|
|
|
editor.on('keypress keydown', tabHandler);
|
|
|
|
} else {
|
|
|
|
editor.on('keydown', tabHandler);
|
|
|
|
}
|
2017-05-08 01:32:46 -04:00
|
|
|
});
|
2018-04-25 18:35:21 -04:00
|
|
|
};
|
2018-07-16 04:07:26 -04:00
|
|
|
var $_6zogdykpjjgwed4h = { setup: setup };
|
2017-05-08 01:32:46 -04:00
|
|
|
|
2018-04-25 18:35:21 -04:00
|
|
|
global.add('tabfocus', function (editor) {
|
2018-07-16 04:07:26 -04:00
|
|
|
$_6zogdykpjjgwed4h.setup(editor);
|
2018-04-25 18:35:21 -04:00
|
|
|
});
|
|
|
|
function Plugin () {
|
2017-05-08 01:32:46 -04:00
|
|
|
}
|
2018-04-25 18:35:21 -04:00
|
|
|
|
|
|
|
return Plugin;
|
|
|
|
|
|
|
|
}());
|
2017-05-08 01:32:46 -04:00
|
|
|
})();
|