diff --git a/public_html/media/js/core.js b/public_html/media/js/core.js index cacd6b39..0bf79348 100644 --- a/public_html/media/js/core.js +++ b/public_html/media/js/core.js @@ -304,15 +304,59 @@ function attachTagIt(element) +//prevent keybindings from executing when flash posts are focused +var oldMousetrapBind = Mousetrap.bind; +Mousetrap.bind = function(key, func, args) +{ + oldMousetrapBind(key, function() + { + if ($(document.activeElement).parents('.post-type-flash').length > 0) + return false; + + func(); + }, args); +}; + + + //hotkeys $(function() { - Mousetrap.bind('q', function() { $('#top-nav input').focus(); return false; }, 'keyup'); - Mousetrap.bind('w', function() { $('body,html').animate({scrollTop: '-=150px'}, 200); }); - Mousetrap.bind('s', function() { $('body,html').animate({scrollTop: '+=150px'}, 200); }); - Mousetrap.bind('a', function() { var url = $('.paginator:visible .prev:not(.disabled) a').attr('href'); if (typeof url !== 'undefined') window.location.href = url; }, 'keyup'); - Mousetrap.bind('d', function() { var url = $('.paginator:visible .next:not(.disabled) a').attr('href'); if (typeof url !== 'undefined') window.location.href = url; }, 'keyup'); - Mousetrap.bind('p', function() { $('.post a').eq(0).focus(); return false; }, 'keyup'); + Mousetrap.bind('q', function() + { + $('#top-nav input').focus(); + return false; + }, 'keyup'); + + Mousetrap.bind('w', function() + { + $('body,html').animate({scrollTop: '-=150px'}, 200); + }); + + Mousetrap.bind('s', function() + { + $('body,html').animate({scrollTop: '+=150px'}, 200); + }); + + Mousetrap.bind('a', function() + { + var url = $('.paginator:visible .prev:not(.disabled) a').attr('href'); + if (typeof url !== 'undefined') + window.location.href = url; + }, 'keyup'); + + Mousetrap.bind('d', function() + { + var url = $('.paginator:visible .next:not(.disabled) a').attr('href'); + if (typeof url !== 'undefined') + window.location.href = url; + }, 'keyup'); + + Mousetrap.bind('p', function() + { + $('.post a').eq(0).focus(); + return false; + }, 'keyup'); }); diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js index ad077643..51060b3e 100644 --- a/public_html/media/js/post-view.js +++ b/public_html/media/js/post-view.js @@ -140,7 +140,31 @@ $(function() $.ajax(ajaxData); }); - Mousetrap.bind('a', function() { var a = $('#sidebar .left a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup'); - Mousetrap.bind('d', function() { var a = $('#sidebar .right a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup'); - Mousetrap.bind('e', function() { $('a.edit-post').trigger('click'); return false; }, 'keyup'); + Mousetrap.bind('a', function() + { + var a = $('#sidebar .left a'); + var url = a.attr('href'); + if (typeof url !== 'undefined') + { + a.click(); + window.location.href = url; + } + }, 'keyup'); + + Mousetrap.bind('d', function() + { + var a = $('#sidebar .right a'); + var url = a.attr('href'); + if (typeof url !== 'undefined') + { + a.click(); + window.location.href = url; + } + }, 'keyup'); + + Mousetrap.bind('e', function() + { + $('a.edit-post').trigger('click'); + return false; + }, 'keyup'); });