TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
/**
|
|
|
|
* plugin.js
|
|
|
|
*
|
|
|
|
* Released under LGPL License.
|
2015-07-01 02:52:25 +02:00
|
|
|
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
*
|
|
|
|
* License: http://www.tinymce.com/license
|
|
|
|
* Contributing: http://www.tinymce.com/contributing
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*global tinymce:true */
|
|
|
|
|
|
|
|
tinymce.PluginManager.add('image', function(editor) {
|
|
|
|
function getImageSize(url, callback) {
|
|
|
|
var img = document.createElement('img');
|
|
|
|
|
|
|
|
function done(width, height) {
|
2014-01-31 01:06:12 +01:00
|
|
|
if (img.parentNode) {
|
|
|
|
img.parentNode.removeChild(img);
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
callback({width: width, height: height});
|
|
|
|
}
|
|
|
|
|
|
|
|
img.onload = function() {
|
2015-07-01 02:52:25 +02:00
|
|
|
done(Math.max(img.width, img.clientWidth), Math.max(img.height, img.clientHeight));
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
img.onerror = function() {
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
|
|
|
|
var style = img.style;
|
|
|
|
style.visibility = 'hidden';
|
|
|
|
style.position = 'fixed';
|
|
|
|
style.bottom = style.left = 0;
|
|
|
|
style.width = style.height = 'auto';
|
|
|
|
|
|
|
|
document.body.appendChild(img);
|
2014-01-31 01:06:12 +01:00
|
|
|
img.src = url;
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
2014-06-18 01:49:15 +02:00
|
|
|
function buildListItems(inputList, itemCallback, startItems) {
|
|
|
|
function appendItems(values, output) {
|
|
|
|
output = output || [];
|
|
|
|
|
|
|
|
tinymce.each(values, function(item) {
|
|
|
|
var menuItem = {text: item.text || item.title};
|
|
|
|
|
|
|
|
if (item.menu) {
|
|
|
|
menuItem.menu = appendItems(item.menu);
|
|
|
|
} else {
|
|
|
|
menuItem.value = item.value;
|
|
|
|
itemCallback(menuItem);
|
|
|
|
}
|
2014-04-02 00:46:14 +02:00
|
|
|
|
2014-06-18 01:49:15 +02:00
|
|
|
output.push(menuItem);
|
|
|
|
});
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
return appendItems(inputList, startItems || []);
|
2014-04-02 00:46:14 +02:00
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
function createImageList(callback) {
|
|
|
|
return function() {
|
|
|
|
var imageList = editor.settings.image_list;
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
if (typeof imageList == "string") {
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
tinymce.util.XHR.send({
|
|
|
|
url: imageList,
|
|
|
|
success: function(text) {
|
|
|
|
callback(tinymce.util.JSON.parse(text));
|
|
|
|
}
|
|
|
|
});
|
2015-03-10 20:20:28 +01:00
|
|
|
} else if (typeof imageList == "function") {
|
2014-05-24 03:44:15 +02:00
|
|
|
imageList(callback);
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
} else {
|
|
|
|
callback(imageList);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showDialog(imageList) {
|
2016-01-20 05:18:33 +01:00
|
|
|
var win, data = {}, dom = editor.dom, imgElm, figureElm;
|
2014-06-18 01:49:15 +02:00
|
|
|
var width, height, imageListCtrl, classListCtrl, imageDimensions = editor.settings.image_dimensions !== false;
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
2014-01-31 01:06:12 +01:00
|
|
|
function recalcSize() {
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
var widthCtrl, heightCtrl, newWidth, newHeight;
|
|
|
|
|
|
|
|
widthCtrl = win.find('#width')[0];
|
|
|
|
heightCtrl = win.find('#height')[0];
|
|
|
|
|
2014-06-18 01:49:15 +02:00
|
|
|
if (!widthCtrl || !heightCtrl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
newWidth = widthCtrl.value();
|
|
|
|
newHeight = heightCtrl.value();
|
|
|
|
|
|
|
|
if (win.find('#constrain')[0].checked() && width && height && newWidth && newHeight) {
|
2014-01-31 01:06:12 +01:00
|
|
|
if (width != newWidth) {
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
newHeight = Math.round((newWidth / width) * newHeight);
|
2015-03-10 20:20:28 +01:00
|
|
|
|
|
|
|
if (!isNaN(newHeight)) {
|
|
|
|
heightCtrl.value(newHeight);
|
|
|
|
}
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
} else {
|
|
|
|
newWidth = Math.round((newHeight / height) * newWidth);
|
2015-03-10 20:20:28 +01:00
|
|
|
|
|
|
|
if (!isNaN(newWidth)) {
|
|
|
|
widthCtrl.value(newWidth);
|
|
|
|
}
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
width = newWidth;
|
|
|
|
height = newHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmitForm() {
|
2016-01-20 05:18:33 +01:00
|
|
|
var figureElm, oldImg;
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
function waitLoad(imgElm) {
|
|
|
|
function selectImage() {
|
|
|
|
imgElm.onload = imgElm.onerror = null;
|
2014-06-18 01:49:15 +02:00
|
|
|
|
|
|
|
if (editor.selection) {
|
|
|
|
editor.selection.select(imgElm);
|
|
|
|
editor.nodeChanged();
|
|
|
|
}
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
imgElm.onload = function() {
|
2014-06-18 01:49:15 +02:00
|
|
|
if (!data.width && !data.height && imageDimensions) {
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
dom.setAttribs(imgElm, {
|
|
|
|
width: imgElm.clientWidth,
|
|
|
|
height: imgElm.clientHeight
|
|
|
|
});
|
|
|
|
//WP
|
|
|
|
editor.fire( 'wpNewImageRefresh', { node: imgElm } );
|
|
|
|
}
|
|
|
|
|
|
|
|
selectImage();
|
|
|
|
};
|
|
|
|
|
|
|
|
imgElm.onerror = selectImage;
|
|
|
|
}
|
2014-04-02 00:46:14 +02:00
|
|
|
|
2014-01-31 01:06:12 +01:00
|
|
|
updateStyle();
|
|
|
|
recalcSize();
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
2014-03-04 02:57:15 +01:00
|
|
|
data = tinymce.extend(data, win.toJSON());
|
2016-01-20 05:18:33 +01:00
|
|
|
var wpcaption = data.wpcaption; // WP
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
2014-04-02 00:46:14 +02:00
|
|
|
if (!data.alt) {
|
|
|
|
data.alt = '';
|
|
|
|
}
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
if (!data.title) {
|
|
|
|
data.title = '';
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
if (data.width === '') {
|
|
|
|
data.width = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.height === '') {
|
|
|
|
data.height = null;
|
|
|
|
}
|
|
|
|
|
2014-05-24 03:44:15 +02:00
|
|
|
if (!data.style) {
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
data.style = null;
|
|
|
|
}
|
|
|
|
|
2014-06-18 01:49:15 +02:00
|
|
|
// Setup new data excluding style properties
|
2015-03-10 20:20:28 +01:00
|
|
|
/*eslint dot-notation: 0*/
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
data = {
|
|
|
|
src: data.src,
|
|
|
|
alt: data.alt,
|
2015-03-10 20:20:28 +01:00
|
|
|
title: data.title,
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
width: data.width,
|
|
|
|
height: data.height,
|
2014-03-04 02:57:15 +01:00
|
|
|
style: data.style,
|
2016-01-20 05:18:33 +01:00
|
|
|
caption: data.caption,
|
2014-03-04 02:57:15 +01:00
|
|
|
"class": data["class"]
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
editor.undoManager.transact(function() {
|
|
|
|
// WP
|
2016-01-20 05:18:33 +01:00
|
|
|
var eventData = { node: imgElm, data: data, wpcaption: wpcaption };
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
|
|
|
editor.fire( 'wpImageFormSubmit', { imgData: eventData } );
|
|
|
|
|
|
|
|
if ( eventData.cancel ) {
|
|
|
|
waitLoad( eventData.node );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// WP end
|
|
|
|
|
|
|
|
if (!data.src) {
|
|
|
|
if (imgElm) {
|
|
|
|
dom.remove(imgElm);
|
2014-03-04 02:57:15 +01:00
|
|
|
editor.focus();
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
editor.nodeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
if (data.title === "") {
|
|
|
|
data.title = null;
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
if (!imgElm) {
|
|
|
|
data.id = '__mcenew';
|
2014-01-31 01:06:12 +01:00
|
|
|
editor.focus();
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
editor.selection.setContent(dom.createHTML('img', data));
|
|
|
|
imgElm = dom.get('__mcenew');
|
|
|
|
dom.setAttrib(imgElm, 'id', null);
|
|
|
|
} else {
|
|
|
|
dom.setAttribs(imgElm, data);
|
2016-01-20 05:18:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
editor.editorUpload.uploadImagesAuto();
|
|
|
|
|
|
|
|
if (data.caption === false) {
|
|
|
|
if (dom.is(imgElm.parentNode, 'figure.image')) {
|
|
|
|
figureElm = imgElm.parentNode;
|
|
|
|
dom.insertAfter(imgElm, figureElm);
|
|
|
|
dom.remove(figureElm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isTextBlock(node) {
|
|
|
|
return editor.schema.getTextBlockElements()[node.nodeName];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.caption === true) {
|
|
|
|
if (!dom.is(imgElm.parentNode, 'figure.image')) {
|
|
|
|
oldImg = imgElm;
|
|
|
|
imgElm = imgElm.cloneNode(true);
|
|
|
|
figureElm = dom.create('figure', {'class': 'image'});
|
|
|
|
figureElm.appendChild(imgElm);
|
|
|
|
figureElm.appendChild(dom.create('figcaption', {contentEditable: true}, 'Caption'));
|
|
|
|
figureElm.contentEditable = false;
|
|
|
|
|
|
|
|
var textBlock = dom.getParent(oldImg, isTextBlock);
|
|
|
|
if (textBlock) {
|
|
|
|
dom.split(textBlock, oldImg, figureElm);
|
|
|
|
} else {
|
|
|
|
dom.replace(figureElm, oldImg);
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.selection.select(figureElm);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
waitLoad(imgElm);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function removePixelSuffix(value) {
|
|
|
|
if (value) {
|
|
|
|
value = value.replace(/px$/, '');
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2014-07-17 02:59:16 +02:00
|
|
|
function srcChange(e) {
|
2015-03-10 20:20:28 +01:00
|
|
|
var srcURL, prependURL, absoluteURLPattern, meta = e.meta || {};
|
2014-07-17 02:59:16 +02:00
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
if (imageListCtrl) {
|
|
|
|
imageListCtrl.value(editor.convertURL(this.value(), 'src'));
|
|
|
|
}
|
|
|
|
|
2014-07-17 02:59:16 +02:00
|
|
|
tinymce.each(meta, function(value, key) {
|
|
|
|
win.find('#' + key).value(value);
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
});
|
2014-07-17 02:59:16 +02:00
|
|
|
|
|
|
|
if (!meta.width && !meta.height) {
|
2015-03-10 20:20:28 +01:00
|
|
|
srcURL = editor.convertURL(this.value(), 'src');
|
2014-12-01 00:28:24 +01:00
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
// Pattern test the src url and make sure we haven't already prepended the url
|
|
|
|
prependURL = editor.settings.image_prepend_url;
|
|
|
|
absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
|
|
if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) {
|
|
|
|
srcURL = prependURL + srcURL;
|
2014-12-01 00:28:24 +01:00
|
|
|
}
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
this.value(srcURL);
|
|
|
|
|
|
|
|
getImageSize(editor.documentBaseURI.toAbsolute(this.value()), function(data) {
|
2014-07-17 02:59:16 +02:00
|
|
|
if (data.width && data.height && imageDimensions) {
|
|
|
|
width = data.width;
|
|
|
|
height = data.height;
|
|
|
|
|
|
|
|
win.find('#width').value(width);
|
|
|
|
win.find('#height').value(height);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
2016-01-20 05:18:33 +01:00
|
|
|
imgElm = editor.selection.getNode();
|
|
|
|
figureElm = dom.getParent(imgElm, 'figure.image');
|
|
|
|
if (figureElm) {
|
|
|
|
imgElm = dom.select('img', figureElm)[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imgElm && (imgElm.nodeName != 'IMG' || imgElm.getAttribute('data-mce-object') || imgElm.getAttribute('data-mce-placeholder'))) {
|
|
|
|
imgElm = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imgElm) {
|
|
|
|
width = dom.getAttrib(imgElm, 'width');
|
|
|
|
height = dom.getAttrib(imgElm, 'height');
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
|
|
|
data = {
|
|
|
|
src: dom.getAttrib(imgElm, 'src'),
|
|
|
|
alt: dom.getAttrib(imgElm, 'alt'),
|
2015-03-10 20:20:28 +01:00
|
|
|
title: dom.getAttrib(imgElm, 'title'),
|
2014-03-04 02:57:15 +01:00
|
|
|
"class": dom.getAttrib(imgElm, 'class'),
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
width: width,
|
2016-01-20 05:18:33 +01:00
|
|
|
height: height,
|
|
|
|
caption: !!figureElm
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// WP
|
|
|
|
editor.fire( 'wpLoadImageData', { imgData: { data: data, node: imgElm } } );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imageList) {
|
|
|
|
imageListCtrl = {
|
|
|
|
type: 'listbox',
|
|
|
|
label: 'Image list',
|
2014-06-18 01:49:15 +02:00
|
|
|
values: buildListItems(
|
|
|
|
imageList,
|
|
|
|
function(item) {
|
|
|
|
item.value = editor.convertURL(item.value || item.url, 'src');
|
|
|
|
},
|
|
|
|
[{text: 'None', value: ''}]
|
|
|
|
),
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
value: data.src && editor.convertURL(data.src, 'src'),
|
|
|
|
onselect: function(e) {
|
|
|
|
var altCtrl = win.find('#alt');
|
|
|
|
|
|
|
|
if (!altCtrl.value() || (e.lastControl && altCtrl.value() == e.lastControl.text())) {
|
|
|
|
altCtrl.value(e.control.text());
|
|
|
|
}
|
|
|
|
|
2014-05-29 02:59:15 +02:00
|
|
|
win.find('#src').value(e.control.value()).fire('change');
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
},
|
|
|
|
onPostRender: function() {
|
2015-07-01 02:52:25 +02:00
|
|
|
/*eslint consistent-this: 0*/
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
imageListCtrl = this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-03-04 02:57:15 +01:00
|
|
|
if (editor.settings.image_class_list) {
|
|
|
|
classListCtrl = {
|
|
|
|
name: 'class',
|
|
|
|
type: 'listbox',
|
|
|
|
label: 'Class',
|
2014-06-18 01:49:15 +02:00
|
|
|
values: buildListItems(
|
|
|
|
editor.settings.image_class_list,
|
|
|
|
function(item) {
|
|
|
|
if (item.value) {
|
|
|
|
item.textStyle = function() {
|
|
|
|
return editor.formatter.getCssText({inline: 'img', classes: [item.value]});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2014-03-04 02:57:15 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
// General settings shared between simple and advanced dialogs
|
|
|
|
var generalFormItems = [
|
2014-07-17 02:59:16 +02:00
|
|
|
{
|
|
|
|
name: 'src',
|
|
|
|
type: 'filepicker',
|
|
|
|
filetype: 'image',
|
|
|
|
label: 'Source',
|
|
|
|
autofocus: true,
|
|
|
|
onchange: srcChange
|
|
|
|
},
|
2014-04-02 00:46:14 +02:00
|
|
|
imageListCtrl
|
|
|
|
];
|
|
|
|
|
|
|
|
if (editor.settings.image_description !== false) {
|
|
|
|
generalFormItems.push({name: 'alt', type: 'textbox', label: 'Image description'});
|
|
|
|
}
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
if (editor.settings.image_title) {
|
|
|
|
generalFormItems.push({name: 'title', type: 'textbox', label: 'Image Title'});
|
|
|
|
}
|
|
|
|
|
2014-06-18 01:49:15 +02:00
|
|
|
if (imageDimensions) {
|
2014-04-02 00:46:14 +02:00
|
|
|
generalFormItems.push({
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
type: 'container',
|
|
|
|
label: 'Dimensions',
|
|
|
|
layout: 'flex',
|
|
|
|
direction: 'row',
|
|
|
|
align: 'center',
|
|
|
|
spacing: 5,
|
|
|
|
items: [
|
2014-03-04 02:57:15 +01:00
|
|
|
{name: 'width', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Width'},
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
{type: 'label', text: 'x'},
|
2014-03-04 02:57:15 +01:00
|
|
|
{name: 'height', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Height'},
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
{name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions'}
|
|
|
|
]
|
2014-04-02 00:46:14 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
generalFormItems.push(classListCtrl);
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
2016-01-20 05:18:33 +01:00
|
|
|
if (editor.settings.image_caption && tinymce.Env.ceFalse) {
|
|
|
|
generalFormItems.push({name: 'caption', type: 'checkbox', label: 'Caption'});
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
// WP
|
|
|
|
editor.fire( 'wpLoadImageForm', { data: generalFormItems } );
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
function mergeMargins(css) {
|
|
|
|
if (css.margin) {
|
|
|
|
|
|
|
|
var splitMargin = css.margin.split(" ");
|
|
|
|
|
|
|
|
switch (splitMargin.length) {
|
|
|
|
case 1: //margin: toprightbottomleft;
|
|
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
|
|
css['margin-right'] = css['margin-right'] || splitMargin[0];
|
|
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
|
|
|
css['margin-left'] = css['margin-left'] || splitMargin[0];
|
|
|
|
break;
|
|
|
|
case 2: //margin: topbottom rightleft;
|
|
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
|
|
|
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
|
|
|
break;
|
|
|
|
case 3: //margin: top rightleft bottom;
|
|
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
|
|
|
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
|
|
|
break;
|
|
|
|
case 4: //margin: top right bottom left;
|
|
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
|
|
|
css['margin-left'] = css['margin-left'] || splitMargin[3];
|
|
|
|
}
|
|
|
|
delete css.margin;
|
|
|
|
}
|
|
|
|
return css;
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
function updateStyle() {
|
|
|
|
function addPixelSuffix(value) {
|
|
|
|
if (value.length > 0 && /^[0-9]+$/.test(value)) {
|
|
|
|
value += 'px';
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2014-01-31 01:06:12 +01:00
|
|
|
if (!editor.settings.image_advtab) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
var data = win.toJSON(),
|
|
|
|
css = dom.parseStyle(data.style);
|
|
|
|
|
|
|
|
css = mergeMargins(css);
|
|
|
|
|
|
|
|
if (data.vspace) {
|
|
|
|
css['margin-top'] = css['margin-bottom'] = addPixelSuffix(data.vspace);
|
|
|
|
}
|
|
|
|
if (data.hspace) {
|
|
|
|
css['margin-left'] = css['margin-right'] = addPixelSuffix(data.hspace);
|
|
|
|
}
|
|
|
|
if (data.border) {
|
|
|
|
css['border-width'] = addPixelSuffix(data.border);
|
|
|
|
}
|
|
|
|
|
|
|
|
win.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css))));
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateVSpaceHSpaceBorder() {
|
|
|
|
if (!editor.settings.image_advtab) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var data = win.toJSON(),
|
|
|
|
css = dom.parseStyle(data.style);
|
|
|
|
|
|
|
|
win.find('#vspace').value("");
|
|
|
|
win.find('#hspace').value("");
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
2015-03-10 20:20:28 +01:00
|
|
|
css = mergeMargins(css);
|
|
|
|
|
|
|
|
//Move opposite equal margins to vspace/hspace field
|
|
|
|
if ((css['margin-top'] && css['margin-bottom']) || (css['margin-right'] && css['margin-left'])) {
|
|
|
|
if (css['margin-top'] === css['margin-bottom']) {
|
|
|
|
win.find('#vspace').value(removePixelSuffix(css['margin-top']));
|
|
|
|
} else {
|
|
|
|
win.find('#vspace').value('');
|
|
|
|
}
|
|
|
|
if (css['margin-right'] === css['margin-left']) {
|
|
|
|
win.find('#hspace').value(removePixelSuffix(css['margin-right']));
|
|
|
|
} else {
|
|
|
|
win.find('#hspace').value('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Move border-width
|
|
|
|
if (css['border-width']) {
|
|
|
|
win.find('#border').value(removePixelSuffix(css['border-width']));
|
|
|
|
}
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
|
|
|
|
win.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css))));
|
2015-03-10 20:20:28 +01:00
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (editor.settings.image_advtab) {
|
|
|
|
// Parse styles from img
|
|
|
|
if (imgElm) {
|
2015-03-10 20:20:28 +01:00
|
|
|
if (imgElm.style.marginLeft && imgElm.style.marginRight && imgElm.style.marginLeft === imgElm.style.marginRight) {
|
|
|
|
data.hspace = removePixelSuffix(imgElm.style.marginLeft);
|
|
|
|
}
|
|
|
|
if (imgElm.style.marginTop && imgElm.style.marginBottom && imgElm.style.marginTop === imgElm.style.marginBottom) {
|
|
|
|
data.vspace = removePixelSuffix(imgElm.style.marginTop);
|
|
|
|
}
|
|
|
|
if (imgElm.style.borderWidth) {
|
|
|
|
data.border = removePixelSuffix(imgElm.style.borderWidth);
|
|
|
|
}
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
data.style = editor.dom.serializeStyle(editor.dom.parseStyle(editor.dom.getAttrib(imgElm, 'style')));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advanced dialog shows general+advanced tabs
|
|
|
|
win = editor.windowManager.open({
|
|
|
|
title: 'Insert/edit image',
|
|
|
|
data: data,
|
|
|
|
bodyType: 'tabpanel',
|
|
|
|
body: [
|
|
|
|
{
|
|
|
|
title: 'General',
|
|
|
|
type: 'form',
|
|
|
|
items: generalFormItems
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
title: 'Advanced',
|
|
|
|
type: 'form',
|
|
|
|
pack: 'start',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Style',
|
|
|
|
name: 'style',
|
2015-03-10 20:20:28 +01:00
|
|
|
type: 'textbox',
|
|
|
|
onchange: updateVSpaceHSpaceBorder
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'form',
|
|
|
|
layout: 'grid',
|
|
|
|
packV: 'start',
|
|
|
|
columns: 2,
|
|
|
|
padding: 0,
|
|
|
|
alignH: ['left', 'right'],
|
|
|
|
defaults: {
|
|
|
|
type: 'textbox',
|
|
|
|
maxWidth: 50,
|
|
|
|
onchange: updateStyle
|
|
|
|
},
|
|
|
|
items: [
|
|
|
|
{label: 'Vertical space', name: 'vspace'},
|
|
|
|
{label: 'Horizontal space', name: 'hspace'},
|
|
|
|
{label: 'Border', name: 'border'}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
onSubmit: onSubmitForm
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Simple default dialog
|
|
|
|
win = editor.windowManager.open({
|
|
|
|
title: 'Insert/edit image',
|
|
|
|
data: data,
|
|
|
|
body: generalFormItems,
|
|
|
|
onSubmit: onSubmitForm
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-20 05:18:33 +01:00
|
|
|
editor.on('preInit', function() {
|
|
|
|
function hasImageClass(node) {
|
|
|
|
var className = node.attr('class');
|
|
|
|
return className && /\bimage\b/.test(className);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleContentEditableState(state) {
|
|
|
|
return function(nodes) {
|
|
|
|
var i = nodes.length, node;
|
|
|
|
|
|
|
|
function toggleContentEditable(node) {
|
|
|
|
node.attr('contenteditable', state ? 'true' : null);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (i--) {
|
|
|
|
node = nodes[i];
|
|
|
|
|
|
|
|
if (hasImageClass(node)) {
|
|
|
|
node.attr('contenteditable', state ? 'false' : null);
|
|
|
|
tinymce.each(node.getAll('figcaption'), toggleContentEditable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
editor.parser.addNodeFilter('figure', toggleContentEditableState(true));
|
|
|
|
editor.serializer.addNodeFilter('figure', toggleContentEditableState(false));
|
|
|
|
});
|
|
|
|
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
editor.addButton('image', {
|
|
|
|
icon: 'image',
|
|
|
|
tooltip: 'Insert/edit image',
|
|
|
|
onclick: createImageList(showDialog),
|
2016-01-20 05:18:33 +01:00
|
|
|
stateSelector: 'img:not([data-mce-object],[data-mce-placeholder]),figure.image'
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
editor.addMenuItem('image', {
|
|
|
|
icon: 'image',
|
2015-03-10 20:20:28 +01:00
|
|
|
text: 'Insert/edit image',
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
onclick: createImageList(showDialog),
|
|
|
|
context: 'insert',
|
|
|
|
prependToContext: true
|
|
|
|
});
|
2014-06-18 01:49:15 +02:00
|
|
|
|
|
|
|
editor.addCommand('mceImage', createImageList(showDialog));
|
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-29 00:53:15 +01:00
|
|
|
});
|