From bc5b8ae50b18bebae29fc5c45e9b256914f65516 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 17 Nov 2009 17:16:38 -0700 Subject: [PATCH] More fixes/optimizations for new pane code --- imp/js/DimpBase.js | 7 +++--- imp/js/DimpSlider.js | 26 ++++++++++---------- imp/js/ViewPort.js | 50 +++++++++++++++++--------------------- imp/templates/index/index-dimp.inc | 2 +- imp/themes/screen-dimp.css | 4 +-- 5 files changed, 41 insertions(+), 48 deletions(-) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index b17e42ab6..52e129fdc 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -40,7 +40,7 @@ var DimpBase = { this.toggleButtons(); - if ($('previewPane').visible()) { + if (DIMP.conf.preview_pref) { if (opts.right) { this.clearPreviewPane(); } else { @@ -66,7 +66,7 @@ var DimpBase = { this.toggleButtons(); if (opts.right || !count) { this.clearPreviewPane(); - } else if ((count == 1) && $('previewPane').visible()) { + } else if ((count == 1) && DIMP.conf.preview_pref) { this.loadPreview(sel.get('dataob').first()); } }, @@ -232,7 +232,6 @@ var DimpBase = { if (!Object.isUndefined(this.folder) && !this.search) { this._addHistory(loc); } - } this.loadMailbox(f); @@ -1082,7 +1081,7 @@ var DimpBase = { { var pp_uid; - if (!$('previewPane').visible()) { + if (!DIMP.conf.preview_pref) { return; } diff --git a/imp/js/DimpSlider.js b/imp/js/DimpSlider.js index 6b30e3563..65de92d54 100644 --- a/imp/js/DimpSlider.js +++ b/imp/js/DimpSlider.js @@ -56,7 +56,7 @@ var DimpSlider = Class.create({ this.sbdownsize = this.sbupsize = this.value = 0; this.active = this.dragging = false; - if (this._showScroll()) { + if (this.needScroll()) { this._initScroll(); } @@ -144,16 +144,18 @@ var DimpSlider = Class.create({ } }, - updateHandleLength: function(pagesize, totalsize) + setHandleLength: function(pagesize, totalsize) { this.options.pagesize = pagesize; this.options.totalsize = totalsize; - if (!this._showScroll()) { + }, + + updateHandleLength: function() + { + if (!this.needScroll()) { this.value = 0; this.track.hide(); - return; - } - if (!this._initScroll()) { + } else if (!this._initScroll()) { this.track.show(); this._updateHandleLength(); } @@ -179,12 +181,10 @@ var DimpSlider = Class.create({ setScrollPosition: function(val) { - if (this._showScroll()) { - var oldval = this.getValue(); - this._setScrollPosition('val', val); - if (oldval != this.getValue()) { - this._updateFinished(); - } + var oldval = this.getValue(); + this._setScrollPosition('val', val); + if (oldval != this.getValue()) { + this._updateFinished(); } }, @@ -212,7 +212,7 @@ var DimpSlider = Class.create({ this.handle.setStyle({ top: this.handlevalue + 'px' }); }, - _showScroll: function() + needScroll: function() { return (this.options.pagesize < this.options.totalsize); } diff --git a/imp/js/ViewPort.js b/imp/js/ViewPort.js index a5c0fda25..b9c70131f 100644 --- a/imp/js/ViewPort.js +++ b/imp/js/ViewPort.js @@ -467,7 +467,7 @@ var ViewPort = Class.create({ break; } - this.scroller.onResize(); + this.requestContentRefresh(this.currentOffset()); }, // offset = (integer) TODO @@ -807,7 +807,7 @@ var ViewPort = Class.create({ this.opts.onClear(this.visibleRows()); } - this.scroller.updateSize(); + this.scroller.setSize(page_size, this.getMetaData('total_rows')); this.scrollTo(offset + 1, { noupdate: true, top: true }); offset = this.currentOffset(); @@ -824,6 +824,8 @@ var ViewPort = Class.create({ this.opts.onContentComplete(c_nodes); } + this.scroller.updateDisplay(); + return true; }, @@ -1148,7 +1150,7 @@ var ViewPort = Class.create({ */ ViewPort_Scroller = Class.create({ // Variables initialized to undefined: - // lastpane, noupdate, scrollDiv, scrollbar, scrollsize, vp + // noupdate, scrollDiv, scrollbar, vertscroll, vp initialize: function(vp) { @@ -1184,56 +1186,48 @@ ViewPort_Scroller = Class.create({ }.bindAsEventListener(this)); }, - onResize: function() + setSize: function(viewsize, totalsize) { - // Update the scrollbar size - this.updateSize(); - - // Update displayed content. - this.vp.requestContentRefresh(this.currentOffset()); + this._createScrollBar(); + this.scrollbar.setHandleLength(viewsize, totalsize); }, - updateSize: function() + updateDisplay: function() { - this._createScrollBar(); - this.scrollbar.updateHandleLength(this.vp.getPageSize(), this.vp.getMetaData('total_rows')); - var c = this.vp.opts.content, - w = this.scrollDiv.getWidth(); + vs = false; - if (this.scrollDiv.visible()) { + if (this.scrollbar.needScroll()) { switch (this.vp.pane_mode) { case 'horiz': - this.scrollDiv.setStyle({ float: 'left', marginLeft: '-' + w + 'px', position: null }); + this.scrollDiv.setStyle({ float: 'left', marginLeft: '-' + this.scrollDiv.getWidth() + 'px', position: null }); break; case 'vert': - if (this.lastpane != this.vp.pane_mode) { - c.setStyle({ width: (c.clientWidth - w) + 'px' }); - } this.scrollDiv.setStyle({ float: 'left', marginLeft: 0, position: null }); + if (!this.vertscroll) { + c.setStyle({ width: (c.clientWidth - this.scrollDiv.getWidth()) + 'px' }); + } + vs = true; break; default: - this.scrollDiv.setStyle({ marginLeft: '-' + w + 'px', position: 'absolute', right: 0, top: 0 }); + this.scrollDiv.setStyle({ float: 'none', marginLeft: '-' + this.scrollDiv.getWidth() + 'px', position: 'absolute', right: 0, top: 0 }); break; } this.scrollDiv.setStyle({ height: c.clientHeight + 'px' }); - this.scrollsize = c.clientHeight; - } else if (this.vp.pane_mode == 'vert' && - this.lastpane == this.vp.pane_mode) { - c.setStyle({ width: (c.clientWidth + w) + 'px' }); + } else if ((this.vp.pane_mode =='vert') && this.vertscroll) { + c.setStyle({ width: (c.clientWidth + this.scrollDiv.getWidth()) + 'px' }); } - this.lastpane = this.vp.pane_mode; + this.vertscroll = vs; + this.scrollbar.updateHandleLength(); }, clear: function() { - if (this.scrollDiv) { - this.scrollbar.updateHandleLength(0, 0); - } + this.setSize(0, 0); }, // offset = (integer) Offset to move the scrollbar to diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index fb67f6144..bbd943ce9 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -196,7 +196,7 @@ function _simpleButton($id, $text, $image)