Permalink
Browse files

focus on esc; n for new post

  • Loading branch information...
1 parent 272ea9a commit d02d86bde1999d456042a66b5c6f2be6fb324d3c Jen Fong-Adwent committed Nov 22, 2012
Showing with 20 additions and 4 deletions.
  1. +3 −0 public/javascripts/appnet.js
  2. +16 −4 public/javascripts/main.js
  3. +1 −0 views/layout.jade
@@ -236,6 +236,9 @@ define(['jquery', 'version-timeout', 'friends', 'jquery.caret'],
if (showDetails) {
detailExtras = generateDetails(data.messages[i], true);
+ } else {
+ detailExtras = '<div class="actions ' + noTouch + '">' +
+ '<a class="reply" title="Reply" href="javascript:;"><span>Reply</span></a></div>';
}
var message = generatePostItem(data.messages[i], detailExtras);
@@ -22,6 +22,8 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
var notifications = body.find('#notifications-preview');
var notificationIcon = body.find('#notifications');
var mapMenu = body.find('#map-menu');
+ var primaryWrite = body.find('#write');
+ var dashboard = body.find('.dashboard-content');
var unreadMessages = $('#unread-messages');
var unreadMessagesNest = unreadMessages.find('ol');
var win = $(window);
@@ -48,6 +50,7 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
var S_KEYCODE = 83;
var T_KEYCODE = 84;
var U_KEYCODE = 85;
+ var N_KEYCODE = 78;
var QUESTION_SLASH_KEYCODE = 191;
var MESSAGE_LIMIT = 99;
@@ -230,10 +233,6 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
var self = $(ev.target);
switch (true) {
- case self.hasClass('reply'):
- self.closest('.message-item').find('time').click();
- break;
-
case self.hasClass('quote'):
var textarea = self.closest('.dashboard-content').find('textarea');
textarea.focus();
@@ -331,6 +330,10 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
}
switch (true) {
+ case self.hasClass('reply'):
+ self.closest('.message-item').find('time').click();
+ break;
+
case self.hasClass('close'):
write.find('textarea').val('');
write.find('textarea').blur();
@@ -443,6 +446,7 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
.addClass('off');
menuOpen = false;
}
+ body.focus();
}
// Open menu if ctrl|cmd|shift + ?|/ is pressed
@@ -452,6 +456,13 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
mapMenu.find('#menu-toggle').click();
}
+ // Create a new post
+ if (ev.keyCode === N_KEYCODE
+ && !write.find('textarea').hasClass('on')) {
+ ev.preventDefault();
+ dashboard.find('.write textarea').focus();
+ }
+
switch (true) {
case self.hasClass('submittable'):
if (ev.keyCode === TAB_KEYCODE || ev.keyCode === SPACE_KEYCODE) {
@@ -586,6 +597,7 @@ define(['jquery', 'appnet', 'friends', 'user', 'jquery.caret'],
charLimit.addClass('on');
checkCharLimit(self.val());
self.closest('form').find('.form-action-wrapper').slideDown('fast');
+ return true;
});
write.find('textarea').blur(function() {
View
@@ -35,6 +35,7 @@ html
ul
li ESC (close overlay / this menu too!)
li cmd+enter or ctrl+enter (post a message)
+ li n (start a new post)
li k (move up feed)
li j (move down feed)
li t (open thread)

0 comments on commit d02d86b

Please sign in to comment.