init
This commit is contained in:
122
public/tinymce/plugins/tabfocus/plugin.js
Normal file
122
public/tinymce/plugins/tabfocus/plugin.js
Normal file
@ -0,0 +1,122 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('tabfocus', function(editor) {
|
||||
var DOM = tinymce.DOM, each = tinymce.each, explode = tinymce.explode;
|
||||
|
||||
function tabCancel(e) {
|
||||
if (e.keyCode === 9) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function tabHandler(e) {
|
||||
var x, el, v, i;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
function canSelectInOldIe(el) {
|
||||
return el.tabIndex || el.nodeName == "INPUT" || el.nodeName == "TEXTAREA";
|
||||
}
|
||||
|
||||
function canSelect(el) {
|
||||
return ((!canSelectInOldIe(el))) && el.getAttribute("tabindex") != '-1' && canSelectRecursive(el);
|
||||
}
|
||||
|
||||
each(el, function(e, i) {
|
||||
if (e.id == editor.id) {
|
||||
x = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (direction > 0) {
|
||||
for (i = x + 1; i < el.length; i++) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = x - 1; i >= 0; i--) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (e.keyCode === 9) {
|
||||
v = explode(editor.getParam('tab_focus', editor.getParam('tabfocus_elements', ':prev,:next')));
|
||||
|
||||
if (v.length == 1) {
|
||||
v[1] = v[0];
|
||||
v[0] = ':prev';
|
||||
}
|
||||
|
||||
// Find element to focus
|
||||
if (e.shiftKey) {
|
||||
if (v[0] == ':prev') {
|
||||
el = find(-1);
|
||||
} else {
|
||||
el = DOM.get(v[0]);
|
||||
}
|
||||
} else {
|
||||
if (v[1] == ':next') {
|
||||
el = find(1);
|
||||
} else {
|
||||
el = DOM.get(v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (el) {
|
||||
var focusEditor = tinymce.get(el.id || el.name);
|
||||
|
||||
if (el.id && focusEditor) {
|
||||
focusEditor.focus();
|
||||
} else {
|
||||
window.setTimeout(function() {
|
||||
if (!tinymce.Env.webkit) {
|
||||
window.focus();
|
||||
}
|
||||
|
||||
el.focus();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
if (editor.inline) {
|
||||
// Remove default tabIndex in inline mode
|
||||
tinymce.DOM.setAttrib(editor.getBody(), 'tabIndex', null);
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('keyup', tabCancel);
|
||||
|
||||
if (tinymce.Env.gecko) {
|
||||
editor.on('keypress keydown', tabHandler);
|
||||
} else {
|
||||
editor.on('keydown', tabHandler);
|
||||
}
|
||||
});
|
1
public/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
1
public/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("tabfocus",function(e){function t(e){9===e.keyCode&&e.preventDefault()}function n(t){function n(t){function n(e){return"BODY"===e.nodeName||"hidden"!=e.type&&"none"!=e.style.display&&"hidden"!=e.style.visibility&&n(e.parentNode)}function o(e){return e.tabIndex||"INPUT"==e.nodeName||"TEXTAREA"==e.nodeName}function l(e){return!o(e)&&"-1"!=e.getAttribute("tabindex")&&n(e)}if(s=r.select(":input:enabled,*[tabindex]:not(iframe)"),i(s,function(t,n){return t.id==e.id?(a=n,!1):void 0}),t>0){for(c=a+1;c<s.length;c++)if(l(s[c]))return s[c]}else for(c=a-1;c>=0;c--)if(l(s[c]))return s[c];return null}var a,s,l,c;if(9===t.keyCode&&(l=o(e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))),1==l.length&&(l[1]=l[0],l[0]=":prev"),s=t.shiftKey?":prev"==l[0]?n(-1):r.get(l[0]):":next"==l[1]?n(1):r.get(l[1]))){var d=tinymce.get(s.id||s.name);s.id&&d?d.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),s.focus()},10),t.preventDefault()}}var r=tinymce.DOM,i=tinymce.each,o=tinymce.explode;e.on("init",function(){e.inline&&tinymce.DOM.setAttrib(e.getBody(),"tabIndex",null)}),e.on("keyup",t),tinymce.Env.gecko?e.on("keypress keydown",n):e.on("keydown",n)});
|
Reference in New Issue
Block a user