diff static/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js @ 442:6c182ceb7147

Fixing #217; upgrade TinyMCE to 3.4.2 and enable the paste plugin.
author Brian Neal <bgneal@gmail.com>
date Thu, 26 May 2011 00:43:49 +0000
parents 88b2b9cb8c1f
children
line wrap: on
line diff
--- a/static/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js	Wed May 25 02:39:08 2011 +0000
+++ b/static/js/tiny_mce/plugins/tabfocus/editor_plugin_src.js	Thu May 26 00:43:49 2011 +0000
@@ -22,27 +22,30 @@
 				var x, i, f, el, v;
 
 				function find(d) {
-					f = DOM.getParent(ed.id, 'form');
-					el = f.elements;
+					el = DOM.select(':input:enabled,*[tabindex]');
+					function canSelect(e) {
+						return e.type != 'hidden' && 
+						e.tabIndex != '-1' && 
+							!(el[i].style.display == "none") && 
+							!(el[i].style.visibility == "hidden");
+				    }
 
-					if (f) {
-						each(el, function(e, i) {
-							if (e.id == ed.id) {
-								x = i;
-								return false;
-							}
-						});
+					each(el, function(e, i) {
+						if (e.id == ed.id) {
+							x = i;
+							return false;
+						}
+					});
 
-						if (d > 0) {
-							for (i = x + 1; i < el.length; i++) {
-								if (el[i].type != 'hidden')
-									return el[i];
-							}
-						} else {
-							for (i = x - 1; i >= 0; i--) {
-								if (el[i].type != 'hidden')
-									return el[i];
-							}
+					if (d > 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];
 						}
 					}
 
@@ -71,10 +74,14 @@
 					}
 
 					if (el) {
-						if (ed = tinymce.get(el.id || el.name))
+						if (el.id && (ed = tinymce.get(el.id || el.name)))
 							ed.focus();
 						else
-							window.setTimeout(function() {window.focus();el.focus();}, 10);
+							window.setTimeout(function() {
+								if (!tinymce.isWebKit)
+									window.focus();
+								el.focus();
+							}, 10);
 
 						return Event.cancel(e);
 					}
@@ -89,11 +96,6 @@
 			} else
 				ed.onKeyDown.add(tabHandler);
 
-			ed.onInit.add(function() {
-				each(DOM.select('a:first,a:last', ed.getContainer()), function(n) {
-					Event.add(n, 'focus', function() {ed.focus();});
-				});
-			});
 		},
 
 		getInfo : function() {