From a51142dc4d9ee9baf2fb4442bb2a170ea005b136 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Fri, 26 Jan 2018 10:51:29 +0800 Subject: [PATCH] feat(forums): global search from forum at home --- modules/core/client/app/trans-string-en.js | 2 + modules/core/client/app/trans-string-zh.js | 2 + .../controllers/home.client.controller.js | 43 ++++++++++++++++++- modules/core/client/less/home.less | 5 +++ .../core/client/views/home.client.view.html | 5 ++- .../client/views/index.client.view.html | 2 + 6 files changed, 55 insertions(+), 4 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 21630d92..e1f27de7 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -1172,6 +1172,8 @@ READ_ONLY_POST: '*** Readonly forum, cannot to post topic!', READ_ONLY_REPLY: '*** Readonly topic, cannot to post reply!', TITLE_READONLY: 'readonly', + TITLE_VIPONLY: 'vip only', + TITLE_OPERONLY: 'oper only', TODAY_NEW_COUNT_ALL: '(Today: {{topic}} topics, {{reply}} replies)', TODAY_NEW_COUNT_TOPIC: '(Today: {{topic}} topics)', TODAY_NEW_COUNT_REPLY: '(Today: {{reply}} replies)', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 1f178814..49335579 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -1172,6 +1172,8 @@ READ_ONLY_POST: '*** 只读版块,不能发表话题!', READ_ONLY_REPLY: '*** 只读话题,不能发表回复!', TITLE_READONLY: '只读', + TITLE_VIPONLY: 'vip 专区', + TITLE_OPERONLY: 'oper 专区', TODAY_NEW_COUNT_ALL: '(今日: {{topic}} 话题, {{reply}} 回复)', TODAY_NEW_COUNT_TOPIC: '(今日: {{topic}} 话题)', TODAY_NEW_COUNT_REPLY: '(今日: {{reply}} 回复)', diff --git a/modules/core/client/controllers/home.client.controller.js b/modules/core/client/controllers/home.client.controller.js index 06127854..85ae477b 100644 --- a/modules/core/client/controllers/home.client.controller.js +++ b/modules/core/client/controllers/home.client.controller.js @@ -6,11 +6,11 @@ .controller('HomeController', HomeController); HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig', - 'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'TopicsService', 'TorrentGetInfoServices', 'DebugConsoleService', + 'getStorageLangService', 'ForumsService', '$timeout', 'localStorageService', 'TopicsService', 'TorrentGetInfoServices', 'DebugConsoleService', 'marked']; function HomeController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService, - DownloadService, $timeout, localStorageService, TopicsService, TorrentGetInfoServices, mtDebug, + ForumsService, $timeout, localStorageService, TopicsService, TorrentGetInfoServices, mtDebug, marked) { var vm = this; vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app; @@ -21,6 +21,45 @@ vm.searchType = 'torrents'; + /** + * getForumList + */ + vm.getForumList = function () { + ForumsService.get({}, function (items) { + vm.forums = items.forumsList; + console.log(items); + }); + }; + + /** + * doGlobalSearch + */ + vm.doGlobalSearch = function () { + if (vm.searchKeys) { + if (vm.searchType === 'forum') { //search from forum + var fid = []; + + angular.forEach(vm.forums, function (f) { + fid.push(f._id); + }); + + $state.go('forums.search', {forumId: fid, keys: vm.searchKeys}); + } else { //search from torrents + + } + } + }; + + /** + * onSearchKeyDown + * @param evt + */ + vm.onSearchKeyDown = function (evt) { + if (evt.keyCode === 13 && vm.searchKeys) { + vm.doGlobalSearch(); + } + }; + /** * getSaleNoticeMessage * @returns {*} diff --git a/modules/core/client/less/home.less b/modules/core/client/less/home.less index abe69419..bba633f1 100644 --- a/modules/core/client/less/home.less +++ b/modules/core/client/less/home.less @@ -132,6 +132,11 @@ } .vip-more { text-shadow: 0 0 0.1em #3a3a3a,-0 -0 0.1em #3a3a3a; + &:hover { + a { + color: @brand-success; + } + } } @media (min-width: @screen-sm-min) { display: table-cell; diff --git a/modules/core/client/views/home.client.view.html b/modules/core/client/views/home.client.view.html index 65c734aa..a24b03c4 100644 --- a/modules/core/client/views/home.client.view.html +++ b/modules/core/client/views/home.client.view.html @@ -9,7 +9,7 @@ -