2008-01-17 10:44:05 -05:00
|
|
|
// Some global instances
|
|
|
|
var tinymce = null, tinyMCEPopup, tinyMCE;
|
2005-08-22 21:33:52 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
tinyMCEPopup = {
|
|
|
|
init : function() {
|
2008-02-21 16:40:25 -05:00
|
|
|
var t = this, w, ti, li, q, i, it;
|
2008-01-17 10:44:05 -05:00
|
|
|
|
2008-02-21 16:40:25 -05:00
|
|
|
li = ('' + document.location.search).replace(/^\?/, '').split('&');
|
|
|
|
q = {};
|
|
|
|
for (i=0; i<li.length; i++) {
|
|
|
|
it = li[i].split('=');
|
|
|
|
q[unescape(it[0])] = unescape(it[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (q.mce_rdomain)
|
|
|
|
document.domain = q.mce_rdomain;
|
|
|
|
|
|
|
|
// Find window & API
|
|
|
|
w = t.getWin();
|
2008-01-17 10:44:05 -05:00
|
|
|
tinymce = w.tinymce;
|
|
|
|
tinyMCE = w.tinyMCE;
|
|
|
|
t.editor = tinymce.EditorManager.activeEditor;
|
|
|
|
t.params = t.editor.windowManager.params;
|
2008-07-31 00:01:30 -04:00
|
|
|
t.features = t.editor.windowManager.features;
|
2008-01-17 10:44:05 -05:00
|
|
|
|
|
|
|
// Setup local DOM
|
|
|
|
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
|
2008-10-02 12:30:14 -04:00
|
|
|
|
|
|
|
// Enables you to skip loading the default css
|
|
|
|
if (t.features.popup_css !== false)
|
|
|
|
t.dom.loadCSS(t.features.popup_css || t.editor.settings.popup_css);
|
2008-01-17 10:44:05 -05:00
|
|
|
|
|
|
|
// Setup on init listeners
|
|
|
|
t.listeners = [];
|
|
|
|
t.onInit = {
|
|
|
|
add : function(f, s) {
|
|
|
|
t.listeners.push({func : f, scope : s});
|
|
|
|
}
|
|
|
|
};
|
2005-08-22 21:33:52 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
t.isWindow = !t.getWindowArg('mce_inline');
|
|
|
|
t.id = t.getWindowArg('mce_window_id');
|
|
|
|
t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
2005-08-22 21:33:52 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
getWin : function() {
|
|
|
|
return window.dialogArguments || opener || parent || top;
|
|
|
|
},
|
2005-11-05 22:30:11 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
getWindowArg : function(n, dv) {
|
|
|
|
var v = this.params[n];
|
2005-08-22 21:33:52 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
return tinymce.is(v) ? v : dv;
|
|
|
|
},
|
2005-08-22 21:33:52 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
getParam : function(n, dv) {
|
|
|
|
return this.editor.getParam(n, dv);
|
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
getLang : function(n, dv) {
|
|
|
|
return this.editor.getLang(n, dv);
|
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-31 13:10:46 -05:00
|
|
|
execCommand : function(cmd, ui, val, a) {
|
2008-02-21 16:40:25 -05:00
|
|
|
a = a || {};
|
|
|
|
a.skip_focus = 1;
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
this.restoreSelection();
|
2008-02-21 16:40:25 -05:00
|
|
|
return this.editor.execCommand(cmd, ui, val, a);
|
2008-01-17 10:44:05 -05:00
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
resizeToInnerSize : function() {
|
|
|
|
var t = this, n, b = document.body, vp = t.dom.getViewPort(window), dw, dh;
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
dw = t.getWindowArg('mce_width') - vp.w;
|
|
|
|
dh = t.getWindowArg('mce_height') - vp.h;
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (t.isWindow)
|
|
|
|
window.resizeBy(dw, dh);
|
|
|
|
else
|
|
|
|
t.editor.windowManager.resizeBy(dw, dh, t.id);
|
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
executeOnLoad : function(s) {
|
|
|
|
this.onInit.add(function() {
|
|
|
|
eval(s);
|
|
|
|
});
|
|
|
|
},
|
2005-11-05 22:30:11 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
storeSelection : function() {
|
|
|
|
this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
|
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
restoreSelection : function() {
|
|
|
|
var t = tinyMCEPopup;
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (!t.isWindow && tinymce.isIE)
|
|
|
|
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
|
|
|
|
},
|
2005-11-05 22:30:11 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
requireLangPack : function() {
|
|
|
|
var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
|
2005-11-05 22:30:11 -05:00
|
|
|
|
2008-02-25 14:03:35 -05:00
|
|
|
if (u && this.editor.settings.language) {
|
|
|
|
u += '/langs/' + this.editor.settings.language + '_dlg.js';
|
|
|
|
|
|
|
|
if (!tinymce.ScriptLoader.isDone(u)) {
|
2008-04-14 18:19:04 -04:00
|
|
|
document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
|
2008-02-25 14:03:35 -05:00
|
|
|
tinymce.ScriptLoader.markDone(u);
|
|
|
|
}
|
|
|
|
}
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
pickColor : function(e, element_id) {
|
|
|
|
this.execCommand('mceColorPicker', true, {
|
|
|
|
color : document.getElementById(element_id).value,
|
|
|
|
func : function(c) {
|
|
|
|
document.getElementById(element_id).value = c;
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-31 13:10:46 -05:00
|
|
|
try {
|
2008-01-17 10:44:05 -05:00
|
|
|
document.getElementById(element_id).onchange();
|
2008-01-31 13:10:46 -05:00
|
|
|
} catch (ex) {
|
|
|
|
// Try fire event, ignore errors
|
|
|
|
}
|
2006-11-20 19:55:06 -05:00
|
|
|
}
|
2008-01-17 10:44:05 -05:00
|
|
|
});
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
openBrowser : function(element_id, type, option) {
|
|
|
|
tinyMCEPopup.restoreSelection();
|
|
|
|
this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
|
|
|
|
2008-07-31 00:01:30 -04:00
|
|
|
confirm : function(t, cb, s) {
|
|
|
|
this.editor.windowManager.confirm(t, cb, s, window);
|
|
|
|
},
|
|
|
|
|
|
|
|
alert : function(tx, cb, s) {
|
|
|
|
this.editor.windowManager.alert(tx, cb, s, window);
|
|
|
|
},
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
close : function() {
|
|
|
|
var t = this;
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-02-21 16:40:25 -05:00
|
|
|
// To avoid domain relaxing issue in Opera
|
|
|
|
function close() {
|
2008-06-04 11:31:14 -04:00
|
|
|
t.editor.windowManager.close(window);
|
2008-02-21 16:40:25 -05:00
|
|
|
tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
|
|
|
|
};
|
|
|
|
|
|
|
|
if (tinymce.isOpera)
|
|
|
|
t.getWin().setTimeout(close, 0);
|
|
|
|
else
|
|
|
|
close();
|
2008-01-17 10:44:05 -05:00
|
|
|
},
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// Internal functions
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
_restoreSelection : function() {
|
|
|
|
var e = window.event.srcElement;
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button'))
|
|
|
|
tinyMCEPopup.restoreSelection();
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
/* _restoreSelection : function() {
|
|
|
|
var e = window.event.srcElement;
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// If user focus a non text input or textarea
|
|
|
|
if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text')
|
|
|
|
tinyMCEPopup.restoreSelection();
|
|
|
|
},*/
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
_onDOMLoaded : function() {
|
2008-10-02 12:30:14 -04:00
|
|
|
var t = this, ti = document.title, bm, h, nv;
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// Translate page
|
2008-10-02 12:30:14 -04:00
|
|
|
if (t.features.translate_i18n !== false) {
|
|
|
|
h = document.body.innerHTML;
|
2006-11-20 19:55:06 -05:00
|
|
|
|
2008-10-02 12:30:14 -04:00
|
|
|
// Replace a=x with a="x" in IE
|
|
|
|
if (tinymce.isIE)
|
|
|
|
h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
|
|
|
|
|
|
|
|
document.dir = t.editor.getParam('directionality','');
|
|
|
|
|
|
|
|
if ((nv = t.editor.translate(h)) && nv != h)
|
|
|
|
document.body.innerHTML = nv;
|
|
|
|
|
|
|
|
if ((nv = t.editor.translate(ti)) && nv != ti)
|
|
|
|
document.title = ti = nv;
|
|
|
|
}
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
document.body.style.display = '';
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// Restore selection in IE when focus is placed on a non textarea or input element of the type text
|
|
|
|
if (tinymce.isIE)
|
|
|
|
document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
|
2007-05-28 15:30:05 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
t.restoreSelection();
|
|
|
|
t.resizeToInnerSize();
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-03-12 18:47:11 -04:00
|
|
|
// Set inline title
|
|
|
|
if (!t.isWindow)
|
2008-06-04 11:31:14 -04:00
|
|
|
t.editor.windowManager.setTitle(window, ti);
|
2008-03-12 18:47:11 -04:00
|
|
|
else
|
|
|
|
window.focus();
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (!tinymce.isIE && !t.isWindow) {
|
|
|
|
tinymce.dom.Event._add(document, 'focus', function() {
|
|
|
|
t.editor.windowManager.focus(t.id)
|
|
|
|
});
|
|
|
|
}
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// Patch for accessibility
|
|
|
|
tinymce.each(t.dom.select('select'), function(e) {
|
|
|
|
e.onkeydown = tinyMCEPopup._accessHandler;
|
|
|
|
});
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-03-12 18:47:11 -04:00
|
|
|
// 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);
|
|
|
|
});
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
// Move focus to window
|
2008-03-12 18:47:11 -04:00
|
|
|
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) {
|
2008-03-21 18:13:03 -04:00
|
|
|
if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
|
2008-03-12 18:47:11 -04:00
|
|
|
e.focus();
|
|
|
|
return false; // Break loop
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2008-04-14 18:19:04 -04:00
|
|
|
document.onkeyup = tinyMCEPopup._closeWinKeyHandler;
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
_accessHandler : function(e) {
|
2008-03-12 18:47:11 -04:00
|
|
|
e = e || window.event;
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (e.keyCode == 13 || e.keyCode == 32) {
|
|
|
|
e = e.target || e.srcElement;
|
2006-03-30 02:50:33 -05:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
if (e.onchange)
|
|
|
|
e.onchange();
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
return tinymce.dom.Event.cancel(e);
|
|
|
|
}
|
2006-11-20 19:55:06 -05:00
|
|
|
},
|
2005-09-26 02:52:30 -04:00
|
|
|
|
2008-03-12 18:47:11 -04:00
|
|
|
_closeWinKeyHandler : function(e) {
|
|
|
|
e = e || window.event;
|
|
|
|
|
|
|
|
if (e.keyCode == 27)
|
|
|
|
tinyMCEPopup.close();
|
|
|
|
},
|
|
|
|
|
2008-01-17 10:44:05 -05:00
|
|
|
_wait : function() {
|
|
|
|
var t = this, ti;
|
|
|
|
|
|
|
|
if (tinymce.isIE && document.location.protocol != 'https:') {
|
|
|
|
// Fake DOMContentLoaded on IE
|
|
|
|
document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
|
|
|
|
document.getElementById("__ie_onload").onreadystatechange = function() {
|
|
|
|
if (this.readyState == "complete") {
|
|
|
|
t._onDOMLoaded();
|
|
|
|
document.getElementById("__ie_onload").onreadystatechange = null; // Prevent leak
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (tinymce.isIE || tinymce.isWebKit) {
|
|
|
|
ti = setInterval(function() {
|
|
|
|
if (/loaded|complete/.test(document.readyState)) {
|
|
|
|
clearInterval(ti);
|
|
|
|
t._onDOMLoaded();
|
|
|
|
}
|
|
|
|
}, 10);
|
|
|
|
} else {
|
|
|
|
window.addEventListener('DOMContentLoaded', function() {
|
|
|
|
t._onDOMLoaded();
|
|
|
|
}, false);
|
|
|
|
}
|
|
|
|
}
|
2006-11-20 19:55:06 -05:00
|
|
|
}
|
2008-01-17 10:44:05 -05:00
|
|
|
};
|
2005-09-26 02:52:30 -04:00
|
|
|
|
|
|
|
tinyMCEPopup.init();
|
2008-01-17 10:44:05 -05:00
|
|
|
tinyMCEPopup._wait(); // Wait for DOM Content Loaded
|