2 * editor_plugin_src.js
\r
4 * Copyright 2009, Moxiecode Systems AB
\r
5 * Released under LGPL License.
\r
7 * License: http://tinymce.moxiecode.com/license
\r
8 * Contributing: http://tinymce.moxiecode.com/contributing
\r
12 var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, explode = tinymce.explode;
\r
14 tinymce.create('tinymce.plugins.TabFocusPlugin', {
\r
15 init : function(ed, url) {
\r
16 function tabCancel(ed, e) {
\r
17 if (e.keyCode === 9)
\r
18 return Event.cancel(e);
\r
21 function tabHandler(ed, e) {
\r
25 f = DOM.getParent(ed.id, 'form');
\r
29 each(el, function(e, i) {
\r
30 if (e.id == ed.id) {
\r
37 for (i = x + 1; i < el.length; i++) {
\r
38 if (el[i].type != 'hidden')
\r
42 for (i = x - 1; i >= 0; i--) {
\r
43 if (el[i].type != 'hidden')
\r
52 if (e.keyCode === 9) {
\r
53 v = explode(ed.getParam('tab_focus', ed.getParam('tabfocus_elements', ':prev,:next')));
\r
55 if (v.length == 1) {
\r
60 // Find element to focus
\r
62 if (v[0] == ':prev')
\r
67 if (v[1] == ':next')
\r
74 if (ed = tinymce.get(el.id || el.name))
\r
77 window.setTimeout(function() {window.focus();el.focus();}, 10);
\r
79 return Event.cancel(e);
\r
84 ed.onKeyUp.add(tabCancel);
\r
86 if (tinymce.isGecko) {
\r
87 ed.onKeyPress.add(tabHandler);
\r
88 ed.onKeyDown.add(tabCancel);
\r
90 ed.onKeyDown.add(tabHandler);
\r
92 ed.onInit.add(function() {
\r
93 each(DOM.select('a:first,a:last', ed.getContainer()), function(n) {
\r
94 Event.add(n, 'focus', function() {ed.focus();});
\r
99 getInfo : function() {
\r
101 longname : 'Tabfocus',
\r
102 author : 'Moxiecode Systems AB',
\r
103 authorurl : 'http://tinymce.moxiecode.com',
\r
104 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus',
\r
105 version : tinymce.majorVersion + "." + tinymce.minorVersion
\r
111 tinymce.PluginManager.add('tabfocus', tinymce.plugins.TabFocusPlugin);
\r