Make label and parent optional values to save on transport/parsing.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 17 Apr 2009 01:28:18 +0000 (19:28 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 17 Apr 2009 06:05:54 +0000 (00:05 -0600)
imp/js/src/DimpBase.js
imp/lib/DIMP.php

index 583ed56..1494a14 100644 (file)
@@ -1870,12 +1870,13 @@ var DimpBase = {
     {
         var div, f_node, li, ll, parent_e,
             fid = this.getFolderId(ob.m),
+            label = ob.l || ob.m,
             mbox = decodeURIComponent(ob.m),
             submboxid = this.getSubFolderId(fid),
             submbox = $(submboxid),
             ftype = ob.v ? (ob.co ? 'vcontainer' : 'virtual') : (ob.co ? 'container' : (ob.s ? 'special' : 'folder'));
 
-        li = new Element('LI', { className: 'folder', id: fid, l: ob.l, mbox: mbox, ftype: ftype });
+        li = new Element('LI', { className: 'folder', id: fid, l: label, mbox: mbox, ftype: ftype });
 
         div = new Element('DIV', { className: ob.cl || 'base', id: fid + '_div' });
         if (ob.i) {
@@ -1885,7 +1886,7 @@ var DimpBase = {
             div.writeAttribute({ className: 'exp' });
         }
 
-        li.insert(div).insert(new Element('A', { id: fid + '_label', title: ob.l }).insert(ob.l));
+        li.insert(div).insert(new Element('A', { id: fid + '_label', title: label }).insert(label));
 
         // Now walk through the parent <ul> to find the right place to
         // insert the new folder.
@@ -1899,7 +1900,7 @@ var DimpBase = {
             if (ob.s) {
                 parent_e = $('specialfolders');
             } else {
-                parent_e = $(this.getSubFolderId(this.getFolderId(ob.pa)));
+                parent_e = $(this.getSubFolderId(this.getFolderId(ob.pa || DIMP.conf.base_mbox)));
                 parent_e = parent_e ? parent_e.down() : $('normalfolders');
             }
 
index 6b84942..da0dd9b 100644 (file)
@@ -199,6 +199,7 @@ class DIMP
             'ham_spammbox' => intval(!empty($conf['notspam']['spamfolder'])),
             'refresh_time' => intval($prefs->getValue('refresh_time')),
 
+            'base_mbox' => IMP_Imap_Tree::BASE_ELT,
             'fixed_folders' => empty($conf['server']['fixed_folders'])
                 ? array()
                 : array_map(array('DIMP', '_appendedFolderPref'), $conf['server']['fixed_folders']),
@@ -386,9 +387,10 @@ class DIMP
      * 'co' (container) = Is this folder a container element? [boolean]
      *                    [DEFAULT: no]
      * 'i' (icon) = A user defined icon to use. [string] [DEFAULT: none]
-     * 'l' (label) = The folder display label. [string]
+     * 'l' (label) = The folder display label. [string] [DEFAULT: 'm' val]
      * 'm' (mbox) = The mailbox value. [string]
-     * 'pa' (parent) = The parent element. [string]
+     * 'pa' (parent) = The parent element. [string] [DEFAULT:
+     *                                               DIMP.conf.base_mbox]
      * 'po' (polled) = Is the element polled? [boolean] [DEFAULT: no]
      * 's' (special) = Is this a "special" element? [boolean] [DEFAULT: no]
      * 'u' (unseen) = The number of unseen messages. [integer]
@@ -401,9 +403,13 @@ class DIMP
         if ($elt['children']) {
            $ob->ch = 1;
         }
-        $ob->l = $elt['base_elt']['l'];
         $ob->m = rawurlencode($elt['value']);
-        $ob->pa = rawurlencode($elt['parent']);
+        if ($ob->m != $elt['base_elt']['l']) {
+            $ob->l = $elt['base_elt']['l'];
+        }
+        if ($elt['parent'] != IMP_Imap_Tree::BASE_ELT) {
+            $ob->pa = rawurlencode($elt['parent']);
+        }
         if ($elt['polled']) {
             $ob->po = 1;
         }