| 1 |
define([ |
| 2 |
"dojo/_base/array", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/dom-class", |
| 5 |
"dojo/dom-construct", |
| 6 |
"dijit/registry", |
| 7 |
"./View", |
| 8 |
"./_ScrollableMixin" |
| 9 |
], function(array, declare, domClass, domConstruct, registry, View, ScrollableMixin){ |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
return declare("dojox.mobile.ScrollableView", [View, ScrollableMixin], { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
scrollableParams: null, |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
keepScrollPos: false, |
| 35 |
|
| 36 |
constructor: function(){ |
| 37 |
|
| 38 |
|
| 39 |
this.scrollableParams = {noResize: true}; |
| 40 |
}, |
| 41 |
|
| 42 |
buildRendering: function(){ |
| 43 |
this.inherited(arguments); |
| 44 |
domClass.add(this.domNode, "mblScrollableView"); |
| 45 |
this.domNode.style.overflow = "hidden"; |
| 46 |
this.domNode.style.top = "0px"; |
| 47 |
this.containerNode = domConstruct.create("div", |
| 48 |
{className:"mblScrollableViewContainer"}, this.domNode); |
| 49 |
this.containerNode.style.position = "absolute"; |
| 50 |
this.containerNode.style.top = "0px"; |
| 51 |
if(this.scrollDir === "v"){ |
| 52 |
this.containerNode.style.width = "100%"; |
| 53 |
} |
| 54 |
}, |
| 55 |
|
| 56 |
startup: function(){ |
| 57 |
if(this._started){ return; } |
| 58 |
|
| 59 |
if(this.fixedFooter && !this.isLocalFooter){ |
| 60 |
this._fixedAppFooter = this.fixedFooter; |
| 61 |
this.fixedFooter = ""; |
| 62 |
} |
| 63 |
this.reparent(); |
| 64 |
this.inherited(arguments); |
| 65 |
}, |
| 66 |
|
| 67 |
resize: function(){ |
| 68 |
|
| 69 |
|
| 70 |
this.inherited(arguments); |
| 71 |
array.forEach(this.getChildren(), function(child){ |
| 72 |
if(child.resize){ child.resize(); } |
| 73 |
}); |
| 74 |
this._dim = this.getDim(); |
| 75 |
if(this._conn){ |
| 76 |
|
| 77 |
this.resetScrollBar(); |
| 78 |
} |
| 79 |
}, |
| 80 |
|
| 81 |
isTopLevel: function(e){ |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
var parent = this.getParent && this.getParent(); |
| 86 |
return (!parent || !parent.resize); |
| 87 |
}, |
| 88 |
|
| 89 |
addFixedBar: function(widget){ |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
var c = widget.domNode; |
| 98 |
var fixed = this.checkFixedBar(c, true); |
| 99 |
if(!fixed){ return; } |
| 100 |
|
| 101 |
this.domNode.appendChild(c); |
| 102 |
if(fixed === "top"){ |
| 103 |
this.fixedHeaderHeight = c.offsetHeight; |
| 104 |
this.isLocalHeader = true; |
| 105 |
}else if(fixed === "bottom"){ |
| 106 |
this.fixedFooterHeight = c.offsetHeight; |
| 107 |
this.isLocalFooter = true; |
| 108 |
c.style.bottom = "0px"; |
| 109 |
} |
| 110 |
this.resize(); |
| 111 |
}, |
| 112 |
|
| 113 |
reparent: function(){ |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
var i, idx, len, c; |
| 118 |
for(i = 0, idx = 0, len = this.domNode.childNodes.length; i < len; i++){ |
| 119 |
c = this.domNode.childNodes[idx]; |
| 120 |
|
| 121 |
if(c === this.containerNode || this.checkFixedBar(c, true)){ |
| 122 |
idx++; |
| 123 |
continue; |
| 124 |
} |
| 125 |
this.containerNode.appendChild(this.domNode.removeChild(c)); |
| 126 |
} |
| 127 |
}, |
| 128 |
|
| 129 |
onAfterTransitionIn: function(moveTo, dir, transition, context, method){ |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
this.flashScrollBar(); |
| 134 |
}, |
| 135 |
|
| 136 |
getChildren: function(){ |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
var children = this.inherited(arguments); |
| 141 |
var fixedWidget; |
| 142 |
if(this.fixedHeader && this.fixedHeader.parentNode === this.domNode){ |
| 143 |
fixedWidget = registry.byNode(this.fixedHeader); |
| 144 |
if(fixedWidget){ |
| 145 |
children.push(fixedWidget); |
| 146 |
} |
| 147 |
} |
| 148 |
if(this.fixedFooter && this.fixedFooter.parentNode === this.domNode){ |
| 149 |
fixedWidget = registry.byNode(this.fixedFooter); |
| 150 |
if(fixedWidget){ |
| 151 |
children.push(fixedWidget); |
| 152 |
} |
| 153 |
} |
| 154 |
return children; |
| 155 |
}, |
| 156 |
|
| 157 |
_addTransitionPaddingTop: function( value){ |
| 158 |
|
| 159 |
this.domNode.style.paddingTop = value + "px"; |
| 160 |
this.containerNode.style.paddingTop = value + "px"; |
| 161 |
}, |
| 162 |
|
| 163 |
_removeTransitionPaddingTop: function(){ |
| 164 |
|
| 165 |
this.domNode.style.paddingTop = ""; |
| 166 |
this.containerNode.style.paddingTop = ""; |
| 167 |
} |
| 168 |
|
| 169 |
}); |
| 170 |
}); |