Remember splitbar position on login/refresh.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 17 Mar 2009 11:49:54 +0000 (05:49 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 17 Mar 2009 11:49:54 +0000 (05:49 -0600)
imp/config/prefs.php.dist
imp/docs/CHANGES
imp/js/src/DimpBase.js
imp/js/src/ViewPort.js
imp/lib/DIMP.php

index 32a1e5f..3a3929a 100644 (file)
@@ -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)
index 8d5ebd6..e981851 100644 (file)
@@ -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).
index 7e45077..81f04b4 100644 (file)
@@ -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)
         });
index 8205e74..27a030c 100644 (file)
@@ -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));
     },
 
index dab0afc..1836bcb 100644 (file)
@@ -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(),