Move all folder icon display to CSS.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Aug 2009 21:43:10 +0000 (15:43 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Aug 2009 21:43:10 +0000 (15:43 -0600)
imp/folders.php
imp/js/DimpBase.js
imp/lib/Dimp.php
imp/lib/Imap/Tree.php
imp/templates/folders/folders.html
imp/templates/index/index-dimp.inc
imp/themes/screen-dimp.css
imp/themes/screen.css
imp/themes/silver/screen-dimp.css
imp/themes/silver/screen.css

index 78981d8..9dbb159 100644 (file)
@@ -13,6 +13,7 @@
  * @package IMP
  */
 
+<<<<<<< Updated upstream
 /**
  * Utility function to return a url for the various images.
  */
@@ -31,7 +32,6 @@ function _image($name, $alt)
 }
 
 require_once dirname(__FILE__) . '/lib/base.php';
-Horde::addScriptFile('folders.js', 'imp', true);
 
 /* Redirect back to the mailbox if folder use is not allowed. */
 if (!$conf['user']['allow_folders']) {
@@ -341,6 +341,8 @@ $folders_token = Horde::getRequestToken('imp.folders');
 
 $folders_url = Horde_Util::addParameter($folders_url, 'folders_token', $folders_token);
 
+Horde::addScriptFile('folders.js', 'imp', true);
+
 if ($_SESSION['imp']['file_upload'] && ($actionID == 'import_mbox')) {
     $title = _("Folder Navigator");
     IMP::prepareMenu();
@@ -440,14 +442,14 @@ foreach ($raw_rows as $val) {
         $val['editvfolder'] = Horde::link($imp_search->editURL($val['value']), _("Edit Virtual Folder")) . _("Edit") . '</a>';
     }
 
-    $val['class'] = (++$rowct % 2) ? 'item0' : 'item1';
+    $val['cname'] = (++$rowct % 2) ? 'item0' : 'item1';
 
     /* Highlight line differently if folder/mailbox is unsubscribed. */
     if ($showAll &&
         $subscribe &&
         !$val['container'] &&
         !$imaptree->isSubscribed($val['base_elt'])) {
-        $val['class'] .= ' folderunsub';
+        $val['cname'] .= ' folderunsub';
     }
 
     if (!$val['container']) {
@@ -457,7 +459,9 @@ foreach ($raw_rows as $val) {
         $val['name'] = Horde::link(Horde_Util::addParameter($name_url, 'mailbox', $val['value']), sprintf(_("View messages in %s"), ($val['vfolder']) ? $val['base_elt']['l'] : $val['display'])) . $val['name'] . '</a>';
     }
 
-    $dir2 = _image($val, null, 'folder');
+    $dir2 = $val['user_icon']
+        ? Horde::img($val['icon'], $val['alt'], null, $val['icondir'])
+        : '<span class="foldersImg ' . $val['class'] . '"></span>';
 
     if ($val['children']) {
         $dir = Horde_Util::addParameter($folders_url, 'folder', $val['value']);
index 059f05e..84d571e 100644 (file)
@@ -2022,7 +2022,7 @@ var DimpBase = {
             cname += ' unsubFolder';
         }
 
-        div = new Element('DIV', { className: 'iconDiv' });
+        div = new Element('SPAN', { className: 'iconSpan' });
         if (ob.i) {
             div.setStyle({ backgroundImage: 'url("' + ob.i + '")' });
         }
@@ -2038,7 +2038,7 @@ var DimpBase = {
                 div.addClassName('col');
             }
         } else {
-            div.addClassName(ob.ch ? 'exp' : (ob.cl || 'base'));
+            div.addClassName(ob.ch ? 'exp' : (ob.cl || 'folderImg'));
 
             if (ob.s) {
                 parent_e = $('specialfolders');
@@ -2046,7 +2046,7 @@ var DimpBase = {
                 /* Create a dummy container element in 'normalfolders'
                  * section. */
                 if (ob.ch) {
-                    div.removeClassName('exp').addClassName(ob.cl || 'base');
+                    div.removeClassName('exp').addClassName(ob.cl || 'folderImg');
 
                     tmp = Object.clone(ob);
                     tmp.co = true;
index ffef8ae..f70c074 100644 (file)
@@ -192,6 +192,7 @@ class IMP_Dimp
         if ($elt['children']) {
             $ob->ch = 1;
         }
+        $ob->cl = $elt['class'];
         $ob->m = $elt['value'];
         if ($ob->m != $elt['name']) {
             $ob->l = $elt['name'];
@@ -215,50 +216,17 @@ class IMP_Dimp
         }
 
         if ($elt['container']) {
-            $ob->co = 1;
             $ob->cl = 'exp';
+            $ob->co = 1;
         } else {
             if ($elt['polled']) {
                 $ob->u = intval($elt['unseen']);
             }
 
-            switch ($elt['special']) {
-            case IMP_Imap_Tree::SPECIAL_INBOX:
-                $ob->cl = 'inbox';
-                $ob->s = 1;
-                break;
-
-            case IMP_Imap_Tree::SPECIAL_TRASH:
-                $ob->cl = 'trash';
-                $ob->s = 1;
-                break;
-
-            case IMP_Imap_Tree::SPECIAL_SPAM:
-                $ob->cl = 'spam';
+            if ($elt['special']) {
                 $ob->s = 1;
-                break;
-
-            case IMP_Imap_Tree::SPECIAL_DRAFT:
-                $ob->cl = 'drafts';
-                $ob->s = 1;
-                break;
-
-            case IMP_Imap_Tree::SPECIAL_SENT:
-                $ob->cl = 'sent';
-                $ob->s = 1;
-                break;
-
-            default:
-                if ($elt['vfolder']) {
-                    if ($GLOBALS['imp_search']->isVTrashFolder($elt['value'])) {
-                        $ob->cl = 'trash';
-                    } elseif ($GLOBALS['imp_search']->isVINBOXFolder($elt['value'])) {
-                        $ob->cl = 'inbox';
-                    }
-                } elseif ($elt['children']) {
-                    $ob->cl = 'exp';
-                }
-                break;
+            } elseif (!$elt['vfolder'] && $elt['children']) {
+                $ob->cl = 'exp';
             }
         }
 
index 8684963..efdb961 100644 (file)
@@ -44,13 +44,6 @@ class IMP_Imap_Tree
      * mailboxes. */
     const BASE_ELT = '\0';
 
-    /* Defines used with the output from the build() function. */
-    const SPECIAL_INBOX = 1;
-    const SPECIAL_TRASH = 2;
-    const SPECIAL_DRAFT = 3;
-    const SPECIAL_SPAM = 4;
-    const SPECIAL_SENT = 5;
-
     /* Defines used with folderList(). */
     const FLIST_CONTAINER = 1;
     const FLIST_UNSUB = 2;
@@ -1806,11 +1799,13 @@ class IMP_Imap_Tree
      * <pre>
      * 'alt' - (string) The alt text for the icon.
      * 'base_elt' - (array) The return from get().
-     * 'children' - (children) Does the element have children?
+     * 'children' - (boolean) Does the element have children?
+     * 'class' - (string) The CSS class name.
      * 'container' - (boolean) Is this a container element?
      * 'editvfolder' - (boolean) Can this virtual folder be edited?
      * 'icon' - (string) The name of the icon graphic to use.
      * 'icondir' - (string) The path of the icon directory.
+     * 'iconopen' - ???
      * 'level' - (integer) The deepness level of this element.
      * 'mbox_val' - (string) A html-ized version of 'value'.
      * 'msgs' - (integer) The number of total messages in the element (if
@@ -1821,7 +1816,7 @@ class IMP_Imap_Tree
      * 'recent' - (integer) The number of new messages in the element (if
      *            polled).
      * 'sub' - (boolean) Is folder subscribed to?
-     * 'special' - (integer) A mask indicating if this is a "special" element.
+     * 'special' - (boolean) Is this is a "special" element?
      * 'specialvfolder' - (boolean) Is this a "special" virtual folder?
      * 'unseen' - (integer) The number of unseen messages in the element (if
      *            polled).
@@ -1855,7 +1850,7 @@ class IMP_Imap_Tree
             'parent' => $mailbox['p'],
             'polled' => false,
             'recent' => 0,
-            'special' => 0,
+            'special' => false,
             'specialvfolder' => false,
             'sub' => $this->isSubscribed($mailbox),
             'user_icon' => false,
@@ -1886,7 +1881,8 @@ class IMP_Imap_Tree
             case 'INBOX':
                 $row['icon'] = 'folders/inbox.png';
                 $row['alt'] = _("Inbox");
-                $row['special'] = self::SPECIAL_INBOX;
+                $row['class'] = 'inboxImg';
+                $row['special'] = true;
                 break;
 
             case $this->_eltCache['trash']:
@@ -1896,29 +1892,39 @@ class IMP_Imap_Tree
                 } else {
                     $row['icon'] = 'folders/trash.png';
                     $row['alt'] = _("Trash folder");
-                    $row['special'] = self::SPECIAL_TRASH;
+                    $row['class'] = 'trashImg';
+                    $row['special'] = true;
                 }
                 break;
 
             case $this->_eltCache['draft']:
                 $row['icon'] = 'folders/drafts.png';
                 $row['alt'] = _("Draft folder");
-                $row['special'] = self::SPECIAL_DRAFT;
+                $row['class'] = 'draftsImg';
+                $row['special'] = true;
                 break;
 
             case $this->_eltCache['spam']:
                 $row['icon'] = 'folders/spam.png';
                 $row['alt'] = _("Spam folder");
-                $row['special'] = self::SPECIAL_SPAM;
+                $row['class'] = 'spamImg';
+                $row['special'] = true;
                 break;
 
             default:
                 if (in_array($mailbox['v'], $this->_eltCache['sent'])) {
                     $row['icon'] = 'folders/sent.png';
                     $row['alt'] = _("Sent mail folder");
-                    $row['special'] = self::SPECIAL_SENT;
+                    $row['class'] = 'sentImg';
+                    $row['special'] = true;
                 } else {
-                    $row['icon'] = ($this->isOpen($mailbox)) ? 'folders/open.png' : 'folders/folder.png';
+                    if ($this->isOpen($mailbox)) {
+                        $row['icon'] = 'folders/open.png';
+                        $row['class'] = 'folderopenImg';
+                    } else {
+                        $row['icon'] = 'folders/folder.png';
+                        $row['class'] = 'folderImg';
+                    }
                     $row['alt'] = _("Mailbox");
                 }
                 break;
@@ -1932,10 +1938,12 @@ class IMP_Imap_Tree
                     $row['specialvfolder'] = true;
                     $row['icon'] = 'folders/trash.png';
                     $row['alt'] = _("Virtual Trash Folder");
+                    $row['class'] = 'trashImg';
                 } elseif ($GLOBALS['imp_search']->isVINBOXFolder($mailbox['v'])) {
                     $row['specialvfolder'] = true;
                     $row['icon'] = 'folders/inbox.png';
                     $row['alt'] = _("Virtual INBOX Folder");
+                    $row['class'] = 'inboxImg';
                 }
             }
         } else {
@@ -1944,10 +1952,12 @@ class IMP_Imap_Tree
             if ($this->_forceopen && $this->isOpen($mailbox)) {
                 $row['icon'] = 'folders/open.png';
                 $row['alt'] = _("Opened Folder");
+                $row['class'] = 'folderopenImg';
             } else {
                 $row['icon'] = 'folders/folder.png';
                 $row['iconopen'] = 'folders/open.png';
                 $row['alt'] = ($this->_forceopen) ? _("Closed Folder") : _("Folder");
+                $row['class'] = 'folderImg';
             }
             if ($this->isVFolder($mailbox)) {
                 $row['vfolder'] = true;
index c27a372..3c9d5f9 100644 (file)
@@ -1,5 +1,5 @@
 <loop:rows>
-<div class="<tag:rows.class />">
+<div class="<tag:rows.cname />">
  &nbsp;<input type="checkbox" class="checkbox" name="folder_list[]" <if:rows.nocheckbox>disabled="disabled" </if:rows.nocheckbox>value="<tag:rows.mbox_val />" /> <tag:rows.line /> <tag:rows.name /><if:rows.polled> (<tag:rows.unseen />/<tag:rows.msgs />)</if:rows.polled> <if:rows.editvfolder>&nbsp;&nbsp;[<tag:rows.delvfolder />] [<tag:rows.editvfolder />]</if:rows.editvfolder>
 </div>
 </loop:rows>
index d050534..d12bc57 100644 (file)
@@ -118,11 +118,11 @@ function _simpleButton($id, $text, $image, $imagedir = null)
     <div id="myfolders"><?php echo _("My Folders") ?></div>
     <ul class="folderlist" id="normalfolders">
      <li class="folder" id="folderopts">
-      <div class="iconDiv base"></div>
+      <span class="iconSpan folderImg"></span>
       <a title="<?php echo _("Folder Options") ?>"><?php echo _("Folder Options") ?></a>
      </li>
      <li class="folder" id="dropbase" style="display:none">
-      <div class="iconDiv base"></div>
+      <span class="iconSpan folderImg"></span>
       <a title="<?php echo _("Move to Base Level") ?>"><?php echo _("Move to Base Level") ?></a>
      </li>
     </ul>
index 87e38b8..3cba370 100644 (file)
@@ -311,7 +311,7 @@ div.vpRow.flagDeleted {
 #sidebarPanel li.on {
     background: #ffa;
 }
-#sidebarPanel li div {
+#sidebarPanel li span {
     cursor: pointer;
 }
 #sidebarPanel .folderlist li a {
@@ -331,37 +331,22 @@ div.vpRow.flagDeleted {
     border: 1px solid orange;
     padding: 1px 1px 1px 19px;
 }
-#sidebarPanel div.iconDiv {
+#sidebarPanel span.iconSpan {
     display: inline;
     float: left;
     width: 20px;
     height: 100%;
     background-repeat: no-repeat;
 }
-#sidebarPanel div.base, #ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg, #ctx_folderopts_sub span.contextImg, #ctx_folderopts_unsub span.contextImg {
+#ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg, #ctx_folderopts_sub span.contextImg, #ctx_folderopts_unsub span.contextImg {
     background-image: url("graphics/folders/folder.png");
 }
-#sidebarPanel div.col, #ctx_folderopts_collapse span.contextImg {
+#sidebarPanel span.col, #ctx_folderopts_collapse span.contextImg {
     background-image: url("graphics/folders/minus.png");
 }
-#sidebarPanel div.exp, #ctx_folderopts_expand span.contextImg {
+#sidebarPanel span.exp, #ctx_folderopts_expand span.contextImg {
     background-image: url("graphics/folders/plus.png");
 }
-#sidebarPanel div.drafts {
-    background-image: url("graphics/folders/drafts.png");
-}
-#sidebarPanel div.inbox {
-    background-image: url("graphics/folders/inbox.png");
-}
-#sidebarPanel div.sent {
-    background-image: url("graphics/folders/sent.png");
-}
-#sidebarPanel div.spam {
-    background-image: url("graphics/folders/spam.png");
-}
-#sidebarPanel div.trash {
-    background-image: url("graphics/folders/trash.png");
-}
 #normalfolders {
     overflow-x: hidden;
 }
index 9bec46f..9384246 100644 (file)
@@ -180,6 +180,27 @@ form#search div {
 #fmanager div.folderChoose {
     padding-left: 5px;
 }
+span.folderImg {
+    background-image: url("graphics/folders/folder.png");
+}
+span.folderopenImg {
+    background-image: url("graphics/folders/open.png");
+}
+span.draftsImg {
+    background-image: url("graphics/folders/drafts.png");
+}
+span.inboxImg {
+    background-image: url("graphics/folders/inbox.png");
+}
+span.sentImg {
+    background-image: url("graphics/folders/sent.png");
+}
+span.spamImg {
+    background-image: url("graphics/folders/spam.png");
+}
+span.trashImg {
+    background-image: url("graphics/folders/trash.png");
+}
 
 /* Style for div that fixes KHTML browsers. */
 .ohide {
@@ -616,7 +637,7 @@ td.addressTr span.loadingImg {
     white-space: nowrap;
 }
 
-.downloadAtc, .downloadZipAtc, .saveImgAtc, .stripAtc {
+.downloadAtc, .downloadZipAtc, .saveImgAtc, .stripAtc, .foldersImg {
     display: -moz-inline-stack;
     display: inline-block;
     height: 16px;
index 7cd7dfc..1275ccb 100644 (file)
@@ -1,27 +1,12 @@
-#sidebarPanel div.base, #ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg, #ctx_folderopts_sub span.contextImg, #ctx_folderopts_unsub span.contextImg {
+#ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg, #ctx_folderopts_sub span.contextImg, #ctx_folderopts_unsub span.contextImg {
     background-image: url("graphics/folders/folder.png");
 }
-#sidebarPanel div.col, #ctx_folderopts_collapse span.contextImg {
+#sidebarPanel span.col, #ctx_folderopts_collapse span.contextImg {
     background-image: url("graphics/folders/minus.png");
 }
-#sidebarPanel div.exp, #ctx_folderopts_expand span.contextImg {
+#sidebarPanel span.exp, #ctx_folderopts_expand span.contextImg {
     background-image: url("graphics/folders/plus.png");
 }
-#sidebarPanel div.drafts {
-    background-image: url("graphics/folders/drafts.png");
-}
-#sidebarPanel div.inbox {
-    background-image: url("graphics/folders/inbox.png");
-}
-#sidebarPanel div.sent {
-    background-image: url("graphics/folders/sent.png");
-}
-#sidebarPanel div.spam {
-    background-image: url("graphics/folders/spam.png");
-}
-#sidebarPanel div.trash {
-    background-image: url("graphics/folders/trash.png");
-}
 
 #attach_list div, span.attachmentImg {
     background-image: url("graphics/attachment.png");
index b451c86..5871775 100644 (file)
@@ -57,3 +57,25 @@ div.msgflags.flagDeleted, span.contextImg.flagDeleted {
 div.msgflags.flagForwarded, span.contextImg.flagForwarded {
     background-image: url("graphics/mail_forwarded.png");
 }
+
+span.folderImg {
+    background-image: url("graphics/folders/folder.png");
+}
+span.folderopenImg {
+    background-image: url("graphics/folders/open.png");
+}
+span.draftsImg {
+    background-image: url("graphics/folders/drafts.png");
+}
+span.inboxImg {
+    background-image: url("graphics/folders/inbox.png");
+}
+span.sentImg {
+    background-image: url("graphics/folders/sent.png");
+}
+span.spamImg {
+    background-image: url("graphics/folders/spam.png");
+}
+span.trashImg {
+    background-image: url("graphics/folders/trash.png");
+}