4 * Copyright 2009, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://tinymce.moxiecode.com/license
8 * Contributing: http://tinymce.moxiecode.com/contributing
12 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, explode = tinymce.explode;
14 tinymce.create('tinymce.plugins.TabFocusPlugin', {
15 init : function(ed, url) {
16 function tabCancel(ed, e) {
18 return Event.cancel(e);
21 function tabHandler(ed, e) {
25 el = DOM.select(':input:enabled,*[tabindex]');
26 function canSelect(e) {
27 return e.type != 'hidden' &&
29 !(el[i].style.display == "none") &&
30 !(el[i].style.visibility == "hidden");
33 each(el, function(e, i) {
41 for (i = x + 1; i < el.length; i++) {
46 for (i = x - 1; i >= 0; i--) {
55 if (e.keyCode === 9) {
56 v = explode(ed.getParam('tab_focus', ed.getParam('tabfocus_elements', ':prev,:next')));
63 // Find element to focus
77 if (el.id && (ed = tinymce.get(el.id || el.name)))
80 window.setTimeout(function() {
81 if (!tinymce.isWebKit)
86 return Event.cancel(e);
91 ed.onKeyUp.add(tabCancel);
93 if (tinymce.isGecko) {
94 ed.onKeyPress.add(tabHandler);
95 ed.onKeyDown.add(tabCancel);
97 ed.onKeyDown.add(tabHandler);
101 getInfo : function() {
103 longname : 'Tabfocus',
104 author : 'Moxiecode Systems AB',
105 authorurl : 'http://tinymce.moxiecode.com',
106 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus',
107 version : tinymce.majorVersion + "." + tinymce.minorVersion
113 tinymce.PluginManager.add('tabfocus', tinymce.plugins.TabFocusPlugin);