1 |
// /: 47, toggle keyboard stuff |
2 |
Refeed.App.assignKeyPressHandler( 47, function(app, event) { toggle_kb(); return false; }, true); |
3 |
|
4 |
// ?: 63, toggle cheat sheet |
5 |
Refeed.App.assignKeyPressHandler( 63, function(app, event) { toggle_cheatsheet(); return false; }, true); |
6 |
|
7 |
// ,: 44, jump up one feed/item |
8 |
Refeed.App.assignKeyPressHandler( 44, function(app, event) { return app.doScroll(-1); }); |
9 |
|
10 |
// .: 46, jump down one feed/item |
11 |
Refeed.App.assignKeyPressHandler( 46, function(app, event) { return app.doScroll(1); }); |
12 |
|
13 |
// vi-like keybindings |
14 |
// j: 106, jump down one feed/item |
15 |
Refeed.App.assignKeyPressHandler(106, function(app, event) { return app.doScroll(1); }); |
16 |
// k: 107, jump up one feed/item |
17 |
Refeed.App.assignKeyPressHandler(107, function(app, event) { return app.doScroll(-1); }); |
18 |
|
19 |
// r: 114, reload page |
20 |
Refeed.App.assignKeyPressHandler(114, function(app, event) { location.reload(true); return false; }); |
21 |
|
22 |
// A: 65, archive all shown items |
23 |
Refeed.App.assignKeyPressHandler( 65, function(app, event) { app.archiveAll(); return false; }); |
24 |
|
25 |
// f: 102, back to feed list |
26 |
Refeed.App.assignKeyPressHandler(102, function(app, event) { location.href = app.feedsHREF; return false; }); |
27 |
|
28 |
// i: 105, new items, paged |
29 |
Refeed.App.assignKeyPressHandler(105, function(app, event) { location.href = app.itemsHREF; return false; }); |
30 |
|
31 |
|
32 |
|
33 |
// enter: 13, open link |
34 |
Refeed.Item.prototype.assignKeyPressHandler( 13, function(item, event) { return Refeed.App.openLink(item.link, item.newWindow); }); |
35 |
Refeed.Feed.prototype.assignKeyPressHandler( 13, function(feed, event) { return Refeed.App.openLink(feed.link, false); }); |
36 |
|
37 |
// return: 3, open link |
38 |
Refeed.Item.prototype.assignKeyPressHandler( 3, function(item, event) { return Refeed.App.openLink(item.link, item.newWindow); }); |
39 |
Refeed.Feed.prototype.assignKeyPressHandler( 3, function(feed, event) { return Refeed.App.openLink(feed.link, false); }); |
40 |
|
41 |
// u: 117, update feed |
42 |
Refeed.Feed.prototype.assignKeyPressHandler(117, function(feed, event) { return feed.update(); }); |
43 |
|
44 |
// a: 97 |
45 |
Refeed.Item.prototype.assignKeyPressHandler( 97, function(item, event) { toggle_read(item.id); Refeed.App.doScroll(1); return false; }); |
46 |
Refeed.Feed.prototype.assignKeyPressHandler( 97, function(feed, event) { archive_feed(feed.id); Refeed.App.doScroll(1); return false; }); |
47 |
|
48 |
// p: 112 |
49 |
Refeed.Item.prototype.assignKeyPressHandler(112, function(item, event) { toggle_published(item.id); return false; }); |
50 |
|
51 |
// v: 118, item body |
52 |
Refeed.Item.prototype.assignKeyPressHandler(118, function(item, event) { populate_item_body(item.id, 'itemBodyHTML', 'itemTab'+item.id+'View'); return false; }); |
53 |
|
54 |
// e: 101, edit form |
55 |
Refeed.Item.prototype.assignKeyPressHandler(101, function(item, event) { populate_item_body(item.id, 'itemEditFormHTML', 'itemTab'+item.id+'Edit'); return false; }); |
56 |
|
57 |
// c: 99, comment form |
58 |
Refeed.Item.prototype.assignKeyPressHandler( 99, function(item, event) { populate_item_body(item.id, 'itemCommentFormHTML', 'itemTab'+item.id+'CommentTag'); return false; }); |
59 |
// t: 116, (tag) comment form |
60 |
Refeed.Item.prototype.assignKeyPressHandler(116, function(item, event) { populate_item_body(item.id, 'itemCommentFormHTML', 'itemTab'+item.id+'CommentTag'); return false; }); |
61 |
|
62 |
// digits: 48-57 |
63 |
for(var keycode = 48; keycode <= 57; keycode += 1) { |
64 |
Refeed.Item.prototype.assignKeyPressHandler(keycode, function(item, event) { |
65 |
|
66 |
var keycode = Refeed.App.getKeycode(event); |
67 |
|
68 |
if(event.altKey || event.ctrlKey) { |
69 |
var link = get_item_link(item.id, keycode - 48); |
70 |
|
71 |
if(link) { |
72 |
return Refeed.App.openLink(link.href, item.newWindow); |
73 |
} |
74 |
} else { |
75 |
return link_select(item.id, (keycode - 48)); |
76 |
} |
77 |
|
78 |
return true; |
79 |
}); |
80 |
} |