Tooltips tweaks.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 3 Sep 2010 21:56:23 +0000 (15:56 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 6 Sep 2010 20:31:14 +0000 (14:31 -0600)
Automatically add JS file when calling linkTooltip().
Move tooltips JS file to horde/Core.

agora/lib/Messages.php
framework/Core/js/tooltips.js [new file with mode: 0644]
framework/Core/lib/Horde.php
framework/Core/package.xml
horde/js/tooltips.js [deleted file]
imp/mailbox.php
ingo/filters.php
kronolith/lib/Block/month.php
kronolith/year.php
mnemo/list.php
mnemo/notes/index.php

index a62620e..2214fce 100644 (file)
@@ -1652,9 +1652,6 @@ class Agora_Messages {
             return $files;
         }
 
-        /* Make sure we have the tooltips javascript. */
-        Horde::addScriptFile('tooltips.js', 'horde', true);
-
         /* Constuct the link with a tooltip for further info on the download. */
         $html = '<br />';
         $view_url = Horde::url('view.php');
diff --git a/framework/Core/js/tooltips.js b/framework/Core/js/tooltips.js
new file mode 100644 (file)
index 0000000..737efb8
--- /dev/null
@@ -0,0 +1,143 @@
+/**
+ * Horde tooltips javascript.
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ */
+
+var Horde_ToolTips =
+{
+    // Vars used and defaulting to null: element, timeout
+
+    attachBehavior: function()
+    {
+        $$('a').each(this.attach.bind(this));
+    },
+
+    attach: function(e)
+    {
+        var t = e.readAttribute('title');
+        if (!t) {
+            return;
+        }
+        e.store('nicetitle', t);
+        try {
+            e.removeAttribute('title');
+        } catch (e) {}
+        e.observe('mouseover', this.onMouseover.bindAsEventListener(this));
+        e.observe('mouseout', this.out.bind(this));
+        e.observe('focus', this.onFocus.bindAsEventListener(this));
+        e.observe('blur', this.out.bind(this));
+    },
+
+    detach: function(e)
+    {
+        e.stopObserving('mouseover');
+        e.stopObserving('mouseout');
+        e.stopObserving('focus');
+        e.stopObserving('blur');
+    },
+
+    onMouseover: function(e)
+    {
+        this.onOver(e, [ e.pointerX(), e.pointerY() ]);
+    },
+
+    onFocus: function(e)
+    {
+        this.onOver(e, e.element().cumulativeOffset());
+    },
+
+    onOver: function(e, p)
+    {
+        if (this.timeout) {
+            clearTimeout(this.timeout);
+        }
+
+        this.element = e.element();
+        this.timeout = this.show.bind(this, p).delay(0.3);
+    },
+
+    out: function()
+    {
+        var iframe, t = $('toolTip');
+
+        if (this.timeout) {
+            clearTimeout(this.timeout);
+        }
+
+        if (t) {
+            t.hide();
+
+            iframe = $('iframe_tt');
+            if (iframe) {
+                iframe.hide();
+            }
+        }
+    },
+
+    show: function(pos)
+    {
+        var iframe, left, link, nicetitle, w,
+            d = $('toolTip'),
+            s_offset = document.viewport.getScrollOffsets(),
+            v_dimens = document.viewport.getDimensions();
+
+        if (d) {
+            this.out();
+        }
+
+        link = this.element;
+        while (!link.retrieve('nicetitle') && link.match('BODY')) {
+            link = link.up();
+        }
+
+        nicetitle = link.retrieve('nicetitle');
+        if (!nicetitle) {
+            return;
+        }
+
+        if (!d) {
+            d = new Element('DIV', { id: 'toolTip', className: 'nicetitle' }).hide();
+            document.body.appendChild(d);
+        }
+
+        d.update(nicetitle);
+
+        // Make sure all of the tooltip is visible.
+        left = pos[0] + 10;
+        w = d.getWidth();
+        if ((left + w) > (v_dimens.width + s_offset.left)) {
+            left = v_dimens.width - w - 40 + s_offset.left;
+        }
+        if (document.body.scrollWidth && ((left + w) > (document.body.scrollWidth + s_offset.left))) {
+            left = document.body.scrollWidth - w - 25 + s_offset.left;
+        }
+
+        d.setStyle({
+            left: Math.max(left, 5) + 'px',
+            top: (pos[1] + 10) + 'px'
+        }).show();
+
+        // IE 6 only.
+        if (Prototype.Browser.IE && !window.XMLHttpRequest) {
+            iframe = $('iframe_tt');
+            if (!iframe) {
+                iframe = new Element('IFRAME', { name: 'iframe_tt', id: 'iframe_tt', src: 'javascript:false;', scrolling: 'no', frameborder: 0 }).hide();
+                document.body.appendChild(iframe);
+            }
+            iframe.clonePosition(d).setStyle({
+                position: 'absolute',
+                display: 'block',
+                zIndex: 99
+            });
+            d.setStyle({ zIndex: 100 });
+        }
+    }
+
+};
+
+if (typeof Horde_ToolTips_Autoload == 'undefined' || !Horde_ToolTips_Autoload) {
+    Event.observe(window, 'load', Horde_ToolTips.attachBehavior.bind(Horde_ToolTips));
+    Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips));
+}
index 2c69ade..87e4e05 100644 (file)
@@ -1178,6 +1178,8 @@ HTML;
             $old_error = error_reporting(0);
             $title = '&lt;pre&gt;' . preg_replace(array('/\n/', '/((?<!<br)\s{1,}(?<!\/>))/em', '/<br \/><br \/>/', '/<br \/>/'), array('', 'str_repeat("&nbsp;", strlen("$1"))', '&lt;br /&gt; &lt;br /&gt;', '&lt;br /&gt;'), nl2br(htmlspecialchars(htmlspecialchars($title, ENT_QUOTES, $charset), ENT_QUOTES, $charset))) . '&lt;/pre&gt;';
             error_reporting($old_error);
+
+            Horde::addScriptFile('tooltips.js', 'horde');
         }
 
         return self::link($url, $title, $class, $target, $onclick, null, $accesskey, $attributes, false);
index ba2b3e8..6ba9af0 100644 (file)
@@ -68,6 +68,7 @@ Application Framework.</description>
     <file name="prettyautocomplete.js" role="horde" />
     <file name="spellchecker.js" role="horde" />
     <file name="sourceselect.js" role="horde" />
+    <file name="tooltips.js" role="horde" />
    </dir> <!-- /js -->
    <dir name="lib">
     <dir name="Horde">
@@ -409,6 +410,7 @@ Application Framework.</description>
    <install as="js/prettyautocomplete.js" name="js/prettyautocomplete.js" />
    <install as="js/spellchecker.js" name="js/spellchecker.js" />
    <install as="js/sourceselect.js" name="js/sourceselect.js" />
+   <install as="js/tooltips.js" name="js/tooltips.js" />
    <install as="Horde.php" name="lib/Horde.php" />
    <install as="Horde/Config.php" name="lib/Horde/Config.php" />
    <install as="Horde/ErrorHandler.php" name="lib/Horde/ErrorHandler.php" />
diff --git a/horde/js/tooltips.js b/horde/js/tooltips.js
deleted file mode 100644 (file)
index 737efb8..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Horde tooltips javascript.
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- */
-
-var Horde_ToolTips =
-{
-    // Vars used and defaulting to null: element, timeout
-
-    attachBehavior: function()
-    {
-        $$('a').each(this.attach.bind(this));
-    },
-
-    attach: function(e)
-    {
-        var t = e.readAttribute('title');
-        if (!t) {
-            return;
-        }
-        e.store('nicetitle', t);
-        try {
-            e.removeAttribute('title');
-        } catch (e) {}
-        e.observe('mouseover', this.onMouseover.bindAsEventListener(this));
-        e.observe('mouseout', this.out.bind(this));
-        e.observe('focus', this.onFocus.bindAsEventListener(this));
-        e.observe('blur', this.out.bind(this));
-    },
-
-    detach: function(e)
-    {
-        e.stopObserving('mouseover');
-        e.stopObserving('mouseout');
-        e.stopObserving('focus');
-        e.stopObserving('blur');
-    },
-
-    onMouseover: function(e)
-    {
-        this.onOver(e, [ e.pointerX(), e.pointerY() ]);
-    },
-
-    onFocus: function(e)
-    {
-        this.onOver(e, e.element().cumulativeOffset());
-    },
-
-    onOver: function(e, p)
-    {
-        if (this.timeout) {
-            clearTimeout(this.timeout);
-        }
-
-        this.element = e.element();
-        this.timeout = this.show.bind(this, p).delay(0.3);
-    },
-
-    out: function()
-    {
-        var iframe, t = $('toolTip');
-
-        if (this.timeout) {
-            clearTimeout(this.timeout);
-        }
-
-        if (t) {
-            t.hide();
-
-            iframe = $('iframe_tt');
-            if (iframe) {
-                iframe.hide();
-            }
-        }
-    },
-
-    show: function(pos)
-    {
-        var iframe, left, link, nicetitle, w,
-            d = $('toolTip'),
-            s_offset = document.viewport.getScrollOffsets(),
-            v_dimens = document.viewport.getDimensions();
-
-        if (d) {
-            this.out();
-        }
-
-        link = this.element;
-        while (!link.retrieve('nicetitle') && link.match('BODY')) {
-            link = link.up();
-        }
-
-        nicetitle = link.retrieve('nicetitle');
-        if (!nicetitle) {
-            return;
-        }
-
-        if (!d) {
-            d = new Element('DIV', { id: 'toolTip', className: 'nicetitle' }).hide();
-            document.body.appendChild(d);
-        }
-
-        d.update(nicetitle);
-
-        // Make sure all of the tooltip is visible.
-        left = pos[0] + 10;
-        w = d.getWidth();
-        if ((left + w) > (v_dimens.width + s_offset.left)) {
-            left = v_dimens.width - w - 40 + s_offset.left;
-        }
-        if (document.body.scrollWidth && ((left + w) > (document.body.scrollWidth + s_offset.left))) {
-            left = document.body.scrollWidth - w - 25 + s_offset.left;
-        }
-
-        d.setStyle({
-            left: Math.max(left, 5) + 'px',
-            top: (pos[1] + 10) + 'px'
-        }).show();
-
-        // IE 6 only.
-        if (Prototype.Browser.IE && !window.XMLHttpRequest) {
-            iframe = $('iframe_tt');
-            if (!iframe) {
-                iframe = new Element('IFRAME', { name: 'iframe_tt', id: 'iframe_tt', src: 'javascript:false;', scrolling: 'no', frameborder: 0 }).hide();
-                document.body.appendChild(iframe);
-            }
-            iframe.clonePosition(d).setStyle({
-                position: 'absolute',
-                display: 'block',
-                zIndex: 99
-            });
-            d.setStyle({ zIndex: 100 });
-        }
-    }
-
-};
-
-if (typeof Horde_ToolTips_Autoload == 'undefined' || !Horde_ToolTips_Autoload) {
-    Event.observe(window, 'load', Horde_ToolTips.attachBehavior.bind(Horde_ToolTips));
-    Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips));
-}
index 2479ba9..5a346cb 100644 (file)
@@ -304,9 +304,7 @@ $sort_url = $mailbox_imp_url->copy()->add('sortdir', ($sortpref['dir']) ? 0 : 1)
 $preview_tooltip = $show_preview
     ? $prefs->getValue('preview_show_tooltip')
     : false;
-if ($preview_tooltip) {
-    Horde::addScriptFile('tooltips.js', 'horde');
-} else {
+if (!$preview_tooltip) {
     $strip_preview = $prefs->getValue('preview_strip_nl');
 }
 
index 6cbb444..ac9dd7f 100644 (file)
@@ -133,7 +133,6 @@ case 'apply_filters':
 /* Get the list of rules now. */
 $filter_list = $filters->getFilterList();
 
-Horde::addScriptFile('tooltips.js', 'horde');
 Horde::addScriptFile('stripe.js', 'horde');
 Horde::addScriptFile('filters.js', 'ingo');
 Ingo::prepareMenu();
index 9365d8c..112ca19 100644 (file)
@@ -70,8 +70,6 @@ class Horde_Block_Kronolith_month extends Horde_Block
             }
         }
 
-        Horde::addScriptFile('tooltips.js', 'horde');
-
         $year = date('Y');
         $month = date('m');
         $startday = new Horde_Date(array('mday' => 1,
index 92a3ea9..a1fc159 100644 (file)
@@ -20,7 +20,6 @@ if (Kronolith::showAjaxView()) {
 $view = Kronolith::getView('Year');
 $title = $view->year;
 
-Horde::addScriptFile('tooltips.js', 'horde');
 require KRONOLITH_TEMPLATES . '/common-header.inc';
 require KRONOLITH_TEMPLATES . '/menu.inc';
 
index b315aa6..559cfba 100644 (file)
@@ -54,7 +54,6 @@ case 'search_memos':
     break;
 }
 
-Horde::addScriptFile('tooltips.js', 'horde', true);
 Horde::addScriptFile('tables.js', 'horde', true);
 Horde::addScriptFile('prototype.js', 'horde', true);
 Horde::addScriptFile('quickfinder.js', 'horde', true);
index 44173e7..5202808 100644 (file)
@@ -38,7 +38,6 @@ if (count($search_results) == 1) {
 $title = _("Search Results");
 $memos = $search_results;
 
-Horde::addScriptFile('tooltips.js', 'horde', true);
 Horde::addScriptFile('tables.js', 'horde', true);
 Horde::addScriptFile('prototype.js', 'horde', true);
 Horde::addScriptFile('quickfinder.js', 'horde', true);