From 96ff2f1fc05f08ae1efc44e27a4c5eece05c2634 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 17 Mar 2009 05:49:54 -0600 Subject: [PATCH] Remember splitbar position on login/refresh. --- imp/config/prefs.php.dist | 6 ++++++ imp/docs/CHANGES | 1 + imp/js/src/DimpBase.js | 4 ++++ imp/js/src/ViewPort.js | 27 +++++++++++++++++++++------ imp/lib/DIMP.php | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 32a1e5fb9..3a3929a5e 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -1474,6 +1474,12 @@ $_prefs['dimp_toggle_headers'] = array( 'shared' => false, 'type' => 'implicit'); +$_prefs['dimp_splitbar'] = array( + 'value' => 0, + 'locked' => false, + 'shared' => false, + 'type' => 'implicit'); + // End DIMP Options // Other entries (used internally in IMP) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 8d5ebd62e..e98185143 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Remember splitbar position on login/refresh (DIMP). [mms] Disable some advanced functions if using POP3 driver (caching, searching, sorting) because it is too resource intensive. [mms] Use native PHP code for POP3 driver (c-client no longer required). diff --git a/imp/js/src/DimpBase.js b/imp/js/src/DimpBase.js index 7e4507712..81f04b491 100644 --- a/imp/js/src/DimpBase.js +++ b/imp/js/src/DimpBase.js @@ -408,6 +408,7 @@ var DimpBase = { selected_class: 'selectedRow', ajaxRequest: DimpCore.doAction.bind(DimpCore), norows: true, + page_size: DIMP.conf.splitbar_pos, onScrollIdle: settitle, onSlide: settitle, onContent: function(rows) { @@ -561,6 +562,9 @@ var DimpBase = { onUpdateClass: function(row) { this.updateStatusFlags(row); }.bind(this), + onSplitBarChange: function() { + this._updatePrefs('dimp_splitbar', this.viewport.getPageSize()); + }.bind(this), selectCallback: this._select.bind(this), deselectCallback: this._deselect.bind(this) }); diff --git a/imp/js/src/ViewPort.js b/imp/js/src/ViewPort.js index 8205e7471..27a030c91 100644 --- a/imp/js/src/ViewPort.js +++ b/imp/js/src/ViewPort.js @@ -18,7 +18,7 @@ var ViewPort = Class.create({ // Required: content_container, lines, fetch_action, template, // cachecheck_action, ajaxRequest, buffer_pages, // limit_factor, content_class, row_class, selected_class - // Optional: show_split_pane + // Optional: show_split_pane, page_size initialize: function(opts) { opts.content = $(opts.content_container); @@ -34,9 +34,10 @@ var ViewPort = Class.create({ this.fetch_hash = $H(); this.views = $H(); + this.splitbar_loc = opts.page_size; this.showSplitPane(opts.show_split_pane); - this.isbusy = this.line_height = this.page_size = this.splitbar = this.splitbar_loc = this.uc_run = this.view = this.viewport_init = null; + this.isbusy = this.line_height = this.page_size = this.splitbar = this.uc_run = this.view = this.viewport_init = null; this.request_num = 1; }, @@ -866,7 +867,8 @@ var ViewPort = Class.create({ return Math.max(parseInt(this.getPageSize('max') * 0.45), 5); case 'max': - return parseInt(this._getMaxHeight() / this._getLineHeight()); + case 'splitmax': + return parseInt((this._getMaxHeight() - (type == 'max' ? 0 : 100)) / this._getLineHeight()); default: return this.page_size; @@ -906,7 +908,12 @@ var ViewPort = Class.create({ if (this.show_split_pane) { if (!pane.visible()) { this._initSplitBar(); - this.page_size = (this.splitbar_loc) ? this.splitbar_loc : this.getPageSize('default'); + if (this.splitbar_loc && + this.splitbar_loc > 0) { + this.splitbar_loc = this.page_size = Math.min(this.splitbar_loc, this.getPageSize('splitmax')); + } else { + this.page_size = this.getPageSize('default'); + } } setpane = true; } else if (pane.visible()) { @@ -949,8 +956,7 @@ var ViewPort = Class.create({ onStart: function() { // Cache these values since we will be using them multiple // times in snap(). - var lh = this._getLineHeight(); - this.sp = { lh: lh, pos: $(this.opts.content).positionedOffset()[1], max: parseInt((this._getMaxHeight() - 100) / lh), lines: this.page_size }; + this.sp = { lh: this._getLineHeight(), pos: $(this.opts.content).positionedOffset()[1], max: this.getPageSize('splitmax'), lines: this.page_size, orig: this.page_size }; }.bind(this), snap: function(x, y, elt) { var l = parseInt((y - this.sp.pos) / this.sp.lh); @@ -965,11 +971,20 @@ var ViewPort = Class.create({ onEnd: function() { this.page_size = this.sp.lines; this._renderViewport(); + if (this.opts.onSplitBarChange && + this.sp.orig != this.sp.lines) { + this.opts.onSplitBarChange(); + } }.bind(this) }); this.splitbar.observe('dblclick', function() { + var old_size = this.page_size; this.page_size = this.getPageSize('default'); this._renderViewport(); + if (this.opts.onSplitBarChange && + old_size != this.page_size) { + this.opts.onSplitBarChange(); + } }.bind(this)); }, diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index dab0afc6c..1836bcb2d 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -184,6 +184,7 @@ class DIMP 'viewport_wait' => intval($conf['dimp']['viewport']['viewport_wait']), 'login_view' => $prefs->getValue('dimp_login_view'), 'background_inbox' => !empty($conf['dimp']['viewport']['background_inbox']), + 'splitbar_pos' => $prefs->getValue('dimp_splitbar'), 'atc_list' => IMP_UI_Mailbox::getAttachmentAltList(), -- 2.11.0