Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrammatiko committed Apr 2, 2017
1 parent e44f4e6 commit 0f12c52
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
tinyMCE.DOM.bind(document, 'dragleave', function(e) {
e.stopPropagation();
e.preventDefault();
tinyMCE.activeEditor.contentAreaContainer.style.borderWidth='';
tinyMCE.activeEditor.contentAreaContainer.style.borderWidth = '1px 0 0';

return false;
});
Expand All @@ -13,7 +13,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
function UploadFile(file) {
var fd = new FormData();
fd.append('Filedata', file);
fd.append('folder', mediaUploadPath);
fd.append('folder', tinyMCE.activeEditor.settings.mediaUploadPath);

var xhr = new XMLHttpRequest();

Expand All @@ -24,9 +24,9 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {

removeProgessBar = function(){
setTimeout(function(){
document.querySelector('#jloader').outerHTML = "";
delete document.querySelector('#jloader');
editor.contentAreaContainer.style.borderWidth = '';
var loader = document.querySelector('#jloader');
loader.parentNode.removeChild(loader);
editor.contentAreaContainer.style.borderWidth = '1px 0 0 0';
}, 200);
};

Expand All @@ -37,7 +37,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
if (resp.status == '0') {
removeProgessBar();

tinyMCE.activeEditor.windowManager.alert(resp.message + ': ' + setCustomDir + resp.location);
editor.windowManager.alert(resp.message + ': ' + setCustomDir + resp.location);

}

Expand All @@ -46,7 +46,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {

// Create the image tag
var newNode = tinyMCE.activeEditor.getDoc().createElement ('img');
newNode.src= setCustomDir + resp.location;
newNode.src= tinyMCE.activeEditor.settings.setCustomDir + resp.location;
tinyMCE.activeEditor.execCommand('mceInsertContent', false, newNode.outerHTML);
}
} else {
Expand All @@ -58,7 +58,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
removeProgessBar();
};

xhr.open("POST", uploadUri, true);
xhr.open("POST", tinyMCE.activeEditor.settings.uploadUri, true);
xhr.send(fd);

}
Expand All @@ -77,8 +77,8 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
// Notify user when file is over the drop area
editor.on('dragover', function(e) {
e.preventDefault();
tinyMCE.activeEditor.contentAreaContainer.style.borderStyle = 'dashed';
tinyMCE.activeEditor.contentAreaContainer.style.borderWidth = '5px';
editor.contentAreaContainer.style.borderStyle = 'dashed';
editor.contentAreaContainer.style.borderWidth = '5px';

return false;
});
Expand All @@ -93,14 +93,23 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
// Only images allowed
if (f.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)) {

// Display a progress bar
document.querySelector('.mce-toolbar-grp').innerHTML +=
'<div id=\"jloader\">' +
' <div class=\"progress progress-success progress-striped active\" style=\"width:100%;height:30px;\">' +
' <div class=\"bar\" style=\"width: 0%\"></div>' +
' </div>' +
'</div>';
editor.contentAreaContainer.style.borderWidth = '';
// Create and display the progress bar
var container, innerDiv, progressBar = '';
container = document.createElement('div');
container.id = 'jloader';
innerDiv = document.createElement('div');
innerDiv.classList.add('progress');
innerDiv.classList.add('progress-success');
innerDiv.classList.add('progress-striped');
innerDiv.classList.add('active');
innerDiv.style.width = '100%';
innerDiv.style.height = '30px';
progressBar = document.createElement('div');
progressBar.classList.add('bar');
progressBar.style.width = '0';
innerDiv.appendChild(progressBar);
container.appendChild(innerDiv);
document.querySelector('.mce-toolbar-grp').appendChild(container);

// Upload the file(s)
UploadFile(f);
Expand All @@ -109,7 +118,7 @@ tinymce.PluginManager.add('jdragdrop', function(editor) {
e.preventDefault();
}
}
editor.contentAreaContainer.style.borderWidth = '';
editor.contentAreaContainer.style.borderWidth = '1px 0 0';
});
} else {
Joomla.renderMessages({'error': [Joomla.JText._("PLG_TINY_ERR_UNSUPPORTEDBROWSER")]});
Expand Down
1 change: 1 addition & 0 deletions media/editors/tinymce/js/plugins/dragdrop/plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion media/editors/tinymce/plugins/jdragdrop/plugin.min.js

This file was deleted.

49 changes: 25 additions & 24 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons

if ($dragdrop && $user->authorise('core.create', 'com_media'))
{
$plugins[] = 'jdragdrop';
$externalPlugins['jdragdrop'] = ($app->isClient('site') ? JUri::root(false) :
str_replace('/administrator', '', JUri::root(false)))
. '/media/editors/tinymce/js/plugins/dragdrop/plugin.min.js';
$allowImgPaste = true;
$isSubDir = '';
$session = JFactory::getSession();
Expand All @@ -598,18 +600,14 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons

if (!empty($tempPath))
{
$tempPath = rtrim($tempPath, '/');
$tempPath = ltrim($tempPath, '/');
$tempPath = ltrim(rtrim($tempPath, '/'));
}

JText::script('PLG_TINY_ERR_UNSUPPORTEDBROWSER');
$doc->addScriptDeclaration(
"
var setCustomDir = '" . $isSubDir . "';
var mediaUploadPath = '" . $tempPath . "';
var uploadUri = '" . $uploadUrl . "';
"
);

$scriptOptions['setCustomDir'] = $isSubDir;
$scriptOptions['mediaUploadPath'] = $tempPath;
$scriptOptions['uploadUri'] = $uploadUrl;
}

// Build the final options set
Expand Down Expand Up @@ -657,6 +655,8 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons
'resize' => $resizing,
'templates' => $templates,
'image_advtab' => (bool) $levelParams->get('image_advtab', false),
'external_plugins' => empty($externalPlugins) ? null : $externalPlugins,

)
);

Expand Down Expand Up @@ -1843,9 +1843,9 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
}

// Drag and drop Images
$allowImgPaste = false;
$dragDropPlg = '';
$dragdrop = $this->params->get('drag_drop', 1);
$externalPlugins = array();
$allowImgPaste = false;
$dragdrop = $this->params->get('drag_drop', 1);

if ($dragdrop && $user->authorise('core.create', 'com_media'))
{
Expand Down Expand Up @@ -1877,15 +1877,15 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
$tempPath = ltrim($tempPath, '/');
}

$dragDropPlg = 'jdragdrop';

JText::script('PLG_TINY_ERR_UNSUPPORTEDBROWSER');
$doc->addScriptDeclaration(
"
var setCustomDir = '" . $isSubDir . "';
var mediaUploadPath = '" . $tempPath . "';
var uploadUri = '" . $uploadUrl . "';
"

$scriptOptions['setCustomDir'] = $isSubDir;
$scriptOptions['mediaUploadPath'] = $tempPath;
$scriptOptions['uploadUri'] = $uploadUrl;

$externalPlugins = array(
array('jdragdrop' => ($app->isClient('site') ? JUri::root(false) : str_replace('/administrator', JUri::root(false)))
. '/media/editors/tinymce/js/plugins/dragdrop/plugin.min.js'),
);
}

Expand Down Expand Up @@ -1928,6 +1928,7 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
'content_css' => $content_css,
'document_base_url' => JUri::root(true) . '/',
'paste_data_images' => $allowImgPaste,
'externalPlugins' => json_encode($externalPlugins),
)
);

Expand Down Expand Up @@ -1964,7 +1965,7 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
case 0: /* Simple mode*/
$scriptOptions['menubar'] = false;
$scriptOptions['toolbar1'] = 'bold italic underline strikethrough | undo redo | bullist numlist | code';
$scriptOptions['plugins'] = $dragDropPlg . ' code';
$scriptOptions['plugins'] = ' code';

break;

Expand All @@ -1976,7 +1977,7 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
$scriptOptions['valid_elements'] = $valid_elements;
$scriptOptions['extended_valid_elements'] = $elements;
$scriptOptions['invalid_elements'] = $invalid_elements;
$scriptOptions['plugins'] = 'table link code hr charmap autolink lists importcss ' . $dragDropPlg;
$scriptOptions['plugins'] = 'table link code hr charmap autolink lists importcss ';
$scriptOptions['toolbar1'] = $toolbar1;
$scriptOptions['removed_menuitems'] = 'newdocument';
$scriptOptions['importcss_append'] = true;
Expand All @@ -1990,7 +1991,7 @@ private function onDisplayLegacy($name, $content, $width, $height, $col, $row, $
$scriptOptions['valid_elements'] = $valid_elements;
$scriptOptions['extended_valid_elements'] = $elements;
$scriptOptions['invalid_elements'] = $invalid_elements;
$scriptOptions['plugins'] = $plugins . ' ' . $dragDropPlg;
$scriptOptions['plugins'] = $plugins;
$scriptOptions['toolbar1'] = $toolbar1;
$scriptOptions['removed_menuitems'] = 'newdocument';
$scriptOptions['rel_list'] = array(
Expand Down

0 comments on commit 0f12c52

Please sign in to comment.