| ... | ... |
@@ -1,275 +1,294 @@ |
| 1 |
-// Some global instances |
|
| 2 |
-var tinymce = null, tinyMCEPopup, tinyMCE; |
|
| 3 |
- |
|
| 4 |
-tinyMCEPopup = {
|
|
| 5 |
- init : function() {
|
|
| 6 |
- var t = this, w, ti, li, q, i, it; |
|
| 7 |
- |
|
| 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(); |
|
| 20 |
- tinymce = w.tinymce; |
|
| 21 |
- tinyMCE = w.tinyMCE; |
|
| 22 |
- t.editor = tinymce.EditorManager.activeEditor; |
|
| 23 |
- t.params = t.editor.windowManager.params; |
|
| 24 |
- |
|
| 25 |
- // Setup local DOM |
|
| 26 |
- t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
|
|
| 27 |
- t.dom.loadCSS(t.editor.settings.popup_css); |
|
| 28 |
- |
|
| 29 |
- // Setup on init listeners |
|
| 30 |
- t.listeners = []; |
|
| 31 |
- t.onInit = {
|
|
| 32 |
- add : function(f, s) {
|
|
| 33 |
- t.listeners.push({func : f, scope : s});
|
|
| 34 |
- } |
|
| 35 |
- }; |
|
| 36 |
- |
|
| 37 |
- t.isWindow = !t.getWindowArg('mce_inline');
|
|
| 38 |
- t.id = t.getWindowArg('mce_window_id');
|
|
| 39 |
- t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window); |
|
| 40 |
- }, |
|
| 41 |
- |
|
| 42 |
- getWin : function() {
|
|
| 43 |
- return window.dialogArguments || opener || parent || top; |
|
| 44 |
- }, |
|
| 45 |
- |
|
| 46 |
- getWindowArg : function(n, dv) {
|
|
| 47 |
- var v = this.params[n]; |
|
| 48 |
- |
|
| 49 |
- return tinymce.is(v) ? v : dv; |
|
| 50 |
- }, |
|
| 51 |
- |
|
| 52 |
- getParam : function(n, dv) {
|
|
| 53 |
- return this.editor.getParam(n, dv); |
|
| 54 |
- }, |
|
| 55 |
- |
|
| 56 |
- getLang : function(n, dv) {
|
|
| 57 |
- return this.editor.getLang(n, dv); |
|
| 58 |
- }, |
|
| 59 |
- |
|
| 60 |
- execCommand : function(cmd, ui, val, a) {
|
|
| 61 |
- a = a || {};
|
|
| 62 |
- a.skip_focus = 1; |
|
| 63 |
- |
|
| 64 |
- this.restoreSelection(); |
|
| 65 |
- return this.editor.execCommand(cmd, ui, val, a); |
|
| 66 |
- }, |
|
| 67 |
- |
|
| 68 |
- resizeToInnerSize : function() {
|
|
| 69 |
- var t = this, n, b = document.body, vp = t.dom.getViewPort(window), dw, dh; |
|
| 70 |
- |
|
| 71 |
- dw = t.getWindowArg('mce_width') - vp.w;
|
|
| 72 |
- dh = t.getWindowArg('mce_height') - vp.h;
|
|
| 73 |
- |
|
| 74 |
- if (t.isWindow) |
|
| 75 |
- window.resizeBy(dw, dh); |
|
| 76 |
- else |
|
| 77 |
- t.editor.windowManager.resizeBy(dw, dh, t.id); |
|
| 78 |
- }, |
|
| 79 |
- |
|
| 80 |
- executeOnLoad : function(s) {
|
|
| 81 |
- this.onInit.add(function() {
|
|
| 82 |
- eval(s); |
|
| 83 |
- }); |
|
| 84 |
- }, |
|
| 85 |
- |
|
| 86 |
- storeSelection : function() {
|
|
| 87 |
- this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
|
|
| 88 |
- }, |
|
| 89 |
- |
|
| 90 |
- restoreSelection : function() {
|
|
| 91 |
- var t = tinyMCEPopup; |
|
| 92 |
- |
|
| 93 |
- if (!t.isWindow && tinymce.isIE) |
|
| 94 |
- t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark); |
|
| 95 |
- }, |
|
| 96 |
- |
|
| 97 |
- requireLangPack : function() {
|
|
| 98 |
- var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
|
|
| 99 |
- |
|
| 100 |
- if (u && this.editor.settings.language) {
|
|
| 101 |
- u += '/langs/' + this.editor.settings.language + '_dlg.js'; |
|
| 102 |
- |
|
| 103 |
- if (!tinymce.ScriptLoader.isDone(u)) {
|
|
| 104 |
- document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
|
|
| 105 |
- tinymce.ScriptLoader.markDone(u); |
|
| 106 |
- } |
|
| 107 |
- } |
|
| 108 |
- }, |
|
| 109 |
- |
|
| 110 |
- pickColor : function(e, element_id) {
|
|
| 111 |
- this.execCommand('mceColorPicker', true, {
|
|
| 112 |
- color : document.getElementById(element_id).value, |
|
| 113 |
- func : function(c) {
|
|
| 114 |
- document.getElementById(element_id).value = c; |
|
| 115 |
- |
|
| 116 |
- try {
|
|
| 117 |
- document.getElementById(element_id).onchange(); |
|
| 118 |
- } catch (ex) {
|
|
| 119 |
- // Try fire event, ignore errors |
|
| 120 |
- } |
|
| 121 |
- } |
|
| 122 |
- }); |
|
| 123 |
- }, |
|
| 124 |
- |
|
| 125 |
- openBrowser : function(element_id, type, option) {
|
|
| 126 |
- tinyMCEPopup.restoreSelection(); |
|
| 127 |
- this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
|
|
| 128 |
- }, |
|
| 129 |
- |
|
| 130 |
- close : function() {
|
|
| 131 |
- var t = this; |
|
| 132 |
- |
|
| 133 |
- // To avoid domain relaxing issue in Opera |
|
| 134 |
- function close() {
|
|
| 135 |
- t.editor.windowManager.close(window); |
|
| 136 |
- tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup |
|
| 137 |
- }; |
|
| 138 |
- |
|
| 139 |
- if (tinymce.isOpera) |
|
| 140 |
- t.getWin().setTimeout(close, 0); |
|
| 141 |
- else |
|
| 142 |
- close(); |
|
| 143 |
- }, |
|
| 144 |
- |
|
| 145 |
- // Internal functions |
|
| 146 |
- |
|
| 147 |
- _restoreSelection : function() {
|
|
| 148 |
- var e = window.event.srcElement; |
|
| 149 |
- |
|
| 150 |
- if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button')) |
|
| 151 |
- tinyMCEPopup.restoreSelection(); |
|
| 152 |
- }, |
|
| 153 |
- |
|
| 154 |
-/* _restoreSelection : function() {
|
|
| 155 |
- var e = window.event.srcElement; |
|
| 156 |
- |
|
| 157 |
- // If user focus a non text input or textarea |
|
| 158 |
- if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text') |
|
| 159 |
- tinyMCEPopup.restoreSelection(); |
|
| 160 |
- },*/ |
|
| 161 |
- |
|
| 162 |
- _onDOMLoaded : function() {
|
|
| 163 |
- var t = this, ti = document.title, bm, h; |
|
| 164 |
- |
|
| 165 |
- // Translate page |
|
| 166 |
- h = document.body.innerHTML; |
|
| 167 |
- |
|
| 168 |
- // Replace a=x with a="x" in IE |
|
| 169 |
- if (tinymce.isIE) |
|
| 170 |
- h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"') |
|
| 171 |
- |
|
| 172 |
- document.dir = t.editor.getParam('directionality','');
|
|
| 173 |
- document.body.innerHTML = t.editor.translate(h); |
|
| 174 |
- document.title = ti = t.editor.translate(ti); |
|
| 175 |
- document.body.style.display = ''; |
|
| 176 |
- |
|
| 177 |
- // Restore selection in IE when focus is placed on a non textarea or input element of the type text |
|
| 178 |
- if (tinymce.isIE) |
|
| 179 |
- document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
|
|
| 180 |
- |
|
| 181 |
- t.restoreSelection(); |
|
| 182 |
- t.resizeToInnerSize(); |
|
| 183 |
- |
|
| 184 |
- // Set inline title |
|
| 185 |
- if (!t.isWindow) |
|
| 186 |
- t.editor.windowManager.setTitle(window, ti); |
|
| 187 |
- else |
|
| 188 |
- window.focus(); |
|
| 189 |
- |
|
| 190 |
- if (!tinymce.isIE && !t.isWindow) {
|
|
| 191 |
- tinymce.dom.Event._add(document, 'focus', function() {
|
|
| 192 |
- t.editor.windowManager.focus(t.id) |
|
| 193 |
- }); |
|
| 194 |
- } |
|
| 195 |
- |
|
| 196 |
- // Patch for accessibility |
|
| 197 |
- tinymce.each(t.dom.select('select'), function(e) {
|
|
| 198 |
- e.onkeydown = tinyMCEPopup._accessHandler; |
|
| 199 |
- }); |
|
| 200 |
- |
|
| 201 |
- // Call onInit |
|
| 202 |
- // Init must be called before focus so the selection won't get lost by the focus call |
|
| 203 |
- tinymce.each(t.listeners, function(o) {
|
|
| 204 |
- o.func.call(o.scope, t.editor); |
|
| 205 |
- }); |
|
| 206 |
- |
|
| 207 |
- // Move focus to window |
|
| 208 |
- if (t.getWindowArg('mce_auto_focus', true)) {
|
|
| 209 |
- window.focus(); |
|
| 210 |
- |
|
| 211 |
- // Focus element with mceFocus class |
|
| 212 |
- tinymce.each(document.forms, function(f) {
|
|
| 213 |
- tinymce.each(f.elements, function(e) {
|
|
| 214 |
- if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
|
|
| 215 |
- e.focus(); |
|
| 216 |
- return false; // Break loop |
|
| 217 |
- } |
|
| 218 |
- }); |
|
| 219 |
- }); |
|
| 220 |
- } |
|
| 221 |
- |
|
| 222 |
- document.onkeyup = tinyMCEPopup._closeWinKeyHandler; |
|
| 223 |
- }, |
|
| 224 |
- |
|
| 225 |
- _accessHandler : function(e) {
|
|
| 226 |
- e = e || window.event; |
|
| 227 |
- |
|
| 228 |
- if (e.keyCode == 13 || e.keyCode == 32) {
|
|
| 229 |
- e = e.target || e.srcElement; |
|
| 230 |
- |
|
| 231 |
- if (e.onchange) |
|
| 232 |
- e.onchange(); |
|
| 233 |
- |
|
| 234 |
- return tinymce.dom.Event.cancel(e); |
|
| 235 |
- } |
|
| 236 |
- }, |
|
| 237 |
- |
|
| 238 |
- _closeWinKeyHandler : function(e) {
|
|
| 239 |
- e = e || window.event; |
|
| 240 |
- |
|
| 241 |
- if (e.keyCode == 27) |
|
| 242 |
- tinyMCEPopup.close(); |
|
| 243 |
- }, |
|
| 244 |
- |
|
| 245 |
- _wait : function() {
|
|
| 246 |
- var t = this, ti; |
|
| 247 |
- |
|
| 248 |
- if (tinymce.isIE && document.location.protocol != 'https:') {
|
|
| 249 |
- // Fake DOMContentLoaded on IE |
|
| 250 |
- document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
|
|
| 251 |
- document.getElementById("__ie_onload").onreadystatechange = function() {
|
|
| 252 |
- if (this.readyState == "complete") {
|
|
| 253 |
- t._onDOMLoaded(); |
|
| 254 |
- document.getElementById("__ie_onload").onreadystatechange = null; // Prevent leak
|
|
| 255 |
- } |
|
| 256 |
- }; |
|
| 257 |
- } else {
|
|
| 258 |
- if (tinymce.isIE || tinymce.isWebKit) {
|
|
| 259 |
- ti = setInterval(function() {
|
|
| 260 |
- if (/loaded|complete/.test(document.readyState)) {
|
|
| 261 |
- clearInterval(ti); |
|
| 262 |
- t._onDOMLoaded(); |
|
| 263 |
- } |
|
| 264 |
- }, 10); |
|
| 265 |
- } else {
|
|
| 266 |
- window.addEventListener('DOMContentLoaded', function() {
|
|
| 267 |
- t._onDOMLoaded(); |
|
| 268 |
- }, false); |
|
| 269 |
- } |
|
| 270 |
- } |
|
| 271 |
- } |
|
| 272 |
-}; |
|
| 273 |
- |
|
| 274 |
-tinyMCEPopup.init(); |
|
| 275 |
-tinyMCEPopup._wait(); // Wait for DOM Content Loaded |
|
| 1 |
+// Some global instances, this will be filled later |
|
| 2 |
+var tinyMCE = null, tinyMCELang = null; |
|
| 3 |
+ |
|
| 4 |
+function TinyMCE_Popup() {
|
|
| 5 |
+}; |
|
| 6 |
+ |
|
| 7 |
+TinyMCE_Popup.prototype = {
|
|
| 8 |
+ findWin : function(w) {
|
|
| 9 |
+ var c; |
|
| 10 |
+ |
|
| 11 |
+ // Check parents |
|
| 12 |
+ c = w; |
|
| 13 |
+ while (c && (c = c.parent) != null) {
|
|
| 14 |
+ if (typeof(c.tinyMCE) != "undefined") |
|
| 15 |
+ return c; |
|
| 16 |
+ } |
|
| 17 |
+ |
|
| 18 |
+ // Check openers |
|
| 19 |
+ c = w; |
|
| 20 |
+ while (c && (c = c.opener) != null) {
|
|
| 21 |
+ if (typeof(c.tinyMCE) != "undefined") |
|
| 22 |
+ return c; |
|
| 23 |
+ } |
|
| 24 |
+ |
|
| 25 |
+ // Try top |
|
| 26 |
+ if (typeof(top.tinyMCE) != "undefined") |
|
| 27 |
+ return top; |
|
| 28 |
+ |
|
| 29 |
+ return null; |
|
| 30 |
+ }, |
|
| 31 |
+ |
|
| 32 |
+ init : function() {
|
|
| 33 |
+ var win = window.opener ? window.opener : window.dialogArguments, c; |
|
| 34 |
+ var inst, re, title, divElm; |
|
| 35 |
+ |
|
| 36 |
+ if (!win) |
|
| 37 |
+ win = this.findWin(window); |
|
| 38 |
+ |
|
| 39 |
+ if (!win) {
|
|
| 40 |
+ alert("tinyMCE object reference not found from popup.");
|
|
| 41 |
+ return; |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ window.opener = win; |
|
| 45 |
+ this.windowOpener = win; |
|
| 46 |
+ this.onLoadEval = ""; |
|
| 47 |
+ |
|
| 48 |
+ // Setup parent references |
|
| 49 |
+ tinyMCE = win.tinyMCE; |
|
| 50 |
+ tinyMCELang = win.tinyMCELang; |
|
| 51 |
+ |
|
| 52 |
+ inst = tinyMCE.selectedInstance; |
|
| 53 |
+ this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
|
|
| 54 |
+ this.storeSelection = (tinyMCE.isRealIE) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
|
|
| 55 |
+ |
|
| 56 |
+ if (this.isWindow) |
|
| 57 |
+ window.focus(); |
|
| 58 |
+ |
|
| 59 |
+ // Store selection |
|
| 60 |
+ if (this.storeSelection) |
|
| 61 |
+ inst.selectionBookmark = inst.selection.getBookmark(true); |
|
| 62 |
+ |
|
| 63 |
+ // Setup dir |
|
| 64 |
+ if (tinyMCELang.lang_dir) |
|
| 65 |
+ document.dir = tinyMCELang.lang_dir; |
|
| 66 |
+ |
|
| 67 |
+ // Setup title |
|
| 68 |
+ re = new RegExp('{|\\\$|}', 'g');
|
|
| 69 |
+ title = document.title.replace(re, ""); |
|
| 70 |
+ if (typeof(tinyMCELang[title]) != "undefined") {
|
|
| 71 |
+ divElm = document.createElement("div");
|
|
| 72 |
+ divElm.innerHTML = tinyMCELang[title]; |
|
| 73 |
+ document.title = divElm.innerHTML; |
|
| 74 |
+ |
|
| 75 |
+ if (typeof(tinyMCE.setWindowTitle) != 'undefined') |
|
| 76 |
+ tinyMCE.setWindowTitle(window, divElm.innerHTML); |
|
| 77 |
+ } |
|
| 78 |
+ |
|
| 79 |
+ // Output Popup CSS class |
|
| 80 |
+ document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
|
|
| 81 |
+ |
|
| 82 |
+ if (tinyMCE.getParam("popups_css_add")) {
|
|
| 83 |
+ c = tinyMCE.getParam("popups_css_add");
|
|
| 84 |
+ |
|
| 85 |
+ // Is relative |
|
| 86 |
+ if (c.indexOf('://') == -1 && c.charAt(0) != '/')
|
|
| 87 |
+ c = tinyMCE.documentBasePath + "/" + c; |
|
| 88 |
+ |
|
| 89 |
+ document.write('<link href="' + c + '" rel="stylesheet" type="text/css">');
|
|
| 90 |
+ } |
|
| 91 |
+ |
|
| 92 |
+ tinyMCE.addEvent(window, "load", this.onLoad); |
|
| 93 |
+ }, |
|
| 94 |
+ |
|
| 95 |
+ onLoad : function() {
|
|
| 96 |
+ var dir, i, elms, body = document.body; |
|
| 97 |
+ |
|
| 98 |
+ if (tinyMCE.getWindowArg('mce_replacevariables', true))
|
|
| 99 |
+ body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs); |
|
| 100 |
+ |
|
| 101 |
+ dir = tinyMCE.selectedInstance.settings.directionality; |
|
| 102 |
+ if (dir == "rtl" && document.forms && document.forms.length > 0) {
|
|
| 103 |
+ elms = document.forms[0].elements; |
|
| 104 |
+ for (i=0; i<elms.length; i++) {
|
|
| 105 |
+ if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
|
|
| 106 |
+ elms[i].dir = dir; |
|
| 107 |
+ } |
|
| 108 |
+ } |
|
| 109 |
+ |
|
| 110 |
+ if (body.style.display == 'none') |
|
| 111 |
+ body.style.display = 'block'; |
|
| 112 |
+ |
|
| 113 |
+ // Execute real onload (Opera fix) |
|
| 114 |
+ if (tinyMCEPopup.onLoadEval !== '') |
|
| 115 |
+ eval(tinyMCEPopup.onLoadEval); |
|
| 116 |
+ }, |
|
| 117 |
+ |
|
| 118 |
+ executeOnLoad : function(str) {
|
|
| 119 |
+ if (tinyMCE.isOpera) |
|
| 120 |
+ this.onLoadEval = str; |
|
| 121 |
+ else |
|
| 122 |
+ eval(str); |
|
| 123 |
+ }, |
|
| 124 |
+ |
|
| 125 |
+ resizeToInnerSize : function() {
|
|
| 126 |
+ var i, doc, body, oldMargin, wrapper, iframe, nodes, dx, dy; |
|
| 127 |
+ |
|
| 128 |
+ // Netscape 7.1 workaround |
|
| 129 |
+ if (this.isWindow && tinyMCE.isNS71) {
|
|
| 130 |
+ window.resizeBy(0, 10); |
|
| 131 |
+ return; |
|
| 132 |
+ } |
|
| 133 |
+ |
|
| 134 |
+ if (this.isWindow) {
|
|
| 135 |
+ doc = document; |
|
| 136 |
+ body = doc.body; |
|
| 137 |
+ |
|
| 138 |
+ if (body.style.display == 'none') |
|
| 139 |
+ body.style.display = 'block'; |
|
| 140 |
+ |
|
| 141 |
+ // Remove margin |
|
| 142 |
+ oldMargin = body.style.margin; |
|
| 143 |
+ body.style.margin = '0'; |
|
| 144 |
+ |
|
| 145 |
+ // Create wrapper |
|
| 146 |
+ wrapper = doc.createElement("div");
|
|
| 147 |
+ wrapper.id = 'mcBodyWrapper'; |
|
| 148 |
+ wrapper.style.display = 'none'; |
|
| 149 |
+ wrapper.style.margin = '0'; |
|
| 150 |
+ |
|
| 151 |
+ // Wrap body elements |
|
| 152 |
+ nodes = doc.body.childNodes; |
|
| 153 |
+ for (i=nodes.length-1; i>=0; i--) {
|
|
| 154 |
+ if (wrapper.hasChildNodes()) |
|
| 155 |
+ wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild); |
|
| 156 |
+ else |
|
| 157 |
+ wrapper.appendChild(nodes[i].cloneNode(true)); |
|
| 158 |
+ |
|
| 159 |
+ nodes[i].parentNode.removeChild(nodes[i]); |
|
| 160 |
+ } |
|
| 161 |
+ |
|
| 162 |
+ // Add wrapper |
|
| 163 |
+ doc.body.appendChild(wrapper); |
|
| 164 |
+ |
|
| 165 |
+ // Create iframe |
|
| 166 |
+ iframe = document.createElement("iframe");
|
|
| 167 |
+ iframe.id = "mcWinIframe"; |
|
| 168 |
+ iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings.default_document;
|
|
| 169 |
+ iframe.width = "100%"; |
|
| 170 |
+ iframe.height = "100%"; |
|
| 171 |
+ iframe.style.margin = '0'; |
|
| 172 |
+ |
|
| 173 |
+ // Add iframe |
|
| 174 |
+ doc.body.appendChild(iframe); |
|
| 175 |
+ |
|
| 176 |
+ // Measure iframe |
|
| 177 |
+ iframe = document.getElementById('mcWinIframe');
|
|
| 178 |
+ dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
|
|
| 179 |
+ dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
|
|
| 180 |
+ |
|
| 181 |
+ // Resize window |
|
| 182 |
+ // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
|
|
| 183 |
+ window.resizeBy(dx, dy); |
|
| 184 |
+ |
|
| 185 |
+ // Hide iframe and show wrapper |
|
| 186 |
+ body.style.margin = oldMargin; |
|
| 187 |
+ iframe.style.display = 'none'; |
|
| 188 |
+ wrapper.style.display = 'block'; |
|
| 189 |
+ } |
|
| 190 |
+ }, |
|
| 191 |
+ |
|
| 192 |
+ resizeToContent : function() {
|
|
| 193 |
+ var isMSIE = (navigator.appName == "Microsoft Internet Explorer"); |
|
| 194 |
+ var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
|
|
| 195 |
+ var elm, width, height, x, y, dx, dy; |
|
| 196 |
+ |
|
| 197 |
+ if (isOpera) |
|
| 198 |
+ return; |
|
| 199 |
+ |
|
| 200 |
+ if (isMSIE) {
|
|
| 201 |
+ try { window.resizeTo(10, 10); } catch (e) {}
|
|
| 202 |
+ |
|
| 203 |
+ elm = document.body; |
|
| 204 |
+ width = elm.offsetWidth; |
|
| 205 |
+ height = elm.offsetHeight; |
|
| 206 |
+ dx = (elm.scrollWidth - width) + 4; |
|
| 207 |
+ dy = elm.scrollHeight - height; |
|
| 208 |
+ |
|
| 209 |
+ try { window.resizeBy(dx, dy); } catch (e) {}
|
|
| 210 |
+ } else {
|
|
| 211 |
+ window.scrollBy(1000, 1000); |
|
| 212 |
+ if (window.scrollX > 0 || window.scrollY > 0) {
|
|
| 213 |
+ window.resizeBy(window.innerWidth * 2, window.innerHeight * 2); |
|
| 214 |
+ window.sizeToContent(); |
|
| 215 |
+ window.scrollTo(0, 0); |
|
| 216 |
+ x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0); |
|
| 217 |
+ y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0); |
|
| 218 |
+ window.moveTo(x, y); |
|
| 219 |
+ } |
|
| 220 |
+ } |
|
| 221 |
+ }, |
|
| 222 |
+ |
|
| 223 |
+ getWindowArg : function(name, default_value) {
|
|
| 224 |
+ return tinyMCE.getWindowArg(name, default_value); |
|
| 225 |
+ }, |
|
| 226 |
+ |
|
| 227 |
+ restoreSelection : function() {
|
|
| 228 |
+ var inst; |
|
| 229 |
+ |
|
| 230 |
+ if (this.storeSelection) {
|
|
| 231 |
+ inst = tinyMCE.selectedInstance; |
|
| 232 |
+ |
|
| 233 |
+ inst.getWin().focus(); |
|
| 234 |
+ |
|
| 235 |
+ if (inst.selectionBookmark) |
|
| 236 |
+ inst.selection.moveToBookmark(inst.selectionBookmark); |
|
| 237 |
+ } |
|
| 238 |
+ }, |
|
| 239 |
+ |
|
| 240 |
+ execCommand : function(command, user_interface, value) {
|
|
| 241 |
+ var inst = tinyMCE.selectedInstance; |
|
| 242 |
+ |
|
| 243 |
+ this.restoreSelection(); |
|
| 244 |
+ inst.execCommand(command, user_interface, value); |
|
| 245 |
+ |
|
| 246 |
+ // Store selection |
|
| 247 |
+ if (this.storeSelection) |
|
| 248 |
+ inst.selectionBookmark = inst.selection.getBookmark(true); |
|
| 249 |
+ }, |
|
| 250 |
+ |
|
| 251 |
+ close : function() {
|
|
| 252 |
+ tinyMCE.closeWindow(window); |
|
| 253 |
+ }, |
|
| 254 |
+ |
|
| 255 |
+ pickColor : function(e, element_id) {
|
|
| 256 |
+ tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
|
|
| 257 |
+ element_id : element_id, |
|
| 258 |
+ document : document, |
|
| 259 |
+ window : window, |
|
| 260 |
+ store_selection : false |
|
| 261 |
+ }); |
|
| 262 |
+ }, |
|
| 263 |
+ |
|
| 264 |
+ openBrowser : function(element_id, type, option) {
|
|
| 265 |
+ var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
|
|
| 266 |
+ var url = document.getElementById(element_id).value; |
|
| 267 |
+ |
|
| 268 |
+ tinyMCE.setWindowArg("window", window);
|
|
| 269 |
+ tinyMCE.setWindowArg("document", document);
|
|
| 270 |
+ |
|
| 271 |
+ // Call to external callback |
|
| 272 |
+ if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
|
|
| 273 |
+ alert("Callback function: " + cb + " could not be found.");
|
|
| 274 |
+ else |
|
| 275 |
+ eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
|
|
| 276 |
+ }, |
|
| 277 |
+ |
|
| 278 |
+ importClass : function(c) {
|
|
| 279 |
+ var n; |
|
| 280 |
+ |
|
| 281 |
+ window[c] = function() {};
|
|
| 282 |
+ |
|
| 283 |
+ for (n in window.opener[c].prototype) |
|
| 284 |
+ window[c].prototype[n] = window.opener[c].prototype[n]; |
|
| 285 |
+ |
|
| 286 |
+ window[c].constructor = window.opener[c].constructor; |
|
| 287 |
+ } |
|
| 288 |
+ |
|
| 289 |
+ }; |
|
| 290 |
+ |
|
| 291 |
+// Setup global instance |
|
| 292 |
+var tinyMCEPopup = new TinyMCE_Popup(); |
|
| 293 |
+ |
|
| 294 |
+tinyMCEPopup.init(); |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,275 @@ |
| 1 |
+// Some global instances |
|
| 2 |
+var tinymce = null, tinyMCEPopup, tinyMCE; |
|
| 3 |
+ |
|
| 4 |
+tinyMCEPopup = {
|
|
| 5 |
+ init : function() {
|
|
| 6 |
+ var t = this, w, ti, li, q, i, it; |
|
| 7 |
+ |
|
| 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(); |
|
| 20 |
+ tinymce = w.tinymce; |
|
| 21 |
+ tinyMCE = w.tinyMCE; |
|
| 22 |
+ t.editor = tinymce.EditorManager.activeEditor; |
|
| 23 |
+ t.params = t.editor.windowManager.params; |
|
| 24 |
+ |
|
| 25 |
+ // Setup local DOM |
|
| 26 |
+ t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
|
|
| 27 |
+ t.dom.loadCSS(t.editor.settings.popup_css); |
|
| 28 |
+ |
|
| 29 |
+ // Setup on init listeners |
|
| 30 |
+ t.listeners = []; |
|
| 31 |
+ t.onInit = {
|
|
| 32 |
+ add : function(f, s) {
|
|
| 33 |
+ t.listeners.push({func : f, scope : s});
|
|
| 34 |
+ } |
|
| 35 |
+ }; |
|
| 36 |
+ |
|
| 37 |
+ t.isWindow = !t.getWindowArg('mce_inline');
|
|
| 38 |
+ t.id = t.getWindowArg('mce_window_id');
|
|
| 39 |
+ t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window); |
|
| 40 |
+ }, |
|
| 41 |
+ |
|
| 42 |
+ getWin : function() {
|
|
| 43 |
+ return window.dialogArguments || opener || parent || top; |
|
| 44 |
+ }, |
|
| 45 |
+ |
|
| 46 |
+ getWindowArg : function(n, dv) {
|
|
| 47 |
+ var v = this.params[n]; |
|
| 48 |
+ |
|
| 49 |
+ return tinymce.is(v) ? v : dv; |
|
| 50 |
+ }, |
|
| 51 |
+ |
|
| 52 |
+ getParam : function(n, dv) {
|
|
| 53 |
+ return this.editor.getParam(n, dv); |
|
| 54 |
+ }, |
|
| 55 |
+ |
|
| 56 |
+ getLang : function(n, dv) {
|
|
| 57 |
+ return this.editor.getLang(n, dv); |
|
| 58 |
+ }, |
|
| 59 |
+ |
|
| 60 |
+ execCommand : function(cmd, ui, val, a) {
|
|
| 61 |
+ a = a || {};
|
|
| 62 |
+ a.skip_focus = 1; |
|
| 63 |
+ |
|
| 64 |
+ this.restoreSelection(); |
|
| 65 |
+ return this.editor.execCommand(cmd, ui, val, a); |
|
| 66 |
+ }, |
|
| 67 |
+ |
|
| 68 |
+ resizeToInnerSize : function() {
|
|
| 69 |
+ var t = this, n, b = document.body, vp = t.dom.getViewPort(window), dw, dh; |
|
| 70 |
+ |
|
| 71 |
+ dw = t.getWindowArg('mce_width') - vp.w;
|
|
| 72 |
+ dh = t.getWindowArg('mce_height') - vp.h;
|
|
| 73 |
+ |
|
| 74 |
+ if (t.isWindow) |
|
| 75 |
+ window.resizeBy(dw, dh); |
|
| 76 |
+ else |
|
| 77 |
+ t.editor.windowManager.resizeBy(dw, dh, t.id); |
|
| 78 |
+ }, |
|
| 79 |
+ |
|
| 80 |
+ executeOnLoad : function(s) {
|
|
| 81 |
+ this.onInit.add(function() {
|
|
| 82 |
+ eval(s); |
|
| 83 |
+ }); |
|
| 84 |
+ }, |
|
| 85 |
+ |
|
| 86 |
+ storeSelection : function() {
|
|
| 87 |
+ this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
|
|
| 88 |
+ }, |
|
| 89 |
+ |
|
| 90 |
+ restoreSelection : function() {
|
|
| 91 |
+ var t = tinyMCEPopup; |
|
| 92 |
+ |
|
| 93 |
+ if (!t.isWindow && tinymce.isIE) |
|
| 94 |
+ t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark); |
|
| 95 |
+ }, |
|
| 96 |
+ |
|
| 97 |
+ requireLangPack : function() {
|
|
| 98 |
+ var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
|
|
| 99 |
+ |
|
| 100 |
+ if (u && this.editor.settings.language) {
|
|
| 101 |
+ u += '/langs/' + this.editor.settings.language + '_dlg.js'; |
|
| 102 |
+ |
|
| 103 |
+ if (!tinymce.ScriptLoader.isDone(u)) {
|
|
| 104 |
+ document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
|
|
| 105 |
+ tinymce.ScriptLoader.markDone(u); |
|
| 106 |
+ } |
|
| 107 |
+ } |
|
| 108 |
+ }, |
|
| 109 |
+ |
|
| 110 |
+ pickColor : function(e, element_id) {
|
|
| 111 |
+ this.execCommand('mceColorPicker', true, {
|
|
| 112 |
+ color : document.getElementById(element_id).value, |
|
| 113 |
+ func : function(c) {
|
|
| 114 |
+ document.getElementById(element_id).value = c; |
|
| 115 |
+ |
|
| 116 |
+ try {
|
|
| 117 |
+ document.getElementById(element_id).onchange(); |
|
| 118 |
+ } catch (ex) {
|
|
| 119 |
+ // Try fire event, ignore errors |
|
| 120 |
+ } |
|
| 121 |
+ } |
|
| 122 |
+ }); |
|
| 123 |
+ }, |
|
| 124 |
+ |
|
| 125 |
+ openBrowser : function(element_id, type, option) {
|
|
| 126 |
+ tinyMCEPopup.restoreSelection(); |
|
| 127 |
+ this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
|
|
| 128 |
+ }, |
|
| 129 |
+ |
|
| 130 |
+ close : function() {
|
|
| 131 |
+ var t = this; |
|
| 132 |
+ |
|
| 133 |
+ // To avoid domain relaxing issue in Opera |
|
| 134 |
+ function close() {
|
|
| 135 |
+ t.editor.windowManager.close(window); |
|
| 136 |
+ tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup |
|
| 137 |
+ }; |
|
| 138 |
+ |
|
| 139 |
+ if (tinymce.isOpera) |
|
| 140 |
+ t.getWin().setTimeout(close, 0); |
|
| 141 |
+ else |
|
| 142 |
+ close(); |
|
| 143 |
+ }, |
|
| 144 |
+ |
|
| 145 |
+ // Internal functions |
|
| 146 |
+ |
|
| 147 |
+ _restoreSelection : function() {
|
|
| 148 |
+ var e = window.event.srcElement; |
|
| 149 |
+ |
|
| 150 |
+ if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button')) |
|
| 151 |
+ tinyMCEPopup.restoreSelection(); |
|
| 152 |
+ }, |
|
| 153 |
+ |
|
| 154 |
+/* _restoreSelection : function() {
|
|
| 155 |
+ var e = window.event.srcElement; |
|
| 156 |
+ |
|
| 157 |
+ // If user focus a non text input or textarea |
|
| 158 |
+ if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text') |
|
| 159 |
+ tinyMCEPopup.restoreSelection(); |
|
| 160 |
+ },*/ |
|
| 161 |
+ |
|
| 162 |
+ _onDOMLoaded : function() {
|
|
| 163 |
+ var t = this, ti = document.title, bm, h; |
|
| 164 |
+ |
|
| 165 |
+ // Translate page |
|
| 166 |
+ h = document.body.innerHTML; |
|
| 167 |
+ |
|
| 168 |
+ // Replace a=x with a="x" in IE |
|
| 169 |
+ if (tinymce.isIE) |
|
| 170 |
+ h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"') |
|
| 171 |
+ |
|
| 172 |
+ document.dir = t.editor.getParam('directionality','');
|
|
| 173 |
+ document.body.innerHTML = t.editor.translate(h); |
|
| 174 |
+ document.title = ti = t.editor.translate(ti); |
|
| 175 |
+ document.body.style.display = ''; |
|
| 176 |
+ |
|
| 177 |
+ // Restore selection in IE when focus is placed on a non textarea or input element of the type text |
|
| 178 |
+ if (tinymce.isIE) |
|
| 179 |
+ document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
|
|
| 180 |
+ |
|
| 181 |
+ t.restoreSelection(); |
|
| 182 |
+ t.resizeToInnerSize(); |
|
| 183 |
+ |
|
| 184 |
+ // Set inline title |
|
| 185 |
+ if (!t.isWindow) |
|
| 186 |
+ t.editor.windowManager.setTitle(window, ti); |
|
| 187 |
+ else |
|
| 188 |
+ window.focus(); |
|
| 189 |
+ |
|
| 190 |
+ if (!tinymce.isIE && !t.isWindow) {
|
|
| 191 |
+ tinymce.dom.Event._add(document, 'focus', function() {
|
|
| 192 |
+ t.editor.windowManager.focus(t.id) |
|
| 193 |
+ }); |
|
| 194 |
+ } |
|
| 195 |
+ |
|
| 196 |
+ // Patch for accessibility |
|
| 197 |
+ tinymce.each(t.dom.select('select'), function(e) {
|
|
| 198 |
+ e.onkeydown = tinyMCEPopup._accessHandler; |
|
| 199 |
+ }); |
|
| 200 |
+ |
|
| 201 |
+ // Call onInit |
|
| 202 |
+ // Init must be called before focus so the selection won't get lost by the focus call |
|
| 203 |
+ tinymce.each(t.listeners, function(o) {
|
|
| 204 |
+ o.func.call(o.scope, t.editor); |
|
| 205 |
+ }); |
|
| 206 |
+ |
|
| 207 |
+ // Move focus to window |
|
| 208 |
+ if (t.getWindowArg('mce_auto_focus', true)) {
|
|
| 209 |
+ window.focus(); |
|
| 210 |
+ |
|
| 211 |
+ // Focus element with mceFocus class |
|
| 212 |
+ tinymce.each(document.forms, function(f) {
|
|
| 213 |
+ tinymce.each(f.elements, function(e) {
|
|
| 214 |
+ if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
|
|
| 215 |
+ e.focus(); |
|
| 216 |
+ return false; // Break loop |
|
| 217 |
+ } |
|
| 218 |
+ }); |
|
| 219 |
+ }); |
|
| 220 |
+ } |
|
| 221 |
+ |
|
| 222 |
+ document.onkeyup = tinyMCEPopup._closeWinKeyHandler; |
|
| 223 |
+ }, |
|
| 224 |
+ |
|
| 225 |
+ _accessHandler : function(e) {
|
|
| 226 |
+ e = e || window.event; |
|
| 227 |
+ |
|
| 228 |
+ if (e.keyCode == 13 || e.keyCode == 32) {
|
|
| 229 |
+ e = e.target || e.srcElement; |
|
| 230 |
+ |
|
| 231 |
+ if (e.onchange) |
|
| 232 |
+ e.onchange(); |
|
| 233 |
+ |
|
| 234 |
+ return tinymce.dom.Event.cancel(e); |
|
| 235 |
+ } |
|
| 236 |
+ }, |
|
| 237 |
+ |
|
| 238 |
+ _closeWinKeyHandler : function(e) {
|
|
| 239 |
+ e = e || window.event; |
|
| 240 |
+ |
|
| 241 |
+ if (e.keyCode == 27) |
|
| 242 |
+ tinyMCEPopup.close(); |
|
| 243 |
+ }, |
|
| 244 |
+ |
|
| 245 |
+ _wait : function() {
|
|
| 246 |
+ var t = this, ti; |
|
| 247 |
+ |
|
| 248 |
+ if (tinymce.isIE && document.location.protocol != 'https:') {
|
|
| 249 |
+ // Fake DOMContentLoaded on IE |
|
| 250 |
+ document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
|
|
| 251 |
+ document.getElementById("__ie_onload").onreadystatechange = function() {
|
|
| 252 |
+ if (this.readyState == "complete") {
|
|
| 253 |
+ t._onDOMLoaded(); |
|
| 254 |
+ document.getElementById("__ie_onload").onreadystatechange = null; // Prevent leak
|
|
| 255 |
+ } |
|
| 256 |
+ }; |
|
| 257 |
+ } else {
|
|
| 258 |
+ if (tinymce.isIE || tinymce.isWebKit) {
|
|
| 259 |
+ ti = setInterval(function() {
|
|
| 260 |
+ if (/loaded|complete/.test(document.readyState)) {
|
|
| 261 |
+ clearInterval(ti); |
|
| 262 |
+ t._onDOMLoaded(); |
|
| 263 |
+ } |
|
| 264 |
+ }, 10); |
|
| 265 |
+ } else {
|
|
| 266 |
+ window.addEventListener('DOMContentLoaded', function() {
|
|
| 267 |
+ t._onDOMLoaded(); |
|
| 268 |
+ }, false); |
|
| 269 |
+ } |
|
| 270 |
+ } |
|
| 271 |
+ } |
|
| 272 |
+}; |
|
| 273 |
+ |
|
| 274 |
+tinyMCEPopup.init(); |
|
| 275 |
+tinyMCEPopup._wait(); // Wait for DOM Content Loaded |