| 1 |
define([ |
| 2 |
"dojo/_base/array", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/_base/lang", |
| 5 |
"dojo/_base/window", |
| 6 |
"dojo/dom-construct", |
| 7 |
"dijit/_Contained", |
| 8 |
"dijit/_Container", |
| 9 |
"dijit/_WidgetBase", |
| 10 |
"./IconItem", |
| 11 |
"./Heading", |
| 12 |
"./View" |
| 13 |
], function(array, declare, lang, win, domConstruct, Contained, Container, WidgetBase, IconItem, Heading, View){ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
return declare("dojox.mobile.IconContainer", [WidgetBase, Container, Contained],{ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
defaultIcon: "", |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
transition: "below", |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
pressedIconOpacity: 0.4, |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
iconBase: "", |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
iconPos: "", |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
back: "Home", |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
label: "My Application", |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
single: false, |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
editable: false, |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
tag: "ul", |
| 78 |
|
| 79 |
|
| 80 |
baseClass: "mblIconContainer", |
| 81 |
editableMixinClass: "dojox/mobile/_EditableIconMixin", |
| 82 |
iconItemPaneContainerClass: "dojox/mobile/Container", |
| 83 |
iconItemPaneContainerProps: null, |
| 84 |
iconItemPaneClass: "dojox/mobile/_IconItemPane", |
| 85 |
iconItemPaneProps: null, |
| 86 |
|
| 87 |
buildRendering: function(){ |
| 88 |
this.domNode = this.containerNode = this.srcNodeRef || domConstruct.create(this.tag); |
| 89 |
|
| 90 |
this._terminator = domConstruct.create(this.tag === "ul" ? "li" : "div", |
| 91 |
{className:"mblIconItemTerminator"}, this.domNode); |
| 92 |
this.inherited(arguments); |
| 93 |
}, |
| 94 |
|
| 95 |
postCreate: function(){ |
| 96 |
if(this.editable && !this.startEdit){ |
| 97 |
require([this.editableMixinClass], lang.hitch(this, function(module){ |
| 98 |
declare.safeMixin(this, new module()); |
| 99 |
this.set("editable", this.editable); |
| 100 |
})); |
| 101 |
} |
| 102 |
}, |
| 103 |
|
| 104 |
startup: function(){ |
| 105 |
if(this._started){ return; } |
| 106 |
|
| 107 |
require([this.iconItemPaneContainerClass], lang.hitch(this, function(module){ |
| 108 |
this.paneContainerWidget = new module(this.iconItemPaneContainerProps); |
| 109 |
if(this.transition === "below"){ |
| 110 |
domConstruct.place(this.paneContainerWidget.domNode, this.domNode, "after"); |
| 111 |
}else{ |
| 112 |
var view = this.appView = new View({id:this.id+"_mblApplView"}); |
| 113 |
var _this = this; |
| 114 |
view.onAfterTransitionIn = function(moveTo, dir, transition, context, method){ |
| 115 |
_this._opening._open_1(); |
| 116 |
}; |
| 117 |
view.domNode.style.visibility = "hidden"; |
| 118 |
var heading = view._heading |
| 119 |
= new Heading({back: this._cv ? this._cv(this.back) : this.back, |
| 120 |
label: this._cv ? this._cv(this.label) : this.label, |
| 121 |
moveTo: this.domNode.parentNode.id, |
| 122 |
transition: this.transition == "zoomIn" ? "zoomOut" : this.transition}); |
| 123 |
view.addChild(heading); |
| 124 |
view.addChild(this.paneContainerWidget); |
| 125 |
|
| 126 |
var target; |
| 127 |
for(var w = this.getParent(); w; w = w.getParent()){ |
| 128 |
if(w instanceof View){ |
| 129 |
target = w.domNode.parentNode; |
| 130 |
break; |
| 131 |
} |
| 132 |
} |
| 133 |
if(!target){ target = win.body(); } |
| 134 |
target.appendChild(view.domNode); |
| 135 |
|
| 136 |
view.startup(); |
| 137 |
} |
| 138 |
})); |
| 139 |
|
| 140 |
this.inherited(arguments); |
| 141 |
}, |
| 142 |
|
| 143 |
closeAll: function(){ |
| 144 |
|
| 145 |
|
| 146 |
array.forEach(this.getChildren(), function(w){ |
| 147 |
w.close(true); |
| 148 |
}, this); |
| 149 |
}, |
| 150 |
|
| 151 |
addChild: function(widget, insertIndex){ |
| 152 |
this.inherited(arguments); |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
if(this._started && widget.paneWidget && !widget.paneWidget.getParent()){ |
| 158 |
this.paneContainerWidget.addChild(widget.paneWidget, insertIndex); |
| 159 |
} |
| 160 |
this.domNode.appendChild(this._terminator); |
| 161 |
}, |
| 162 |
|
| 163 |
removeChild: function(widget){ |
| 164 |
var index = (typeof widget == "number") ? widget : widget.getIndexInParent(); |
| 165 |
this.paneContainerWidget.removeChild(index); |
| 166 |
this.inherited(arguments); |
| 167 |
}, |
| 168 |
|
| 169 |
_setLabelAttr: function(text){ |
| 170 |
|
| 171 |
|
| 172 |
if(!this.appView){ return; } |
| 173 |
this.label = text; |
| 174 |
var s = this._cv ? this._cv(text) : text; |
| 175 |
this.appView._heading.set("label", s); |
| 176 |
} |
| 177 |
}); |
| 178 |
}); |