summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorAcho Arnold <arnold@archlinux.info>2014-04-17 17:44:08 +0200
committerGervase Markham <gerv@gerv.net>2014-04-17 17:44:08 +0200
commit08f83a7fd0618065e2cbae443674e44fac8102e2 (patch)
treefdc7123b87380b4448490cae812e39a7ceccddd1 /js
parent23bad39c2d516b7834b4fa95de054bf1ed769e8e (diff)
downloadbugzilla-08f83a7fd0618065e2cbae443674e44fac8102e2.tar.gz
bugzilla-08f83a7fd0618065e2cbae443674e44fac8102e2.tar.xz
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.
Diffstat (limited to 'js')
-rw-r--r--js/field.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/js/field.js b/js/field.js
index 892c8669f..b7e90ce1c 100644
--- a/js/field.js
+++ b/js/field.js
@@ -1083,3 +1083,33 @@ function updateRemainingTime() {
// if the remaining time is changed manually, update bz_remaining_time
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