]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7.
authorvyshane <vyshane>
Tue, 14 Nov 2006 05:04:15 +0000 (05:04 +0000)
committervyshane <vyshane>
Tue, 14 Nov 2006 05:04:15 +0000 (05:04 +0000)
lib/ajax/block_classes.js

index 1ce31817404b67c1ff026e5e80eceee887d4356b..4292eb4e0b7a813061199d5e758cc21c6df074b3 100644 (file)
@@ -21,39 +21,40 @@ YAHOO.extend(block_class, YAHOO.util.DDProxy);
 
 block_class.prototype.debug = false;
 
-block_class.prototype.init_block = function(id, sGroup, config){
-    if (!id) { return; }
 
-    //Drag and Drop 
+block_class.prototype.init_block = function(id, sGroup, config) {
+
+       if (!id) {
+               return;
+       }
+
+    //Drag and Drop
     this.init(id, sGroup, config);
     this.initFrame();
     this.createFrame();
-    
-    this.is = 'block'; 
-    this.instanceId = this.getEl().id.replace(/inst/i,'');
-    
+
+    this.is = 'block';
+    this.instanceId = this.getEl().id.replace(/inst/i, '');
+
     this.addInvalidHandleType('a');
-    
+
     var s = this.getEl().style;
     s.opacity = 0.76;
     s.filter = "alpha(opacity=76)";
-    
-    
+
     // specify that this is not currently a drop target
     this.isTarget = false;
-    
-        this.region = YAHOO.util.Region.getRegion(this.getEl());
 
+    this.region = YAHOO.util.Region.getRegion(this.getEl());
     this.type = block_class.TYPE;
-    
-    
-    //DHTML 
+
+    //DHTML
     this.viewbutton = null;
     this.originalClass = this.getEl().className;
-    
+
     this.init_buttons();
-    }
+}
+
 
 block_class.prototype.startDrag = function(x, y) {
     //operates in intersect mode
@@ -189,61 +190,75 @@ block_class.prototype.move_block = function(columnid){
         
     }
 
-block_class.prototype.reset_regions = function(){
-      var blockcount = main.blocks.length;
-      for(i=0;i<blockcount;i++)
-           main.blocks[i].region = YAHOO.util.Region.getRegion(main.blocks[i].getEl());
-    }
 
-block_class.prototype.init_buttons = function(){
+block_class.prototype.reset_regions = function() {
+       var blockcount = main.blocks.length;
+    for (i=0; i<blockcount; i++) {
+               main.blocks[i].region = YAHOO.util.Region.getRegion(main.blocks[i].getEl());
+       }
+}
 
-       var viewbutton = main.mk_button('a', '/t/hide.gif',[['class','icon hide']]);
-       YAHOO.util.Event.addListener(viewbutton,'click',this.toggle_hide,this,true);
 
-       var deletebutton = main.mk_button('a', '/t/delete.gif',[['class','icon delete']]);
-       YAHOO.util.Event.addListener(deletebutton,'click',this.delete_button,this,true);       
-       
-       
-       this.viewbutton = viewbutton;
-       
-       buttonCont = YAHOO.util.Dom.getElementsByClassName('commands','div',this.getEl())[0];       
-       buttonCont.appendChild(viewbutton);
-       buttonCont.appendChild(deletebutton);       
+block_class.prototype.init_buttons = function() {
+       var viewbutton = main.mk_button('a', '/t/hide.gif', [['class', 'icon hide']]);
+    YAHOO.util.Event.addListener(viewbutton, 'click', this.toggle_hide, this, true);
 
-    }
+    var deletebutton = main.mk_button('a', '/t/delete.gif', [['class', 'icon delete']]);
+    YAHOO.util.Event.addListener(deletebutton, 'click', this.delete_button, this, true);
+
+    this.viewbutton = viewbutton;
+
+    buttonCont = YAHOO.util.Dom.getElementsByClassName('commands', 'div', this.getEl())[0];
+
+       if (buttonCont) {
+       buttonCont.appendChild(viewbutton);
+       buttonCont.appendChild(deletebutton);
+       }
+}
 
-block_class.prototype.toggle_hide = function(e,target,isCosmetic){     
-       if(YAHOO.util.Dom.hasClass(this.getEl(),'hidden')){
-           this.getEl().className = this.originalClass;
-           this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/show.gif/i,'hide.gif');
-           if(!isCosmetic)main.connect('post','class=block&field=visible',null,'value=1&instanceId='+this.instanceId);
-           
-       }else{
-           this.originalClass = this.getEl().className;
-           this.getEl().className = "hidden sideblock";
-           this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/hide.gif/i,'show.gif');
-           if(!isCosmetic)main.connect('post','class=block&field=visible',null,'value=0&instanceId='+this.instanceId);
-           
-       }
+
+block_class.prototype.toggle_hide = function(e, target, isCosmetic) {
+
+    if (YAHOO.util.Dom.hasClass(this.getEl(), 'hidden')) {
+       this.getEl().className = this.originalClass;
+        this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/show.gif/i, 'hide.gif');
+
+        if (!isCosmetic) {
+                       main.connect('post', 'class=block&field=visible', null,
+                                                'value=1&instanceId='+this.instanceId);
+               }
+    } else {
+        this.originalClass = this.getEl().className;
+        this.getEl().className = "hidden sideblock";
+        this.viewbutton.childNodes[0].src = this.viewbutton.childNodes[0].src.replace(/hide.gif/i,'show.gif');
+
+        if (!isCosmetic) {
+                       main.connect('post', 'class=block&field=visible', null,
+                                                'value=0&instanceId='+this.instanceId);
+        }
     }
+}
 
-block_class.prototype.delete_button = function(){
-        //remove from local model
-        if(main.rightcolumn.has_block(this))
-              main.rightcolumn.remove_block(this);
-              
-        else if(main.leftcolumn.has_block(this))
-              main.leftcolumn.remove_block(this);
-        
-        //remove from remote model
-        main.connect('delete','class=block&instanceId='+this.instanceId);
-        
-        //remove from view
-        if(this.debug)YAHOO.log("Deleting "+this.getEl().id);
-        main.blocks[main.get_block_index(this)] = null;
-        this.getEl().parentNode.removeChild(this.getEl());                              
+
+block_class.prototype.delete_button = function() {
+
+       //remove from local model
+    if (main.rightcolumn.has_block(this)) {
+       main.rightcolumn.remove_block(this);
+    } else if (main.leftcolumn.has_block(this)) {
+        main.leftcolumn.remove_block(this);
+       }
+    //remove from remote model
+    main.connect('delete','class=block&instanceId='+this.instanceId);
         
-    } 
+    //remove from view
+    main.blocks[main.get_block_index(this)] = null;
+    this.getEl().parentNode.removeChild(this.getEl());
+
+       if (this.debug) {
+               YAHOO.log("Deleting "+this.getEl().id);
+       }
+}