From 4349e33097820c1cd2d80ea2e033720d0b3c4b2c Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 25 Nov 2016 02:46:41 +0500 Subject: [PATCH] tune processWhoToFollowSuggestion() --- home.html | 13 +++---- js/interface_common.js | 1 + js/twister_following.js | 80 ++++++++++++++++++++--------------------- 3 files changed, 46 insertions(+), 48 deletions(-) diff --git a/home.html b/home.html index 66c96bd..8deaac4 100644 --- a/home.html +++ b/home.html @@ -220,9 +220,7 @@ Refresh . View All -
    - -
+
    @@ -237,9 +235,7 @@ Refresh . View All - +
    @@ -301,8 +297,8 @@
    - -
  1. +
    +
  2. user-photo @@ -328,6 +324,7 @@
  3. +
      diff --git a/js/interface_common.js b/js/interface_common.js index 4f513bc..f4ee860 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -2812,6 +2812,7 @@ $(document).ready(function () { twister.tmpl.followersPeer = extractTemplate('#template-followers-peer'); twister.tmpl.followingList = extractTemplate('#template-following-list'); twister.tmpl.followingPeer = extractTemplate('#template-following-peer'); + twister.tmpl.whoTofollowPeer = extractTemplate('#template-whotofollow-peer'); twister.tmpl.commonDMsListItem = extractTemplate('#template-direct-messages-list-item') .on('mouseup', function (event) { event.data = {route: diff --git a/js/twister_following.js b/js/twister_following.js index f0a700a..848234e 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -624,50 +624,50 @@ function getWhoFollows(peerAlias, elem) { ; } -function processWhoToFollowSuggestion(module, suggestion, followedBy, prepend) { - if (suggestion) { - var list = module.find('.follow-suggestions'); - var item = $('#follow-suggestion-template').clone(true) - .removeAttr('id'); - - item.find('.twister-user-info').attr('data-screen-name', suggestion); - item.find('.twister-user-name').attr('href', $.MAL.userUrl(suggestion)); - item.find('.twister-user-tag').text('@' + suggestion); - - getAvatar(suggestion, item.find('.twister-user-photo')); - getStatusTime(suggestion, item.find('.latest-activity .time')); - - if (module.hasClass('who-to-follow') || module.hasClass('who-to-follow-modal')) { - item.find('.twister-by-user-name').attr('href', $.MAL.userUrl(followedBy)); - getFullname(followedBy, item.find('.followed-by').text(followedBy)); - item.find('.twister-user-remove').on('click', function () { - item.remove(); - getRandomFollowSuggestion(); - }); - } - else if (module.hasClass('new-users') || module.hasClass('new-users-modal')){ - item.find('.followers').remove(); - item.find('.twister-user-remove').remove(); - } +function processWhoToFollowSuggestion(module, peerAlias, followedBy, prepend) { + if (!peerAlias) { + console.warn('nothing to proceed: no twisters to follow was suggested'); + return; + } - if (module.hasClass('modal-wrapper')) { - getFullname(suggestion, item.find('.twister-user-full')); - getBioToElem(suggestion, item.find('.bio')); - item.find('.twister-user-remove').remove(); - } + var list = module.find('.follow-suggestions'); + var item = twister.tmpl.whoTofollowPeer.clone(true); - if (prepend) - list.prepend(item).show(); - else - list.append(item).show(); + item.find('.twister-user-info').attr('data-screen-name', peerAlias); + item.find('.twister-user-name').attr('href', $.MAL.userUrl(peerAlias)); + item.find('.twister-user-tag').text('@' + peerAlias); - while (module.hasClass('new-users') && list.children().length > 3) - list.children().last().remove(); + getAvatar(peerAlias, item.find('.twister-user-photo')); + getStatusTime(peerAlias, item.find('.latest-activity .time')); - module.find('.refresh-users').show(); - module.find('.loading-roller').hide(); - } else - console.warn('nothing to proceed: no twisters to follow was suggested'); + if (module.hasClass('who-to-follow') || module.hasClass('who-to-follow-modal')) { + item.find('.twister-by-user-name').attr('href', $.MAL.userUrl(followedBy)); + getFullname(followedBy, item.find('.followed-by').text(followedBy)); + item.find('.twister-user-remove').on('click', {item: item}, function (event) { + event.data.item.remove(); + getRandomFollowSuggestion(); + }); + } else if (module.hasClass('new-users') || module.hasClass('new-users-modal')) { + item.find('.followers').remove(); + item.find('.twister-user-remove').remove(); + } + + if (module.hasClass('modal-wrapper')) { + getFullname(peerAlias, item.find('.twister-user-full')); + getBioToElem(peerAlias, item.find('.bio')); + item.find('.twister-user-remove').remove(); + } + + if (prepend) + list.prepend(item).show(); + else + list.append(item).show(); + + while (module.hasClass('new-users') && list.children().length > 3) + list.children().last().remove(); + + module.find('.refresh-users').show(); + module.find('.loading-roller').hide(); } function closeSearchDialog(event) {