From 65c8ccc02ed4124ce07eefe6d5a1b985e0fad7c3 Mon Sep 17 00:00:00 2001 From: Paul Nicholls Date: Wed, 5 Sep 2012 14:14:39 +1200 Subject: [PATCH] MDL-34328: block dragdrop - performance rewrite Use YUI's DragDrop delegates for block dragdrop - one per block region - rather than initialising a Drag object for each individual block. --- lib/yui/blocks/blocks.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/yui/blocks/blocks.js b/lib/yui/blocks/blocks.js index cec719f859b..b0835f69035 100644 --- a/lib/yui/blocks/blocks.js +++ b/lib/yui/blocks/blocks.js @@ -68,23 +68,26 @@ YUI.add('moodle-core-blocks', function(Y) { padding: '40 240 40 240' }); + // Make each div element in the list of blocks draggable + var del = new Y.DD.Delegate({ + container: blockregionnode, + nodes: '.'+CSS.BLOCK, + target: true, + handles: ['.'+CSS.HEADER], + dragConfig: {groups: this.groups} + }); + del.dd.plug(Y.Plugin.DDProxy, { + // Don't move the node at the end of the drag + moveOnEnd: false + }); + del.dd.plug(Y.Plugin.DDWinScroll); + var blocklist = blockregionnode.all('.'+CSS.BLOCK); blocklist.each(function(blocknode) { var move = blocknode.one('a.'+CSS.EDITINGMOVE); if (move) { move.remove(); blocknode.one('.'+CSS.HEADER).setStyle('cursor', 'move'); - // Make each div element in the list of blocks draggable - var dd = new Y.DD.Drag({ - node: blocknode, - groups: this.groups, - // Make each div a Drop target too - target: true, - handles: ['.'+CSS.HEADER] - }).plug(Y.Plugin.DDProxy, { - // Don't move the node at the end of the drag - moveOnEnd: false - }).plug(Y.Plugin.DDWinScroll); } }, this); }, this);