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

📄 sync.datagrid.js

📁 echo3 很炫的ajax框架技术 js 演示demo ajax j2ee 里面有jsp演示代码
💻 JS
📖 第 1 页 / 共 3 页
字号:
                if (this.fixedCells.bottom) {            if (this.fixedCells.left) {                this.regions.bottomLeft = new Extras.Sync.DataGrid.Region(this, "bottomLeft");            }            this.regions.bottom = new Extras.Sync.DataGrid.Region(this, "bottom");            if (this.fixedCells.right) {                this.regions.bottomRight = new Extras.Sync.DataGrid.Region(this, "bottomRight");            }        }                if (this.fixedCells.left) {            this.regions.left = new Extras.Sync.DataGrid.Region(this, "left");        }        this.regions.center = new Extras.Sync.DataGrid.Region(this, "center");        if (this.fixedCells.right) {            this.regions.right = new Extras.Sync.DataGrid.Region(this, "right");        }                for (var name in this.regions) {            this.scrollContainer.contentElement.appendChild(this.regions[name].element);        }                this._updateRegionBounds();    },        _getCellBorderHeight: function(column, row) {        return 2;    },        _getCellBorderWidth: function(column, row) {        return 2;    },        _getColumnWidth: function(column) {        return 80;    },        getPrototypeTable: function() {        if (!this._prototypeTable) {            this._prototypeTable = document.createElement("table");            this._prototypeTable.cellPadding = this._prototypeTable.cellSpacing = 0;            this._prototypeTable.style.cssText = "table-layout:fixed;padding:0;border:0px none;";            var tbody = document.createElement("tbody");            this._prototypeTable.appendChild(tbody);        }        return this._prototypeTable;    },        _getRowHeight: function(row) {        return 20;    },    _loadProperties: function() {        this._cellBorder = this.component.render("cellBorder");        this._model = this.component.get("model");        this.fixedCells = {            left: parseInt(this.component.render("fixedColumnsLeft", 0), 10),            top: parseInt(this.component.render("fixedRowsTop", 0), 10),            right: parseInt(this.component.render("fixedColumnsRight", 0), 10),            bottom: parseInt(this.component.render("fixedRowsBottom", 0), 10)        };        // FIXME temporary        this.fixedCellSizes = {             left: this.fixedCells.left * this._getColumnWidth(),            top: this.fixedCells.top * this._getRowHeight(),            right: this.fixedCells.right * this._getColumnWidth(),            bottom: this.fixedCells.bottom * this._getRowHeight()        };    },        _processScroll: function(e) {        if (e.verticalIncrement) {            this._scrollIncrementalVertical(e.verticalIncrement);        }        if (e.horizontalIncrement) {            this._scrollIncrementalHorizontal(e.horizontalIncrement);        }    },        /** @see Echo.Render.ComponentSync#renderAdd */    renderAdd: function(update, parentElement) {        this._div = document.createElement("div");        this._div.style.cssText = "position:absolute;top:0;left:0;right:0;bottom:0;background-color:lime;";        this._div.id = this.component.renderId;                this.scrollContainer = new Extras.Sync.DataGrid.ScrollContainer();        this.scrollContainer.configure(10, 10);        this.scrollContainer.onScroll = Core.method(this, this._processScroll);        this._div.appendChild(this.scrollContainer.rootElement);                this._loadProperties();        this._fullRenderRequired = true;        parentElement.appendChild(this._div);    },        /** @see Echo.Render.ComponentSync#renderDisplay */    renderDisplay: function() {        Core.Web.VirtualPosition.redraw(this._div);        this.scrollContainer.renderDisplay();                if (this._fullRenderRequired) {                    this._createRegions();            if (this._model == null) {                this.size = {                    columns: 0,                    rows: 0                };            } else {                this.size = {                    columns: this._model.getColumnCount(),                    rows: this._model.getRowCount()                };                var topRowIndex = Math.floor(this._displayRowIndex);                var leftColumnIndex = Math.floor(this._displayColumnIndex);                this.setPosition(this.component.get("columnIndex") || 0, Extras.Sync.DataGrid.INDEX,                        this.component.get("rowIndex") || 0, Extras.Sync.DataGrid.INDEX);            }            this._fullRenderRequired = false;        }        this._updateRegionBounds();    },        /** @see Echo.Render.ComponentSync#renderDispose */    renderDispose: function(update) {        this._cachedTileRows = { };        this._prototypeTable = null;        this.regions = null;        this._div = null;    },    /** @see Echo.Render.ComponentSync#renderUpdate */    renderUpdate: function(update) {        var element = this._div;        var containerElement = element.parentNode;        Echo.Render.renderComponentDispose(update, update.parent);        containerElement.removeChild(element);        this.renderAdd(update, containerElement);        return true;    },        /**     * Scrolls the viewable area left or right by a percentage of the viewable area width.     */    _scrollIncrementalHorizontal: function(percent) {        var scrollPixels = Math.round(this.scrollContainer.bounds.width * percent / 10);        this.adjustPosition(0 - scrollPixels, 0);            },        /**     * Scrolls the viewable area up or down by a percentage of the viewable area height.     */    _scrollIncrementalVertical: function(percent) {        var scrollPixels = Math.round(this.scrollContainer.bounds.height * percent / 10);        this.adjustPosition(0, 0 - scrollPixels);            },        _scrollRowPercentVertical: function(percent) {        var row = this.size.rows * percent / 100;    },        /**     * Sets the position of the viewport.  Invocation will clear all existing tiles.     */    setPosition: function(x, xUnits, y, yUnits) {        for (var name in this.regions) {            this.regions[name].setPosition(x, xUnits, y, yUnits);        }    },    _updateRegionBounds: function() {        var i, name, left = 0, top = 0, right = 0, bottom = 0;                if (this.fixedCells.top) {            for (i = 0; i < this.fixedCells.top; ++i) {                top += this._getRowHeight(i);            }        }        if (this.fixedCells.bottom) {            for (i = 0; i < this.fixedCells.bottom; ++i) {                bottom += this._getRowHeight(this.size.rows - i - 1);            }        }        if (this.fixedCells.left) {            for (i = 0; i < this.fixedCells.left; ++i) {                left += this._getColumnWidth(i);            }        }                if (this.fixedCells.right) {            for (i = 0; i < this.fixedCells.right; ++i) {                right += this._getColumnWidth(this.size.columns - i - 1);            }        }                for (name in this.regions) {            this.regions[name].updateBounds(left, top, right, bottom);        }    }});/** * Renders a scrolling container for the DataGrid, processing scroll events and managing scroll bar positions. */Extras.Sync.DataGrid.ScrollContainer = Core.extend({    _hScrollAccumulator: 0,    _vScrollAccumulator: 0,        bounds: null,    rootElement: null,    contentElement: null,        onScroll: null,    /**     * Creates a ScrollContainer.  The dispose() method should be invoked when the ScrollContainer will no longer be used.     *     * @param horizontal     * @param vertical     */    $construct: function(horizontal, vertical) {        this.rootElement = document.createElement("div");        this.rootElement.style.cssText = "position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;";                this._vScrollContainer = document.createElement("div");        this._vScrollContainer.style.cssText = "position:absolute;top:0;bottom:0;right:0;overflow:scroll;";        this._vScrollContainer.style.width = (1 + Core.Web.Measure.SCROLL_WIDTH) + "px";        this._vScrollContent = document.createElement("div");        this._vScrollContent.style.cssText = "width:1px;height:500%;";        this._vScrollContainer.appendChild(this._vScrollContent);        this.rootElement.appendChild(this._vScrollContainer);                this._hScrollContainer = document.createElement("div");        this._hScrollContainer.style.cssText = "position:absolute;;bottom:0;left:0;right:0;overflow:scroll;";        this._hScrollContainer.style.height = (1 + Core.Web.Measure.SCROLL_HEIGHT) + "px";        this._hScrollContent = document.createElement("div");        this._hScrollContent.style.cssText = "height:1px;width:500%;";        this._hScrollContainer.appendChild(this._hScrollContent);        this.rootElement.appendChild(this._hScrollContainer);                this.contentElement = document.createElement("div");        this.contentElement.style.cssText = "position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:white;";        this.rootElement.appendChild(this.contentElement);                Core.Web.Event.add(this._vScrollContainer, "scroll", Core.method(this, this._processScrollV), true);        Core.Web.Event.add(this._hScrollContainer, "scroll", Core.method(this, this._processScrollH), true);        Core.Web.Event.add(this.rootElement, Core.Web.Env.BROWSER_MOZILLA ? "DOMMouseScroll" :  "mousewheel",                Core.method(this, this._processWheel), true);    },        _accumulatedScroll: function() {        if (this._vScrollAccumulator || this._hScrollAccumulator) {            var v = this._vScrollAccumulator;            this._vScrollAccumulator = 0;            var h = this._hScrollAccumulator;            this._hScrollAccumulator = 0;            if (this.onScroll) {                // FIXME                this.onScroll({source: this, type: "scroll", horizontalIncrement: h, verticalIncrement:  v });            }        }    },        configure: function(horizontal, vertical) {        if (horizontal > 1) {            this._vScrollContainer.style.bottom = this.contentElement.style.bottom = Core.Web.Measure.SCROLL_HEIGHT + "px";        } else {            this._vScrollContainer.style.bottom = this.contentElement.style.bottom = 0;        }        if (vertical > 1) {            this._hScrollContainer.style.right = this.contentElement.style.right = Core.Web.Measure.SCROLL_WIDTH + "px";        } else {            this._hScrollContainer.style.right = this.contentElement.style.right = 0;        }    },        /**     * Disposes of the ScrollContainer, releasing any resources in use.     */    dispose: function() {        Core.Web.Event.removeAll(this._hScrollContainer);        Core.Web.Event.removeAll(this._vScrollContainer);        Core.Web.Event.removeAll(this.rootElement);            this.rootElement = null;        this.contentElement = null;    },        /**     * Process a horizontal scroll bar drag adjustment event.     *     * @param e the event     */    _processScrollH: function(e) {        //FIXME Implement        Core.Debug.consoleWrite("hscroll:" + this._hScrollContainer.scrollLeft);        if (this.onScroll) {        }    },        /**     * Process a vertical scroll bar drag adjustment event.     *     * @param e the event     */    _processScrollV: function(e) {        Core.Debug.consoleWrite("vscroll:" + this._vScrollContainer.scrollTop);        //FIXME Implement        if (this.onScroll) {        }    },        /**     * Processes a scroll wheel event.     *     * @param e the event     */    _processWheel: function(e) {        // Convert scroll wheel direction/distance data into uniform/cross-browser format:        // A value of 1 indicates one notch scroll down, -1 indicates one notch scroll up.        var wheelScroll;        if (e.wheelDelta) {            wheelScroll = e.wheelDelta / -120;        } else if (e.detail) {            wheelScroll = e.detail / 3;        } else {            return;        }                if (e.shiftKey) {            // Scroll horizontally.            this._hScrollContainer.scrollTop += wheelScroll * 90;            this._hScrollAccumulator += wheelScroll;        } else {            // Scroll vertically.            this._vScrollContainer.scrollTop += wheelScroll * 90;            this._vScrollAccumulator += wheelScroll;        }        Core.Web.Scheduler.run(Core.method(this, this._accumulatedScroll), 10);                // Prevent default scrolling action, or in the case of modifier keys, font adjustments, etc.        Core.Web.DOM.preventEventDefault(e);                return true;    },        /**     * Executes operations which should be performed when the containing component synchronize peer's <code>renderDisplay</code>     * method is invoked.     */    renderDisplay: function() {        Core.Web.VirtualPosition.redraw(this.rootElement);        Core.Web.VirtualPosition.redraw(this.contentElement);        Core.Web.VirtualPosition.redraw(this._hScrollContainer);        Core.Web.VirtualPosition.redraw(this._vScrollContainer);                this.bounds = new Core.Web.Measure.Bounds(this.contentElement);    }});

⌨️ 快捷键说明

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