📄 button-debug.js
字号:
this.addStateCSSClasses("active"); this._activationButtonPressed = true; } if (sType == "split" || sType == "menu") { this._hideMenuTimer = Lang.later(250, this, this.on, ["mouseup", onMouseUp]); } } return bReturnVal; }, /** * @method _onMouseUp * @description "mouseup" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onMouseUp: function (p_oEvent) { var sType = this.get("type"), oHideMenuTimer = this._hideMenuTimer, bReturnVal = true; if (oHideMenuTimer) { oHideMenuTimer.cancel(); } if (sType == "checkbox" || sType == "radio") { this.set("checked", !(this.get("checked"))); } this._activationButtonPressed = false; if (sType != "menu") { this.removeStateCSSClasses("active"); } if (sType == "split" && Event.getPageX(p_oEvent) > this._nOptionRegionX) { bReturnVal = false; } return bReturnVal; }, /** * @method _onFocus * @description "focus" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onFocus: function (p_oEvent) { var oElement; this.addStateCSSClasses("focus"); if (this._activationKeyPressed) { this.addStateCSSClasses("active"); } m_oFocusedButton = this; if (!this._hasKeyEventHandlers) { oElement = this._button; Event.on(oElement, "blur", this._onBlur, null, this); Event.on(oElement, "keydown", this._onKeyDown, null, this); Event.on(oElement, "keyup", this._onKeyUp, null, this); this._hasKeyEventHandlers = true; } this.fireEvent("focus", p_oEvent); }, /** * @method _onBlur * @description "blur" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onBlur: function (p_oEvent) { this.removeStateCSSClasses("focus"); if (this.get("type") != "menu") { this.removeStateCSSClasses("active"); } if (this._activationKeyPressed) { Event.on(document, "keyup", this._onDocumentKeyUp, null, this); } m_oFocusedButton = null; this.fireEvent("blur", p_oEvent); }, /** * @method _onDocumentKeyUp * @description "keyup" event handler for the document. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onDocumentKeyUp: function (p_oEvent) { if (this._isActivationKey(Event.getCharCode(p_oEvent))) { this._activationKeyPressed = false; Event.removeListener(document, "keyup", this._onDocumentKeyUp); } }, /** * @method _onKeyDown * @description "keydown" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onKeyDown: function (p_oEvent) { var oMenu = this._menu; if (this.get("type") == "split" && this._isSplitButtonOptionKey(p_oEvent)) { this.fireEvent("option", p_oEvent); } else if (this._isActivationKey(Event.getCharCode(p_oEvent))) { if (this.get("type") == "menu") { this._showMenu(p_oEvent); } else { this._activationKeyPressed = true; this.addStateCSSClasses("active"); } } if (oMenu && oMenu.cfg.getProperty("visible") && Event.getCharCode(p_oEvent) == 27) { oMenu.hide(); this.focus(); } }, /** * @method _onKeyUp * @description "keyup" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onKeyUp: function (p_oEvent) { var sType; if (this._isActivationKey(Event.getCharCode(p_oEvent))) { sType = this.get("type"); if (sType == "checkbox" || sType == "radio") { this.set("checked", !(this.get("checked"))); } this._activationKeyPressed = false; if (this.get("type") != "menu") { this.removeStateCSSClasses("active"); } } }, /** * @method _onClick * @description "click" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onClick: function (p_oEvent) { var sType = this.get("type"), sTitle, oForm, oSrcElement, bReturnVal; switch (sType) { case "radio": case "checkbox": if (!this._hasDefaultTitle) { if (this.get("checked")) { sTitle = (sType == "radio") ? this.RADIO_CHECKED_TITLE : this.CHECKBOX_CHECKED_TITLE; } else { sTitle = (sType == "radio") ? this.RADIO_DEFAULT_TITLE : this.CHECKBOX_DEFAULT_TITLE; } this.set("title", sTitle); } break; case "submit": if (p_oEvent.returnValue !== false) { this.submitForm(); } break; case "reset": oForm = this.getForm(); if (oForm) { oForm.reset(); } break; case "menu": sTitle = this._menu.cfg.getProperty("visible") ? this.MENUBUTTON_MENU_VISIBLE_TITLE : this.MENUBUTTON_DEFAULT_TITLE; this.set("title", sTitle); break; case "split": if (Event.getPageX(p_oEvent) > this._nOptionRegionX) { bReturnVal = false; } else { this._hideMenu(); oSrcElement = this.get("srcelement"); if (oSrcElement && oSrcElement.type == "submit") { this.submitForm(); } } sTitle = this._menu.cfg.getProperty("visible") ? this.SPLITBUTTON_OPTION_VISIBLE_TITLE : this.SPLITBUTTON_DEFAULT_TITLE; this.set("title", sTitle); break; } return bReturnVal; }, /** * @method _onDblClick * @description "dblclick" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onDblClick: function (p_oEvent) { var bReturnVal = true; if (this.get("type") == "split" && Event.getPageX(p_oEvent) > this._nOptionRegionX) { bReturnVal = false; } return bReturnVal; }, /** * @method _onAppendTo * @description "appendTo" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onAppendTo: function (p_oEvent) { /* It is necessary to call "_addListenersToForm" using "setTimeout" to make sure that the button's "form" property returns a node reference. Sometimes, if you try to get the reference immediately after appending the field, it is null. */ Lang.later(0, this, this._addListenersToForm); }, /** * @method _onFormReset * @description "reset" event handler for the button's form. * @protected * @param {Event} p_oEvent Object representing the DOM event * object passed back by the event utility (YAHOO.util.Event). */ _onFormReset: function (p_oEvent) { var sType = this.get("type"), oMenu = this._menu; if (sType == "checkbox" || sType == "radio") { this.resetValue("checked"); } if (Menu && oMenu && (oMenu instanceof Menu)) { this.resetValue("selectedMenuItem"); } }, /** * @method _onFormSubmit * @description "submit" event handler for the button's form. * @protected * @param {Event} p_oEvent Object representing the DOM event * object passed back by the event utility (YAHOO.util.Event). */ _onFormSubmit: function (p_oEvent) { this.createHiddenFields(); }, /** * @method _onDocumentMouseDown * @description "mousedown" event handler for the document. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onDocumentMouseDown: function (p_oEvent) { var oTarget = Event.getTarget(p_oEvent), oButtonElement = this.get("element"), oMenuElement = this._menu.element; if (oTarget != oButtonElement && !Dom.isAncestor(oButtonElement, oTarget) && oTarget != oMenuElement && !Dom.isAncestor(oMenuElement, oTarget)) { this._hideMenu(); Event.removeListener(document, "mousedown", this._onDocumentMouseDown); } }, /** * @method _onOption * @description "option" event handler for the button. * @protected * @param {Event} p_oEvent Object representing the DOM event object * passed back by the event utility (YAHOO.util.Event). */ _onOption: function (p_oEvent) { if (t
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -