r1021 - in branches/dev/grid: tests/visual ui

r1021 - in branches/dev/grid: tests/visual ui


Author: paul.bakaus
Date: Fri Nov 28 02:28:30 2008
New Revision: 1021
Modified:
branches/dev/grid/tests/visual/infiniteScrolling.html
branches/dev/grid/ui/ui.grid.js
branches/dev/grid/ui/ui.infiniteScrolling.js
Log:
infiniteScrolling: renamed option 'block' to 'chunk'
Modified: branches/dev/grid/tests/visual/infiniteScrolling.html
==============================================================================
--- branches/dev/grid/tests/visual/infiniteScrolling.html    (original)
+++ branches/dev/grid/tests/visual/infiniteScrolling.html    Fri Nov 28
02:28:30 2008
@@ -43,7 +43,7 @@
                        window.setTimeout(function() {
                            ui.fill({
-                                block: ui.block,
+                                chunk: ui.chunk,
                                data: data
                            });
Modified: branches/dev/grid/ui/ui.grid.js
==============================================================================
--- branches/dev/grid/ui/ui.grid.js    (original)
+++ branches/dev/grid/ui/ui.grid.js    Fri Nov 28 02:28:30 2008
@@ -221,7 +221,7 @@
                };
                o.fill({
-                    block: o.block,
+                    chunk: o.chunk,
                    data: data
                });                
@@ -242,10 +242,10 @@
                self.infiniteScrollingJustInitiated = true;
                $('div.ui-grid-content', self.grid).infiniteScrolling({
                    total: response.totalRecords,
-                    block: 20,
+                    chunk: 20,
                    scroll: function(e, ui) {
                        self.offset = ui.start;
-                        self._update({ fill: ui.fill, block: ui.block });
+                        self._update({ fill: ui.fill, chunk: ui.chunk });
                    },
                    update: function(e, ui) {
                        $('div.ui-grid-limits', self.footer).html('Result ' + ui.firstItem
+ '-' + ui.lastItem + ' of ' + ui.total);
Modified: branches/dev/grid/ui/ui.infiniteScrolling.js
==============================================================================
--- branches/dev/grid/ui/ui.infiniteScrolling.js    (original)
+++ branches/dev/grid/ui/ui.infiniteScrolling.js    Fri Nov 28 02:28:30 2008
@@ -44,8 +44,8 @@
    
    _prepareCache: function() {
        
-        this.cache = new Array(Math.ceil(this.options.total /
this.options.block));
-        var alreadyCached = Math.floor($('tr', this.tbody).length /
this.options.block);
+        this.cache = new Array(Math.ceil(this.options.total /
this.options.chunk));
+        var alreadyCached = Math.floor($('tr', this.tbody).length /
this.options.chunk);
        for (var i=0; i < alreadyCached; i++) {
            this.cache[i] = (new Date()).getTime();
        };
@@ -81,17 +81,17 @@
        var firstItem = Math.floor((start+this.rowHeight) / this.rowHeight);
        var lastItem = Math.floor(stop / this.rowHeight); //Usually we should
use 'ceil' here, but to accomodate the bottom scrollbar, we use floor
        
-        var firstBlock = Math.round(firstItem / this.options.block);
-        var lastBlock = Math.round(lastItem / this.options.block);
+        var firstChunk = Math.round(firstItem / this.options.chunk);
+        var lastChunk = Math.round(lastItem / this.options.chunk);
-        for (var i=firstBlock - this.options.preload; i <= lastBlock +
this.options.preload; i++) {
+        for (var i=firstChunk - this.options.preload; i <= lastChunk +
this.options.preload; i++) {
            
            if(i < 0 || i >= this.cache.length) continue;
            timeoutFunctions.push(function(i2) {
                return function() {
                    if(self.cache[i2]) return;
                    self.cache[i2] = (new Date()).getTime(); //TODO: Revalidation option
-                    self._trigger('scroll', event, { total: self.options.total, block:
i2, start: i2 * self.options.block, fill: function() { return
self.fill.apply(self, arguments); } });
+                    self._trigger('scroll', event, { total: self.options.total, chunk:
i2, start: i2 * self.options.chunk, fill: function() { return
self.fill.apply(self, arguments); } });
                };
            }(i));
@@ -105,7 +105,7 @@
                this();
            });
            
-            self._trigger('update', event, { firstBlock: firstBlock, lastBlock:
lastBlock, firstItem: firstItem, lastItem: lastItem, total:
self.options.total });
+            self._trigger('update', event, { firstChunk: firstChunk, lastChunk:
lastChunk, firstItem: firstItem, lastItem: lastItem, total:
self.options.total });
        }, this.options.delay);
        
@@ -129,7 +129,7 @@
            
            //I'm sure there is a better way to do this..
-            this.tbody[0].replaceChild($(template)[0], rows[(o.block *
this.options.block)+i]);
+            this.tbody[0].replaceChild($(template)[0], rows[(o.chunk *
this.options.chunk)+i]);
            
        };
        
@@ -141,7 +141,7 @@
    version: "@VERSION",
    defaults: {
        total: 1000,
-        block: 20,
+        chunk: 20,
        preload: 1,
        delay: 100
    }