Changeset 5940
- Timestamp:
- 10/02/06 02:25:05 (2 years ago)
- Location:
- trunk/src
- Files:
-
- 1 removed
- 2 modified
-
namespaces/dojo.js (modified) (2 diffs)
-
widget/AccordionContainer.js (modified) (7 diffs)
-
widget/AccordionPane.js (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/namespaces/dojo.js
r5939 r5940 12 12 html: { 13 13 "accordioncontainer": "dojo.widget.AccordionContainer", 14 "treerpccontroller": "dojo.widget.TreeRPCController",15 "accordionpane": "dojo.widget.AccordionPane",16 14 "button": "dojo.widget.Button", 17 15 "chart": "dojo.widget.Chart", … … 95 93 "treecontrollerextension": "dojo.widget.TreeControllerExtension", 96 94 "treenode": "dojo.widget.TreeNode", 95 "treerpccontroller": "dojo.widget.TreeRPCController", 97 96 "treebasiccontrollerv3": "dojo.widget.TreeBasicControllerV3", 98 97 "treecontextmenuv3": "dojo.widget.TreeContextMenuV3", -
trunk/src/widget/AccordionContainer.js
r5910 r5940 1 dojo.provide("dojo.widget.AccordionContainer"); 2 3 dojo.require("dojo.widget.*"); 4 dojo.require("dojo.html.*"); 5 dojo.require("dojo.lfx.html"); 6 dojo.require("dojo.html.selection"); 7 dojo.require("dojo.widget.html.layout"); 8 dojo.require("dojo.widget.PageContainer"); 9 10 1 11 /** 2 * Holds a set of panes where every pane's title is visible, but only one pane's content is visible at a time. 3 * 4 * Front view (3 panes, pane #2 open) 5 * ------------------------ 6 * |:::Pane#1 title::: | 7 * |:::Pane#2 title::: | 8 * | | 9 * | pane#2 contents | 10 * | | 11 * |:::Pane#3 title::: | 12 * ------------------------ 13 * 14 * Side view (showing implementation): 12 *summary 13 * Holds a set of panes where every pane's title is visible, but only one pane's content is visible at a time, 14 * and switching between panes is visualized by sliding the other panes up/down. 15 * 16 * description 17 * Front view (3 panes, pane #2 open) 18 * ------------------------ 19 * |:::Pane#1 title::: | 20 * |:::Pane#2 title::: | 21 * | | 22 * | pane#2 contents | 23 * | | 24 * |:::Pane#3 title::: | 25 * ------------------------ 26 * 27 * Side view (showing implementation): 15 28 * 16 29 * viewport pane#3 pane#2 pane#1 … … 18 31 * | = 19 32 * | = | 20 * front| | |33 * front | | | 21 34 * | | = 22 35 * | = … … 26 39 * = 27 40 * 28 * Panes are stacked by z-index like a stack of cards, so they can be slid correctly. 29 * The panes on the bottom extend past the bottom of the viewport. 30 * 31 * TODO: this class should extend PageContainer 41 * Panes are stacked by z-index like a stack of cards, so they can be slid correctly. 42 * The panes on the bottom extend past the bottom of the viewport (but are hidden). 43 * 44 * TODO: 45 * * this widget should extend PageContainer 46 * * call child.onShow(), child.onHide() so you can attach to those methods if you want 32 47 */ 33 34 dojo.provide("dojo.widget.AccordionContainer"); 35 36 dojo.require("dojo.widget.*"); 37 dojo.require("dojo.html.*"); 38 dojo.require("dojo.lfx.html"); 39 dojo.require("dojo.widget.AccordionPane"); 40 dojo.require("dojo.widget.PageContainer"); 41 42 dojo.widget.defineWidget( 48 dojo.widget.defineWidget( 43 49 "dojo.widget.AccordionContainer", 44 50 dojo.widget.HtmlWidget, 45 51 { 46 52 isContainer: true, 53 54 // String 55 // CSS class name for dom node w/the title 47 56 labelNodeClass: "label", 57 58 // String 59 // CSS class name for dom node holding the content 48 60 containerNodeClass: "accBody", 49 61 … … 62 74 }, 63 75 64 addChild: function( widget, overrideContainerNode, pos, ref, insertIndex){76 addChild: function(/*Widget*/ widget){ 65 77 var child = this._addChild(widget); 66 78 this._setSizes(); … … 99 111 }, 100 112 101 removeChild: function( widget) {113 removeChild: function(/*Widget*/ widget) { 102 114 dojo.widget.AccordionContainer.superclass.removeChild.call(this, widget); 103 115 this._setSizes(); … … 110 122 _setSizes: function() { 111 123 // summary 112 // Move panes to right position based oncurrent open node.124 // Set panes' size/position based on my size, and the current open node. 113 125 114 126 // get cumulative height of all the title bars, and figure out which pane is open … … 152 164 ); 153 165 166 /** 167 * summary 168 * AccordionPane is a box with a title that contains another widget (often a ContentPane). 169 * It's a widget used internally by AccordionContainer. 170 */ 171 dojo.widget.defineWidget( 172 "dojo.widget.AccordionPane", 173 dojo.widget.HtmlWidget, 174 { 175 // parameters 176 177 // String 178 // label to print on top of AccordionPane 179 label: "", 180 181 // String 182 // CSS class name for the AccordionPane's dom node 183 "class": "dojoAccordionPane", 184 185 // String 186 // CSS class name for the AccordionPane's label node 187 labelNodeClass: "label", 188 189 // String 190 // CSS class name for the AccordionPane's container node 191 containerNodeClass: "accBody", 192 193 // Boolean 194 // if true, this is the open pane 195 selected: false, 196 197 templatePath: dojo.uri.dojoUri("src/widget/templates/AccordionPane.html"), 198 templateCssPath: dojo.uri.dojoUri("src/widget/templates/AccordionPane.css"), 199 200 isContainer: true, 201 202 fillInTemplate: function() { 203 dojo.html.addClass(this.domNode, this["class"]); 204 dojo.widget.AccordionPane.superclass.fillInTemplate.call(this); 205 dojo.html.disableSelection(this.labelNode); 206 this.setSelected(this.selected); 207 }, 208 209 setLabel: function(/*String*/ label) { 210 // summary: set the title of the node 211 this.labelNode.innerHTML=label; 212 }, 213 214 resizeTo: function(width, height){ 215 dojo.html.setMarginBox(this.domNode, {width: width, height: height}); 216 var children = [ 217 {domNode: this.labelNode, layoutAlign: "top"}, 218 {domNode: this.containerNode, layoutAlign: "client"} 219 ]; 220 dojo.widget.html.layout(this.domNode, children); 221 var childSize = dojo.html.getContentBox(this.containerNode); 222 this.children[0].resizeTo(childSize.width, childSize.height); 223 }, 224 225 getLabelHeight: function() { 226 // summary: returns the height of the title dom node 227 return dojo.html.getMarginBox(this.labelNode).height; 228 }, 229 230 onLabelClick: function() { 231 // summary: callback when someone clicks my label 232 this.parent.selectChild(this); 233 }, 234 235 setSelected: function(/*Boolean*/ isSelected){ 236 this.selected=isSelected; 237 (isSelected ? dojo.html.addClass : dojo.html.removeClass)(this.domNode, this["class"]+"-selected"); 238 239 // make sure child is showing (lazy load) 240 if(isSelected && this.children.length){ 241 var child = this.children[0]; 242 if(!child.isShowing()){ 243 child.show(); 244 } 245 } 246 } 247 }); 248 154 249 // These arguments can be specified for the children of an AccordionContainer 155 250 // Since any widget can be specified as a child, mix them