📄 button.js
字号:
dojo.disconnect(handler); self._openDropDown(); }); dropDown._loadCheck(true); return; }else{ this._openDropDown(); } }else{ this._closeDropDown(); } }, _openDropDown: function(){ var dropDown = this.dropDown; var oldWidth=dropDown.domNode.style.width; var self = this; dijit.popup.open({ parent: this, popup: dropDown, around: this.domNode, orient: // TODO: add user-defined positioning option, like in Tooltip.js this.isLeftToRight() ? {'BL':'TL', 'BR':'TR', 'TL':'BL', 'TR':'BR'} : {'BR':'TR', 'BL':'TL', 'TR':'BR', 'TL':'BL'}, onExecute: function(){ self._closeDropDown(true); }, onCancel: function(){ self._closeDropDown(true); }, onClose: function(){ dropDown.domNode.style.width = oldWidth; self.popupStateNode.removeAttribute("popupActive"); this._opened = false; } }); if(this.domNode.offsetWidth > dropDown.domNode.offsetWidth){ var adjustNode = null; if(!this.isLeftToRight()){ adjustNode = dropDown.domNode.parentNode; var oldRight = adjustNode.offsetLeft + adjustNode.offsetWidth; } // make menu at least as wide as the button dojo.marginBox(dropDown.domNode, {w: this.domNode.offsetWidth}); if(adjustNode){ adjustNode.style.left = oldRight - this.domNode.offsetWidth + "px"; } } this.popupStateNode.setAttribute("popupActive", "true"); this._opened=true; if(dropDown.focus){ dropDown.focus(); } // TODO: set this.checked and call setStateClass(), to affect button look while drop down is shown }, _closeDropDown: function(/*Boolean*/ focus){ if(this._opened){ dijit.popup.close(this.dropDown); if(focus){ this.focus(); } this._opened = false; } }});dojo.declare("dijit.form.ComboButton", dijit.form.DropDownButton, { // summary: A Normal Button with a DropDown // // example: // | <button dojoType="dijit.form.ComboButton" onClick="..."> // | <span>Hello world</span> // | <div dojoType="dijit.Menu">...</div> // | </button> // // example: // | var button1 = new dijit.form.ComboButton({label: "hello world", onClick: foo, dropDown: "myMenu"}); // | dojo.body().appendChild(button1.domNode); // templateString:"<table class='dijit dijitReset dijitInline dijitLeft'\n\tcellspacing='0' cellpadding='0' waiRole=\"presentation\"\n\t><tbody waiRole=\"presentation\"><tr waiRole=\"presentation\"\n\t\t><td\tclass=\"dijitReset dijitStretch dijitButtonContents dijitButtonNode\"\n\t\t\ttabIndex=\"${tabIndex}\"\n\t\t\tdojoAttachEvent=\"ondijitclick:_onButtonClick,onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\" dojoAttachPoint=\"titleNode\"\n\t\t\twaiRole=\"button\" waiState=\"labelledby-${id}_label\"\n\t\t\t><div class=\"dijitReset dijitInline ${iconClass}\" dojoAttachPoint=\"iconNode\" waiRole=\"presentation\"></div\n\t\t\t><div class=\"dijitReset dijitInline dijitButtonText\" id=\"${id}_label\" dojoAttachPoint=\"containerNode\" waiRole=\"presentation\">${label}</div\n\t\t></td\n\t\t><td class='dijitReset dijitStretch dijitButtonNode dijitArrowButton dijitDownArrowButton'\n\t\t\tdojoAttachPoint=\"popupStateNode,focusNode\"\n\t\t\tdojoAttachEvent=\"ondijitclick:_onArrowClick, onkeypress:_onKey,onmouseenter:_onMouse,onmouseleave:_onMouse\"\n\t\t\tstateModifier=\"DownArrow\"\n\t\t\ttitle=\"${optionsTitle}\" name=\"${name}\"\n\t\t\twaiRole=\"button\" waiState=\"haspopup-true\"\n\t\t\t><div class=\"dijitReset dijitArrowButtonInner\" waiRole=\"presentation\"> </div\n\t\t\t><div class=\"dijitReset dijitArrowButtonChar\" waiRole=\"presentation\">▼</div\n\t\t></td\n\t></tr></tbody\n></table>\n", attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), {id:"", name:""}), // optionsTitle: String // text that describes the options menu (accessibility) optionsTitle: "", baseClass: "dijitComboButton", _focusedNode: null, postCreate: function(){ this.inherited(arguments); this._focalNodes = [this.titleNode, this.popupStateNode]; dojo.forEach(this._focalNodes, dojo.hitch(this, function(node){ if(dojo.isIE){ this.connect(node, "onactivate", this._onNodeFocus); this.connect(node, "ondeactivate", this._onNodeBlur); }else{ this.connect(node, "onfocus", this._onNodeFocus); this.connect(node, "onblur", this._onNodeBlur); } })); }, focusFocalNode: function(node){ // summary: Focus the focal node node. this._focusedNode = node; dijit.focus(node); }, hasNextFocalNode: function(){ // summary: Returns true if this widget has no node currently // focused or if there is a node following the focused one. // False is returned if the last node has focus. return this._focusedNode !== this.getFocalNodes()[1]; }, focusNext: function(){ // summary: Focus the focal node following the current node with focus // or the first one if no node currently has focus. this._focusedNode = this.getFocalNodes()[this._focusedNode ? 1 : 0]; dijit.focus(this._focusedNode); }, hasPrevFocalNode: function(){ // summary: Returns true if this widget has no node currently // focused or if there is a node before the focused one. // False is returned if the first node has focus. return this._focusedNode !== this.getFocalNodes()[0]; }, focusPrev: function(){ // summary: Focus the focal node before the current node with focus // or the last one if no node currently has focus. this._focusedNode = this.getFocalNodes()[this._focusedNode ? 0 : 1]; dijit.focus(this._focusedNode); }, getFocalNodes: function(){ // summary: Returns an array of focal nodes for this widget. return this._focalNodes; }, _onNodeFocus: function(evt){ this._focusedNode = evt.currentTarget; var fnc = this._focusedNode == this.focusNode ? "dijitDownArrowButtonFocused" : "dijitButtonContentsFocused"; dojo.addClass(this._focusedNode, fnc); }, _onNodeBlur: function(evt){ var fnc = evt.currentTarget == this.focusNode ? "dijitDownArrowButtonFocused" : "dijitButtonContentsFocused"; dojo.removeClass(evt.currentTarget, fnc); }, _onBlur: function(){ this.inherited(arguments); this._focusedNode = null; }});dojo.declare("dijit.form.ToggleButton", dijit.form.Button, { // summary: // A button that can be in two states (checked or not). // Can be base class for things like tabs or checkbox or radio buttons baseClass: "dijitToggleButton", // checked: Boolean // Corresponds to the native HTML <input> element's attribute. // In markup, specified as "checked='checked'" or just "checked". // True if the button is depressed, or the checkbox is checked, // or the radio button is selected, etc. checked: false, _onChangeMonitor: 'checked', attributeMap: dojo.mixin(dojo.clone(dijit.form.Button.prototype.attributeMap), {checked:"focusNode"}), _clicked: function(/*Event*/ evt){ this.setAttribute('checked', !this.checked); }, setAttribute: function(/*String*/ attr, /*anything*/ value){ this.inherited(arguments); switch(attr){ case "checked": dijit.setWaiState(this.focusNode || this.domNode, "pressed", this.checked); this._setStateClass(); this._handleOnChange(this.checked, true); } }, setChecked: function(/*Boolean*/ checked){ // summary: // Programatically deselect the button dojo.deprecated("setChecked("+checked+") is deprecated. Use setAttribute('checked',"+checked+") instead.", "", "2.0"); this.setAttribute('checked', checked); }, postCreate: function(){ this.inherited(arguments); this.setAttribute('checked', this.checked); //to initially set wai pressed state }});}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -