public
Fork of sproutit/sproutcore
Description: JavaScript Application Framework - JS library only
Homepage: http://www.sproutcore.com
Clone URL: git://github.com/mauritslamers/sproutcore.git
Added working disabler and enabler to SC.CollectionView
Maurits Lamers (author)
Thu Nov 27 05:26:53 -0800 2008
commit  f212cda55ee2716b9f866db3d66c61190d7cddf1
tree    595a33314eb051f3a67ff4411f55b75219e04ebd
parent  e6917cb39a730f25a6f3781f45753ca724a7d61f
...
538
539
540
541
 
542
543
544
...
625
626
627
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
629
630
...
1055
1056
1057
1058
 
1059
1060
1061
...
538
539
540
 
541
542
543
544
...
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
...
1100
1101
1102
 
1103
1104
1105
1106
0
@@ -538,7 +538,7 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate,
0
   /**
0
     Returns the groupView that represents the passed group value.
0
     
0
-    If no group view is currently rendered for the gorup value, this method
0
+    If no group view is currently rendered for the group value, this method
0
     will return null.  If grouping is disabled, this method will also return
0
     null.
0
     
0
@@ -625,6 +625,51 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate,
0
   //
0
   
0
   /**
0
+   Update the enabled status of the child views
0
+  
0
+  */
0
+  
0
+  _updateChildrensEnabledState: function(children){
0
+    // recursively running through the children
0
+    if(!children.childNodes){
0
+      //check for the empty array not necessary, as checked by observer
0
+      // if no childNodes found, children is just an array, so set the state on every item
0
+      if(this.isEnabled){
0
+         children.each(function(s){
0
+           if(s.removeClassName){
0
+             s.removeClassName('disabled');
0
+           }
0
+         });
0
+      }
0
+      else {
0
+        children.each(function(s){
0
+          if(s.addClassName){
0
+            s.addClassName('disabled'); 
0
+          }
0
+        });  
0
+      } // end if(this.isEnabled)
0
+    } // end if (!children.childNodes)
0
+    else {
0
+      // childnodes found
0
+      children.childNodes.each(this._updateChildrensEnabledState(s));
0
+      // and set the state on the current object too
0
+      if(this.isEnabled && children.addClassName){ // if addClassName exists, so does removeClassName
0
+        children.addClassName('disabled');
0
+      }
0
+      else {
0
+        children.removeClassName('disabled');  
0
+      }    
0
+    } // end childnodes found
0
+  },
0
+  
0
+  updateChildrensEnabledState: function(){
0
+   // updating children only makes sense when there are children to update
0
+   if(this.childNodes && (this.childNodes.length>0)){
0
+      this._updateChildrensEnabledState(this.childNodes);   
0
+   }
0
+  }.observes('isEnabled'),
0
+  
0
+  /**
0
     Update the itemViews in the receiver to match the currently visible 
0
     content objects.  Normally this method assumes the content objects 
0
     themselves have not changed and only updates the views if the range of 
0
@@ -1055,7 +1100,7 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate,
0
         owner: this, displayDelegate: this 
0
       }) ;
0
       ret.addClassName('sc-collection-item') ; // add class name for display
0
-      
0
+
0
       // set content and add to content hash
0
       ret.set('content', content) ;
0
       this._itemViewsByContent[key] = ret ;
...
317
318
319
320
321
322
323
...
334
335
336
337
338
339
340
...
317
318
319
 
320
321
322
...
333
334
335
 
336
337
338
0
@@ -317,7 +317,6 @@ SC.ListItemView = SC.View.extend(SC.Control, SC.InlineEditorDelegate,
0
     button.
0
    */
0
    mouseDown: function(evt) {
0
-
0
       var del = this.displayDelegate ;
0
       var checkboxKey = this.getDelegateProperty(del, 'contentCheckboxKey') ;
0
       if (checkboxKey) {
0
@@ -334,7 +333,6 @@ SC.ListItemView = SC.View.extend(SC.Control, SC.InlineEditorDelegate,
0
    mouseUp: function(evt) {
0
      var ret= NO ;
0
      if (this._isMouseDownOnCheckbox) {
0
-       
0
        // update only if mouse inside on mouse up...
0
        if (this._isMouseInsideCheckbox) {
0
          var del = this.displayDelegate ;

Comments