Y.extend(DRAGSECTION, M.core.dragdrop, {
sectionlistselector : null,
- initializer : function(params) {
+ initializer : function() {
// Set group for parent class
this.groups = [ CSS.SECTIONDRAGGABLE ];
this.samenodeclass = M.course.format.get_sectionwrapperclass();
loopend = dragnodeid;
}
- // Get the list of nodes
+ // Get the list of nodes.
drag.get('dragNode').removeClass(CSS.COURSECONTENT);
var sectionlist = Y.Node.all(this.sectionlistselector);
- // Add lightbox if it not there
+ // Add a lightbox if it's not there.
var lightbox = M.util.add_lightbox(Y, dragnode);
- var params = {};
+ // Handle any variables which we must pass via AJAX.
+ var params = {},
+ pageparams = this.get('config').pageparams,
+ varname;
- // Handle any variables which we must pass back through to
- var pageparams = this.get('config').pageparams;
for (varname in pageparams) {
+ if (!pageparams.hasOwnProperty(varname)) {
+ continue;
+ }
params[varname] = pageparams[varname];
}
params.id = dragnodeid;
params.value = dropnodeindex;
- // Do AJAX request
+ // Perform the AJAX request.
var uri = M.cfg.wwwroot + this.get('ajaxurl');
-
Y.io(uri, {
method: 'POST',
data: params,
on: {
- start : function(tid) {
+ start : function() {
lightbox.show();
},
success: function(tid, response) {
lightbox.hide();
}, 250);
},
+
failure: function(tid, response) {
this.ajax_failure(response);
lightbox.hide();
},
global_drop_over : function(e) {
- // Check that drop object belong to correct group
+ // Check that drop object belong to correct group.
if (!e.drop || !e.drop.inGroup(this.groups)) {
return;
}
- //Get a reference to our drag and drop nodes
- var drag = e.drag.get('node');
- var drop = e.drop.get('node');
- // Save last drop target for the case of missed target processing
+
+ // Get a reference to our drag and drop nodes.
+ var drag = e.drag.get('node'),
+ drop = e.drop.get('node');
+
+ // Save last drop target for the case of missed target processing.
this.lastdroptarget = e.drop;
- //Are we dropping on the same node?
+
+ // Are we dropping within the same parent node?
if (drop.hasClass(this.samenodeclass)) {
var where;