From 7f933d8f71ac4c717ff70d712b10a9982ce98a8d Mon Sep 17 00:00:00 2001 From: vyshane Date: Tue, 17 Oct 2006 04:00:57 +0000 Subject: [PATCH] Merged from 1.7. --- lib/ajax/section_classes.js | 88 ++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 1616a00ad3..b08bd8272d 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -4,6 +4,14 @@ * * This library requires a 'main' object created in calling document. * + * Drag and drop notes: + * + * Dropping an activity or resource on a section will always add the activity + * or resource at the end of that section. + * + * Dropping an activity or resource on another activity or resource will + * always move the former just above the latter. + * * $Id$ */ @@ -128,19 +136,19 @@ section_class.prototype.process_section = function() { this.resources_ul.className='section'; this.content_td.insertBefore(this.resources_ul, this.content_td.childNodes[1]); } - var resource_count = this.resources_ul.getElementsByTagName('li').length; for (var i=0;i 0) { + // We need to have a border at the bottom of the last activity in + // that section. + YAHOO.util.Dom.setStyle(target.resources[target.resources.length - 1].getEl().id, + 'border-bottom', '1px solid #BBB'); } +} - // get the drag and drop object that was targeted - var target = YAHOO.util.DDM.getBestMatch(id); +resource_class.prototype.onDragOut = function(e, ids) { + var target = YAHOO.util.DDM.getBestMatch(ids); + this.clear_move_markers(target); +} +resource_class.prototype.onDragDrop = function(e, ids) { + var target = YAHOO.util.DDM.getBestMatch(ids); + if (this.debug) { YAHOO.log("Dropped on section id="+target.sectionId +", 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); if (target.is == 'resource' || target.is == 'activity') { target.parentObj.insert_resource(this, target); } else if (target.is == 'section') { - target.insert_resource(this); + target.insert_resource(this); } + this.clear_move_markers(target); return; } @@ -618,28 +641,24 @@ resource_class.prototype.endDrag = function() { } - /** * activity_class extends resource class */ -function activity_class(id,group,config,parentObj) { - this.init_activity(id,group,config,parentObj); +function activity_class(id, group, config, parentObj) { + this.init_activity(id, group, config, parentObj); } YAHOO.extend(activity_class, resource_class); -activity_class.prototype.init_activity = function(id,group,config,parentObj) { +activity_class.prototype.init_activity = function(id, group, config, parentObj) { if (!id) { YAHOO.log("Init activity, NO ID FOUND!",'error'); return; } - this.is = 'activity'; this.currentGroup = this.get_current_group(id); - - this.init_resource(id,group,config,parentObj); - + this.init_resource(id, group, config, parentObj); this.groupButton= null; this.init_activity_button(); @@ -648,7 +667,7 @@ activity_class.prototype.init_activity = function(id,group,config,parentObj) { } } -activity_class.prototype.groupImages = ['/pix/t/groupn.gif','/pix/t/groups.gif','/pix/t/groupv.gif']; +activity_class.prototype.groupImages = ['/pix/t/groupn.gif', '/pix/t/groups.gif', '/pix/t/groupv.gif']; activity_class.prototype.init_activity_button = function() { var button = main.mk_button('a',this.groupImages[this.currentGroup]); @@ -661,7 +680,6 @@ activity_class.prototype.get_current_group = function(id) { if (document.getElementById(id) == null) { return; } - var groupNodeArray = document.getElementById(id).getElementsByTagName('a'); var groupNode = groupNodeArray[groupNodeArray.length-1]; @@ -680,5 +698,5 @@ activity_class.prototype.toggle_group = function() { } this.groupButton.getElementsByTagName('img')[0].src = main.portal.wwwroot + this.groupImages[this.currentGroup]; - main.connect('post','class=resource&field=groupmode',null,'value='+this.currentGroup+'&id='+this.id); + main.connect('post', 'class=resource&field=groupmode', null, 'value='+this.currentGroup+'&id='+this.id); } -- 2.39.5