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

📄 sync.js

📁 echo3 很炫的ajax框架技术 js 演示demo ajax j2ee 里面有jsp演示代码
💻 JS
📖 第 1 页 / 共 4 页
字号:
         * @param {Echo.Component} component the component         * @param {String} propertyName the alignment property name         * @param {#Alignment} defaultValue default alignment value to use if component does not have specified property         * @return the orientation         * @type Number         */        getOrientation: function(component, propertyName, defaultValue) {            var position = component.render(propertyName, defaultValue);            var orientation;            if (position) {                switch (Echo.Sync.Alignment.getRenderedHorizontal(position, component)) {                case "left":   return this.LEADING_TRAILING;                case "right":  return this.TRAILING_LEADING;                }                switch (Echo.Sync.Alignment.getVertical(position, component)) {                case "top":    return this.TOP_BOTTOM;                case "bottom": return this.BOTTOM_TOP;                }            }            return component.getRenderLayoutDirection().isLeftToRight() ? this.TRAILING_LEADING : this.LEADING_TRAILING;         }    },        $load: function() {        this._tablePrototype = this._createTablePrototype();     },        /**     * The rendered TABLE element.     * @type Element     */    tableElement: null,        /**     * The rendered TBODY element.     * @type Element     */    tbodyElement: null,    /**     * Creates a new <code>TriCellTable</code>     *      * @param {Number} orientation0_1 the orientation of element 0 with respect to element 1, one of      *        the following values:     *        <ul>     *        <li>LEADING_TRAILING (element 0 is leading element 1)</li>     *        <li>TRAILING_LEADING (element 1 is leading element 0)</li>     *        <li>TOP_BOTTOM (element 0 is above element 1)</li>     *        <li>BOTTOM_TOP (element 1 is above element 0)</li>     *        </ul>     * @param {Number} margin0_1 the margin size between element 0 and element 1     * @param {Number} orientation01_2 (omitted for two-cell tables)     *        the orientation of Elements 0 and 1 with      *        respect to Element 2, one of the following values:     *        <ul>     *        <li>LEADING_TRAILING (elements 0 and 1 are leading element 2)</li>     *        <li>TRAILING_LEADING (element 2 is trailing elements 0 and 1)</li>     *        <li>TOP_BOTTOM (elements 0 and 1 are above element 2)</li>     *        <li>BOTTOM_TOP (element 2 is above elements 0 and 1)</li>     *        </ul>     * @param {Number} margin01_2 (omitted for two-cell tables)     *        the margin size between the combination     *        of elements 0 and 1 and element 2     */    $construct: function(orientation0_1, margin0_1, orientation01_2, margin01_2) {        this.tableElement = Echo.Sync.TriCellTable._tablePrototype.cloneNode(true);        this.tbodyElement = this.tableElement.firstChild;                if (orientation01_2 == null) {            this._configure2(orientation0_1, margin0_1);        } else {            this._configure3(orientation0_1, margin0_1, orientation01_2, margin01_2);        }    },        /**     * Appends a TD element to a TR element, if TD element is not null.     *      * @param {Element} tr the table row (TR) element     * @param {Element} td the table cell (TD) element     */    _addColumn: function(tr, td) {        if (td != null) {            tr.appendChild(td);        }    },        /**     * If the TD element is not null, creates a TR row element and appends the TD element to it;     * then appends the TR element to the table body.     *      * @param {Element} td the table cell element     */    _addRow: function(td) {        if (td == null) {            return;        }        var tr = document.createElement("tr");        tr.appendChild(td);        this.tbodyElement.appendChild(tr);    },        /**     * Adds a spacer DIV to the specified parent element.     *      * @param {Element} parentElement the parent element to which the spacer DIV should be added     * @param {Number} size the pixel size of the spacer     * @param {Boolean} vertical boolean flag indicating the orientation of the spacer,      *        true for vertical spacers, false for horizontal     */    _addSpacer: function(parentElement, size, vertical) {        var divElement = document.createElement("div");        if (vertical) {            divElement.style.cssText = "width:1px;height:" + size + "px;font-size:1px;line-height:0;";        } else {            divElement.style.cssText = "width:" + size + "px;height:1px;font-size:1px;line-height:0;";        }        parentElement.appendChild(divElement);    },        /**     * Configures a two-celled TriCellTable.     *      * @param {Number} orientation0_1 the orientation of element 0 with respect to element 1     * @param {Number} margin0_1 the margin size between element 0 and element 1     */    _configure2: function(orientation0_1, margin0_1) {        this.tdElements = [document.createElement("td"), document.createElement("td")];        this.tdElements[0].style.padding = "0";        this.tdElements[1].style.padding = "0";        this.marginTdElements = [];                if (margin0_1) {            this.marginTdElements[0] = document.createElement("td");            this.marginTdElements[0].style.padding = "0";            if ((orientation0_1 & Echo.Sync.TriCellTable.VERTICAL) === 0) {                this.marginTdElements[0].style.width = margin0_1 + "px";                this._addSpacer(this.marginTdElements[0], margin0_1, false);            } else {                this.marginTdElements[0].style.height = margin0_1 + "px";                this._addSpacer(this.marginTdElements[0], margin0_1, true);            }        }                if (orientation0_1 & Echo.Sync.TriCellTable.VERTICAL) {            // Vertically oriented.            if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                // Inverted (bottom to top).                this._addRow(this.tdElements[1]);                this._addRow(this.marginTdElements[0]);                this._addRow(this.tdElements[0]);            } else {                // Normal (top to bottom).                this._addRow(this.tdElements[0]);                this._addRow(this.marginTdElements[0]);                this._addRow(this.tdElements[1]);            }        } else {            // Horizontally oriented.            var tr = document.createElement("tr");            if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                // Trailing to leading.                this._addColumn(tr, this.tdElements[1]);                this._addColumn(tr, this.marginTdElements[0]);                this._addColumn(tr, this.tdElements[0]);            } else {                // Leading to trailing.                this._addColumn(tr, this.tdElements[0]);                this._addColumn(tr, this.marginTdElements[0]);                this._addColumn(tr, this.tdElements[1]);            }            this.tbodyElement.appendChild(tr);        }    },        /**     * Configures a two-celled TriCellTable.     *      * @param {Number} orientation0_1 the orientation of element 0 with respect to element 1     * @param {Number} margin0_1 the margin size between element 0 and element 1     * @param {Number} orientation01_2 the orientation of Elements 0 and 1 with respect to Element 2     * @param {Number} margin01_2 the margin size between the combination of elements 0 and 1 and element 2     */    _configure3: function(orientation0_1, margin0_1, orientation01_2, margin01_2) {        this.tdElements = [];        for (var i = 0; i < 3; ++i) {            this.tdElements[i] = document.createElement("td");            this.tdElements[i].style.padding = "0";        }        this.marginTdElements = [];                if (margin0_1 || margin01_2 != null) {            if (margin0_1 && margin0_1 > 0) {                this.marginTdElements[0] = document.createElement("td");                if (orientation0_1 & Echo.Sync.TriCellTable.VERTICAL) {                    this.marginTdElements[0].style.height = margin0_1 + "px";                    this._addSpacer(this.marginTdElements[0], margin0_1, true);                } else {                    this.marginTdElements[0].style.width = margin0_1 + "px";                    this._addSpacer(this.marginTdElements[0], margin0_1, false);                }            }            if (margin01_2 != null && margin01_2 > 0) {                this.marginTdElements[1] = document.createElement("td");                if (orientation0_1 & Echo.Sync.TriCellTable.VERTICAL) {                    this.marginTdElements[1].style.height = margin01_2 + "px";                    this._addSpacer(this.marginTdElements[1], margin01_2, true);                } else {                    this.marginTdElements[1].style.width = margin01_2 + "px";                    this._addSpacer(this.marginTdElements[1], margin01_2, false);                }            }        }                if (orientation0_1 & Echo.Sync.TriCellTable.VERTICAL) {            // Vertically oriented 0/1.            if (orientation01_2 & Echo.Sync.TriCellTable.VERTICAL) {                // Vertically oriented 01/2                                if (orientation01_2 & Echo.Sync.TriCellTable.INVERTED) {                    // 2 before 01: render #2 and margin at beginning of TABLE.                    this._addRow(this.tdElements[2]);                    this._addRow(this.marginTdElements[1]);                }                                // Render 01                if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                    // Inverted (bottom to top)                    this._addRow(this.tdElements[1]);                    this._addRow(this.marginTdElements[0]);                    this._addRow(this.tdElements[0]);                } else {                    // Normal (top to bottom)                    this._addRow(this.tdElements[0]);                    this._addRow(this.marginTdElements[0]);                    this._addRow(this.tdElements[1]);                }                    if (!(orientation01_2 & Echo.Sync.TriCellTable.INVERTED)) {                    // 01 before 2: render #2 and margin at end of TABLE.                    this._addRow(this.marginTdElements[1]);                    this._addRow(this.tdElements[2]);                }            } else {                // Horizontally oriented 01/2                                // Determine and apply row span based on presence of margin between 0 and 1.                var rows = (margin0_1 && margin0_1 > 0) ? 3 : 2;                this.tdElements[2].rowSpan = rows;                if (this.marginTdElements[1]) {                    this.marginTdElements[1].rowSpan = rows;                }                                var tr = document.createElement("tr");                if (orientation01_2 & Echo.Sync.TriCellTable.INVERTED) {                    this._addColumn(tr, this.tdElements[2]);                    this._addColumn(tr, this.marginTdElements[1]);                    if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                        this._addColumn(tr, this.tdElements[1]);                    } else {                        this._addColumn(tr, this.tdElements[0]);                    }                } else {                    if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                        this._addColumn(tr, this.tdElements[1]);                    } else {                        this._addColumn(tr, this.tdElements[0]);                    }                    this._addColumn(tr, this.marginTdElements[1]);                    this._addColumn(tr, this.tdElements[2]);                }                this.tbodyElement.appendChild(tr);                                this._addRow(this.marginTdElements[0]);                if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                    this._addRow(this.tdElements[0]);                } else {                    this._addRow(this.tdElements[1]);                }            }        } else {            // horizontally oriented 0/1            if (orientation01_2 & Echo.Sync.TriCellTable.VERTICAL) {                // vertically oriented 01/2                    // determine and apply column span based on presence of margin between 0 and 1                var columns = margin0_1 ? 3 : 2;                this.tdElements[2].setAttribute("colspan", columns);                if (this.marginTdElements[1] != null) {                    this.marginTdElements[1].setAttribute("colspan", columns);                }                                if (orientation01_2 & Echo.Sync.TriCellTable.INVERTED) {                    // 2 before 01: render #2 and margin at beginning of TR.                    this._addRow(this.tdElements[2]);                    this._addRow(this.marginTdElements[1]);                }                                // Render 01                tr = document.createElement("tr");                if ((orientation0_1 & Echo.Sync.TriCellTable.INVERTED) === 0) {                    // normal (left to right)                    this._addColumn(tr, this.tdElements[0]);                    this._addColumn(tr, this.marginTdElements[0]);                    this._addColumn(tr, this.tdElements[1]);                } else {                    // inverted (right to left)                    this._addColumn(tr, this.tdElements[1]);                    this._addColumn(tr, this.marginTdElements[0]);                    this._addColumn(tr, this.tdElements[0]);                }                this.tbodyElement.appendChild(tr);                                if (!(orientation01_2 & Echo.Sync.TriCellTable.INVERTED)) {                    // 01 before 2: render margin and #2 at end of TR.                    this._addRow(this.marginTdElements[1]);                    this._addRow(this.tdElements[2]);                }            } else {                // horizontally oriented 01/2                tr = document.createElement("tr");                if (orientation01_2 & Echo.Sync.TriCellTable.INVERTED) {                    // 2 before 01: render #2 and margin at beginning of TR.                    this._addColumn(tr, this.tdElements[2]);                    this._addColumn(tr, this.marginTdElements[1]);                }                                // Render 01                if (orientation0_1 & Echo.Sync.TriCellTable.INVERTED) {                    // inverted (right to left)                    this._addColumn(tr, this.tdElements[1]);                    this._addColumn(tr, this.marginTdElements[0]);                    this._addColumn(tr, this.tdElements[0]);                } else {                    // normal (left to right)                    this._addColumn(tr, this.tdElements[0]);                    this._addColumn(tr, this.marginTdElements[0]);                    this._addColumn(tr, this.tdElements[1]);                }                                if (!(orientation01_2 & Echo.Sync.TriCellTable.INVERTED)) {                    this._addColumn(tr, this.marginTdElements[1]);                    this._addColumn(tr, this.tdElements[2]);                }                                this.tbodyElement.appendChild(tr);                    }        }    }});

⌨️ 快捷键说明

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