Improvements to CSS/JS loading
authorMichael M Slusarz <slusarz@curecanti.org>
Sat, 1 Aug 2009 23:03:24 +0000 (17:03 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 3 Aug 2009 05:39:19 +0000 (23:39 -0600)
imp/index-dimp.php
imp/js/src/imp.js
imp/templates/common-header.inc

index 86e582d..defadbc 100644 (file)
@@ -36,11 +36,11 @@ if (is_readable(IMP_BASE . '/config/menu.php')) {
 /* Add the site specific javascript now. */
 if (!empty($site_menu)) {
     foreach ($site_menu as $key => $menu_item) {
-        if ($menu_item == 'separator') {
-            continue;
+        if ($menu_item != 'separator') {
+            foreach (array('menu', 'tab') as $val) {
+                $js_code[] = 'DimpCore.clickObserveHandler({ d: $(\'' . $val . $key . '\'), f: function() { ' . $menu_item['action'] . ' } })';
+            }
         }
-        $js_code[] = 'DimpCore.clickObserveHandler({ d: $(\'menu' . $key . '\'), f: function() { ' . $menu_item['action'] . ' } })';
-        $js_code[] = 'DimpCore.clickObserveHandler({ d: $(\'tab' . $key . '\'), f: function() { ' . $menu_item['action'] . ' } })';
     }
 }
 
index c2dd05e..81318be 100644 (file)
@@ -5,47 +5,52 @@
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */
 
-var IMP = window.IMP || {};
-
-IMP.menuFolderSubmit = function(clear)
-{
-    var mf = $('menuform');
-
-    if ((!this.menufolder_load || clear) &&
-        $F(mf.down('SELECT[name="mailbox"]'))) {
-        this.menufolder_load = true;
-        mf.submit();
+document.observe('dom:loaded', function() {
+    if (!window.IMP) {
+        window.IMP = {};
     }
-};
 
-/**
- * Use DOM manipulation to un-block images.
- */
-IMP.unblockImages = function(e)
-{
-    var elt = e.element().up('TABLE.mimeStatusMessage');
-
-    elt.next('.htmlMessage').select('[blocked]').each(function(e) {
-        var src = decodeURIComponent(e.readAttribute('blocked'));
-        if (e.hasAttribute('src')) {
-            e.writeAttribute('src', src);
-        } else if (e.hasAttribute('background')) {
-            e.writeAttribute('background', src);
-        } else if (e.style.backgroundImage) {
-            e.setStyle({ backgroundImage: 'url(' + src + ')' });
-        }
-    });
-
-    Effect.Fade(elt, { duration: 0.6, afterFinish: function() { elt.remove(); } });
+    window.IMP.menuFolderSubmit = function(clear)
+    {
+        var mf = $('menuform');
 
-    e.stop();
-};
+        if ((!this.menufolder_load || clear) &&
+            $F(mf.down('SELECT[name="mailbox"]'))) {
+            this.menufolder_load = true;
+            mf.submit();
+        }
+    };
+
+    /**
+     * Use DOM manipulation to un-block images.
+     */
+    window.IMP.unblockImages = function(e)
+    {
+        var elt = e.element().up('TABLE.mimeStatusMessage');
+
+        elt.next('.htmlMessage').select('[blocked]').each(function(e) {
+            var src = decodeURIComponent(e.readAttribute('blocked'));
+            if (e.hasAttribute('src')) {
+                e.writeAttribute('src', src);
+            } else if (e.hasAttribute('background')) {
+                e.writeAttribute('background', src);
+            } else if (e.style.backgroundImage) {
+                e.setStyle({ backgroundImage: 'url(' + src + ')' });
+            }
+        });
+
+        Effect.Fade(elt, {
+            afterFinish: function() { elt.remove(); },
+            duration: 0.6
+        });
+
+        e.stop();
+    };
 
-document.observe('dom:loaded', function() {
     // If menu is present, attach event handlers to folder switcher.
     var tmp = $('openfoldericon');
     if (tmp) {
-        $('menuform').observe('change', IMP.menuFolderSubmit.bind(IMP));
-        tmp.down().observe('click', IMP.menuFolderSubmit.bind(IMP, true));
+        $('menuform').observe('change', window.IMP.menuFolderSubmit.bind(window.IMP));
+        tmp.down().observe('click', window.IMP.menuFolderSubmit.bind(window.IMP, true));
     }
 });
index 91d1911..0145e1f 100644 (file)
@@ -15,8 +15,6 @@ if (!empty($refresh_time) && !empty($refresh_url)) {
 $imp_view = Horde_Util::nonInputVar('imp_view');
 switch ($imp_view) {
 case 'dimp':
-    include IMP_TEMPLATES . '/javascript_defs_dimp.php';
-
     $css = array();
     if (!empty($GLOBALS['conf']['dimp']['css_files'])) {
         foreach ($GLOBALS['conf']['css_files'] as $css_file) {
@@ -26,14 +24,14 @@ case 'dimp':
             );
         }
     }
-
     Horde::includeStylesheetFiles(array('additional' => $css, 'sub' => 'dimp'));
+    include IMP_TEMPLATES . '/javascript_defs_dimp.php';
     break;
 
 default:
-    include IMP_TEMPLATES . '/javascript_defs.php';
-    Horde::includeScriptFiles();
     Horde::includeStylesheetFiles();
+    Horde::includeScriptFiles();
+    include IMP_TEMPLATES . '/javascript_defs.php';
     break;
 }
 ?>