From 10f722a4807ee27ceb007926d306bb71d7b98139 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Thu, 6 Oct 2016 17:11:17 +0300 Subject: [PATCH 1/6] drop jquery, fix jModalClose() --- media/editors/tinymce/js/tinymce-init.min.js | 1 - .../tinymce/plugins/jdragdrop/plugin.js | 11 +++--- .../tinymce/plugins/jdragdrop/plugin.min.js | 2 +- media/system/js/tiny-close.js | 39 +++++++++---------- media/system/js/tiny-close.min.js | 2 +- .../tinymce => system}/js/tinymce-init.js | 27 ++++++------- media/system/js/tinymce-init.min.js | 1 + plugins/editors/tinymce/tinymce.php | 5 +-- 8 files changed, 41 insertions(+), 47 deletions(-) delete mode 100644 media/editors/tinymce/js/tinymce-init.min.js rename media/{editors/tinymce => system}/js/tinymce-init.js (75%) create mode 100644 media/system/js/tinymce-init.min.js diff --git a/media/editors/tinymce/js/tinymce-init.min.js b/media/editors/tinymce/js/tinymce-init.min.js deleted file mode 100644 index 1e48dc6f7a63a..0000000000000 --- a/media/editors/tinymce/js/tinymce-init.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(tinyMCE,Joomla,$,window,document){"use strict";window.getSize=window.getSize||function(){return{x:$(window).width(),y:$(window).height()}};window.jInsertEditorText=function(text,editor){tinyMCE.activeEditor.execCommand("mceInsertContent",false,text)};var JoomlaTinyMCE={setupEditors:function(target){target=target||document;var pluginOptions=Joomla.getOptions?Joomla.getOptions("plg_editor_tinymce",{}):Joomla.optionsStorage.plg_editor_tinymce||{},$editors=$(target).find(".joomla-editor-tinymce");for(var i=0,l=$editors.length;i' + '
' + ' ' + - ''); + ''; editor.contentAreaContainer.style.borderWidth = ''; // Upload the file(s) diff --git a/media/editors/tinymce/plugins/jdragdrop/plugin.min.js b/media/editors/tinymce/plugins/jdragdrop/plugin.min.js index 285f2446bf654..be72316c759e1 100644 --- a/media/editors/tinymce/plugins/jdragdrop/plugin.min.js +++ b/media/editors/tinymce/plugins/jdragdrop/plugin.min.js @@ -1 +1 @@ -tinymce.PluginManager.add("jdragdrop",function(e){function t(t){var r=new FormData;r.append("Filedata",t),r.append("folder",mediaUploadPath);var o=new XMLHttpRequest;o.upload.onprogress=function(e){var t=e.loaded/e.total*100;jQuery(".bar").width(t+"%")},removeProgessBar=function(){setTimeout(function(){jQuery("#jloader").remove(),e.contentAreaContainer.style.borderWidth=""},200)},o.onload=function(){var e=JSON.parse(o.responseText);if(200==o.status){if("0"==e.status&&(removeProgessBar(),tinyMCE.activeEditor.windowManager.alert(e.message+": "+setCustomDir+e.location)),"1"==e.status){removeProgessBar();var t=tinyMCE.activeEditor.getDoc().createElement("img");t.src=setCustomDir+e.location,tinyMCE.activeEditor.execCommand("mceInsertContent",!1,t.outerHTML)}}else removeProgessBar()},o.onerror=function(){removeProgessBar()},o.open("POST",uploadUri,!0),o.send(r)}tinyMCE.DOM.bind(document,"dragleave",function(e){return e.stopPropagation(),e.preventDefault(),tinyMCE.activeEditor.contentAreaContainer.style.borderWidth="",!1}),"undefined"!=typeof FormData?(e.on("dragenter",function(e){return e.stopPropagation(),!1}),e.on("dragover",function(e){return e.preventDefault(),tinyMCE.activeEditor.contentAreaContainer.style.borderStyle="dashed",tinyMCE.activeEditor.contentAreaContainer.style.borderWidth="5px",!1}),e.on("drop",function(r){if(r.dataTransfer&&r.dataTransfer.files&&r.dataTransfer.files.length>0)for(var o,n=0;o=r.dataTransfer.files[n];n++)o.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)&&(jQuery(".mce-toolbar-grp").append('
'),e.contentAreaContainer.style.borderWidth="",t(o)),r.preventDefault();e.contentAreaContainer.style.borderWidth=""})):(Joomla.renderMessages({error:[Joomla.JText._("PLG_TINY_ERR_UNSUPPORTEDBROWSER")]}),e.on("drop",function(e){return e.preventDefault(),!1}))}); \ No newline at end of file +tinymce.PluginManager.add("jdragdrop",function(a){function b(b){var c=new FormData;c.append("Filedata",b),c.append("folder",mediaUploadPath);var d=new XMLHttpRequest;d.upload.onprogress=function(a){var b=a.loaded/a.total*100;document.querySelector(".bar").style.width=b+"%"},removeProgessBar=function(){setTimeout(function(){document.querySelector("#jloader").outerHTML="",delete document.querySelector("#jloader"),a.contentAreaContainer.style.borderWidth=""},200)},d.onload=function(){var a=JSON.parse(d.responseText);if(200==d.status){if("0"==a.status&&(removeProgessBar(),tinyMCE.activeEditor.windowManager.alert(a.message+": "+setCustomDir+a.location)),"1"==a.status){removeProgessBar();var b=tinyMCE.activeEditor.getDoc().createElement("img");b.src=setCustomDir+a.location,tinyMCE.activeEditor.execCommand("mceInsertContent",!1,b.outerHTML)}}else removeProgessBar()},d.onerror=function(){removeProgessBar()},d.open("POST",uploadUri,!0),d.send(c)}tinyMCE.DOM.bind(document,"dragleave",function(a){return a.stopPropagation(),a.preventDefault(),tinyMCE.activeEditor.contentAreaContainer.style.borderWidth="",!1}),"undefined"!=typeof FormData?(a.on("dragenter",function(a){return a.stopPropagation(),!1}),a.on("dragover",function(a){return a.preventDefault(),tinyMCE.activeEditor.contentAreaContainer.style.borderStyle="dashed",tinyMCE.activeEditor.contentAreaContainer.style.borderWidth="5px",!1}),a.on("drop",function(c){if(c.dataTransfer&&c.dataTransfer.files&&c.dataTransfer.files.length>0)for(var e,d=0;e=c.dataTransfer.files[d];d++)e.name.toLowerCase().match(/\.(jpg|jpeg|png|gif)$/)&&(document.querySelector(".mce-toolbar-grp").innerHTML+='
',a.contentAreaContainer.style.borderWidth="",b(e)),c.preventDefault();a.contentAreaContainer.style.borderWidth=""})):(Joomla.renderMessages({error:[Joomla.JText._("PLG_TINY_ERR_UNSUPPORTEDBROWSER")]}),a.on("drop",function(a){return a.preventDefault(),!1}))}); \ No newline at end of file diff --git a/media/system/js/tiny-close.js b/media/system/js/tiny-close.js index 008b56bf239ba..10a148c7b9730 100644 --- a/media/system/js/tiny-close.js +++ b/media/system/js/tiny-close.js @@ -11,28 +11,25 @@ * @since 3.5.1 * @version 1.0 */ -document.onreadystatechange = function () { - if (document.readyState == "interactive" && typeof tinyMCE != 'undefined' && tinyMCE) +document.addEventListener('DOMContentLoaded', function () { + if (typeof window.jModalClose_no_tinyMCE === 'undefined') { - if (typeof window.jModalClose_no_tinyMCE === 'undefined') - { - window.jModalClose_no_tinyMCE = typeof(jModalClose) == 'function' ? jModalClose : false; - - jModalClose = function () { - if (window.jModalClose_no_tinyMCE) window.jModalClose_no_tinyMCE.apply(this, arguments); - tinyMCE.activeEditor.windowManager.close(); - }; - } + window.jModalClose_no_tinyMCE = typeof(jModalClose) == 'function' ? jModalClose : false; - if (typeof window.SqueezeBoxClose_no_tinyMCE === 'undefined') - { - if (typeof(SqueezeBox) == 'undefined') SqueezeBox = {}; - window.SqueezeBoxClose_no_tinyMCE = typeof(SqueezeBox.close) == 'function' ? SqueezeBox.close : false; + jModalClose = function () { + if (window.jModalClose_no_tinyMCE) window.jModalClose_no_tinyMCE.apply(this, arguments); + tinyMCE.activeEditor.windowManager.close(); + }; + } + + if (typeof window.SqueezeBoxClose_no_tinyMCE === 'undefined') + { + if (typeof(SqueezeBox) == 'undefined') SqueezeBox = {}; + window.SqueezeBoxClose_no_tinyMCE = typeof(SqueezeBox.close) == 'function' ? SqueezeBox.close : false; - SqueezeBox.close = function () { - if (window.SqueezeBoxClose_no_tinyMCE) window.SqueezeBoxClose_no_tinyMCE.apply(this, arguments); - tinyMCE.activeEditor.windowManager.close(); - }; - } + SqueezeBox.close = function () { + if (window.SqueezeBoxClose_no_tinyMCE) window.SqueezeBoxClose_no_tinyMCE.apply(this, arguments); + tinyMCE.activeEditor.windowManager.close(); + }; } -}; +}); diff --git a/media/system/js/tiny-close.min.js b/media/system/js/tiny-close.min.js index 42d51731023cb..7d96870552326 100644 --- a/media/system/js/tiny-close.min.js +++ b/media/system/js/tiny-close.min.js @@ -1 +1 @@ -document.onreadystatechange=function(){"interactive"==document.readyState&&"undefined"!=typeof tinyMCE&&tinyMCE&&("undefined"==typeof window.jModalClose_no_tinyMCE&&(window.jModalClose_no_tinyMCE="function"==typeof jModalClose?jModalClose:!1,jModalClose=function(){window.jModalClose_no_tinyMCE&&window.jModalClose_no_tinyMCE.apply(this,arguments),tinyMCE.activeEditor.windowManager.close()}),"undefined"==typeof window.SqueezeBoxClose_no_tinyMCE&&("undefined"==typeof SqueezeBox&&(SqueezeBox={}),window.SqueezeBoxClose_no_tinyMCE="function"==typeof SqueezeBox.close?SqueezeBox.close:!1,SqueezeBox.close=function(){window.SqueezeBoxClose_no_tinyMCE&&window.SqueezeBoxClose_no_tinyMCE.apply(this,arguments),tinyMCE.activeEditor.windowManager.close()}))}; \ No newline at end of file +document.addEventListener("DOMContentLoaded",function(){"undefined"==typeof window.jModalClose_no_tinyMCE&&(window.jModalClose_no_tinyMCE="function"==typeof jModalClose&&jModalClose,jModalClose=function(){window.jModalClose_no_tinyMCE&&window.jModalClose_no_tinyMCE.apply(this,arguments),tinyMCE.activeEditor.windowManager.close()}),"undefined"==typeof window.SqueezeBoxClose_no_tinyMCE&&("undefined"==typeof SqueezeBox&&(SqueezeBox={}),window.SqueezeBoxClose_no_tinyMCE="function"==typeof SqueezeBox.close&&SqueezeBox.close,SqueezeBox.close=function(){window.SqueezeBoxClose_no_tinyMCE&&window.SqueezeBoxClose_no_tinyMCE.apply(this,arguments),tinyMCE.activeEditor.windowManager.close()})}); \ No newline at end of file diff --git a/media/editors/tinymce/js/tinymce-init.js b/media/system/js/tinymce-init.js similarity index 75% rename from media/editors/tinymce/js/tinymce-init.js rename to media/system/js/tinymce-init.js index e656dacc92b98..e6ca9a1de9896 100644 --- a/media/editors/tinymce/js/tinymce-init.js +++ b/media/system/js/tinymce-init.js @@ -3,15 +3,15 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ -;(function(tinyMCE, Joomla, $, window, document){ +;(function(tinyMCE, Joomla, window, document){ "use strict"; // This line is for Mootools b/c - window.getSize = window.getSize || function(){return {x: $(window).width(), y: $(window).height()};}; + window.getSize = window.getSize || function(){return {x: window.width, y: window.height};}; window.jInsertEditorText = function ( text, editor ) { tinyMCE.activeEditor.execCommand('mceInsertContent', false, text); - } + }; var JoomlaTinyMCE = { @@ -21,12 +21,12 @@ * @param {HTMLElement} target Target Element where to search for the editor element * * @since __DEPLOY_VERSION__ - */ + */ setupEditors: function ( target ) { target = target || document; var pluginOptions = Joomla.getOptions ? Joomla.getOptions('plg_editor_tinymce', {}) : (Joomla.optionsStorage.plg_editor_tinymce || {}), - $editors = $(target).find('.joomla-editor-tinymce'); + $editors = target.querySelectorAll('.joomla-editor-tinymce'); for(var i = 0, l = $editors.length; i < l; i++) { this.setupEditor($editors[i], pluginOptions); @@ -40,16 +40,13 @@ * @param {Object} pluginOptions * * @since __DEPLOY_VERSION__ - */ + */ setupEditor: function ( element, pluginOptions ) { - var name = element ? $(element).attr('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name + var name = element ? element.getAttribute('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {}, defaultOptions = tinyMCEOptions['default'] || {}, options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name - // Avoid unexpected changes - options = jQuery.extend({}, options); - if (element) { // We already have the Target, so reset the selector and assign given element as target options.selector = null; @@ -68,13 +65,13 @@ Joomla.JoomlaTinyMCE = JoomlaTinyMCE; // Init on doomready - $(document).ready(function(){ + document.addEventListener('DOMContentLoaded', function () { Joomla.JoomlaTinyMCE.setupEditors(); - // Init in subform field - $(document).on('subform-row-add', function(event, row){ + // Init in subform field + document.addEventListener('subform-row-add', function(event, row){ Joomla.JoomlaTinyMCE.setupEditors(row); - }) + }) }); -}(tinyMCE, Joomla, jQuery, window, document)); +}(tinyMCE, Joomla, window, document)); diff --git a/media/system/js/tinymce-init.min.js b/media/system/js/tinymce-init.min.js new file mode 100644 index 0000000000000..1b27b167c223a --- /dev/null +++ b/media/system/js/tinymce-init.min.js @@ -0,0 +1 @@ +!function(a,b,c,d){"use strict";c.getSize=c.getSize||function(){return{x:c.width,y:c.height}},c.jInsertEditorText=function(b,c){a.activeEditor.execCommand("mceInsertContent",!1,b)};var e={setupEditors:function(a){a=a||d;for(var c=b.getOptions?b.getOptions("plg_editor_tinymce",{}):b.optionsStorage.plg_editor_tinymce||{},e=a.querySelectorAll(".joomla-editor-tinymce"),f=0,g=e.length;f_basePath . '/tinymce.min.js', false, false, false, false, false); - JHtml::_('script', 'editors/tinymce/tinymce-init.min.js', false, true); - - return; + JHtml::_('script', 'system/tinymce-init.min.js', false, true); } /** From cbaba667c574cbec3a7842ba5047f2aeaa9c4f2a Mon Sep 17 00:00:00 2001 From: dgt41 Date: Thu, 6 Oct 2016 17:33:40 +0300 Subject: [PATCH 2/6] classList polyfill not needed here --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index b4b33b153d97b..e21a6a58e0e6e 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -46,7 +46,7 @@ class PlgEditorTinymce extends JPlugin */ public function onInit() { - JHtml::_('behavior.polyfill', array('event', 'classlist'), 'lte IE 11'); + JHtml::_('behavior.polyfill', array('event'), 'lte IE 11'); JHtml::_('script', $this->_basePath . '/tinymce.min.js', false, false, false, false, false); JHtml::_('script', 'system/tinymce-init.min.js', false, true); } From f27e12baa08bac5fdb0f1737d03056c4d5382c61 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Thu, 6 Oct 2016 18:38:04 +0300 Subject: [PATCH 3/6] window.width (seriously?), merge options --- media/system/js/tinymce-init.js | 10 ++++++++-- media/system/js/tinymce-init.min.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/media/system/js/tinymce-init.js b/media/system/js/tinymce-init.js index e6ca9a1de9896..b3c57247f48ab 100644 --- a/media/system/js/tinymce-init.js +++ b/media/system/js/tinymce-init.js @@ -7,7 +7,7 @@ "use strict"; // This line is for Mootools b/c - window.getSize = window.getSize || function(){return {x: window.width, y: window.height};}; + window.getSize = window.getSize || function(){return {x: window.innerWidth, y: window.innerHeight};}; window.jInsertEditorText = function ( text, editor ) { tinyMCE.activeEditor.execCommand('mceInsertContent', false, text); @@ -45,7 +45,13 @@ var name = element ? element.getAttribute('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {}, defaultOptions = tinyMCEOptions['default'] || {}, - options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name + options = defaultOptions, + currentOptions = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name + + // Merge the parameters + for (name in currentOptions) { + options[name] = currentOptions[name]; + } if (element) { // We already have the Target, so reset the selector and assign given element as target diff --git a/media/system/js/tinymce-init.min.js b/media/system/js/tinymce-init.min.js index 1b27b167c223a..718438de1e277 100644 --- a/media/system/js/tinymce-init.min.js +++ b/media/system/js/tinymce-init.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";c.getSize=c.getSize||function(){return{x:c.width,y:c.height}},c.jInsertEditorText=function(b,c){a.activeEditor.execCommand("mceInsertContent",!1,b)};var e={setupEditors:function(a){a=a||d;for(var c=b.getOptions?b.getOptions("plg_editor_tinymce",{}):b.optionsStorage.plg_editor_tinymce||{},e=a.querySelectorAll(".joomla-editor-tinymce"),f=0,g=e.length;f Date: Thu, 6 Oct 2016 19:41:33 +0300 Subject: [PATCH 4/6] use Joomla.extend() --- media/system/js/tinymce-init.js | 9 +++------ media/system/js/tinymce-init.min.js | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/media/system/js/tinymce-init.js b/media/system/js/tinymce-init.js index b3c57247f48ab..b72eb08e74f5a 100644 --- a/media/system/js/tinymce-init.js +++ b/media/system/js/tinymce-init.js @@ -45,13 +45,10 @@ var name = element ? element.getAttribute('name').replace(/\[\]|\]/g, '').split('[').pop() : 'default', // Get Editor name tinyMCEOptions = pluginOptions ? pluginOptions.tinyMCE || {} : {}, defaultOptions = tinyMCEOptions['default'] || {}, - options = defaultOptions, - currentOptions = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name + options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name - // Merge the parameters - for (name in currentOptions) { - options[name] = currentOptions[name]; - } + // Avoid unexpected changes + Joomla.extend({}, options); if (element) { // We already have the Target, so reset the selector and assign given element as target diff --git a/media/system/js/tinymce-init.min.js b/media/system/js/tinymce-init.min.js index 718438de1e277..9af8bb7340886 100644 --- a/media/system/js/tinymce-init.min.js +++ b/media/system/js/tinymce-init.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";c.getSize=c.getSize||function(){return{x:c.innerWidth,y:c.innerHeight}},c.jInsertEditorText=function(b,c){a.activeEditor.execCommand("mceInsertContent",!1,b)};var e={setupEditors:function(a){a=a||d;for(var c=b.getOptions?b.getOptions("plg_editor_tinymce",{}):b.optionsStorage.plg_editor_tinymce||{},e=a.querySelectorAll(".joomla-editor-tinymce"),f=0,g=e.length;f Date: Thu, 6 Oct 2016 19:46:54 +0300 Subject: [PATCH 5/6] my bad --- media/system/js/tinymce-init.js | 10 ++++++---- media/system/js/tinymce-init.min.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/media/system/js/tinymce-init.js b/media/system/js/tinymce-init.js index b72eb08e74f5a..d38978039dc76 100644 --- a/media/system/js/tinymce-init.js +++ b/media/system/js/tinymce-init.js @@ -48,7 +48,7 @@ options = tinyMCEOptions[name] ? tinyMCEOptions[name] : defaultOptions; // Check specific options by the name // Avoid unexpected changes - Joomla.extend({}, options); + options = Joomla.extend({}, options); if (element) { // We already have the Target, so reset the selector and assign given element as target @@ -72,9 +72,11 @@ Joomla.JoomlaTinyMCE.setupEditors(); // Init in subform field - document.addEventListener('subform-row-add', function(event, row){ - Joomla.JoomlaTinyMCE.setupEditors(row); - }) + if(window.jQuery) { + jQuery(document).on('subform-row-add', function (event, row) { + Joomla.JoomlaTinyMCE.setupEditors(row); + }); + } }); }(tinyMCE, Joomla, window, document)); diff --git a/media/system/js/tinymce-init.min.js b/media/system/js/tinymce-init.min.js index 9af8bb7340886..54f7a622a2118 100644 --- a/media/system/js/tinymce-init.min.js +++ b/media/system/js/tinymce-init.min.js @@ -1 +1 @@ -!function(a,b,c,d){"use strict";c.getSize=c.getSize||function(){return{x:c.innerWidth,y:c.innerHeight}},c.jInsertEditorText=function(b,c){a.activeEditor.execCommand("mceInsertContent",!1,b)};var e={setupEditors:function(a){a=a||d;for(var c=b.getOptions?b.getOptions("plg_editor_tinymce",{}):b.optionsStorage.plg_editor_tinymce||{},e=a.querySelectorAll(".joomla-editor-tinymce"),f=0,g=e.length;f Date: Thu, 6 Oct 2016 23:26:04 +0300 Subject: [PATCH 6/6] IE<9 --- plugins/editors/tinymce/tinymce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index e21a6a58e0e6e..fda2878d0075a 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -46,7 +46,7 @@ class PlgEditorTinymce extends JPlugin */ public function onInit() { - JHtml::_('behavior.polyfill', array('event'), 'lte IE 11'); + JHtml::_('behavior.polyfill', array('event'), 'lt IE 9'); JHtml::_('script', $this->_basePath . '/tinymce.min.js', false, false, false, false, false); JHtml::_('script', 'system/tinymce-init.min.js', false, true); }