From fe5c0510819e6fa0597cd54c444c22baf70644e6 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 17 Apr 2015 00:11:33 +0500 Subject: [PATCH] option to disable toptrends module --- css/style.css | 10 +++-- home.html | 21 +++++---- js/interface_home.js | 86 ++++++++++++++++++++++-------------- js/interface_localization.js | 2 +- js/options.js | 20 +++++++++ options.html | 24 ++++++---- theme_calm/css/style.css | 5 ++- theme_nin/css/style.css | 13 +++--- theme_nin/sass/style.sass | 10 +++-- 9 files changed, 129 insertions(+), 62 deletions(-) diff --git a/css/style.css b/css/style.css index 6c28d37..d89e75c 100644 --- a/css/style.css +++ b/css/style.css @@ -785,6 +785,7 @@ textarea.splited-post { opacity: 1; } +.refresh-toptrends, .refresh-users, .view-all-users { @@ -794,8 +795,9 @@ textarea.splited-post { } /*********************************** -**********TOP TRENDS**************** +************ TOP TRENDS ************ ***********************************/ + ol.toptrends-list { margin: 0% 5% 5% 5%; padding: 5px; @@ -803,9 +805,9 @@ ol.toptrends-list { border-top: solid 1px rgba( 69, 71, 77, .1 ); } -.toptrends h3 -{ - margin: 5% 5% 2% 5%; +.toptrends h3 { + margin: 5% 0% 2% 5%; + display: inline; } /*********************************** diff --git a/home.html b/home.html index e3eaa45..fb404ae 100644 --- a/home.html +++ b/home.html @@ -155,13 +155,8 @@
- -
-

Top Trends

-
    - -
-
+ +
@@ -215,7 +210,7 @@
-

Who to Follow

+

Who to Follow

. Refresh . @@ -225,6 +220,16 @@
+ +
+

Top Trends

+ . + Refresh +
    + +
+
+
  • diff --git a/js/interface_home.js b/js/interface_home.js index 4603759..734412a 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -118,45 +118,67 @@ var InterfaceFunctions = function() }); } - setTimeout(updateTrendingHashtags, 1000); - if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable' && $.Options.getTopTrendsAutoUpdateTimerOpt() > 0) - setInterval(updateTrendingHashtags, $.Options.getTopTrendsAutoUpdateTimerOpt()*1000); + if ($.Options.getTopTrendsOpt() === 'enable') + initTopTrends(); + else + killTopTrends(); } }; +function initTopTrends() { + var $tt = $('.module.toptrends'); + if ($tt.length) { + $tt.html($('#toptrends-template').html()).show(); + var $ttRefresh = $tt.find('.refresh-toptrends'); + $ttRefresh.on('click', updateTrendingHashtags); + setTimeout(function() { $ttRefresh.click() }, 100); + } +} + +function killTopTrends() { + var $tt = $('.module.toptrends'); + if ($tt.length) + $tt.empty().hide(); +} + function updateTrendingHashtags() { - twisterRpc('gettrendinghashtags', [10], - function(args, ret) { - $('.toptrends-list').empty(); - //console.log('hashtags trends: '+ret); - for( var i = 0; i < ret.length; i++ ) { - if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForTopTrendsOpt()) - var langFilterData = filterLang(ret[i]); - if (typeof(langFilterData) === 'undefined' || langFilterData['pass'] || $.Options.getFilterLangSimulateOpt()) { - var $li = $('
  • '); - var hashtagLinkTemplate = $('#hashtag-link-template').clone(true); - - hashtagLinkTemplate.removeAttr('id'); - hashtagLinkTemplate.attr('href',$.MAL.hashtagUrl(ret[i])); - hashtagLinkTemplate.text('#'+ret[i]); - - $li.append(hashtagLinkTemplate); - if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangSimulateOpt()) { - if (typeof(langFilterData) !== 'undefined') { - $li.append(' '+((langFilterData['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+': '+langFilterData['prob'][0].toString()+''); - } else { - $li.append(' '+polyglot.t('not analyzed')+''); + var $ttl = $('.module.toptrends .toptrends-list'); + if ($ttl.length) { + twisterRpc('gettrendinghashtags', [10], + function(args, ret) { + $ttl.empty(); + //console.log('hashtags trends: '+ret); + for( var i = 0; i < ret.length; i++ ) { + if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangForTopTrendsOpt()) + var langFilterData = filterLang(ret[i]); + if (typeof(langFilterData) === 'undefined' || langFilterData['pass'] || $.Options.getFilterLangSimulateOpt()) { + var $li = $('
  • '); + var hashtagLinkTemplate = $('#hashtag-link-template').clone(true); + + hashtagLinkTemplate.removeAttr('id'); + hashtagLinkTemplate.attr('href',$.MAL.hashtagUrl(ret[i])); + hashtagLinkTemplate.text('#'+ret[i]); + + $li.append(hashtagLinkTemplate); + if ($.Options.getFilterLangOpt() !== 'disable' && $.Options.getFilterLangSimulateOpt()) { + if (typeof(langFilterData) !== 'undefined') { + $li.append(' '+((langFilterData['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+': '+langFilterData['prob'][0].toString()+''); + } else { + $li.append(' '+polyglot.t('not analyzed')+''); + } } - } - $('.toptrends-list').append($li); + $ttl.append($li); + } } - } - }, {}, - function(args, ret) { - console.log('Error with gettrendinghashtags. Older twister daemon?'); - }, {} - ); + }, {}, + function(args, ret) { + console.log('Error with gettrendinghashtags. Older twister daemon?'); + }, {} + ); + if ($.Options.getTopTrendsAutoUpdateOpt() === 'enable' && $.Options.getTopTrendsAutoUpdateTimerOpt() > 0) + setTimeout(updateTrendingHashtags, $.Options.getTopTrendsAutoUpdateTimerOpt()*1000); + } }; //*********************************************** diff --git a/js/interface_localization.js b/js/interface_localization.js index 83626bc..d17f0ef 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -3570,7 +3570,7 @@ var fixedLabels = [ "button", ".postboard-news", ".post-area-new textarea", - ".refresh-users, .view-all-users", + ".refresh-toptrends, .refresh-users, .view-all-users", ".who-to-follow h3", ".userMenu-search-field", "a.dropdown-menu-item, a.direct-messages", diff --git a/js/options.js b/js/options.js index 1d76dbc..d28cfe9 100644 --- a/js/options.js +++ b/js/options.js @@ -372,6 +372,25 @@ var TwisterOptions = function() }); } + this.getTopTrendsOpt = function() { + return this.getOption('TopTrends', 'enable'); + } + + this.setTopTrendsOpt = function () { + function TopTrendsCfg() { + if ($.Options.getTopTrendsOpt() === 'enable') + $('#TopTrendsCont').show(); + else + $('#TopTrendsCont').hide(); + } + $('#TopTrends').val(this.getTopTrendsOpt()); + TopTrendsCfg(); + $('#TopTrends').on('change', function() { + $.Options.setOption(this.id, this.value); + TopTrendsCfg(); + }); + } + this.getTopTrendsAutoUpdateOpt = function() { return this.getOption('TopTrendsAutoUpdate', 'enable'); } @@ -601,6 +620,7 @@ var TwisterOptions = function() this.setUseProxyOpt(); this.setUseProxyForImgOnlyOpt(); this.setTopTrendsAutoUpdateOpt(); + this.setTopTrendsOpt(); this.setTopTrendsAutoUpdateTimerOpt(); this.setWhoToFollowOpt(); this.setSplitPostsOpt(); diff --git a/options.html b/options.html index 4788250..4464861 100644 --- a/options.html +++ b/options.html @@ -302,15 +302,23 @@

    Top Trends

    -
    +
    -

    Auto updating

    - -
    - second(s) +

    + +

    +
    +

    Auto updating

    + +
    + second(s) +
    diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index 8c5318c..aae48a6 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -969,6 +969,7 @@ textarea.splited-post { text-decoration: none; } +.refresh-toptrends, .refresh-users, .view-all-users { @@ -979,14 +980,16 @@ textarea.splited-post { } /*********************************** -********************* TOP TRENDS +************ TOP TRENDS ************ ***********************************/ + .module.toptrends { margin-top: 10px; } .module.toptrends h3 { margin: 5px 0 5px 10px; font: 14px 'Open Sans', sans-serif; + display: inline; } .module.toptrends ol { margin: 0 0 10px 10px; diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 42bdde5..0878ab9 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -56,7 +56,7 @@ font-style: normal; } /* line 64, ../sass/_fonts.sass */ -[class^="icon-"]:before, [class*=" icon-"]:before, .extend-icon:before, .userMenu li.userMenu-config > a:before, .post-context span:before, .post-reply:before, .post-propagate:before, .post-favorite:before, .post .show-more:before, .mini-profile-actions span:before, ul.userMenu-search-profiles button:before, .mini-profile-indicators .userMenu-connections a:before, .mini-profile-indicators .userMenu-messages a:before, .mini-profile-indicators .userMenu-user a:before, .twister-user-remove:before, .refresh-users:before, .modal-close:before, .mark-all-as-read:before, .modal-back:before, .icon-down-after:after { +[class^="icon-"]:before, [class*=" icon-"]:before, .extend-icon:before, .userMenu li.userMenu-config > a:before, .post-context span:before, .post-reply:before, .post-propagate:before, .post-favorite:before, .post .show-more:before, .mini-profile-actions span:before, ul.userMenu-search-profiles button:before, .mini-profile-indicators .userMenu-connections a:before, .mini-profile-indicators .userMenu-messages a:before, .mini-profile-indicators .userMenu-user a:before, .twister-user-remove:before, .refresh-toptrends:before, .refresh-users:before, .modal-close:before, .mark-all-as-read:before, .modal-back:before, .icon-down-after:after { font-family: "fontello"; font-style: normal; font-weight: normal; @@ -198,7 +198,7 @@ /* '' */ /* line 183, ../sass/_fonts.sass */ -.icon-arrows:before, .refresh-users:before { +.icon-arrows:before, .refresh-toptrends:before, .refresh-users:before { content: ""; } @@ -1823,7 +1823,7 @@ button.disabled:hover, .mini-profile-actions span.disabled:hover, a.button.disab width: 90%; } -.options #filterLangListCont div,.options #TopTrendsAutoUpdateCont div { +.options #filterLangListCont div,.options #TopTrendsCont div { float: none; padding: 0px 4px; } @@ -2449,7 +2449,7 @@ button.follow:hover, .mini-profile-actions span.follow:hover, button.unfollow, . } /* line 499, ../sass/style.sass */ -.refresh-users { +.refresh-toptrends, .refresh-users { color: #66686B; cursor: pointer; font-size: 11px; @@ -2479,13 +2479,16 @@ button.follow:hover, .mini-profile-actions span.follow:hover, button.unfollow, . } /* line 527, ../sass/style.sass */ -.refresh-users:hover, .view-all-users:hover { +.refresh-toptrends:hover, .refresh-users:hover, .view-all-users:hover { color: #B4C669; text-decoration: none; background-color: transparent; } /***********TOP TRENDS************** */ +.toptrends h3 { + float: left; +} /* line 534, ../sass/style.sass */ ol.toptrends-list { margin: 0; diff --git a/theme_nin/sass/style.sass b/theme_nin/sass/style.sass index 54d8291..6c3e78f 100755 --- a/theme_nin/sass/style.sass +++ b/theme_nin/sass/style.sass @@ -516,7 +516,7 @@ textarea.splited-post .twister-user-remove:hover opacity: 1 -.refresh-users +.refresh-toptrends, .refresh-users @extend .icon-arrows @extend .extend-icon color: $main-color-dark @@ -544,13 +544,17 @@ textarea.splited-post margin: 0 0 0 15px position: relative -.refresh-users:hover, .view-all-users:hover +.refresh-toptrends:hover, .refresh-users:hover, .view-all-users:hover color: $main-color-color text-decoration: none background-color: transparent /***********TOP TRENDS***************/ +.toptrends + h3 + float: left + ol.toptrends-list margin: 0 margin-bottom: 10px @@ -1096,7 +1100,7 @@ ol.toptrends-list #filterLangList width: 90% - #filterLangListCont div, #TopTrendsAutoUpdateCont div + #filterLangListCont div, #TopTrendsCont div float: none padding: 0px 4px