includes/clientside/tinymce/tiny_mce_popup.js
changeset 459 31c23016ab62
parent 395 fa4c5ecb7c9a
child 476 f26a69c40431
equal deleted inserted replaced
458:c433348f3628 459:31c23016ab62
     1 // Some global instances
     1 // Some global instances
     2 var tinymce = null, tinyMCEPopup, tinyMCE;
     2 var tinymce = null, tinyMCEPopup, tinyMCE;
     3 
     3 
     4 tinyMCEPopup = {
     4 tinyMCEPopup = {
     5 	init : function() {
     5 	init : function() {
     6 		var t = this, w = t.getWin(), ti;
     6 		var t = this, w, ti, li, q, i, it;
     7 
     7 
     8 		// Find API
     8 		li = ('' + document.location.search).replace(/^\?/, '').split('&');
       
     9 		q = {};
       
    10 		for (i=0; i<li.length; i++) {
       
    11 			it = li[i].split('=');
       
    12 			q[unescape(it[0])] = unescape(it[1]);
       
    13 		}
       
    14 
       
    15 		if (q.mce_rdomain)
       
    16 			document.domain = q.mce_rdomain;
       
    17 
       
    18 		// Find window & API
       
    19 		w = t.getWin();
     9 		tinymce = w.tinymce;
    20 		tinymce = w.tinymce;
    10 		tinyMCE = w.tinyMCE;
    21 		tinyMCE = w.tinyMCE;
    11 		t.editor = tinymce.EditorManager.activeEditor;
    22 		t.editor = tinymce.EditorManager.activeEditor;
    12 		t.params = t.editor.windowManager.params;
    23 		t.params = t.editor.windowManager.params;
    13 
    24 
    45 	getLang : function(n, dv) {
    56 	getLang : function(n, dv) {
    46 		return this.editor.getLang(n, dv);
    57 		return this.editor.getLang(n, dv);
    47 	},
    58 	},
    48 
    59 
    49 	execCommand : function(cmd, ui, val, a) {
    60 	execCommand : function(cmd, ui, val, a) {
       
    61 		a = a || {};
       
    62 		a.skip_focus = 1;
       
    63 
    50 		this.restoreSelection();
    64 		this.restoreSelection();
    51 		return this.editor.execCommand(cmd, ui, val, a || {skip_focus : 1});
    65 		return this.editor.execCommand(cmd, ui, val, a);
    52 	},
    66 	},
    53 
    67 
    54 	resizeToInnerSize : function() {
    68 	resizeToInnerSize : function() {
    55 		var t = this, n, b = document.body, vp = t.dom.getViewPort(window), dw, dh;
    69 		var t = this, n, b = document.body, vp = t.dom.getViewPort(window), dw, dh;
    56 
    70 
    81 	},
    95 	},
    82 
    96 
    83 	requireLangPack : function() {
    97 	requireLangPack : function() {
    84 		var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
    98 		var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
    85 
    99 
    86 		if (u)
   100 		if (u && this.editor.settings.language)
    87 			document.write('<script type="text/javascript" src="' + u + '/langs/' + this.editor.settings.language + '_dlg.js' + '"></script>');
   101 			document.write('<script type="text/javascript" src="' + u + '/langs/' + this.editor.settings.language + '_dlg.js' + '"></script>');
    88 	},
   102 	},
    89 
   103 
    90 	pickColor : function(e, element_id) {
   104 	pickColor : function(e, element_id) {
    91 		this.execCommand('mceColorPicker', true, {
   105 		this.execCommand('mceColorPicker', true, {
   108 	},
   122 	},
   109 
   123 
   110 	close : function() {
   124 	close : function() {
   111 		var t = this;
   125 		var t = this;
   112 
   126 
   113 		t.dom = t.dom.doc = null; // Cleanup
   127 		// To avoid domain relaxing issue in Opera
   114 		t.editor.windowManager.close(window, t.id);
   128 		function close() {
       
   129 			t.editor.windowManager.close(window, t.id);
       
   130 			tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
       
   131 		};
       
   132 
       
   133 		if (tinymce.isOpera)
       
   134 			t.getWin().setTimeout(close, 0);
       
   135 		else
       
   136 			close();
   115 	},
   137 	},
   116 
   138 
   117 	// Internal functions	
   139 	// Internal functions	
   118 
   140 
   119 	_restoreSelection : function() {
   141 	_restoreSelection : function() {
   137 		// Translate page
   159 		// Translate page
   138 		h = document.body.innerHTML;
   160 		h = document.body.innerHTML;
   139 
   161 
   140 		// Replace a=x with a="x" in IE
   162 		// Replace a=x with a="x" in IE
   141 		if (tinymce.isIE)
   163 		if (tinymce.isIE)
   142 			h = h.replace(/ (value|title|alt)=([^\s>]+)/gi, ' $1="$2"');
   164 			h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
   143 
   165 
   144 		document.body.innerHTML = t.editor.translate(h);
   166 		document.body.innerHTML = t.editor.translate(h);
   145 		document.title = ti = t.editor.translate(ti);
   167 		document.title = ti = t.editor.translate(ti);
   146 		document.body.style.display = '';
   168 		document.body.style.display = '';
   147 
   169