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

📄 button-beta.js

📁 国外的人才求职招聘最新版
💻 JS
📖 第 1 页 / 共 5 页
字号:
        * @method _setHref        * @description Sets the value of the button's "href" attribute.        * @protected        * @param {String} p_sHref String indicating the value for the button's         * "href" attribute.        */        _setHref: function (p_sHref) {                    if (this.get("type") == "link") {                        this._button.href = p_sHref;                        }                },                        /**        * @method _setTarget        * @description Sets the value of the button's "target" attribute.        * @protected        * @param {String} p_sTarget String indicating the value for the button's         * "target" attribute.        */        _setTarget: function (p_sTarget) {                    if (this.get("type") == "link") {                        this._button.setAttribute("target", p_sTarget);                        }                },                        /**        * @method _setChecked        * @description Sets the value of the button's "target" attribute.        * @protected        * @param {Boolean} p_bChecked Boolean indicating the value for          * the button's "checked" attribute.        */        _setChecked: function (p_bChecked) {                    var sType = this.get("type"),                sTitle;                    if (sType == "checkbox" || sType == "radio") {                        if (p_bChecked) {                            this.addStateCSSClasses("checked");                                        sTitle = (sType == "radio") ?                                 this.RADIO_CHECKED_TITLE :                                 this.CHECKBOX_CHECKED_TITLE;                                }                else {                    this.removeStateCSSClasses("checked");                            sTitle = (sType == "radio") ?                                 this.RADIO_DEFAULT_TITLE :                                 this.CHECKBOX_DEFAULT_TITLE;                                }                        this.set("title", sTitle);                    }                },                        /**        * @method _setMenu        * @description Sets the value of the button's "menu" attribute.        * @protected        * @param {Object} p_oMenu Object indicating the value for the button's         * "menu" attribute.        */        _setMenu: function (p_oMenu) {            var bLazyLoad = this.get("lazyloadmenu"),                oButtonElement = this.get("element"),                        /*                    Boolean indicating if the value of p_oMenu is an instance                     of YAHOO.widget.Menu or YAHOO.widget.Overlay.                */                        bInstance = false,                        oMenu,                oMenuElement,                oSrcElement,                aItems,                nItems,                oItem,                i;                            if (!Overlay) {                                return false;                        }                            if (!Menu) {                                return false;                        }                            function onAppendTo() {                oMenu.render(oButtonElement.parentNode);                                this.removeListener("appendTo", onAppendTo);                        }                            function initMenu() {                        if (oMenu) {                    Dom.addClass(oMenu.element, this.get("menuclassname"));                    Dom.addClass(oMenu.element,                             "yui-" + this.get("type") + "-button-menu");                    oMenu.showEvent.subscribe(this._onMenuShow, null, this);                    oMenu.hideEvent.subscribe(this._onMenuHide, null, this);                    oMenu.renderEvent.subscribe(this._onMenuRender, null, this);                                    if (oMenu instanceof Menu) {                                oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,                             this, true);                        oMenu.clickEvent.subscribe(this._onMenuClick,                             this, true);                        oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,                             this, true);                                oSrcElement = oMenu.srcElement;                                if (oSrcElement &&                             oSrcElement.nodeName.toUpperCase() == "SELECT") {                                            oSrcElement.style.display = "none";                            oSrcElement.parentNode.removeChild(oSrcElement);                                }                            }                    else if (oMenu instanceof Overlay) {                                if (!m_oOverlayManager) {                                    m_oOverlayManager =                                 new YAHOO.widget.OverlayManager();                                                }                                                m_oOverlayManager.register(oMenu);                                            }                                    this._menu = oMenu;                            if (!bInstance) {                                if (bLazyLoad && !(oMenu instanceof Menu)) {                                    /*                                Mimic Menu's "lazyload" functionality by adding                                  a "beforeshow" event listener that renders the                                 Overlay instance before it is made visible by                                  the button.                            */                                    oMenu.beforeShowEvent.subscribe(                                this._onOverlayBeforeShow, null, this);                                    }                        else if (!bLazyLoad) {                                    if (Dom.inDocument(oButtonElement)) {                                        oMenu.render(oButtonElement.parentNode);                                                        }                            else {                                            this.on("appendTo", onAppendTo);                                                        }                                                }                                        }                        }                    }                            if (p_oMenu && (p_oMenu instanceof Menu)) {                        oMenu = p_oMenu;                aItems = oMenu.getItems();                nItems = aItems.length;                bInstance = true;                                if (nItems > 0) {                            i = nItems - 1;                            do {                                oItem = aItems[i];                                if (oItem) {                                    oItem.cfg.subscribeToConfigEvent("selected",                                 this._onMenuItemSelected,                                 oItem,                                 this);                                }                            }                    while (i--);                        }                        initMenu.call(this);                    }            else if (p_oMenu && (p_oMenu instanceof Overlay)) {                        oMenu = p_oMenu;                bInstance = true;                        oMenu.cfg.setProperty("visible", false);                oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]);                        initMenu.call(this);                    }            else if (Lang.isArray(p_oMenu)) {                        this.on("appendTo", function () {                            oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad,                         itemdata: p_oMenu });                            initMenu.call(this);                        });                    }            else if (Lang.isString(p_oMenu)) {                        oMenuElement = Dom.get(p_oMenu);                        if (oMenuElement) {                            if (Dom.hasClass(oMenuElement,                         Menu.prototype.CSS_CLASS_NAME) ||                         oMenuElement.nodeName == "SELECT") {                                    oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });                                    initMenu.call(this);                                }                    else {                                oMenu = new Overlay(p_oMenu, { visible: false,                             context: [oButtonElement, "tl", "bl"] });                                    initMenu.call(this);                                }                        }                    }            else if (p_oMenu && p_oMenu.nodeName) {                        if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) ||                         p_oMenu.nodeName == "SELECT") {                            oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad });                                    initMenu.call(this);                        }                else {                            if (!p_oMenu.id) {                                            Dom.generateId(p_oMenu);                                        }                            oMenu = new Overlay(p_oMenu, { visible: false,                                     context: [oButtonElement, "tl", "bl"] });                            initMenu.call(this);                                }                        }                },                        /**        * @method _setOnClick        * @description Sets the value of the button's "onclick" attribute.        * @protected        * @param {Object} p_oObject Object indicating the value for the button's         * "onclick" attribute.        */        _setOnClick: function (p_oObject) {                    /*                Remove any existing listeners if a "click" event handler                 has already been specified.            */                    if (this._onclickAttributeValue &&                 (this._onclickAttributeValue != p_oObject)) {                        this.removeListener("click", this._onclickAttributeValue.fn);                        this._onclickAttributeValue = null;                    }                            if (!this._onclickAttributeValue &&                 Lang.isObject(p_oObject) &&                 Lang.isFunction(p_oObject.fn)) {                        this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope);                        this._onclickAttributeValue = p_oObject;                    }                },                        /**        * @method _setSelectedMenuItem        * @description Sets the value of the button's         * "selectedMenuItem" attribute.        * @protected        * @param {Number} p_nIndex Number representing the index of the item         * in the button's menu that is currently selected.        */        _setSelectedMenuItem: function (p_nIndex) {            var oMenu = this._menu,                oMenuItem;            if (oMenu && oMenu instanceof Menu) {                oMenuItem = oMenu.getItem(p_nIndex);                                if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) {                                    oMenuItem.cfg.setProperty("selected", true);                                }                        }        },                        // Protected methods                        /**        * @method _isActivationKey        * @description Determines if the specified keycode is one that toggles          * the button's "active" state.        * @protected        * @param {Number} p_nKeyCode Number representing the keycode to         * be evaluated.        * @return {Boolean}        */        _isActivationKey: function (p_nKeyCode) {                    var sType = this.get("type"),                aKeyCodes = (sType == "checkbox" || sType == "radio") ?                     this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS,                        nKeyCodes = aKeyCodes.length,                i;                    if (nKeyCodes > 0) {                        i = nKeyCodes - 1;                        do {                            if (p_nKeyCode == aKeyCodes[i]) {                                return true;                            }                        }                while (i--);                        }                },                        /**        * @method _isSplitButtonOptionKey        * @description Determines if the specified keycode is one that toggles          * the display of the split button's menu.        * @protected        * @param {Event} p_oEvent Object representing the DOM event object          * passed back by the event utility (YAHOO.util.Event).        * @return {Boolean}        */        _isSplitButtonOptionKey: function (p_oEvent) {                    return (p_oEvent.ctrlKey && p_oEvent.shiftKey &&                 Event.getCharCode(p_oEvent) == 77);                },                        /**        * @method _addListenersToForm

⌨️ 快捷键说明

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