Changeset 6114

Show
Ignore:
Timestamp:
04/23/10 18:09:46 (3 years ago)
Author:
Cyrus
Message:

nyu2: Prepare iterator support

Location:
luci2/nyu2/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • luci2/nyu2/src/nyu2/widget.js

    r6113 r6114  
    2626        if (this.container && this.container != this) { 
    2727            this.container.registry[this.name] = this; 
     28        } 
     29        if (!this.caption) { 
     30            this.caption = this.name; 
    2831        } 
    2932         
     
    3942         
    4043        if (!this.isPlain) { 
     44            this.body = $('<div class="nyu2-widget-body" />'); 
     45             
    4146            this.header = $("<div />"); 
    42             this.body = $('<div class="nyu2-widget-body" />'); 
    4347            this.footer = $('<div class="nyu2-widget-footer" />');; 
    4448     
     
    6367                var child = nyu2.parseWidget(key, options.elements[key], this); 
    6468                if (child) { 
    65                     this.append(child); 
     69                    this.append(child, key); 
    6670                } 
    6771            } 
     
    148152            this.node.addClass(options.css); 
    149153        } 
    150     } 
     154    }, 
    151155}); 
    152156 
    153157nyu2.widget.Iterate = nyu2.declare(nyu2.Widget, { 
    154158    isContainer: true, 
    155     isSection: true 
     159    isSection: true, 
     160    useTabular: true, 
     161     
     162    prepare: function(options) { 
     163        this.elements = {}; 
     164    }, 
     165     
     166    complete: function(options) { 
     167        if (this.useTabular) { 
     168            this.sectiontable = $("<table />").appendTo(this.body); 
     169            var titlerow = $("<tr />").appendTo(this.sectiontable); 
     170            for (var key in this.elements) { 
     171                titlerow.append($("<th />").text(this.elements[key].caption)); 
     172            } 
     173        } 
     174    }, 
     175     
     176    append: function(child, key) { 
     177        if (child.isPlain || child.isContainer) { 
     178            this.children.push(child); 
     179            this.body.append(child.node); 
     180        } else { 
     181            this.elements[key] = child; 
     182        } 
     183    } 
    156184}); 
    157185 
  • luci2/nyu2/src/style.css

    r6113 r6114  
    44 
    55#nyu2-main { 
    6     width: 300px; 
     6    max-width: 400px; 
    77} 
    88