From b72c3d438bf179df8dc09e53bec1dc455cf80fdf Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Mon, 7 Apr 2014 19:15:45 +0400 Subject: [PATCH] search hashtags --- js/twister_following.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/js/twister_following.js b/js/twister_following.js index 3bcc575..4fc54c2 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -355,12 +355,28 @@ function closeSearchDialog() } function userSearchKeypress(item) { - var partialName = $(".userMenu-search-field").val().toLowerCase(); + var partialName = $(".userMenu-search-field").val().toLowerCase(), + prefix = partialName.substr( 0, 1 ); - if ( partialName.substr( 0, 1 ) == '@' ) { + if ( prefix == '@' || prefix == '#') { partialName = partialName.substr( 1 ); } + var keyCode = item.keyCode || item.which; + if (keyCode == 13) { + // Enter pressed + var dummy = $(''); + if (prefix == '#') { // hashtag + dummy.attr('href', $.MAL.hashtagUrl(partialName)); + dummy.text('#' + partialName); + openHashtagModal.call(dummy.get(0), item); + } else { // username + dummy.attr('href', $.MAL.userUrl(partialName)); + openProfileModal.call(dummy.get(0), item); + } + return false; + } + //var partialName = item.val(); if( !partialName.length ) {