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

📄 sync.js

📁 echo3 很炫的ajax框架技术 js 演示demo ajax j2ee 里面有jsp演示代码
💻 JS
📖 第 1 页 / 共 4 页
字号:
/** * @fileoverview * <ul>  *  <li>Provides property rendering utilities for core properties.</li> *  <li>Provides TriCellTable rendering utility (used by buttons and labels).</li> *  <li>Provides a floating pane z-index management system.</li>  * </ul> *//** * @namespace */Echo.Sync = {     /**     * Retrieves an "effect-specific" property from a component (e.g., a rollover background) if it     * is available, or otherwise returns the default (non-effect) property value.     *      * @param {Echo.Component} component the component to query     * @param {String} defaultPropertyName the name of the default (non-effect) property, e.g., "background"     * @param {String} effectPropertyName the name of the effect property, e.g., "rolloverBackground"     * @param {Boolean} effectState flag indicating whether the effect is enabled (if the effect is not enabled,     *        the default (non-effect) value will always be returned)     * @param defaultDefaultPropertyValue (optional) the default (non-effect) property value (this value will be returned     *        if no other value can be determined for the property)     * @param defaultEffectPropertyValue (optional) the default effect property value (this value will be returned if the     *        effectState is true and no value has been specifically set for the effect property)      */    getEffectProperty: function(component, defaultPropertyName, effectPropertyName, effectState,            defaultDefaultPropertyValue, effectDefaultPropertyValue) {        var property;        if (effectState) {            property = component.render(effectPropertyName, effectDefaultPropertyValue);        }        if (!property) {            property = component.render(defaultPropertyName, defaultDefaultPropertyValue);        }        return property;    },        /**     * Renders component foreground, background, font, and layout direction properties     * (if each is provided) to the specified element.  This is a performance/convenience method     * which combines capabilities found in Echo.Sync.Color/Font/LayoutDirection.     *      * @param {Echo.Component} component the component     * @param {Element} element the target element     */    renderComponentDefaults: function(component, element) {        var color;        if ((color = component.render("foreground"))) {            element.style.color = color;        }        if ((color = component.render("background"))) {            element.style.backgroundColor = color;        }        var font = component.render("font");        if (font) {            Echo.Sync.Font.render(font, element);        }        if (component.getLayoutDirection()) {            element.dir = component.getLayoutDirection().isLeftToRight() ? "ltr" : "rtl";        }    }};/** * Provides tools for rendering alignment properties. * @class */Echo.Sync.Alignment = {    _HORIZONTALS: { left: true, center: true, right: true, leading: true, trailing: true },    _VERTICALS: { top: true, middle: true, bottom: true },    /**     * Returns the render-able horizontal component of an alignment property.  This method     * translates leading/trailing horizontal values to left/right based on the specified layout     * direction provider.  If a provider is no given, leading defaults to left and trailing to     * right.     *      * @param {#Alignment} alignment the alignment     * @return the rendered horizontal component, i.e., "left", "center", "right", or null     * @type String     */    getRenderedHorizontal: function(alignment, layoutDirectionProvider) {        if (alignment == null) {            return null;        }            var layoutDirection = layoutDirectionProvider ?                 layoutDirectionProvider.getRenderLayoutDirection() : Echo.LayoutDirection.LTR;                 var horizontal = typeof(alignment) == "object" ? alignment.horizontal : alignment;                         switch (horizontal) {        case "leading":            return layoutDirection.isLeftToRight() ? "left" : "right";        case "trailing":            return layoutDirection.isLeftToRight() ? "right" : "left";        default:            return horizontal in this._HORIZONTALS ? horizontal : null;        }    },        /**     * Returns the horizontal component of an alignment property.     *      * @param {#Alignment} the alignment     * @return the horizontal component, i.e., "left", "center", "right", "leading", "trailing", or null     * @type String     */    getHorizontal: function(alignment) {        if (alignment == null) {            return null;        }        if (typeof(alignment == "string")) {            return alignment in this._HORIZONTALS ? alignment : null;        } else {            return alignment.horizontal;        }    },    /**     * Returns the vertical component of an alignment property.     *      * @param {#Alignment} the alignment     * @return the vertical component, i.e., "top", "middle", "bottom", or null      * @type String     */    getVertical: function(alignment) {        if (alignment == null) {            return null;        }        if (typeof(alignment == "string")) {            return alignment in this._VERTICALS ? alignment : null;        } else {            return alignment.vertical;        }    },    /**     * Renders an alignment property to an element.     *      * @param {#Alignment} alignment the alignment     * @param {Element} the target element     * @param {Boolean} renderToElement flag indicating whether the alignment state should be rendered to the element using     *        attributes (true) or CSS (false)     * @param layoutDirectionProvider an (optional) object providing a getRenderLayoutDirection() method to determine if the     *        element has a layout direction of left-to-right or right-to-left     */    render: function(alignment, element, renderToElement, layoutDirectionProvider) {        if (alignment == null) {            return;        }                var horizontal = Echo.Sync.Alignment.getRenderedHorizontal(alignment, layoutDirectionProvider);        var vertical = typeof(alignment) == "object" ? alignment.vertical : alignment;            var horizontalValue;        switch (horizontal) {        case "left":   horizontalValue = "left";   break;        case "center": horizontalValue = "center"; break;        case "right":  horizontalValue = "right";  break;        default:       horizontalValue = "";       break;        }        var verticalValue;        switch (vertical) {        case "top":    verticalValue = "top";      break;        case "middle": verticalValue = "middle";   break;        case "bottom": verticalValue = "bottom";   break;        default:       verticalValue = "";         break;        }                if (renderToElement) {            element.align = horizontalValue;            element.vAlign = verticalValue;        } else {            element.style.textAlign = horizontalValue;            element.style.verticalAlign = verticalValue;        }    }};/** * Provides tools for rendering border properties. * @class */Echo.Sync.Border = {    /**     * Regular expression to validate/parse a CSS border expression, e.g., "1px solid #abcdef".     * Supports omission of any term, or empty strings.     * @type RegExp     */    _PARSER_PX: new RegExp("^(-?\\d+px)?(?:^|$|(?= )) ?(none|hidden|dotted|dashed|solid|" +             "double|groove|ridge|inset|outset)?(?:^|$|(?= )) ?(#[0-9a-fA-F]{6})?$"),    /**     * Regular expression to validate/parse a pixel-based CSS border expression, e.g., "1px solid #abcdef".     * Supports omission of any term, or empty strings.     * @type RegExp     */    _PARSER: new RegExp("^(-?\\d+(?:px|pt|pc|cm|mm|in|em|ex))?(?:^|$|(?= )) ?(none|hidden|dotted|dashed|solid|" +            "double|groove|ridge|inset|outset)?(?:^|$|(?= )) ?(#[0-9a-fA-F]{6})?$"),                /**      * Regular expression to test whether an extent string is a properly formatted integer pixel value.     * @type RegExp      */    _TEST_EXTENT_PX: /^-?\d+px$/,        /**     * Creates a border property from a size, style, and color.     *      * @param {#Extent} size the border size     * @param {String} the border style     * @param {#Color} the border color     * @return a border object     * @type #Border     */    compose: function(size, style, color) {        if (typeof size == "number") {            size += "px";        }        var out = [];        if (size) {            out.push(size);        }        if (style) {            out.push(style);        }        if (color) {            out.push(color);        }        return out.join(" ");    },        /**      * Determines if a border is multisided.     *      * @param {#Border} border the border to analyze     * @return true if the border is multisided     * @type Boolean     */    isMultisided: function(border) {        return (border && (border.top || border.bottom || border.left || border.right)) ? true : false;    },        /**     * Parses a border into size, style, and color components.     *      * @param {#Border} border the border to parse     * @return an object containing size, style, and color properties of the border     */    parse: function(border) {        if (!border) {            // Return an empty object if border evaluates false.            return { };        }        if (typeof(border) == "string") {            // Parse the border.            var parts = this._PARSER.exec(border);            return { size: parts[1], style: parts[2], color: parts[3] };         } else {            // Parse an individual border side.            return Echo.Sync.Border.parse(border.top || border.right || border.bottom || border.left);        }    },    /**     * Renders a border to a DOM element.     *      * @param {#Border} border the border to render     * @param {Element} the target DOM element     * @param {String} styleAttribute the CSS style attribute name (defaults to "border" if omitted)     */    render: function(border, element, styleAttribute) {        if (!border) {            return;        }        styleAttribute = styleAttribute ? styleAttribute : "border";        if (typeof(border) == "string") {            if (this._PARSER_PX.test(border)) {                element.style[styleAttribute] = border;            } else {                var elements = this._PARSER.exec(border);                if (elements == null) {                    throw new Error("Invalid border: \"" + border + "\"");                }                this.render(Echo.Sync.Extent.toPixels(elements[1]) + "px " + elements[2] + " " + elements[3],                         element, styleAttribute);            }        } else {            this.render(border.top, element, styleAttribute + "Top");            if (border.right !== null) {                this.render(border.right || border.top, element, styleAttribute + "Right");            }            if (border.bottom !== null) {                this.render(border.bottom || border.top, element, styleAttribute + "Bottom");            }            if (border.left !== null) {                this.render(border.left || border.right || border.top, element, styleAttribute + "Left");            }                    }    },        /**     * Renders a border to a DOM element, clearing an existing border if the border value is null.     *      * @param {#Border} border the border to render     * @param {Element} the target DOM element     * @param {String} styleAttribute the CSS style attribute name (defaults to "border" if omitted)     */    renderClear: function(border, element) {        if (border) {            if (border instanceof Object) {                element.style.border = "";            }            this.render(border, element);        } else {            element.style.border = "";        }    },    /**     * Determines the size of a particular side of the border in pixels.     *      * @param {#Border} border the border     * @param {String} sideName, the border side name, "left", "right", "bottom", or "top" (defaults to "top" if omitted)     * @return the border size in pixels     * @type {Number}     */    getPixelSize: function(border, sideName) {        if (!border) {            return 0;        }                if (typeof(border) == "string") {            var extent = this._PARSER.exec(border)[1];            if (extent == null) {                return 0;            } else if (this._TEST_EXTENT_PX.test(extent)) {                return parseInt(extent, 10);            } else {                return Echo.Sync.Extent.toPixels(extent);            }        } else if (typeof(border) == "object") {            // Retrieve value for individual side.            // Specified side is queried first, followed by alternatives.

⌨️ 快捷键说明

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