incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [15/17] git commit: [#5769] ticket:528 Made code browser ignore double and triple clicks
Date Thu, 13 Feb 2014 15:05:49 GMT
[#5769] ticket:528 Made code browser ignore double and triple clicks


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/36ba2d62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/36ba2d62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/36ba2d62

Branch: refs/heads/cj/7097
Commit: 36ba2d62d9bcf79e5581f3b1af39114e0546863c
Parents: 390043a
Author: Ferens Dmitriy <ferensdima@gmail.com>
Authored: Fri Feb 7 16:57:25 2014 +0200
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Feb 12 20:16:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/templates/repo/file.html | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/36ba2d62/Allura/allura/templates/repo/file.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/file.html b/Allura/allura/templates/repo/file.html
index 8fe2819..7221557 100644
--- a/Allura/allura/templates/repo/file.html
+++ b/Allura/allura/templates/repo/file.html
@@ -51,17 +51,24 @@
     }
   }).trigger('hashchange');
 
+  var clicks = 0;
   $('.code_block').each(function(index, element) {
     $(element).bind('click', function() {
-      // Let double/triple clicks select code first
-      setTimeout(function() {
-        var hash = window.location.hash.substring(1);
-        if (hash !== '' && hash.substring(0, 1) === 'l' && !isNaN(hash.substring(1)))
{
-          $('#' + hash).css('background-color', 'transparent');
-        }
-        $(element).css('background-color', '#ffff99');
-        window.location.href = '#' + $(element).attr('id');
-      }, 500);
+      // Trick to ignore double and triple clicks
+      clicks++;
+      if (clicks == 1) {
+        setTimeout(function() {
+          if (clicks == 1) {
+            var hash = window.location.hash.substring(1);
+            if (hash !== '' && hash.substring(0, 1) === 'l' && !isNaN(hash.substring(1)))
{
+              $('#' + hash).css('background-color', 'transparent');
+            }
+            $(element).css('background-color', '#ffff99');
+            window.location.href = '#' + $(element).attr('id');
+          };
+          clicks = 0;
+        }, 500);
+      };
     });
   });
 }());


Mime
View raw message