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

📄 sync.button.js

📁 echo3 很炫的ajax框架技术 js 演示demo ajax j2ee 里面有jsp演示代码
💻 JS
📖 第 1 页 / 共 2 页
字号:
/** * Component rendering peer: Button */Echo.Sync.Button = Core.extend(Echo.Render.ComponentSync, {    $static: {        /**         * Default margin between icon and text elements.         * @type Number         */        _defaultIconTextMargin: 5,                /**         * Prototype DOM hierarchy for a rendered button.         * @type Element         */        _prototypeButton: null,                /**         * Creates the prototype DOM hierarchy for a rendered button.         * @type Element         */        _createPrototypeButton: function() {            var div = document.createElement("div");            div.tabIndex = "0";            div.style.outlineStyle = "none";            div.style.cursor = "pointer";            return div;        }    },        $load: function() {        this._prototypeButton = this._createPrototypeButton();        Echo.Render.registerPeer("Button", this);    },        /**     * Outer DIV containing button.     * @type Element     */    _div: null,        /**     * Text-containing element, upon which font styles should be set.     * @type Element     */    _textElement: null,        /**     * IMG element representing buttons icon.     * @type Element     */    _iconImg: null,        /**     * Method reference to _processRolloverExit.     * @type Function     */    _processRolloverExitRef: null,        /**     * Method reference to _processInitEvent.     * @type Function     */    _processInitEventRef: null,        /**     * The rendered focus state of the button.     * @type Boolean     */    _focused: false,        /** Creates a new Echo.Sync.Button */    $construct: function() {         this._processInitEventRef = Core.method(this, this._processInitEvent);    },        $virtual: {                /**         * Processes a user action (i.e., clicking or pressing enter when button is focused).         * Default implementation invokes <code>doAction()</code> on supported <code>Echo.Component</code>.         */        doAction: function() {            this.component.doAction();        },                /**         * Renders the content (e.g. text and/or icon) of the button.         * Appends rendered content to bounding element (<code>this._div</code>).         */        renderContent: function() {            var text = this.component.render("text");            var icon = Echo.Sync.getEffectProperty(this.component, "icon", "disabledIcon", !this._enabled);            if (text != null) {                if (icon) {                    // Text and icon.                    var iconTextMargin = this.component.render("iconTextMargin",                             Echo.Sync.Button._defaultIconTextMargin);                    var orientation = Echo.Sync.TriCellTable.getOrientation(this.component, "textPosition");                    var tct = new Echo.Sync.TriCellTable(orientation,                             Echo.Sync.Extent.toPixels(iconTextMargin));                    this._renderButtonText(tct.tdElements[0], text);                    this._iconImg = this._renderButtonIcon(tct.tdElements[1], icon);                    this._div.appendChild(tct.tableElement);                } else {                    // Text only.                    this._renderButtonText(this._div, text);                }            } else if (icon) {                // Icon only.                this._iconImg = this._renderButtonIcon(this._div, icon);            }        },            /**         * Enables/disables pressed appearance of button.         *          * @param {Boolean} pressedState the new pressed state.         */        setPressedState: function(pressedState) {            var foreground = Echo.Sync.getEffectProperty(this.component, "foreground", "pressedForeground", pressedState);            var background = Echo.Sync.getEffectProperty(this.component, "background", "pressedBackground", pressedState);            var backgroundImage = Echo.Sync.getEffectProperty(                    this.component, "backgroundImage", "pressedBackgroundImage", pressedState);            var font = Echo.Sync.getEffectProperty(this.component, "font", "pressedFont", pressedState);            var border = Echo.Sync.getEffectProperty(this.component, "border", "pressedBorder", pressedState);                        Echo.Sync.Color.renderClear(foreground, this._div, "color");            Echo.Sync.Color.renderClear(background, this._div, "backgroundColor");            Echo.Sync.FillImage.renderClear(backgroundImage, this._div, "backgroundColor");            Echo.Sync.Border.renderClear(border, this._div);            if (this._textElement) {                Echo.Sync.Font.renderClear(font, this._textElement);            }                        if (this._iconImg) {                var iconUrl = Echo.Sync.ImageReference.getUrl(                        Echo.Sync.getEffectProperty(this.component, "icon", "pressedIcon", pressedState));                if (iconUrl != this._iconImg.src) {                    this._iconImg.src = iconUrl;                }            }        },                /**         * Enables/disables rollover appearance of button.         *          * @param {Boolean} rolloverState the new rollover state.         */        setRolloverState: function(rolloverState) {            var foreground = Echo.Sync.getEffectProperty(this.component, "foreground", "rolloverForeground", rolloverState);            var background = Echo.Sync.getEffectProperty(this.component, "background", "rolloverBackground", rolloverState);            var backgroundImage = Echo.Sync.getEffectProperty(                    this.component, "backgroundImage", "rolloverBackgroundImage", rolloverState);            var font = Echo.Sync.getEffectProperty(this.component, "font", "rolloverFont", rolloverState);            var border = Echo.Sync.getEffectProperty(this.component, "border", "rolloverBorder", rolloverState);                        Echo.Sync.Color.renderClear(foreground, this._div, "color");            Echo.Sync.Color.renderClear(background, this._div, "backgroundColor");            Echo.Sync.FillImage.renderClear(backgroundImage, this._div, "backgroundColor");            Echo.Sync.Border.renderClear(border, this._div);            if (this._textElement) {                Echo.Sync.Font.renderClear(font, this._textElement);            }                    if (this._iconImg) {                var iconUrl = Echo.Sync.ImageReference.getUrl(                        Echo.Sync.getEffectProperty(this.component, "icon", "rolloverIcon", rolloverState));                if (iconUrl != this._iconImg.src) {                    this._iconImg.src = iconUrl;                }            }        }    },        /**     * Registers event listeners on the button.  This method is invoked lazily, i.e., the first time the button     * is focused or rolled over with the mouse.  The initial focus/mouse rollover listeners are removed by this method.     * This strategy is used for performance reasons due to the fact that many buttons may be present      * on the screen, and each button has many event listeners, which would otherwise need to be registered on the initial render.     */    _addEventListeners: function() {        this._processRolloverExitRef = Core.method(this, this._processRolloverExit);            // Remove initialization listeners.        Core.Web.Event.remove(this._div, "focus", this._processInitEventRef);        Core.Web.Event.remove(this._div, "mouseover", this._processInitEventRef);                Core.Web.Event.add(this._div, "click", Core.method(this, this._processClick), false);        Core.Web.Event.add(this._div, "keypress", Core.method(this, this._processKeyPress), false);        if (this.component.render("rolloverEnabled")) {            Core.Web.Event.add(this._div, Core.Web.Env.PROPRIETARY_EVENT_MOUSE_ENTER_LEAVE_SUPPORTED ? "mouseenter" : "mouseover",                     Core.method(this, this._processRolloverEnter), false);            Core.Web.Event.add(this._div, Core.Web.Env.PROPRIETARY_EVENT_MOUSE_ENTER_LEAVE_SUPPORTED ? "mouseleave" : "mouseout",                     Core.method(this, this._processRolloverExit), false);        }        if (this.component.render("pressedEnabled")) {            Core.Web.Event.add(this._div, "mousedown", Core.method(this, this._processPress), false);            Core.Web.Event.add(this._div, "mouseup", Core.method(this, this._processRelease), false);        }        Core.Web.Event.add(this._div, "focus", Core.method(this, this._processFocus), false);        Core.Web.Event.add(this._div, "blur", Core.method(this, this._processBlur), false);                Core.Web.Event.Selection.disable(this._div);    },        /** @see Echo.Render.ComponentSync#getFocusFlags */     getFocusFlags: function() {        return Echo.Render.ComponentSync.FOCUS_PERMIT_ARROW_ALL;    },        /** Processes a focus blur event. */    _processBlur: function(e) {        this._renderFocusStyle(false);    },        /** Processes a mouse click event. */    _processClick: function(e) {        if (!this.client || !this.client.verifyInput(this.component)) {            return true;        }        this.client.application.setFocusedComponent(this.component);        this.doAction();    },        /** Processes a focus event. */    _processFocus: function(e) {        if (!this.client || !this.client.verifyInput(this.component)) {            return true;        }        this.client.application.setFocusedComponent(this.component);    },        /**     * The Initial focus/mouse rollover listener.     * This listener is invoked the FIRST TIME the button is focused or mouse rolled over.     * It invokes the addListeners() method to lazily add the full listener set to the button.     */

⌨️ 快捷键说明

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