From ac764c548101d86749342135922b98090ee8b77f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 11 Nov 2013 21:46:22 -0600
Subject: [PATCH] Fixup image hover

Since the ticket thread is nested in a div now (required for inline videos
to be displayed correctly), the image hover caused the images to be shown at
the end of the thread entry body rather that its original location.
---
 js/osticket.js   | 19 +++++++++++++------
 scp/js/ticket.js |  7 +++----
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/js/osticket.js b/js/osticket.js
index 3f38a6ec3..e78c2aa0a 100644
--- a/js/osticket.js
+++ b/js/osticket.js
@@ -119,16 +119,23 @@ 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">');
+            e.wrap(caption).parent()
                 .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>')
-                )
-            caption.appendTo(e.parent())
-            e.appendTo(caption);
+                );
         }
     });
 
diff --git a/scp/js/ticket.js b/scp/js/ticket.js
index fb9f7370e..ee78effcf 100644
--- a/scp/js/ticket.js
+++ b/scp/js/ticket.js
@@ -428,7 +428,8 @@ showImagesInline = function(urls, thread_id) {
             e = $(el);
         if (info) {
             // Add a hover effect with the filename
-            var timeout, caption = $('<div class="image-hover">')
+            var timeout, caption = $('<div class="image-hover">');
+            e.wrap(caption).parent()
                 .hover(
                     function() {
                         var self = this;
@@ -443,9 +444,7 @@ showImagesInline = function(urls, thread_id) {
                 ).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>')
-                )
-            caption.appendTo(e.parent())
-            e.appendTo(caption);
+                );
         }
     });
 }
-- 
GitLab