Commit 08f83a7f authored by Acho Arnold's avatar Acho Arnold Committed by Gervase Markham

Bug 984980 - add framework for keyboard shortcuts, and key to switch between…

Bug 984980 - add framework for keyboard shortcuts, and key to switch between preview and edit mode. Patch by <arnold@archlinux.info>, r=gerv, a=justdave.
parent 23bad39c
...@@ -1083,3 +1083,33 @@ function updateRemainingTime() { ...@@ -1083,3 +1083,33 @@ function updateRemainingTime() {
// if the remaining time is changed manually, update bz_remaining_time // if the remaining time is changed manually, update bz_remaining_time
bz_remaining_time = document.changeform.remaining_time.value; bz_remaining_time = document.changeform.remaining_time.value;
} }
var keys = [];
function keys_pressed(e, bug_id) {
// Store an entry for every key pressed
keys[e.keyCode] = true;
// (Ctrl XOR cmd) + Shift + P
if ((!keys[17] != !keys[224]) && keys[16] && keys[80]) {
// Check if we are already in preview mode
if (YAHOO.util.Dom.hasClass('comment_preview_tab', 'active_comment_tab')){
show_comment_edit();
document.getElementById('comment').focus();
YAHOO.util.Event.preventDefault(e);
}
else {
// Ensure that we switch to preview mode only if the textarea is in focus
var comment = document.getElementById('comment');
if (document.activeElement == comment) {
show_comment_preview(bug_id);
YAHOO.util.Event.preventDefault(e);
}
}
}
}
function keys_released(e) {
// Mark keys that were released
keys[e.keyCode] = false;
}
\ No newline at end of file
...@@ -11,6 +11,13 @@ ...@@ -11,6 +11,13 @@
[% header = BLOCK %]Create New Attachment for [% header = BLOCK %]Create New Attachment for
[%+ "$terms.Bug $bug.bug_id" FILTER bug_link(bug) FILTER none %][% END %] [%+ "$terms.Bug $bug.bug_id" FILTER bug_link(bug) FILTER none %][% END %]
[% subheader = BLOCK %][% bug.short_desc FILTER html %][% END %] [% subheader = BLOCK %][% bug.short_desc FILTER html %][% END %]
[% javascript = BLOCK %]
YAHOO.util.Event.onDOMReady(function() {
YAHOO.util.Event.addListener(window, 'keydown', keys_pressed, [% bug.id FILTER none %]);
YAHOO.util.Event.addListener(window, 'keyup', keys_released);
});
[% END %]
[% PROCESS global/header.html.tmpl [% PROCESS global/header.html.tmpl
title = title title = title
......
...@@ -56,6 +56,12 @@ ...@@ -56,6 +56,12 @@
[% javascript FILTER none %] [% javascript FILTER none %]
[% END %] [% END %]
[% END %] [% END %]
+[% javascript = BLOCK %]
YAHOO.util.Event.onDOMReady(function() {
YAHOO.util.Event.addListener(window, 'keydown', keys_pressed, [% bug.id FILTER none %]);
YAHOO.util.Event.addListener(window, 'keyup', keys_released);
});
[% END %]
[% style_urls = ['skins/standard/bug.css'] %] [% style_urls = ['skins/standard/bug.css'] %]
[% doc_section = "using.html#anatomy-of-a-bug" %] [% doc_section = "using.html#anatomy-of-a-bug" %]
[% bodyclasses = ['bz_bug', [% bodyclasses = ['bz_bug',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment