| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/_base/kernel", |
| 4 |
"dojo/_base/lang", |
| 5 |
"dojo/query", |
| 6 |
"../registry", |
| 7 |
"../popup", |
| 8 |
"./Button", |
| 9 |
"../_Container", |
| 10 |
"../_HasDropDown", |
| 11 |
"dojo/text!./templates/DropDownButton.html", |
| 12 |
"../a11yclick" |
| 13 |
], function(declare, kernel, lang, query, registry, popup, Button, _Container, _HasDropDown, template){ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
return declare("dijit.form.DropDownButton", [Button, _Container, _HasDropDown], { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
baseClass: "dijitDropDownButton", |
| 34 |
|
| 35 |
templateString: template, |
| 36 |
|
| 37 |
_fillContent: function(){ |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
var source = this.srcNodeRef; |
| 43 |
var dest = this.containerNode; |
| 44 |
if(source && dest){ |
| 45 |
while(source.hasChildNodes()){ |
| 46 |
var child = source.firstChild; |
| 47 |
if(child.hasAttribute && (child.hasAttribute("data-dojo-type") || child.hasAttribute("dojoType") || |
| 48 |
child.hasAttribute("data-" + kernel._scopeName + "-type") || |
| 49 |
child.hasAttribute(kernel._scopeName + "Type"))){ |
| 50 |
|
| 51 |
|
| 52 |
this.dropDownContainer = this.ownerDocument.createElement("div"); |
| 53 |
this.dropDownContainer.appendChild(child); |
| 54 |
}else{ |
| 55 |
dest.appendChild(child); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
}, |
| 60 |
|
| 61 |
startup: function(){ |
| 62 |
if(this._started){ |
| 63 |
return; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
if(!this.dropDown && this.dropDownContainer){ |
| 69 |
this.dropDown = registry.byNode(this.dropDownContainer.firstChild); |
| 70 |
delete this.dropDownContainer; |
| 71 |
} |
| 72 |
if(this.dropDown){ |
| 73 |
popup.hide(this.dropDown); |
| 74 |
} |
| 75 |
|
| 76 |
this.inherited(arguments); |
| 77 |
}, |
| 78 |
|
| 79 |
isLoaded: function(){ |
| 80 |
|
| 81 |
|
| 82 |
var dropDown = this.dropDown; |
| 83 |
return (!!dropDown && (!dropDown.href || dropDown.isLoaded)); |
| 84 |
}, |
| 85 |
|
| 86 |
loadDropDown: function( callback){ |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
var dropDown = this.dropDown; |
| 91 |
var handler = dropDown.on("load", lang.hitch(this, function(){ |
| 92 |
handler.remove(); |
| 93 |
callback(); |
| 94 |
})); |
| 95 |
dropDown.refresh(); |
| 96 |
}, |
| 97 |
|
| 98 |
isFocusable: function(){ |
| 99 |
|
| 100 |
|
| 101 |
return this.inherited(arguments) && !this._mouseDown; |
| 102 |
} |
| 103 |
}); |
| 104 |
}); |