- md5
- 1b5e6bff2290f3fa7ea2aa036b64b0db
- sha1
- d0af505c662756920330d638d7ce282f83d82fca
- sha256
- d5b3b3084018513772603e31fb790ed65fd40738b8041f4062ae54ca61a853f3
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* eslint-disable no-undef */
tinymce.PluginManager.add('jdragndrop', function (editor) {
var responseData; // Reset the drop area border
tinyMCE.DOM.bind(document, 'dragleave', function (e) {
e.stopPropagation();
e.preventDefault();
editor.contentAreaContainer.style.borderWidth = '1px 0 0';
return false;
}); // Fix for Chrome
editor.on('dragenter', function (e) {
e.stopPropagation();
return false;
}); // Notify user when file is over the drop area
editor.on('dragover', function (e) {
e.preventDefault();
editor.contentAreaContainer.style.borderStyle = 'dashed';
editor.contentAreaContainer.style.borderWidth = '5px';
return false;
});
function uploadFile(name, content) {
var _data;
var url = "".concat(editor.settings.uploadUri, "&path=").concat(editor.settings.comMediaAdapter);
var data = (_data = {}, _defineProperty(_data, editor.settings.csrfToken, '1'), _defineProperty(_data, "name", name), _defineProperty(_data, "content", content), _defineProperty(_data, "parent", editor.settings.parentUploadFolder), _data);
Joomla.request({
url: url,
method: 'POST',
data: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
},
onSuccess: function onSuccess(resp) {
var response;
try {
response = JSON.parse(resp);
} catch (e) {
editor.windowManager.alert("".concat(Joomla.Text._('JERROR'), ": {e}"));
}
if (response.data && response.data.path) {
responseData = response.data;
var urlPath; // For local adapters use relative paths
if (/local-/.test(responseData.adapter)) {
var _Joomla$getOptions = Joomla.getOptions('system.paths'),
rootFull = _Joomla$getOptions.rootFull;
urlPath = "".concat(response.data.thumb_path.split(rootFull)[1]);
} else if (responseData.thumb_path) {
// Absolute path for different domain
urlPath = responseData.thumb_path;
}
var dialogClose = function dialogClose(api) {
var dialogData = api.getData();
var altEmpty = dialogData.altEmpty ? ' alt=""' : '';
var altValue = dialogData.altText ? " alt=\"".concat(dialogData.altText, "\"") : altEmpty;
var lazyValue = dialogData.isLazy ? ' loading="lazy"' : '';
var width = dialogData.isLazy ? " width=\"".concat(responseData.width, "\"") : '';
var height = dialogData.isLazy ? " height=\"".concat(responseData.height, "\"") : '';
editor.execCommand('mceInsertContent', false, "<img src=\"".concat(urlPath, "\"").concat(altValue).concat(lazyValue).concat(width).concat(height, "/>"));
};
editor.windowManager.open({
title: Joomla.Text._('PLG_TINY_DND_ADDITIONALDATA'),
body: {
type: 'panel',
items: [{
type: 'input',
name: 'altText',
label: Joomla.Text._('PLG_TINY_DND_ALTTEXT')
}, {
type: 'checkbox',
name: 'altEmpty',
label: Joomla.Text._('PLG_TINY_DND_EMPTY_ALT')
}, {
type: 'checkbox',
name: 'isLazy',
label: Joomla.Text._('PLG_TINY_DND_LAZYLOADED')
}]
},
buttons: [{
type: 'cancel',
text: 'Cancel'
}, {
type: 'submit',
name: 'submitButton',
text: 'Save',
primary: true
}],
initialData: {
altText: '',
isLazy: true,
altEmpty: false
},
onSubmit: function onSubmit(api) {
dialogClose(api);
api.close();
},
onCancel: function onCancel(api) {
dialogClose(api);
}
});
}
},
onError: function onError(xhr) {
editor.windowManager.alert("Error: ".concat(xhr.statusText));
}
});
}
function readFile(file) {
// Create a new file reader instance
var reader = new FileReader(); // Add the on load callback
reader.onload = function (progressEvent) {
var result = progressEvent.target.result;
var splitIndex = result.indexOf('base64') + 7;
var content = result.slice(splitIndex, result.length); // Upload the file
uploadFile(file.name, content);
};
reader.readAsDataURL(file);
} // Listers for drag and drop
if (typeof FormData !== 'undefined') {
// Logic for the dropped file
editor.on('drop', function (e) {
e.preventDefault(); // We override only for files
if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length > 0) {
var files = [].slice.call(e.dataTransfer.files);
files.forEach(function (file) {
// Only images allowed
if (file.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)) {
// Upload the file(s)
readFile(file);
}
});
}
editor.contentAreaContainer.style.borderWidth = '1px 0 0';
});
} else {
Joomla.renderMessages({
error: [Joomla.JText._('PLG_TINY_ERR_UNSUPPORTEDBROWSER')]
});
editor.on('drop', function (e) {
e.preventDefault();
return false;
});
}
});
The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.