From 4a1aed561bdea8afcbbec30b2d17c0a47b33433a Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 21 Oct 2013 15:21:19 +0000
Subject: [PATCH] Provide delay on inline-image hover

This means that drive-by mouse hovers, where the user likely did not intend
for the hover to actually popup the banner with the filename and download
button, do not trigger the popup. This patch changes the popup effect so
that it requires a 500ms hover before the popup is shown.
---
 scp/js/ticket.js | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scp/js/ticket.js b/scp/js/ticket.js
index cbe042f44..fb9f7370e 100644
--- a/scp/js/ticket.js
+++ b/scp/js/ticket.js
@@ -428,10 +428,18 @@ showImagesInline = function(urls, thread_id) {
             e = $(el);
         if (info) {
             // Add a hover effect with the filename
-            var caption = $('<div class="image-hover">')
+            var timeout, caption = $('<div class="image-hover">')
                 .hover(
-                    function() { $(this).find('.caption').slideDown(250); },
-                    function() { $(this).find('.caption').slideUp(250); }
+                    function() {
+                        var self = this;
+                        timeout = setTimeout(
+                            function() { $(self).find('.caption').slideDown(250); },
+                            500);
+                    },
+                    function() {
+                        clearTimeout(timeout);
+                        $(this).find('.caption').slideUp(250);
+                    }
                 ).append($('<div class="caption">')
                     .append('<span class="filename">'+info.filename+'</span>')
                     .append('<a href="'+info.download_url+'" class="action-button"><i class="icon-download-alt"></i> Download</a>')
-- 
GitLab