X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..refs/tags/wordpress-4.4:/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 6c8f73b6..cf516a4a 100644 --- a/wp-includes/js/tinymce/tiny_mce_popup.js +++ b/wp-includes/js/tinymce/tiny_mce_popup.js @@ -1,132 +1,316 @@ -// 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 (settings.language !== false) {
+ lang = settings.language || "en";
+ }
- if (u && this.editor.settings.language) {
- u += '/langs/' + this.editor.settings.language + '_dlg.js';
+ if (url && lang && self.features.translate_i18n !== false && settings.language_load !== false) {
+ url += '/langs/' + lang + '_dlg.js';
- if (!tinymce.ScriptLoader.isDone(u)) {
- document.write('');
- tinymce.ScriptLoader.markDone(u);
+ 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,
- func : function(c) {
- document.getElementById(element_id).value = c;
-
- try {
- document.getElementById(element_id).onchange();
- } catch (ex) {
- // Try fire event, ignore errors
- }
- }
- });
+ var el = document.getElementById(element_id), colorPickerCallback = this.editor.settings.color_picker_callback;
+ if (colorPickerCallback) {
+ colorPickerCallback.call(
+ this.editor,
+ function (value) {
+ el.value = value;
+ try {
+ el.onchange();
+ } catch (ex) {
+ // Try fire event, ignore errors
+ }
+ },
+ el.value
+ );
+ }
},
- 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;
@@ -134,21 +318,23 @@ tinyMCEPopup = {
function close() {
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
+ // Internal functions
_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 +346,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 ? tinymce.settings : t.editor.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','');
+
+ if ((nv = t.editor.translate(h)) && nv != h) {
+ document.body.innerHTML = nv;
+ }
+
+ if ((nv = t.editor.translate(ti)) && nv != ti) {
+ document.title = ti = nv;
+ }
+ }
- // Replace a=x with a="x" in IE
- if (tinymce.isIE)
- h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+ 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)
+ if (!t.isWindow) {
t.editor.windowManager.setTitle(window, ti);
- else
+ } 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 +443,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 +468,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;
-
- if (tinymce.isIE && document.location.protocol != 'https:') {
- // Fake DOMContentLoaded on IE
- document.write('