From a81246cd5f40ec5b3e28cc21ab5e215b91564225 Mon Sep 17 00:00:00 2001 From: digital dreamer Date: Mon, 14 Apr 2014 12:01:26 +0200 Subject: [PATCH] add hashtag search --- home.html | 1 + js/interface_common.js | 28 ++++++++++++++++------------ js/interface_localization.js | 3 ++- js/twister_actions.js | 4 ++++ js/twister_following.js | 14 +++++++++++++- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/home.html b/home.html index 2891326..3217093 100644 --- a/home.html +++ b/home.html @@ -429,6 +429,7 @@ +
diff --git a/js/interface_common.js b/js/interface_common.js index 4e1c8f9..d28b789 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -5,8 +5,6 @@ // Profile, mentions and hashtag modal // Post actions: submit, count characters -var preventSlide = false; - //dispara o modal genérico //o modalClass me permite fazer tratamentos específicos de CSS para cada modal function openModal( modalClass ) @@ -161,6 +159,19 @@ function openHashtagModal(e) $( "."+hashtagModalClass + " h3" ).text( "#" + hashtag ); } +function openHashtagModalFromSearch(hashtag) +{ + var hashtagModalClass = "hashtag-modal"; + openModal( hashtagModalClass ); + $( "."+hashtagModalClass ).attr("data-resource","hashtag"); + + var hashtagModalContent = newHashtagModal( hashtag ); + hashtagModalContent.appendTo("." +hashtagModalClass + " .modal-content"); + + //título do modal + $( "."+hashtagModalClass + " h3" ).text( "#" + hashtag ); +} + function updateHashtagModal(postboard,hashtag) { var $hashtagModalClass = $(".hashtag-modal"); if( !$hashtagModalClass.length || $hashtagModalClass.css("display") == 'none' ) @@ -239,7 +250,7 @@ var reTwistPopup = function( e ) { if(!defaultScreenName) { - preventSlide=true; + e.stopPropagation(); alert(polyglot.t("You have to log in to retransmit messages.")); return; } @@ -317,14 +328,7 @@ var postExpandFunction = function( e, postLi ) var openClass = "open"; - //This is used in "guest mode", when user gets an alert that he can't reply or retransmit - //when not logged in. Otherwise, this click would also be understood as a command to open/close - //the post, which would look weird. - if(preventSlide) - { - preventSlide=false; - } - else if( !postLi.hasClass( openClass ) ) { + if( !postLi.hasClass( openClass ) ) { originalPost.detach(); postLi.empty(); postLi.addClass( openClass ); @@ -388,7 +392,7 @@ var postReplyClick = function( e ) { if(!defaultScreenName) { - preventSlide=true; + e.stopPropagation(); alert(polyglot.t("You have to log in to post replies.")); return; } diff --git a/js/interface_localization.js b/js/interface_localization.js index 0221175..5c51934 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -205,7 +205,8 @@ if(preferredLanguage == "en"){ "Custom": "Custom", "Mentions": "Mentions", "Use proxy for image preview only": "Use proxy for image preview only", - "Use external links behind a proxy": "Use external links behind a proxy" + "Use external links behind a proxy": "Use external links behind a proxy", + "There aren't any posts with this hashtag.": "There aren't any posts with this hashtag.", }; } if(preferredLanguage == "es"){ diff --git a/js/twister_actions.js b/js/twister_actions.js index b125682..2a38fc0 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -236,6 +236,9 @@ function processHashtag(postboard, hashtag, data) { _hashtagPendingPosts.push(data[i]); } } + + if(!postboard.children().length&&!_hashtagPendingPosts.length) + postboard.closest("div").find(".no-posts-found-message").show(); if( _hashtagPendingPosts.length ) { if( !postboard.children().length || autoUpdateHashtag ) { @@ -245,6 +248,7 @@ function processHashtag(postboard, hashtag, data) { newTweetsBar.text(polyglot.t("new_posts", _hashtagPendingPosts.length)); newTweetsBar.fadeIn("slow"); } + postboard.closest("div").find(".no-posts-found-message").hide(); } } } diff --git a/js/twister_following.js b/js/twister_following.js index c171870..78facd9 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -354,8 +354,20 @@ function closeSearchDialog() _lastSearchUsersResults = []; } -function userSearchKeypress(item) { +function userSearchKeypress(event) { var partialName = $(".userMenu-search-field").val().toLowerCase(); + var searchResults = $(".search-results"); + + if ( partialName.substr( 0, 1 ) == '#' ) { + + if(searchResults.is(":visible")) + searchResults.slideUp( "fast" ); + + if ( event.which == 13 ) + openHashtagModalFromSearch(partialName.substr(1)); + + return; + } if ( partialName.substr( 0, 1 ) == '@' ) { partialName = partialName.substr( 1 );