\n"}});
define("dijit/form/Select", [
"dojo/_base/array", // array.forEach
"dojo/_base/declare", // declare
"dojo/dom-attr", // domAttr.set
"dojo/dom-class", // domClass.add domClass.remove domClass.toggle
"dojo/dom-geometry", // domGeometry.setMarginBox
"dojo/_base/event", // event.stop
"dojo/i18n", // i18n.getLocalization
"dojo/_base/lang", // lang.hitch
"dojo/sniff", // has("ie")
"./_FormSelectWidget",
"../_HasDropDown",
"../Menu",
"../MenuItem",
"../MenuSeparator",
"../Tooltip",
"dojo/text!./templates/Select.html",
"dojo/i18n!./nls/validate"
], function(array, declare, domAttr, domClass, domGeometry, event, i18n, lang, has,
_FormSelectWidget, _HasDropDown, Menu, MenuItem, MenuSeparator, Tooltip, template){
// module:
// dijit/form/Select
var _SelectMenu = declare("dijit.form._SelectMenu", Menu, {
// summary:
// An internally-used menu for dropdown that allows us a vertical scrollbar
// Override Menu.autoFocus setting so that opening a Select highlights the current value.
autoFocus: true,
buildRendering: function(){
// summary:
// Stub in our own changes, so that our domNode is not a table
// otherwise, we won't respond correctly to heights/overflows
this.inherited(arguments);
var o = (this.menuTableNode = this.domNode);
var n = (this.domNode = this.ownerDocument.createElement("div"));
n.style.cssText = "overflow-x: hidden; overflow-y: scroll";
if(o.parentNode){
o.parentNode.replaceChild(n, o);
}
domClass.remove(o, "dijitMenuTable");
n.className = o.className + " dijitSelectMenu";
o.className = "dijitReset dijitMenuTable";
o.setAttribute("role", "listbox");
n.setAttribute("role", "presentation");
n.appendChild(o);
},
postCreate: function(){
// summary:
// stop mousemove from selecting text on IE to be consistent with other browsers
this.inherited(arguments);
this.connect(this.domNode, "onselectstart", event.stop);
},
focus: function(){
// summary:
// Overridden so that the previously selected value will be focused instead of only the first item
var found = false,
val = this.parentWidget.value;
if(lang.isArray(val)){
val = val[val.length-1];
}
if(val){ // if focus selected
array.forEach(this.parentWidget._getChildren(), function(child){
if(child.option && (val === child.option.value)){ // find menu item widget with this value
found = true;
this.focusChild(child, false); // focus previous selection
}
}, this);
}
if(!found){
this.inherited(arguments); // focus first item by default
}
},
resize: function(/*Object*/ mb){
// summary:
// Overridden so that we are able to handle resizing our
// internal widget. Note that this is not a "full" resize
// implementation - it only works correctly if you pass it a
// marginBox.
//
// mb: Object
// The margin box to set this dropdown to.
if(mb){
domGeometry.setMarginBox(this.domNode, mb);
if("w" in mb){
// We've explicitly set the wrapper
's width, so set
width to match.
// 100% is safer than a pixel value because there may be a scroll bar with
// browser/OS specific width.
this.menuTableNode.style.width = "100%";
}
}
}
});
var Select = declare("dijit.form.Select", [_FormSelectWidget, _HasDropDown], {
// summary:
// This is a "styleable" select box - it is basically a DropDownButton which
// can take a `