dojox/grid/_Scroller.js

  • Provides:

    • dojox.grid._Scroller
  • dojox.grid._Scroller

    • type
      Function
    • parameters:
      • inContentNodes: (typeof )
    • source: [view]
         this.setContentNodes(inContentNodes);
         this.pageHeights = [];
         this.pageNodes = [];
         this.stack = [];
    • summary
  • dojox.grid._Scroller.rowCount

    • summary
  • dojox.grid._Scroller.defaultRowHeight

    • summary
  • dojox.grid._Scroller.keepRows

    • summary
  • dojox.grid._Scroller.contentNode

    • summary
  • dojox.grid._Scroller.scrollboxNode

    • summary
  • dojox.grid._Scroller.defaultPageHeight

    • summary
  • dojox.grid._Scroller.keepPages

    • summary
  • dojox.grid._Scroller.pageCount

    • summary
  • dojox.grid._Scroller.windowHeight

    • summary
  • dojox.grid._Scroller.firstVisibleRow

    • summary
  • dojox.grid._Scroller.lastVisibleRow

    • summary
  • dojox.grid._Scroller.averageRowHeight

    • summary
  • dojox.grid._Scroller.page

    • summary
  • dojox.grid._Scroller.pageTop

    • summary
  • dojox.grid._Scroller.init

    • type
      Function
    • parameters:
      • inRowCount: (typeof )
      • inKeepRows: (typeof )
      • inRowsPerPage: (typeof )
    • source: [view]
         switch(arguments.length){
          case 3: this.rowsPerPage = inRowsPerPage;
          case 2: this.keepRows = inKeepRows;
          case 1: this.rowCount = inRowCount;
          default: break;
         }
         this.defaultPageHeight = this.defaultRowHeight * this.rowsPerPage;
         this.pageCount = this._getPageCount(this.rowCount, this.rowsPerPage);
         this.setKeepInfo(this.keepRows);
         this.invalidate();
         if(this.scrollboxNode){
          this.scrollboxNode.scrollTop = 0;
          this.scroll(0);
          this.scrollboxNode.onscroll = dojo.hitch(this, 'onscroll');
         }
    • summary
  • dojox.grid._Scroller._getPageCount

    • type
      Function
    • parameters:
      • rowCount: (typeof )
      • rowsPerPage: (typeof )
    • source: [view]
         return rowCount ? (Math.ceil(rowCount / rowsPerPage) || 1) : 0;
    • summary
  • dojox.grid._Scroller.destroy

    • type
      Function
    • source: [view]
         this.invalidateNodes();
         delete this.contentNodes;
         delete this.contentNode;
         delete this.scrollboxNode;
    • summary
  • dojox.grid._Scroller.setKeepInfo

    • type
      Function
    • parameters:
      • inKeepRows: (typeof )
    • source: [view]
         this.keepRows = inKeepRows;
         this.keepPages = !this.keepRows ? this.keepPages : Math.max(Math.ceil(this.keepRows / this.rowsPerPage), 2);
    • summary
  • dojox.grid._Scroller.setContentNodes

    • type
      Function
    • parameters:
      • inNodes: (typeof )
    • source: [view]
         this.contentNodes = inNodes;
         this.colCount = (this.contentNodes ? this.contentNodes.length : 0);
         this.pageNodes = [];
         for(var i=0; i    this.pageNodes[i] = [];
         }
    • summary
  • dojox.grid._Scroller.getDefaultNodes

    • type
      Function
    • source: [view]
         return this.pageNodes[0] || [];
    • summary
  • dojox.grid._Scroller.invalidate

    • type
      Function
    • source: [view]
         this._invalidating = true;
         this.invalidateNodes();
         this.pageHeights = [];
         this.height = (this.pageCount ? (this.pageCount - 1)* this.defaultPageHeight + this.calcLastPageHeight() : 0);
         this.resize();
         this._invalidating = false;
    • summary
  • dojox.grid._Scroller.updateRowCount

    • type
      Function
    • parameters:
      • inRowCount: (typeof )
    • source: [view]
         this.invalidateNodes();
         this.rowCount = inRowCount;
         // update page count, adjust document height
         var oldPageCount = this.pageCount;
         if(oldPageCount === 0){
          //We want to have at least 1px in height to keep scroller. Otherwise with an
          //empty grid you can't scroll to see the header.
          this.height = 1;
         }
         this.pageCount = this._getPageCount(this.rowCount, this.rowsPerPage);
         if(this.pageCount < oldPageCount){
          for(var i=oldPageCount-1; i>=this.pageCount; i--){
           this.height -= this.getPageHeight(i);
           delete this.pageHeights[i];
          }
         }else if(this.pageCount > oldPageCount){
          this.height += this.defaultPageHeight * (this.pageCount - oldPageCount - 1) + this.calcLastPageHeight();
         }
         this.resize();
    • summary
  • dojox.grid._Scroller.pageExists

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         return Boolean(this.getDefaultPageNode(inPageIndex));
    • summary
  • dojox.grid._Scroller.measurePage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         if(this.grid.rowHeight){
          var height = this.grid.rowHeight + 1;
          return ((inPageIndex + 1) * this.rowsPerPage > this.rowCount ?
           this.rowCount - inPageIndex * this.rowsPerPage :
           this.rowsPerPage) * height;

           
         }
         var n = this.getDefaultPageNode(inPageIndex);
         return (n && n.innerHTML) ? n.offsetHeight : undefined;
    • summary
  • dojox.grid._Scroller.positionPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • inPos: (typeof )
    • source: [view]
         for(var i=0; i    this.pageNodes[i][inPageIndex].style.top = inPos + 'px';
         }
    • summary
  • dojox.grid._Scroller.repositionPages

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         var nodes = this.getDefaultNodes();
         var last = 0;


         for(var i=0; i    last = Math.max(this.stack[i], last);
         }
         //
         var n = nodes[inPageIndex];
         var y = (n ? this.getPageNodePosition(n) + this.getPageHeight(inPageIndex) : 0);
         for(var p=inPageIndex+1; p<=last; p++){
          n = nodes[p];
          if(n){
           if(this.getPageNodePosition(n) == y){
            return;
           }
           this.positionPage(p, y);
          }
          y += this.getPageHeight(p);
         }
    • summary
  • dojox.grid._Scroller.installPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         for(var i=0; i    this.contentNodes[i].appendChild(this.pageNodes[i][inPageIndex]);
         }
    • summary
  • dojox.grid._Scroller.preparePage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • inReuseNode: (typeof )
    • source: [view]
         var p = (inReuseNode ? this.popPage() : null);
         for(var i=0; i    var nodes = this.pageNodes[i];
          var new_p = (p === null ? this.createPageNode() : this.invalidatePageNode(p, nodes));
          new_p.pageIndex = inPageIndex;
          nodes[inPageIndex] = new_p;
         }
    • summary
  • dojox.grid._Scroller.renderPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         var nodes = [];
         var i, j;
         for(i=0; i    nodes[i] = this.pageNodes[i][inPageIndex];
         }
         for(i=0, j=inPageIndex*this.rowsPerPage; (i    this.renderRow(j, nodes);
         }
    • summary
  • dojox.grid._Scroller.removePage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         for(var i=0, j=inPageIndex*this.rowsPerPage; i    this.removeRow(j);
         }
    • summary
  • dojox.grid._Scroller.destroyPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         for(var i=0; i    var n = this.invalidatePageNode(inPageIndex, this.pageNodes[i]);
          if(n){
           dojo.destroy(n);
          }
         }
    • summary
  • dojox.grid._Scroller.pacify

    • type
      Function
    • parameters:
      • inShouldPacify: (typeof )
    • source: [view]
    • summary
  • dojox.grid._Scroller.pacifying

    • summary
  • dojox.grid._Scroller.pacifyTicks

    • summary
  • dojox.grid._Scroller.setPacifying

    • type
      Function
    • parameters:
      • inPacifying: (typeof )
    • source: [view]
         if(this.pacifying != inPacifying){
          this.pacifying = inPacifying;
          this.pacify(this.pacifying);
         }
    • summary
  • dojox.grid._Scroller.startPacify

    • type
      Function
    • source: [view]
         this.startPacifyTicks = new Date().getTime();
    • summary
  • dojox.grid._Scroller.doPacify

    • type
      Function
    • source: [view]
         var result = (new Date().getTime() - this.startPacifyTicks) > this.pacifyTicks;
         this.setPacifying(true);
         this.startPacify();
         return result;
    • summary
  • dojox.grid._Scroller.endPacify

    • type
      Function
    • source: [view]
         this.setPacifying(false);
    • summary
  • dojox.grid._Scroller.resize

    • type
      Function
    • source: [view]
         if(this.scrollboxNode){
          this.windowHeight = this.scrollboxNode.clientHeight;
         }
         for(var i=0; i    //We want to have 1px in height min to keep scroller. Otherwise can't scroll
          //and see header in empty grid.
          dojox.grid.util.setStyleHeightPx(this.contentNodes[i], Math.max(1,this.height));
         }

         
         // Calculate the average row height and update the defaults (row and page).
         var needPage = (!this._invalidating);
         if(!needPage){
          var ah = this.grid.get("autoHeight");
          if(typeof ah == "number" && ah <= Math.min(this.rowsPerPage, this.rowCount)){
           needPage = true;
          }
         }
         if(needPage){
          this.needPage(this.page, this.pageTop);
         }
         var rowsOnPage = (this.page < this.pageCount - 1) ? this.rowsPerPage : ((this.rowCount % this.rowsPerPage) || this.rowsPerPage);
         var pageHeight = this.getPageHeight(this.page);
         this.averageRowHeight = (pageHeight > 0 && rowsOnPage > 0) ? (pageHeight / rowsOnPage) : 0;
    • summary
  • dojox.grid._Scroller.calcLastPageHeight

    • type
      Function
    • source: [view]
         if(!this.pageCount){
          return 0;
         }
         var lastPage = this.pageCount - 1;
         var lastPageHeight = ((this.rowCount % this.rowsPerPage)||(this.rowsPerPage)) * this.defaultRowHeight;
         this.pageHeights[lastPage] = lastPageHeight;
         return lastPageHeight;
    • summary
  • dojox.grid._Scroller.updateContentHeight

    • type
      Function
    • parameters:
      • inDh: (typeof )
    • source: [view]
         this.height += inDh;
         this.resize();
    • summary
  • dojox.grid._Scroller.updatePageHeight

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • fromBuild: (typeof )
      • fromAsynRendering: (typeof )
    • source: [view]
         if(this.pageExists(inPageIndex)){
          var oh = this.getPageHeight(inPageIndex);
          var h = (this.measurePage(inPageIndex));
          if(h === undefined){
           h = oh;
          }
          this.pageHeights[inPageIndex] = h;
          if(oh != h){
           this.updateContentHeight(h - oh);
           var ah = this.grid.get("autoHeight");
           if((typeof ah == "number" && ah > this.rowCount)||(ah === true && !fromBuild)){
            if(!fromAsynRendering){
             this.grid.sizeChange();
            }else{//fix #11101 by using fromAsynRendering to avoid deadlock
             var ns = this.grid.viewsNode.style;
             ns.height = parseInt(ns.height) + h - oh + 'px';
             this.repositionPages(inPageIndex);
            }
           }else{
            this.repositionPages(inPageIndex);
           }
          }
          return h;
         }
         return 0;
    • summary
  • dojox.grid._Scroller.rowHeightChanged

    • type
      Function
    • parameters:
      • inRowIndex: (typeof )
      • fromAsynRendering: (typeof )
    • source: [view]
         this.updatePageHeight(Math.floor(inRowIndex / this.rowsPerPage), false, fromAsynRendering);
    • summary
  • dojox.grid._Scroller.invalidateNodes

    • type
      Function
    • source: [view]
         while(this.stack.length){
          this.destroyPage(this.popPage());
         }
    • summary
  • dojox.grid._Scroller.createPageNode

    • type
      Function
    • source: [view]
         var p = document.createElement('div');
         dojo.attr(p,"role","presentation");
         p.style.position = 'absolute';
         //p.style.width = '100%';
         p.style[dojo._isBodyLtr() ? "left" : "right"] = '0';
         return p;
    • summary
  • dojox.grid._Scroller.getPageHeight

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         var ph = this.pageHeights[inPageIndex];
         return (ph !== undefined ? ph : this.defaultPageHeight);
    • summary
  • dojox.grid._Scroller.pushPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         return this.stack.push(inPageIndex);
    • summary
  • dojox.grid._Scroller.popPage

    • type
      Function
    • source: [view]
         return this.stack.shift();
    • summary
  • dojox.grid._Scroller.findPage

    • type
      Function
    • parameters:
      • inTop: (typeof )
    • source: [view]
         var i = 0, h = 0;
         for(var ph = 0; i    ph = this.getPageHeight(i);
          if(h + ph >= inTop){
           break;
          }
         }
         this.page = i;
         this.pageTop = h;
    • summary
  • dojox.grid._Scroller.buildPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • inReuseNode: (typeof )
      • inPos: (typeof )
    • source: [view]
         this.preparePage(inPageIndex, inReuseNode);
         this.positionPage(inPageIndex, inPos);
         // order of operations is key below
         this.installPage(inPageIndex);
         this.renderPage(inPageIndex);
         // order of operations is key above
         this.pushPage(inPageIndex);
    • summary
  • dojox.grid._Scroller.needPage

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • inPos: (typeof )
    • source: [view]
         var h = this.getPageHeight(inPageIndex), oh = h;
         if(!this.pageExists(inPageIndex)){
          this.buildPage(inPageIndex, (!this.grid._autoHeight/*fix #10543*/ && this.keepPages&&(this.stack.length >= this.keepPages)), inPos);
          h = this.updatePageHeight(inPageIndex, true);
         }else{
          this.positionPage(inPageIndex, inPos);
         }
         return h;
    • summary
  • dojox.grid._Scroller.onscroll

    • type
      Function
    • source: [view]
         this.scroll(this.scrollboxNode.scrollTop);
    • summary
  • dojox.grid._Scroller.scroll

    • type
      Function
    • parameters:
      • inTop: (typeof )
    • source: [view]
         this.grid.scrollTop = inTop;
         if(this.colCount){
          this.startPacify();
          this.findPage(inTop);
          var h = this.height;
          var b = this.getScrollBottom(inTop);
          for(var p=this.page, y=this.pageTop; (p     y += this.needPage(p, y);
          }
          this.firstVisibleRow = this.getFirstVisibleRow(this.page, this.pageTop, inTop);
          this.lastVisibleRow = this.getLastVisibleRow(p - 1, y, b);
          // indicates some page size has been updated
          if(h != this.height){
           this.repositionPages(p-1);
          }
          this.endPacify();
         }
    • summary
  • dojox.grid._Scroller.getScrollBottom

    • type
      Function
    • parameters:
      • inTop: (typeof )
    • source: [view]
         return (this.windowHeight >= 0 ? inTop + this.windowHeight : -1);
    • summary
  • dojox.grid._Scroller.processNodeEvent

    • type
      Function
    • parameters:
      • e: (typeof )
      • inNode: (typeof )
    • source: [view]
         var t = e.target;
         while(t && (t != inNode) && t.parentNode && (t.parentNode.parentNode != inNode)){
          t = t.parentNode;
         }
         if(!t || !t.parentNode || (t.parentNode.parentNode != inNode)){
          return false;
         }
         var page = t.parentNode;
         e.topRowIndex = page.pageIndex * this.rowsPerPage;
         e.rowIndex = e.topRowIndex + indexInParent(t);
         e.rowTarget = t;
         return true;
    • summary
  • dojox.grid._Scroller.processEvent

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         return this.processNodeEvent(e, this.contentNode);
    • summary
  • dojox.grid._Scroller.renderRow

    • type
      Function
    • parameters:
      • inRowIndex: (typeof )
      • inPageNode: (typeof )
    • source: [view]
    • summary
  • dojox.grid._Scroller.removeRow

    • type
      Function
    • parameters:
      • inRowIndex: (typeof )
    • source: [view]
    • summary
  • dojox.grid._Scroller.getDefaultPageNode

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
    • source: [view]
         return this.getDefaultNodes()[inPageIndex];
    • summary
  • dojox.grid._Scroller.positionPageNode

    • type
      Function
    • parameters:
      • inNode: (typeof )
      • inPos: (typeof )
    • source: [view]
    • summary
  • dojox.grid._Scroller.getPageNodePosition

    • type
      Function
    • parameters:
      • inNode: (typeof )
    • source: [view]
         return inNode.offsetTop;
    • summary
  • dojox.grid._Scroller.invalidatePageNode

    • type
      Function
    • parameters:
      • inPageIndex: (typeof )
      • inNodes: (typeof )
    • source: [view]
         var p = inNodes[inPageIndex];
         if(p){
          delete inNodes[inPageIndex];
          this.removePage(inPageIndex, p);
          cleanNode(p);
          p.innerHTML = '';
         }
         return p;
    • summary
  • dojox.grid._Scroller.getPageRow

    • type
      Function
    • parameters:
      • inPage: (typeof )
    • source: [view]
         return inPage * this.rowsPerPage;
    • summary
  • dojox.grid._Scroller.getLastPageRow

    • type
      Function
    • parameters:
      • inPage: (typeof )
    • source: [view]
         return Math.min(this.rowCount, this.getPageRow(inPage + 1)) - 1;
    • summary
  • dojox.grid._Scroller.getFirstVisibleRow

    • type
      Function
    • parameters:
      • inPage: (typeof )
      • inPageTop: (typeof )
      • inScrollTop: (typeof )
    • source: [view]
         if(!this.pageExists(inPage)){
          return 0;
         }
         var row = this.getPageRow(inPage);
         var nodes = this.getDefaultNodes();
         var rows = divkids(nodes[inPage]);
         for(var i=0,l=rows.length; i    inPageTop += rows[i].offsetHeight;
         }
         return (row ? row - 1 : row);
    • summary
  • dojox.grid._Scroller.getLastVisibleRow

    • type
      Function
    • parameters:
      • inPage: (typeof )
      • inBottom: (typeof )
      • inScrollBottom: (typeof )
    • source: [view]
         if(!this.pageExists(inPage)){
          return 0;
         }
         var nodes = this.getDefaultNodes();
         var row = this.getLastPageRow(inPage);
         var rows = divkids(nodes[inPage]);
         for(var i=rows.length-1; i>=0 && inBottom>inScrollBottom; i--, row--){
          inBottom -= rows[i].offsetHeight;
         }
         return row + 1;
    • summary
  • dojox.grid._Scroller.findTopRow

    • type
      Function
    • parameters:
      • inScrollTop: (typeof )
    • source: [view]
         var nodes = this.getDefaultNodes();
         var rows = divkids(nodes[this.page]);
         for(var i=0,l=rows.length,t=this.pageTop,h; i    h = rows[i].offsetHeight;
          t += h;
          if(t >= inScrollTop){
           this.offset = h - (t - inScrollTop);
           return i + this.page * this.rowsPerPage;
          }
         }
         return -1;
    • summary
  • dojox.grid._Scroller.findScrollTop

    • type
      Function
    • parameters:
      • inRow: (typeof )
    • source: [view]
         var rowPage = Math.floor(inRow / this.rowsPerPage);
         var t = 0;
         var i, l;
         for(i=0; i    t += this.getPageHeight(i);
         }
         this.pageTop = t;
         this.page = rowPage;//fix #10543
         this.needPage(rowPage, this.pageTop);


         var nodes = this.getDefaultNodes();
         var rows = divkids(nodes[rowPage]);
         var r = inRow - this.rowsPerPage * rowPage;
         for(i=0,l=rows.length; i    t += rows[i].offsetHeight;
         }
         return t;
    • summary
  • dojox.grid._Scroller.dummy

    • summary
  • dojox.grid._Scroller.rowsPerPage

    • summary
  • dojox.grid._Scroller.scrollboxNode.scrollTop

    • summary
  • dojox.grid._Scroller.scrollboxNode.onscroll

    • summary
  • dojox.grid._Scroller.contentNodes

    • summary
  • dojox.grid._Scroller.colCount

    • summary
  • dojox.grid._Scroller.pageNodes

    • summary
  • dojox.grid._Scroller._invalidating

    • summary
  • dojox.grid._Scroller.pageHeights

    • summary
  • dojox.grid._Scroller.height

    • summary
  • dojox.grid._Scroller.startPacifyTicks

    • summary
  • dojox.grid._Scroller.grid.scrollTop

    • summary
  • dojox.grid._Scroller.offset

    • summary
  • dojox.grid._Scroller.stack

    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary