| 1 |
define([ |
| 2 |
"dojo/_base/array", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/_base/window", |
| 5 |
"dojo/dom-class", |
| 6 |
"dojo/dom-geometry", |
| 7 |
"dijit/_Contained", |
| 8 |
"dijit/_Container", |
| 9 |
"dijit/_WidgetBase", |
| 10 |
"dojo/has", |
| 11 |
"./common" |
| 12 |
], function(array, declare, win, domClass, domGeometry, Contained, Container, WidgetBase, has){ |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
return declare("dojox.mobile.FixedSplitter", [WidgetBase, Container, Contained], { |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
orientation: "H", |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
variablePane: -1, |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
screenSizeAware: false, |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
screenSizeAwareClass: "dojox/mobile/ScreenSizeAware", |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
baseClass: "mblFixedSplitter", |
| 75 |
|
| 76 |
startup: function(){ |
| 77 |
if(this._started){ return; } |
| 78 |
domClass.add(this.domNode, this.baseClass + this.orientation); |
| 79 |
|
| 80 |
var parent = this.getParent(), f; |
| 81 |
if(!parent || !parent.resize){ |
| 82 |
var _this = this; |
| 83 |
f = function(){ |
| 84 |
_this.defer(function(){ |
| 85 |
_this.resize(); |
| 86 |
}); |
| 87 |
}; |
| 88 |
} |
| 89 |
|
| 90 |
if(this.screenSizeAware){ |
| 91 |
require([this.screenSizeAwareClass], function(module){ |
| 92 |
module.getInstance(); |
| 93 |
f && f(); |
| 94 |
}); |
| 95 |
}else{ |
| 96 |
f && f(); |
| 97 |
} |
| 98 |
|
| 99 |
this.inherited(arguments); |
| 100 |
}, |
| 101 |
|
| 102 |
resize: function(){ |
| 103 |
var paddingTop = domGeometry.getPadExtents(this.domNode).t; |
| 104 |
var wh = this.orientation === "H" ? "w" : "h", |
| 105 |
tl = this.orientation === "H" ? "l" : "t", |
| 106 |
props1 = {}, props2 = {}, |
| 107 |
i, c, h, |
| 108 |
a = [], offset = 0, total = 0, |
| 109 |
children = array.filter(this.domNode.childNodes, function(node){ return node.nodeType == 1; }), |
| 110 |
idx = this.variablePane == -1 ? children.length - 1 : this.variablePane; |
| 111 |
for(i = 0; i < children.length; i++){ |
| 112 |
if(i != idx){ |
| 113 |
a[i] = domGeometry.getMarginBox(children[i])[wh]; |
| 114 |
total += a[i]; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
if(this.orientation == "V"){ |
| 119 |
if(this.domNode.parentNode.tagName == "BODY"){ |
| 120 |
if(array.filter(win.body().childNodes, function(node){ return node.nodeType == 1; }).length == 1){ |
| 121 |
h = (win.global.innerHeight||win.doc.documentElement.clientHeight); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
var l = (h || domGeometry.getMarginBox(this.domNode)[wh]) - total; |
| 126 |
if(this.orientation === "V"){ |
| 127 |
l -= paddingTop; |
| 128 |
} |
| 129 |
props2[wh] = a[idx] = l; |
| 130 |
c = children[idx]; |
| 131 |
domGeometry.setMarginBox(c, props2); |
| 132 |
c.style[this.orientation === "H" ? "height" : "width"] = ""; |
| 133 |
|
| 134 |
if(has("dojo-bidi") && (this.orientation=="H" && !this.isLeftToRight())){ |
| 135 |
offset = l; |
| 136 |
for(i = children.length - 1; i >= 0; i--){ |
| 137 |
c = children[i]; |
| 138 |
props1[tl] = l - offset; |
| 139 |
domGeometry.setMarginBox(c, props1); |
| 140 |
if(this.orientation === "H"){ |
| 141 |
c.style.top = paddingTop +"px"; |
| 142 |
}else{ |
| 143 |
c.style.left = ""; |
| 144 |
} |
| 145 |
offset -= a[i]; |
| 146 |
} |
| 147 |
}else{ |
| 148 |
if(this.orientation === "V"){ |
| 149 |
offset = offset ? offset + paddingTop : paddingTop; |
| 150 |
} |
| 151 |
|
| 152 |
for(i = 0; i < children.length; i++){ |
| 153 |
c = children[i]; |
| 154 |
props1[tl] = offset; |
| 155 |
|
| 156 |
domGeometry.setMarginBox(c, props1); |
| 157 |
if(this.orientation === "H"){ |
| 158 |
c.style.top = paddingTop +"px"; |
| 159 |
}else{ |
| 160 |
c.style.left = ""; |
| 161 |
} |
| 162 |
offset += a[i]; |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
array.forEach(this.getChildren(), function(child){ |
| 167 |
if(child.resize){ child.resize(); } |
| 168 |
}); |
| 169 |
}, |
| 170 |
|
| 171 |
_setOrientationAttr: function(orientation){ |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
var s = this.baseClass; |
| 181 |
domClass.replace(this.domNode, s + orientation, s + this.orientation); |
| 182 |
this.orientation = orientation; |
| 183 |
if(this._started){ |
| 184 |
this.resize(); |
| 185 |
} |
| 186 |
} |
| 187 |
}); |
| 188 |
}); |