define([ "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/i18n", // i18n.getLocalization "dojo/keys", "dojo/_base/lang", // lang.hitch "dojo/on", "dojo/sniff", // has("ie") "./_FormSelectWidget", "../_HasDropDown", "../DropDownMenu", "../MenuItem", "../MenuSeparator", "../Tooltip", "../_KeyNavMixin", "../registry", // registry.byNode "dojo/text!./templates/Select.html", "dojo/i18n!./nls/validate" ], function(array, declare, domAttr, domClass, domGeometry, i18n, keys, lang, on, has, _FormSelectWidget, _HasDropDown, DropDownMenu, MenuItem, MenuSeparator, Tooltip, _KeyNavMixin, registry, template){ // module: // dijit/form/Select var _SelectMenu = declare("dijit.form._SelectMenu", DropDownMenu, { // 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(){ this.inherited(arguments); this.domNode.setAttribute("role", "listbox"); }, postCreate: function(){ this.inherited(arguments); // stop mousemove from selecting text on IE to be consistent with other browsers this.own(on(this.domNode, "selectstart", function(evt){ evt.preventDefault(); evt.stopPropagation(); })); }, 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 } } }); var Select = declare("dijit.form.Select" + (has("dojo-bidi") ? "_NoBidi" : ""), [_FormSelectWidget, _HasDropDown, _KeyNavMixin], { // summary: // This is a "styleable" select box - it is basically a DropDownButton which // can take a `