MDL-43723 Blocks drag and drop: Javascript cleanup

Declare the selector instead of repeating it several times.
This commit is contained in:
Damyon Wiese
2014-02-25 17:01:45 +08:00
parent 58ff6e51df
commit 45fdcb7ce3
5 changed files with 23 additions and 11 deletions
@@ -21,6 +21,10 @@ CSS = {
REGIONMAIN : 'region-main'
};
var SELECTOR = {
DRAGHANDLE : '.' + CSS.HEADER + ' .commands .moodle-core-dragdrop-draghandle'
};
/**
* Legacy drag and drop manager.
* This drag and drop manager is specifically designed for themes using side-pre and side-post
@@ -101,7 +105,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
container: blockregionnode,
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});
@@ -116,7 +120,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
var move = blocknode.one('a.'+CSS.EDITINGMOVE);
if (move) {
move.replace(this.get_drag_handle(move.getAttribute('title'), '', 'iconsmall', true));
blocknode.one('.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle').setStyle('cursor', 'move');
blocknode.one(SELECTOR.DRAGHANDLE).setStyle('cursor', 'move');
}
}, this);
}, this);
@@ -480,7 +484,7 @@ MANAGER.prototype = {
container: region.get_droptarget(),
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});
File diff suppressed because one or more lines are too long
+7 -3
View File
@@ -21,6 +21,10 @@ CSS = {
REGIONMAIN : 'region-main'
};
var SELECTOR = {
DRAGHANDLE : '.' + CSS.HEADER + ' .commands .moodle-core-dragdrop-draghandle'
};
/**
* Legacy drag and drop manager.
* This drag and drop manager is specifically designed for themes using side-pre and side-post
@@ -101,7 +105,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
container: blockregionnode,
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});
@@ -116,7 +120,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
var move = blocknode.one('a.'+CSS.EDITINGMOVE);
if (move) {
move.replace(this.get_drag_handle(move.getAttribute('title'), '', 'iconsmall', true));
blocknode.one('.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle').setStyle('cursor', 'move');
blocknode.one(SELECTOR.DRAGHANDLE).setStyle('cursor', 'move');
}
}, this);
}, this);
@@ -479,7 +483,7 @@ MANAGER.prototype = {
container: region.get_droptarget(),
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});
+6 -2
View File
@@ -19,6 +19,10 @@ CSS = {
REGIONMAIN : 'region-main'
};
var SELECTOR = {
DRAGHANDLE : '.' + CSS.HEADER + ' .commands .moodle-core-dragdrop-draghandle'
};
/**
* Legacy drag and drop manager.
* This drag and drop manager is specifically designed for themes using side-pre and side-post
@@ -99,7 +103,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
container: blockregionnode,
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});
@@ -114,7 +118,7 @@ Y.extend(DRAGBLOCK, M.core.dragdrop, {
var move = blocknode.one('a.'+CSS.EDITINGMOVE);
if (move) {
move.replace(this.get_drag_handle(move.getAttribute('title'), '', 'iconsmall', true));
blocknode.one('.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle').setStyle('cursor', 'move');
blocknode.one(SELECTOR.DRAGHANDLE).setStyle('cursor', 'move');
}
}, this);
}, this);
+1 -1
View File
@@ -98,7 +98,7 @@ MANAGER.prototype = {
container: region.get_droptarget(),
nodes: '.'+CSS.BLOCK,
target: true,
handles: ['.'+CSS.HEADER+' .commands .moodle-core-dragdrop-draghandle'],
handles: [SELECTOR.DRAGHANDLE],
invalid: '.block-hider-hide, .block-hider-show, .moveto',
dragConfig: {groups: this.groups}
});