⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 button-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
				Event.preventDefault(p_oEvent);				this.removeListener("keypress", onKeyPress);						};			// Prevent the browser from scrolling the window			if (bShowMenu) {				if (UA.opera) {						this.on("keypress", onKeyPress);					}				Event.preventDefault(p_oEvent);			}            return bShowMenu;                },                        /**        * @method _addListenersToForm        * @description Adds event handlers to the button's form.        * @protected        */        _addListenersToForm: function () {                    var oForm = this.getForm(),                onFormKeyPress = YAHOO.widget.Button.onFormKeyPress,                bHasKeyPressListener,                oSrcElement,                aListeners,                nListeners,                i;                            if (oForm) {                        Event.on(oForm, "reset", this._onFormReset, null, this);                Event.on(oForm, "submit", this._onFormSubmit, null, this);                        oSrcElement = this.get("srcelement");                                if (this.get("type") == "submit" ||                     (oSrcElement && oSrcElement.type == "submit"))                 {                                    aListeners = Event.getListeners(oForm, "keypress");                    bHasKeyPressListener = false;                                if (aListeners) {                                    nListeners = aListeners.length;                                if (nListeners > 0) {                                        i = nListeners - 1;                                                        do {                                               if (aListeners[i].fn == onFormKeyPress) {                                                    bHasKeyPressListener = true;                                    break;                                                                }                                            }                            while (i--);                                                }                                        }                                            if (!bHasKeyPressListener) {                                       Event.on(oForm, "keypress", onFormKeyPress);                                }                        }                        }                },                                /**        * @method _showMenu        * @description Shows the button's menu.        * @protected        * @param {Event} p_oEvent Object representing the DOM event object         * passed back by the event utility (YAHOO.util.Event) that triggered         * the display of the menu.        */        _showMenu: function (p_oEvent) {            if (YAHOO.widget.MenuManager) {                YAHOO.widget.MenuManager.hideVisible();            }                    if (m_oOverlayManager) {                m_oOverlayManager.hideAll();            }            var oMenu = this._menu,            	aMenuAlignment = this.get("menualignment"),            	bFocusMenu = this.get("focusmenu"),				fnFocusMethod;			if (this._renderedMenu) {				oMenu.cfg.setProperty("context", 								[this.get("element"), aMenuAlignment[0], aMenuAlignment[1]]);					oMenu.cfg.setProperty("preventcontextoverlap", true);				oMenu.cfg.setProperty("constraintoviewport", true);			}			else {				oMenu.cfg.queueProperty("context", 								[this.get("element"), aMenuAlignment[0], aMenuAlignment[1]]);					oMenu.cfg.queueProperty("preventcontextoverlap", true);				oMenu.cfg.queueProperty("constraintoviewport", true);						}			/*				 Refocus the Button before showing its Menu in case the call to 				 YAHOO.widget.MenuManager.hideVisible() resulted in another element in the 				 DOM being focused after another Menu was hidden.			*/						this.focus();            if (Menu && oMenu && (oMenu instanceof Menu)) {				// Since Menus automatically focus themselves when made visible, temporarily 				// replace the Menu focus method so that the value of the Button's "focusmenu"				// attribute determines if the Menu should be focus when made visible.				fnFocusMethod = oMenu.focus;				oMenu.focus = function () {};				if (this._renderedMenu) {					oMenu.cfg.setProperty("minscrollheight", this.get("menuminscrollheight"));					oMenu.cfg.setProperty("maxheight", this.get("menumaxheight"));								}				else {					oMenu.cfg.queueProperty("minscrollheight", this.get("menuminscrollheight"));					oMenu.cfg.queueProperty("maxheight", this.get("menumaxheight"));								}                oMenu.show();        		oMenu.focus = fnFocusMethod;				oMenu.align();                        /*                    Stop the propagation of the event so that the MenuManager                     doesn't blur the menu after it gets focus.                */                        if (p_oEvent.type == "mousedown") {                    Event.stopPropagation(p_oEvent);                }                        if (bFocusMenu) {                     oMenu.focus();                }            }            else if (Overlay && oMenu && (oMenu instanceof Overlay)) {				if (!this._renderedMenu) {		            oMenu.render(this.get("element").parentNode);				}                oMenu.show();				oMenu.align();            }                },                        /**        * @method _hideMenu        * @description Hides the button's menu.        * @protected        */        _hideMenu: function () {                    var oMenu = this._menu;                    if (oMenu) {                        oMenu.hide();                    }                },                                        // Protected event handlers                        /**        * @method _onMouseOver        * @description "mouseover" 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).        */        _onMouseOver: function (p_oEvent) {                	var sType = this.get("type"),        		oElement,				nOptionRegionX;			if (sType === "split") {				oElement = this.get("element");				nOptionRegionX = 					(Dom.getX(oElement) + (oElement.offsetWidth - this.OPTION_AREA_WIDTH));									this._nOptionRegionX = nOptionRegionX;						}                    if (!this._hasMouseEventHandlers) {        				if (sType === "split") {        	        		this.on("mousemove", this._onMouseMove);        		}                this.on("mouseout", this._onMouseOut);                        this._hasMouseEventHandlers = true;                    }                    this.addStateCSSClasses("hover");			if (sType === "split" && (Event.getPageX(p_oEvent) > nOptionRegionX)) {					this.addStateCSSClasses("hoveroption");				}                    if (this._activationButtonPressed) {                        this.addStateCSSClasses("active");                    }                            if (this._bOptionPressed) {                        this.addStateCSSClasses("activeoption");                        }            if (this._activationButtonPressed || this._bOptionPressed) {                        Event.removeListener(document, "mouseup", this._onDocumentMouseUp);                    }        },        /**        * @method _onMouseMove        * @description "mousemove" 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).        */                _onMouseMove: function (p_oEvent) {                	var nOptionRegionX = this._nOptionRegionX;                	if (nOptionRegionX) {				if (Event.getPageX(p_oEvent) > nOptionRegionX) {										this.addStateCSSClasses("hoveroption");					}				else {					this.removeStateCSSClasses("hoveroption");								}				        	}                },                /**        * @method _onMouseOut        * @description "mouseout" 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).        */        _onMouseOut: function (p_oEvent) {			var sType = this.get("type");                    this.removeStateCSSClasses("hover");                    if (sType != "menu") {                        this.removeStateCSSClasses("active");                    }                    if (this._activationButtonPressed || this._bOptionPressed) {                        Event.on(document, "mouseup", this._onDocumentMouseUp, null, this);                    }			if (sType === "split" && (Event.getPageX(p_oEvent) > this._nOptionRegionX)) {							this.removeStateCSSClasses("hoveroption");				}                    },                        /**        * @method _onDocumentMouseUp        * @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).        */        _onDocumentMouseUp: function (p_oEvent) {                    this._activationButtonPressed = false;            this._bOptionPressed = false;                    var sType = this.get("type"),                oTarget,                oMenuElement;                    if (sType == "menu" || sType == "split") {                oTarget = Event.getTarget(p_oEvent);                oMenuElement = this._menu.element;                        if (oTarget != oMenuElement &&                     !Dom.isAncestor(oMenuElement, oTarget)) {                    this.removeStateCSSClasses((sType == "menu" ?                         "active" : "activeoption"));                                this._hideMenu();                }                    }                    Event.removeListener(document, "mouseup", this._onDocumentMouseUp);                },                        /**        * @method _onMouseDown        * @description "mousedown" 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).        */        _onMouseDown: function (p_oEvent) {                    var sType,            	bReturnVal = true;                            function onMouseUp() {                            this._hideMenu();                this.removeListener("mouseup", onMouseUp);                        }                            if ((p_oEvent.which || p_oEvent.button) == 1) {                                if (!this.hasFocus()) {                                    this.focus();                                }                                sType = this.get("type");                                if (sType == "split") {                                    if (Event.getPageX(p_oEvent) > this._nOptionRegionX) {                                                this.fireEvent("option", p_oEvent);						bReturnVal = false;                            }                    else {                                this.addStateCSSClasses("active");                                this._activationButtonPressed = true;                            }                        }                else if (sType == "menu") {                            if (this.isActive()) {                                this._hideMenu();                                this._activationButtonPressed = false;                            }                    else {                                this._showMenu(p_oEvent);                                this._activationButtonPressed = true;                                        }                        }                else {        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -