X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/177fd6fefd2e3d5a0ea6591c71d660cabdb3c1a4..41578db67d72562346e4dbb2a14889b23d522813:/wp-includes/js/tinymce/tiny_mce_popup.js diff --git a/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-includes/js/tinymce/tiny_mce_popup.js index 84cbded5..9150f865 100644 --- a/wp-includes/js/tinymce/tiny_mce_popup.js +++ b/wp-includes/js/tinymce/tiny_mce_popup.js @@ -1,112 +1,253 @@ -// Some global instances -var tinymce = null, tinyMCEPopup, tinyMCE; - -tinyMCEPopup = { - init : function() { - var t = this, w, ti, li, q, i, it; - - li = ('' + document.location.search).replace(/^\?/, '').split('&'); - q = {}; - for (i=0; i
_dlg.js lang pack file.
+ *
+ * @method requireLangPack
+ */
requireLangPack : function() {
- var u = this.getWindowArg('plugin_url') || this.getWindowArg('theme_url');
+ var self = this, url = self.getWindowArg('plugin_url') || self.getWindowArg('theme_url'), settings = self.editor.settings, lang;
- if (u && this.editor.settings.language) {
- u += '/langs/' + this.editor.settings.language + '_dlg.js';
+ if (settings.language !== false) {
+ lang = settings.language || "en";
+ }
- if (!tinymce.ScriptLoader.isDone(u)) {
- document.write('');
- tinymce.ScriptLoader.markDone(u);
+ if (url && lang && self.features.translate_i18n !== false && settings.language_load !== false) {
+ url += '/langs/' + lang + '_dlg.js';
+
+ if (!tinymce.ScriptLoader.isDone(url)) {
+ document.write('');
+ tinymce.ScriptLoader.markDone(url);
}
}
},
+ /**
+ * Executes a color picker on the specified element id. When the user
+ * then selects a color it will be set as the value of the specified element.
+ *
+ * @method pickColor
+ * @param {DOMEvent} e DOM event object.
+ * @param {string} element_id Element id to be filled with the color value from the picker.
+ */
pickColor : function(e, element_id) {
this.execCommand('mceColorPicker', true, {
color : document.getElementById(element_id).value,
@@ -122,24 +263,65 @@ tinyMCEPopup = {
});
},
- openBrowser : function(element_id, type, option) {
+ /**
+ * Opens a filebrowser/imagebrowser this will set the output value from
+ * the browser as a value on the specified element.
+ *
+ * @method openBrowser
+ * @param {string} element_id Id of the element to set value in.
+ * @param {string} type Type of browser to open image/file/flash.
+ * @param {string} option Option name to get the file_broswer_callback function name from.
+ */
+ openBrowser : function(element_id, type) {
tinyMCEPopup.restoreSelection();
this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
},
+ /**
+ * Creates a confirm dialog. Please don't use the blocking behavior of this
+ * native version use the callback method instead then it can be extended.
+ *
+ * @method confirm
+ * @param {String} t Title for the new confirm dialog.
+ * @param {function} cb Callback function to be executed after the user has selected ok or cancel.
+ * @param {Object} s Optional scope to execute the callback in.
+ */
+ confirm : function(t, cb, s) {
+ this.editor.windowManager.confirm(t, cb, s, window);
+ },
+
+ /**
+ * Creates a alert dialog. Please don't use the blocking behavior of this
+ * native version use the callback method instead then it can be extended.
+ *
+ * @method alert
+ * @param {String} tx Title for the new alert dialog.
+ * @param {function} cb Callback function to be executed after the user has selected ok.
+ * @param {Object} s Optional scope to execute the callback in.
+ */
+ alert : function(tx, cb, s) {
+ this.editor.windowManager.alert(tx, cb, s, window);
+ },
+
+ /**
+ * Closes the current window.
+ *
+ * @method close
+ */
close : function() {
var t = this;
// 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
- };
+ }
- if (tinymce.isOpera)
+ if (tinymce.isOpera) {
t.getWin().setTimeout(close, 0);
- else
+ } else {
close();
+ }
},
// Internal functions
@@ -147,8 +329,9 @@ tinyMCEPopup = {
_restoreSelection : function() {
var e = window.event.srcElement;
- if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button'))
+ if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button')) {
tinyMCEPopup.restoreSelection();
+ }
},
/* _restoreSelection : function() {
@@ -160,36 +343,73 @@ tinyMCEPopup = {
},*/
_onDOMLoaded : function() {
- var t = this, ti = document.title, bm, h;
+ var t = tinyMCEPopup, ti = document.title, h, nv;
// Translate page
- h = document.body.innerHTML;
+ if (t.features.translate_i18n !== false) {
+ var map = {
+ "update": "Ok",
+ "insert": "Ok",
+ "cancel": "Cancel",
+ "not_set": "--",
+ "class_name": "Class name",
+ "browse": "Browse"
+ };
+
+ var langCode = tinymce.settings.language || 'en';
+ for (var key in map) {
+ tinymce.i18n.data[langCode + "." + key] = tinymce.i18n.translate(map[key]);
+ }
+
+ h = document.body.innerHTML;
+
+ // 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','');
- // Replace a=x with a="x" in IE
- if (tinymce.isIE)
- h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+ if ((nv = t.editor.translate(h)) && nv != h) {
+ document.body.innerHTML = nv;
+ }
+
+ if ((nv = t.editor.translate(ti)) && nv != ti) {
+ document.title = ti = nv;
+ }
+ }
+
+ if (!t.editor.getParam('browser_preferred_colors', false) || !t.isWindow) {
+ t.dom.addClass(document.body, 'forceColors');
+ }
- document.dir = t.editor.getParam('directionality','');
- document.body.innerHTML = t.editor.translate(h);
- document.title = ti = t.editor.translate(ti);
document.body.style.display = '';
// 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);
+ if (tinymce.Env.ie) {
+ if (tinymce.Env.ie < 11) {
+ document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
+
+ // Add base target element for it since it would fail with modal dialogs
+ t.dom.add(t.dom.select('head')[0], 'base', {target: '_self'});
+ } else {
+ document.addEventListener('mouseup', tinyMCEPopup._restoreSelection, false);
+ }
+ }
t.restoreSelection();
t.resizeToInnerSize();
// Set inline title
- if (!t.isWindow)
- t.editor.windowManager.setTitle(ti, t.id);
- else
+ if (!t.isWindow) {
+ t.editor.windowManager.setTitle(window, ti);
+ } else {
window.focus();
+ }
if (!tinymce.isIE && !t.isWindow) {
- tinymce.dom.Event._add(document, 'focus', function() {
- t.editor.windowManager.focus(t.id)
+ t.dom.bind(document, 'focus', function() {
+ t.editor.windowManager.focus(t.id);
});
}
@@ -220,16 +440,23 @@ tinyMCEPopup = {
}
document.onkeyup = tinyMCEPopup._closeWinKeyHandler;
+
+ if ('textContent' in document) {
+ t.uiWindow.getEl('head').firstChild.textContent = document.title;
+ } else {
+ t.uiWindow.getEl('head').firstChild.innerText = document.title;
+ }
},
_accessHandler : function(e) {
e = e || window.event;
if (e.keyCode == 13 || e.keyCode == 32) {
- e = e.target || e.srcElement;
+ var elm = e.target || e.srcElement;
- if (e.onchange)
- e.onchange();
+ if (elm.onchange) {
+ elm.onchange();
+ }
return tinymce.dom.Event.cancel(e);
}
@@ -238,38 +465,75 @@ tinyMCEPopup = {
_closeWinKeyHandler : function(e) {
e = e || window.event;
- if (e.keyCode == 27)
+ if (e.keyCode == 27) {
tinyMCEPopup.close();
+ }
},
- _wait : function() {
- var t = this, ti;
+ _eventProxy: function(id) {
+ return function(evt) {
+ tinyMCEPopup.dom.events.callNativeHandler(id, evt);
+ };
+ }
+};
+
+tinyMCEPopup.init();
- if (tinymce.isIE && document.location.protocol != 'https:') {
- // Fake DOMContentLoaded on IE
- document.write('