mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Some fixes for MDL-6674. This should fix moving activities (resources).
Thanks to Dan Poltawski for suggestions.
This commit is contained in:
parent
8e6461f749
commit
64e5a68d91
@ -29,7 +29,7 @@ section_class.prototype.init_section = function(id, group,config,isDraggable) {
|
||||
this.handle = null;
|
||||
}
|
||||
|
||||
this.createFrame();
|
||||
this.createFrame();
|
||||
this.isTarget = true;
|
||||
|
||||
this.resources = [];
|
||||
@ -341,20 +341,20 @@ section_class.prototype.remove_resource = function(el) {
|
||||
|
||||
}
|
||||
|
||||
section_class.prototype.insert_resource = function(el,targetel) {
|
||||
section_class.prototype.insert_resource = function(el, targetel) {
|
||||
var resourcecount = this.resources.length;
|
||||
var found = false;
|
||||
var tempStore = nextStore = null;
|
||||
|
||||
//update in backend
|
||||
targetId='';
|
||||
if (targetel !=null) {
|
||||
targetId=targetel.id;
|
||||
}
|
||||
|
||||
main.connect('post','class=resource&field=move',null,'id='+el.id+'&beforeId='+targetId+'§ionId='+this.sectionId);
|
||||
|
||||
targetId = '';
|
||||
if (targetel != null) {
|
||||
targetId = targetel.id;
|
||||
}
|
||||
|
||||
main.connect('post', 'class=resource&field=move', null,
|
||||
'id='+el.id+'&beforeId='+targetId
|
||||
+'§ionId='+this.id.replace(/section-/i, ''));
|
||||
|
||||
//if inserting into a hidden resource hide
|
||||
if (this.hidden) {
|
||||
@ -572,41 +572,45 @@ resource_class.prototype.startDrag = function(x, y) {
|
||||
resource_class.prototype.onDragDrop = function(e, ids) {
|
||||
// best fit Id
|
||||
var id=[];
|
||||
for (var i=0;i<ids.length;i++)
|
||||
if (ids[i].is == 'resource')
|
||||
|
||||
for (var i=0; i<ids.length; i++) {
|
||||
if (ids[i].is == 'resource') {
|
||||
id[id.length] = ids[i];
|
||||
|
||||
if (id.length == 0)
|
||||
}
|
||||
}
|
||||
if (id.length == 0) {
|
||||
id = ids;
|
||||
|
||||
}
|
||||
|
||||
// get the drag and drop object that was targeted
|
||||
var target = YAHOO.util.DDM.getBestMatch(id);
|
||||
|
||||
if (this.debug)YAHOO.log("dropped on id="+target+" el = "+this.getEl().id+" x="+YAHOO.util.Dom.getXY(this.getDragEl()));
|
||||
if (this.debug) {
|
||||
YAHOO.log("Dropped on section id="+target.id.replace(/section-/i, '')
|
||||
+", el="+this.getEl().id
|
||||
+", x="+YAHOO.util.Dom.getXY( this.getDragEl() ));
|
||||
}
|
||||
/* var oldid = this.parentObj.id;
|
||||
this.previousId = oldid.replace(/section-/i, '');*/
|
||||
this.parentObj.remove_resource(this);
|
||||
|
||||
this.parentObj.remove_resource(this);
|
||||
|
||||
if (target.is == 'resource'||target.is == 'activity') {
|
||||
target.parentObj.insert_resource(this,target);
|
||||
|
||||
} else if (target.is =='section') {
|
||||
if (target.is == 'resource' || target.is == 'activity') {
|
||||
target.parentObj.insert_resource(this, target);
|
||||
} else if (target.is == 'section') {
|
||||
target.insert_resource(this);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
resource_class.prototype.endDrag = function() {
|
||||
//eliminates default action
|
||||
}
|
||||
|
||||
/*
|
||||
* activity Class extends resource class
|
||||
*/
|
||||
resource_class.prototype.endDrag = function() {
|
||||
// Eliminates default action
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* activity Class extends resource class
|
||||
*/
|
||||
|
||||
function activity_class(id,group,config,parentObj) {
|
||||
this.init_activity(id,group,config,parentObj);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user