| 1 |
define(["dojo/_base/declare", "dojo/_base/lang", "dijit/registry", "dojo/dom-attr", "dojo/dom-geometry", |
| 2 |
"dojo/dom-style", "dijit/_WidgetBase", "dijit/_Container", "dijit/_Contained", "dojo/_base/array", "dojo/query", "../utils/layout", "./_ScrollableMixin"], |
| 3 |
function(declare, lang, registry, domAttr, domGeom, domStyle, WidgetBase, Container, Contained, array, query, layoutUtils, ScrollableMixin){ |
| 4 |
return declare("dojox.app.widgets.Container", [WidgetBase, Container, Contained, ScrollableMixin], { |
| 5 |
scrollable: false, |
| 6 |
fixedFooter:"", |
| 7 |
fixedHeader:"", |
| 8 |
|
| 9 |
buildRendering: function(){ |
| 10 |
|
| 11 |
if(!this._constraint){ |
| 12 |
this._constraint = "center"; |
| 13 |
domAttr.set(this.srcNodeRef, "data-app-constraint", "center"); |
| 14 |
} |
| 15 |
this.inherited(arguments); |
| 16 |
|
| 17 |
|
| 18 |
domStyle.set(this.domNode, "overflow-x", "hidden"); |
| 19 |
domStyle.set(this.domNode, "overflow-y", "auto"); |
| 20 |
|
| 21 |
|
| 22 |
if(this.scrollable){ |
| 23 |
this.inherited(arguments); |
| 24 |
this.domNode.style.position = "absolute"; |
| 25 |
this.domNode.style.width = "100%"; |
| 26 |
this.domNode.style.height = "100%"; |
| 27 |
} |
| 28 |
}, |
| 29 |
|
| 30 |
startup: function(){ |
| 31 |
if(this._started){ |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
if(this.scrollable){ |
| 36 |
this.inherited(arguments); |
| 37 |
} |
| 38 |
this._started = true; |
| 39 |
}, |
| 40 |
|
| 41 |
resize: function(changeSize, resultSize){ |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
var node = this.domNode; |
| 81 |
|
| 82 |
if(this.scrollable){ |
| 83 |
this.inherited(arguments); |
| 84 |
this.layout(); |
| 85 |
return; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
if(changeSize){ |
| 90 |
domGeom.setMarginBox(node, changeSize); |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
var mb = resultSize || {}; |
| 97 |
lang.mixin(mb, changeSize || {}); |
| 98 |
if( !("h" in mb) || !("w" in mb) ){ |
| 99 |
mb = lang.mixin(domGeom.getMarginBox(node), mb); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
var cs = domStyle.getComputedStyle(node); |
| 105 |
var me = domGeom.getMarginExtents(node, cs); |
| 106 |
var be = domGeom.getBorderExtents(node, cs); |
| 107 |
var bb = (this._borderBox = { |
| 108 |
w: mb.w - (me.w + be.w), |
| 109 |
h: mb.h - (me.h + be.h) |
| 110 |
}); |
| 111 |
var pe = domGeom.getPadExtents(node, cs); |
| 112 |
this._contentBox = { |
| 113 |
l: domStyle.toPixelValue(node, cs.paddingLeft), |
| 114 |
t: domStyle.toPixelValue(node, cs.paddingTop), |
| 115 |
w: bb.w - pe.w, |
| 116 |
h: bb.h - pe.h |
| 117 |
}; |
| 118 |
|
| 119 |
|
| 120 |
this.layout(); |
| 121 |
}, |
| 122 |
|
| 123 |
layout: function(){ |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
var children = query("> [data-app-constraint]", this.domNode).map(function(node){ |
| 128 |
var w = registry.getEnclosingWidget(node); |
| 129 |
if(w){ |
| 130 |
w._constraint = domAttr.get(node, "data-app-constraint"); |
| 131 |
return w; |
| 132 |
} |
| 133 |
|
| 134 |
return { |
| 135 |
domNode: node, |
| 136 |
_constraint: domAttr.get(node, "data-app-constraint") |
| 137 |
}; |
| 138 |
}); |
| 139 |
|
| 140 |
if(this._contentBox){ |
| 141 |
layoutUtils.layoutChildren(this.domNode, this._contentBox, children); |
| 142 |
} |
| 143 |
array.forEach(this.getChildren(), function(child){ |
| 144 |
if(!child._started && child.startup){ |
| 145 |
child.startup(); |
| 146 |
} |
| 147 |
}); |
| 148 |
} |
| 149 |
}); |
| 150 |
}); |