From a8a349670a83754afc761cd5e3c66db6a70cc8bb Mon Sep 17 00:00:00 2001 From: Cesar G Date: Fri, 24 Jan 2014 04:37:29 -0800 Subject: [PATCH 1/5] [ticket/12124] Revert to basic uploader if the html5 runtime is not supported. PHPBB3-12124 --- phpBB/assets/javascript/plupload.js | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 6b37b009a4..2a5e290384 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -11,25 +11,30 @@ phpbb.plupload.ids = []; * @return undefined */ phpbb.plupload.initialize = function() { - phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0], - phpbb.plupload.rowTpl = $('#attach-row-tpl')[0].outerHTML; - - // Hide the basic upload panel and remove the attach row template. - $('#attach-row-tpl, #attach-panel-basic').remove(); - // Show multi-file upload options. - $('#attach-panel-multi').show(); - - // Set attachment data. - phpbb.plupload.setData(phpbb.plupload.data); - phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); - // Initialize the Plupload uploader. uploader.init(); - // Point out the drag-and-drop zone if it's supported. - if (!uploader.features.dragdrop) { - $('#drag-n-drop-message').show(); - } + // Only execute if Plupload initialized successfully. + uploader.bind('Init', function() { + phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0], + phpbb.plupload.rowTpl = $('#attach-row-tpl')[0].outerHTML; + + // Hide the basic upload panel and remove the attach row template. + $('#attach-row-tpl, #attach-panel-basic').remove(); + // Show multi-file upload options. + $('#attach-panel-multi').show(); + + // Set attachment data. + phpbb.plupload.setData(phpbb.plupload.data); + phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); + }); + + uploader.bind('PostInit', function() { + // Point out the drag-and-drop zone if it's supported. + if (!!uploader.features.dragdrop) { + $('#drag-n-drop-message').show(); + } + }); }; /** From 10149933bdd18fea7af2bd28d548111ad98ee644 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 25 Jan 2014 15:26:37 -0800 Subject: [PATCH 2/5] [ticket/12124] Remove double bang. PHPBB3-12124 --- phpBB/assets/javascript/plupload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 2a5e290384..429baffbc9 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -31,9 +31,9 @@ phpbb.plupload.initialize = function() { uploader.bind('PostInit', function() { // Point out the drag-and-drop zone if it's supported. - if (!!uploader.features.dragdrop) { + if (uploader.features.dragdrop) { $('#drag-n-drop-message').show(); - } + } }); }; From a18dc8d1d6e25682f1d305cbc9c4c69776c1e00d Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 28 Jan 2014 15:42:53 -0800 Subject: [PATCH 3/5] [ticket/12124] Set attachment data to preserve AJAX delete functionality. PHPBB3-12124 --- phpBB/assets/javascript/plupload.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 429baffbc9..c188febc6c 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -14,6 +14,10 @@ phpbb.plupload.initialize = function() { // Initialize the Plupload uploader. uploader.init(); + // Set attachment data. + phpbb.plupload.setData(phpbb.plupload.data); + phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); + // Only execute if Plupload initialized successfully. uploader.bind('Init', function() { phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0], @@ -23,10 +27,6 @@ phpbb.plupload.initialize = function() { $('#attach-row-tpl, #attach-panel-basic').remove(); // Show multi-file upload options. $('#attach-panel-multi').show(); - - // Set attachment data. - phpbb.plupload.setData(phpbb.plupload.data); - phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData()); }); uploader.bind('PostInit', function() { From 53ef25e837cd8cf16a5a5d1e4e39693f0af62d3c Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 28 Jan 2014 15:44:34 -0800 Subject: [PATCH 4/5] [ticket/12124] The textarea selector is failing in IE8 & 9. PHPBB3-12124 --- phpBB/assets/javascript/plupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index c188febc6c..cb86d18f20 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -313,7 +313,7 @@ phpbb.plupload.hideEmptyList = function() { * @return undefined */ phpbb.plupload.updateBbcode = function(action, index) { - var textarea = $(phpbb.plupload.form).find('textarea[name="message"]'), + var textarea = $('#message', phpbb.plupload.form), text = textarea.val(), removal = (action === 'removal'); From d32b758428145a8582f649423ca68a96792c9070 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 28 Jan 2014 15:47:43 -0800 Subject: [PATCH 5/5] [ticket/12124] IE8 does not support indexOf() for arrays. PHPBB3-12124 --- phpBB/assets/javascript/plupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index cb86d18f20..a90757d487 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -97,7 +97,7 @@ phpbb.plupload.getSerializedData = function() { * @return int Returns the index of the file if it exists. */ phpbb.plupload.getIndex = function(attach_id) { - var index = phpbb.plupload.ids.indexOf(Number(attach_id)); + var index = $.inArray(Number(attach_id), phpbb.plupload.ids); return (index !== -1) ? index : false; };