From 2eea820daf95f179517919940b65323654c05530 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Thu, 3 Dec 2009 01:31:10 +0000 Subject: [PATCH] BUGFIX: Cleanup after aborted drag operation in Assets (#4735) (from r93071) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@94319 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/AssetAdmin.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index 0a28abbe..a3f08fbf 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -164,7 +164,7 @@ Object.extend(Class, { var SubsDraggable = Class.create(); SubsDraggable.prototype = Object.extend({}, Draggable.prototype); -Class.superrise(SubsDraggable.prototype, ['initialize', 'startDrag', 'finishDrag']) +Class.superrise(SubsDraggable.prototype, ['initialize', 'startDrag', 'finishDrag', 'endDrag']) Object.extend( SubsDraggable.prototype , { initialize: function(event) { this.super_initialize.apply(this, arguments); @@ -198,6 +198,15 @@ Object.extend( SubsDraggable.prototype , { } this.super_startDrag(event); }, + endDrag: function(event) { + this.super_endDrag(event); + // Remove any remaining orphaned NumFilesIndicator spans + // See ticket #4735 + var elts = $$('.NumFilesIndicator') + if (elts) { + elts.each(function(x){ Element.remove(x); }); + } + }, finishDrag: function(event, success) { this.super_finishDrag(event, success); @@ -348,7 +357,7 @@ FilesystemSyncClass.prototype = { /** * Delete folder action */ -deletefolder = { +var deletefolder = { button_onclick : function() { if(treeactions.toggleSelection(this)) { deletefolder.o1 = $('sitetree').observeMethod('SelectionChanged', deletefolder.treeSelectionChanged); @@ -490,7 +499,15 @@ appendLoader(function () { if($('deletepage')) { $('deletepage').onclick = deletefolder.button_onclick; $('deletepage').getElementsByTagName('button')[0].onclick = function() { return false; }; - $('Form_DeleteItemsForm').onsubmit = deletefolder.form_submit; + // Prevent bug #4740, particularly with IE + Behaviour.register({ + '#Form_DeleteItemsForm' : { + onsubmit: function(event) { + deletefolder.form_submit(); + Event.stop(event); + } + } + }); Element.hide('Form_DeleteItemsForm'); }