includes/clientside/tinymce/tiny_mce_popup.js
changeset 543 dffcbfbc4e59
parent 476 f26a69c40431
child 778 57ce13805b6f
--- a/includes/clientside/tinymce/tiny_mce_popup.js	Mon May 05 20:06:37 2008 -0400
+++ b/includes/clientside/tinymce/tiny_mce_popup.js	Mon May 05 20:08:44 2008 -0400
@@ -101,7 +101,7 @@
 			u += '/langs/' + this.editor.settings.language + '_dlg.js';
 
 			if (!tinymce.ScriptLoader.isDone(u)) {
-				document.write('<script type="text/javascript" src="' + u + '"></script>');
+				document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
 				tinymce.ScriptLoader.markDone(u);
 			}
 		}
@@ -132,7 +132,7 @@
 
 		// To avoid domain relaxing issue in Opera
 		function close() {
-			t.editor.windowManager.close(window, t.id);
+			t.editor.windowManager.close(window);
 			tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
 		};
 
@@ -169,6 +169,7 @@
 		if (tinymce.isIE)
 			h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
 
+		document.dir = t.editor.getParam('directionality','');
 		document.body.innerHTML = t.editor.translate(h);
 		document.title = ti = t.editor.translate(ti);
 		document.body.style.display = '';
@@ -178,18 +179,13 @@
 			document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
 
 		t.restoreSelection();
-
-		// Call onInit
-		tinymce.each(t.listeners, function(o) {
-			o.func.call(o.scope, t.editor);
-		});
-
 		t.resizeToInnerSize();
 
-		if (t.isWindow)
+		// Set inline title
+		if (!t.isWindow)
+			t.editor.windowManager.setTitle(window, ti);
+		else
 			window.focus();
-		else
-			t.editor.windowManager.setTitle(ti, t.id);
 
 		if (!tinymce.isIE && !t.isWindow) {
 			tinymce.dom.Event._add(document, 'focus', function() {
@@ -202,12 +198,32 @@
 			e.onkeydown = tinyMCEPopup._accessHandler;
 		});
 
+		// Call onInit
+		// Init must be called before focus so the selection won't get lost by the focus call
+		tinymce.each(t.listeners, function(o) {
+			o.func.call(o.scope, t.editor);
+		});
+
 		// Move focus to window
-		window.focus();
+		if (t.getWindowArg('mce_auto_focus', true)) {
+			window.focus();
+
+			// Focus element with mceFocus class
+			tinymce.each(document.forms, function(f) {
+				tinymce.each(f.elements, function(e) {
+					if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
+						e.focus();
+						return false; // Break loop
+					}
+				});
+			});
+		}
+
+		document.onkeyup = tinyMCEPopup._closeWinKeyHandler;
 	},
 
 	_accessHandler : function(e) {
-		var e = e || window.event;
+		e = e || window.event;
 
 		if (e.keyCode == 13 || e.keyCode == 32) {
 			e = e.target || e.srcElement;
@@ -219,6 +235,13 @@
 		}
 	},
 
+	_closeWinKeyHandler : function(e) {
+		e = e || window.event;
+
+		if (e.keyCode == 27)
+			tinyMCEPopup.close();
+	},
+
 	_wait : function() {
 		var t = this, ti;