Fixed problem with keyboard shortcuts on Flash
Previous attempt - f226c3eb0c
.
Approach introduced in this commit is theoretically much better, but it still
might not be perfect.
This commit is contained in:
parent
f7837dc190
commit
4879ba94b0
2 changed files with 77 additions and 9 deletions
|
@ -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');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue