/**
* library for ajaxcourse formats, the classes and related functions for drag and drop blocks
- *
+ *
* this library requires a 'main' object created in calling document
*/
-//set Drag and Drop to Intersect mode:
-YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
+//set Drag and Drop to Intersect mode:
+YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
/**
block_class.prototype.startDrag = function(x, y) {
//operates in intersect mode
YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
-
+
YAHOO.log(this.id + " startDrag");
var dragEl = this.getDragEl();
var targets = YAHOO.util.DDM.getRelated(this, true);
YAHOO.log(targets.length + " targets");
-
+
//restyle side boxes to highlight
for (var i=0; i<targets.length; i++) {
-
+
var targetEl = targets[i].getEl();
-
+
targetEl.style.background = "#fefff0";
targetEl.opacity = .3;
targetEl.filter = "alpha(opacity=30)";
block_class.prototype.onDragDrop = function(e, id) {
// get the drag and drop object that was targeted
var oDD;
-
+
if ("string" == typeof id) {
oDD = YAHOO.util.DDM.getDDById(id);
} else {
}
var el = this.getEl();
-
+
if (this.debug) {
YAHOO.log("id="+id+" el="+e+" x="+YAHOO.util.Dom.getXY(this.getDragEl()));
}
this.move_block(id);
//YAHOO.util.DDM.moveToEl(el, oDD.getEl());
-
+
this.resetTargets();
}
block_class.prototype.find_target = function(column){
var collisions = column.find_sub_collision(YAHOO.util.Region.getRegion(this.getDragEl()));
-
+
//determine position
var insertbefore = null;
if(collisions.length == 0)
return;
-
- insertbefore = column.blocks[collisions[0][0]];
-
+
+ insertbefore = column.blocks[collisions[0][0]];
+
return insertbefore;
}
var targetEl = targets[i].getEl();
targetEl.style.background = "";
targetEl.opacity = 1;
- targetEl.filter = "alpha(opacity=100)";
+ targetEl.filter = "alpha(opacity=100)";
}
}
var inserttarget = this.find_target(column);
if(this.debug && inserttarget != null)YAHOO.log("moving "+this.getEl().id+" before "+inserttarget.getEl().id+" - parentNode="+this.getEl().parentNode.id);
-
+
if(this == inserttarget){
if(this.debug)YAHOO.log("Dropping on self, resetting");
this.endDrag();
return;
}
-
- //remove from document
+
+ //remove from document
if(this.getEl().parentNode != null)
- this.getEl().parentNode.removeChild(this.getEl());
-
+ this.getEl().parentNode.removeChild(this.getEl());
+
//insert into correct place
if(inserttarget != null ){
inserttarget.getEl().parentNode.insertBefore(this.getEl(),inserttarget.getEl());
-
+
}else if(column == main.rightcolumn){//if right side insert before admin block
- column.getEl().insertBefore(this.getEl(),main.adminBlock);
-
- }else{
- column.getEl().appendChild(this.getEl());
+ column.getEl().insertBefore(this.getEl(),main.adminBlock);
+
+ }else{
+ column.getEl().appendChild(this.getEl());
}
-
+
this.reset_regions();
-
+
//remove block from current array
if(main.rightcolumn.has_block(this))
main.rightcolumn.remove_block(this);
-
+
else if(main.leftcolumn.has_block(this))
main.leftcolumn.remove_block(this);
-
+
//insert into new array
column.insert_block(this,inserttarget);
-
+
}
// Remove from remote model.
main.connect('POST', 'class=block&action=DELETE&instanceId='+this.instanceId);
-
+
// Remove from view
main.blocks.splice(main.get_block_index(this), 1);
this.getEl().parentNode.removeChild(this.getEl());
column_class.prototype.init_column = function(id, group,config,ident){
if (!id) { return; }
-
+
this.initTarget(id,group,config);
this.blocks = new Array();
this.ident = ident;
-
+
// YAHOO.log("init_column "+id+"-"+el.id);
- this.region = YAHOO.util.Region.getRegion(id);
+ this.region = YAHOO.util.Region.getRegion(id);
}
if(this.debug)YAHOO.log(index+" Collides with "+this.blocks[i].getEl().id+" area" + collisions[index][1].getArea());
}
}
- return collisions;
+ return collisions;
}
column_class.prototype.add_block = function(el){
if(found > 0){
tempStore = this.blocks[i];
this.blocks[i] = nextStore;
- nextStore = tempStore;
-
+ nextStore = tempStore;
+
}else if(this.blocks[i] == targetel){
found = i;
nextStore = this.blocks[i];
- this.blocks[i] = el;
+ this.blocks[i] = el;
blockcount++;
- }
+ }
}
-
+
if(found<0){//insert at end
- found = this.blocks.length;
- this.add_block(el);
-
+ found = this.blocks.length;
+ this.add_block(el);
+
}
-
+
el.updatePosition(found,this.ident);
}
return true;
return false;
}
-
-
+
+
column_class.prototype.remove_block = function(el){
var blockcount = this.blocks.length;
var found = false;
if(this.blocks[i]==el || found){
if(!found)
found = true;
-
+
if(i < blockcount-1){
- this.blocks[i] = this.blocks[i+1];
+ this.blocks[i] = this.blocks[i+1];
}else{
- this.blocks.pop();
+ this.blocks.pop();
}
}
}
YAHOO.log("column "+this.indent+" has "+blockcount+"blocks");
}
-
-
-
+
+
+
YAHOO.util.Event.addListener(highlightbutton, 'click', this.mk_marker, this, true);
commandContainer.appendChild(highlightbutton);
this.highlightButton = highlightbutton;
- }
+ }
if (this.sectionId > 0 ) {
var viewbutton = main.mk_button('div', main.portal.icons['hide'], main.getString('hidesection', this.sectionId),
[['title', main.portal.strings['hide'] ]]);
}
-section_class.prototype.onDragDrop = function(e, id) {
+section_class.prototype.onDragDrop = function(e, id) {
// get the drag and drop object that was targeted
var target = YAHOO.util.DDM.getDDById(id);
//move on front end
for (var i=loopStart; eval(loopCondition); eval(loopInc)) {
- if ((main.sections[i] == this) && !found) {
+ if ((main.sections[i] == this) && !found) {
//encounter with original node
if (this.debug) {
YAHOO.log("Found Original "+main.sections[i].getEl().id);
YAHOO.log("Found target "+main.sections[i].getEl().id);
}
main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]);
- main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
+ main.sections[i].swap_dates(main.sections[eval(loopmodifier)]);
found = false;
break;
} else if (found) {