From 5a68ad0d7b4cf7a63323efb2f222c4eedf6902df Mon Sep 17 00:00:00 2001 From: Catouse Date: Wed, 16 Nov 2016 10:44:06 +0800 Subject: [PATCH] * adjust js code. --- www/js/my.full.js | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/www/js/my.full.js b/www/js/my.full.js index ff067f5070..9d4b9806e7 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -1674,35 +1674,28 @@ function removeCookieByKey(cookieKey) */ function initHotKey() { - /* CTRL+g, auto focus on the search box. */ - $(document).bind('keydown', 'Ctrl+g', function(evt) + $(document).on('keydown', 'Ctrl+g', function(e) { - $('#searchQuery').attr('value', ''); - $('#searchQuery').focus(); - evt.stopPropagation( ); - evt.preventDefault( ); + /* CTRL+g, auto focus on the search box. */ + $('#searchQuery').val('').focus(); + e.stopPropagation(); + e.preventDefault(); return false; - }); - - /* Alt+up, go back to the previous page. */ - $(document).bind('keydown', 'Alt+up', function(evt) + }).on('keydown', 'Alt+up', function() { - backLink = ($('#back').attr("href")); - if(typeof(backLink) != 'undefined') location.href = backLink; - }); - - /* left, go to pre object. */ - $(document).bind('keydown', 'left', function(evt) + /* Alt+up, go back to the previous page. */ + var backLink = $('#back').attr("href"); + if(backLink) location.href = backLink; + }).on('keydown', 'left', function() { - preLink = ($('#pre').attr("href")); - if(typeof(preLink) != 'undefined') location.href = preLink; - }); - - /* right, go to next object. */ - $(document).bind('keydown', 'right', function(evt) + /* left, go to pre object. */ + var preLink = $('#pre').attr("href"); + if(preLink) location.href = preLink; + }).on('keydown', 'right', function() { - nextLink = ($('#next').attr("href")); - if(typeof(nextLink) != 'undefined') location.href = nextLink; + /* right, go to next object. */ + var nextLink = $('#next').attr("href"); + if(preLink) location.href = nextLink; }); }