redesign buffer-modes and page-modes
[conkeror.git] / modules / page-modes / gmail.js
blob1e4fc13fb69470e8ec9ce09d1ae63628a95818a2
1 /**
2  * (C) Copyright 2008 David Glasser
3  * (C) Copyright 2008 Will Farrington
4  * (C) Copyright 2008 Jeremy Maitin-Shepard
5  * (C) Copyright 2009-2010 John J. Foerch
6  *
7  * Use, modification, and distribution are subject to the terms specified in the
8  * COPYING file.
9 **/
11 in_module(null);
13 require("content-buffer.js");
15 define_keymap("gmail_keymap", $display_name = "gmail");
17 // Jumping
18 define_key(gmail_keymap, "g", null, $fallthrough);
19 define_key(gmail_keymap, "i", null, $fallthrough);
20 define_key(gmail_keymap, "t", null, $fallthrough);
21 define_key(gmail_keymap, "d", null, $fallthrough);
22 define_key(gmail_keymap, "a", null, $fallthrough);
23 define_key(gmail_keymap, "b", null, $fallthrough);
25 // Threadlist
26 define_key(gmail_keymap, "*", null, $fallthrough);
28 // Navigation
29 define_key(gmail_keymap, "u", null, $fallthrough);
30 define_key(gmail_keymap, "j", null, $fallthrough);
31 define_key(gmail_keymap, "k", null, $fallthrough);
32 define_key(gmail_keymap, "o", null, $fallthrough);
33 define_key(gmail_keymap, "n", null, $fallthrough);
34 define_key(gmail_keymap, "p", null, $fallthrough);
36 // Application
37 define_key(gmail_keymap, "c", null, $fallthrough);
38 define_key(gmail_keymap, "C", null, $fallthrough);
39 define_key(gmail_keymap, "/", null, $fallthrough);
40 define_key(gmail_keymap, "q", null, $fallthrough);
41 define_key(gmail_keymap, "?", null, $fallthrough);
43 // Actions
44 define_key(gmail_keymap, "s", null, $fallthrough);
45 define_key(gmail_keymap, "e", null, $fallthrough);
46 define_key(gmail_keymap, "x", null, $fallthrough);
47 define_key(gmail_keymap, "y", null, $fallthrough);
48 define_key(gmail_keymap, "!", null, $fallthrough);
49 define_key(gmail_keymap, "m", null, $fallthrough);
50 define_key(gmail_keymap, "#", null, $fallthrough);
51 define_key(gmail_keymap, "r", null, $fallthrough);
52 define_key(gmail_keymap, "f", null, $fallthrough);
53 define_key(gmail_keymap, "N", null, $fallthrough);
54 define_key(gmail_keymap, ".", null, $fallthrough);
55 define_key(gmail_keymap, "I", null, $fallthrough);
56 define_key(gmail_keymap, "U", null, $fallthrough);
57 define_key(gmail_keymap, "]", null, $fallthrough);
58 define_key(gmail_keymap, "[", null, $fallthrough);
59 define_key(gmail_keymap, "l", null, $fallthrough);
60 define_key(gmail_keymap, "return", null, $fallthrough);
61 define_key(gmail_keymap, "tab", null, $fallthrough);
64 var gmail_modality = {
65     normal: gmail_keymap
68 function gmail_focus_primary_frame (buffer) {
69     var frames = buffer.top_frame.frames;
70     if (frames.length >= 4)
71         buffer.top_frame.frames[3].focus();
74 define_page_mode("gmail-mode",
75     build_url_regex($domain = "mail.google",
76                     $path = new RegExp('(?!support)')),
77     function enable (buffer) {
78         add_hook.call(buffer, "buffer_dom_content_loaded_hook",
79                       gmail_focus_primary_frame);
80         add_hook.call(buffer, "unfocus_hook", gmail_focus_primary_frame);
81         buffer.content_modalities.push(gmail_modality);
82     },
83     function disable (buffer) {
84         remove_hook.call(buffer, "buffer_dom_content_loaded_hook",
85                          gmail_focus_primary_frame);
86         remove_hook.call(buffer, "unfocus_hook", gmail_focus_primary_frame);
87         var i = buffer.content_modalities.indexOf(gmail_modality);
88         if (i > -1)
89             buffer.content_modalities.splice(i, 1);
90     },
91     $display_name = "GMail");
93 page_mode_activate(gmail_mode);
95 provide("gmail");