Permalink
Browse files

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.
  • Loading branch information...
1 parent a000ff6 commit 6cc43fedbb82121f45ebc80954550528b484c709 @pauln pauln committed with andrewnicols Sep 5, 2012
Showing with 14 additions and 11 deletions.
  1. +14 −11 lib/yui/blocks/blocks.js
View
25 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);

0 comments on commit 6cc43fe

Please sign in to comment.