From 4db7cb04389cddacd70a7358ce86dabdff2c2ccf Mon Sep 17 00:00:00 2001 From: OldHawk Date: Thu, 27 Apr 2017 09:36:56 +0800 Subject: [PATCH] add page changed effect --- modules/core/client/app/trans-string-cn.js | 6 + modules/core/client/app/trans-string-en.js | 6 + .../controllers/home.client.controller.js | 4 +- .../torrent-info.client.controller.js | 60 ++++++--- .../controllers/torrents.client.controller.js | 32 +++-- .../client/views/movie-list.client.view.html | 5 +- .../views/view-torrent.client.view.html | 127 +++++++++--------- 7 files changed, 149 insertions(+), 91 deletions(-) diff --git a/modules/core/client/app/trans-string-cn.js b/modules/core/client/app/trans-string-cn.js index aa07f013..309cc250 100644 --- a/modules/core/client/app/trans-string-cn.js +++ b/modules/core/client/app/trans-string-cn.js @@ -153,6 +153,12 @@ SUBTITLE_DELETE_SUCCESSFULLY: '字幕文件删除成功', SUBTITLE_DELETE_ERROR: '字幕文件下载失败', + //page text + PAGE_TEXT_FIRST: '首页', + PAGE_TEXT_PREVIOUS: '上一页', + PAGE_TEXT_NEXT: '下一页', + PAGE_TEXT_LAST: '尾页', + //comment USER_COMMENT_LIST: '用户评论', POST_NEW_COMMENT: '发表新评论', diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 07c29bd5..48c4def5 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -153,6 +153,12 @@ SUBTITLE_DELETE_SUCCESSFULLY: 'Subtitle file delete successfully', SUBTITLE_DELETE_ERROR: 'Subtitle file delete failed', + //page text + PAGE_TEXT_FIRST: 'First', + PAGE_TEXT_PREVIOUS: 'Previous', + PAGE_TEXT_NEXT: 'Next', + PAGE_TEXT_LAST: 'Last', + //comment USER_COMMENT_LIST: 'User Comments List', POST_NEW_COMMENT: 'Post New Comment', diff --git a/modules/core/client/controllers/home.client.controller.js b/modules/core/client/controllers/home.client.controller.js index 450f6237..0ec1e1f1 100644 --- a/modules/core/client/controllers/home.client.controller.js +++ b/modules/core/client/controllers/home.client.controller.js @@ -50,10 +50,10 @@ * getMovieTopInfo */ vm.getMovieTopInfo = function () { - vm.moviesInfo = TorrentsService.query({ + vm.moviesInfo = TorrentsService.get({ limit: 16 }, function (items) { - vm.movieTopList = items; + vm.movieTopList = items.rows; }, function (err) { Notification.error({ message: ' ' + $translate.instant('TOP_MOVIE_INFO_ERROR') diff --git a/modules/torrents/client/controllers/torrent-info.client.controller.js b/modules/torrents/client/controllers/torrent-info.client.controller.js index d1bf1e13..8bbe5969 100644 --- a/modules/torrents/client/controllers/torrent-info.client.controller.js +++ b/modules/torrents/client/controllers/torrent-info.client.controller.js @@ -22,38 +22,68 @@ vm.progress = 0; //page init - vm.commentBuildPager = commentBuildPager; - vm.commentFigureOutItemsToDisplay = commentFigureOutItemsToDisplay; - vm.commentPageChanged = commentPageChanged; - - function commentBuildPager() { + vm.commentBuildPager = function () { vm.commentPagedItems = []; vm.commentItemsPerPage = 10; vm.commentCurrentPage = 1; vm.commentFigureOutItemsToDisplay(); - } + }; - function commentFigureOutItemsToDisplay() { + vm.commentFigureOutItemsToDisplay = function (callback) { vm.commentFilterLength = vm.torrentLocalInfo._replies.length; var begin = ((vm.commentCurrentPage - 1) * vm.commentItemsPerPage); var end = begin + vm.commentItemsPerPage; vm.commentPagedItems = vm.torrentLocalInfo._replies.slice(begin, end); - } - function commentPageChanged() { + if (callback) callback(); + }; + + vm.commentPageChanged = function (autoScroll) { var element = angular.element('#top_of_comments'); - vm.commentFigureOutItemsToDisplay(); - window.scrollTo(0, element[0].offsetTop - 30); - } + $('#comment-list-div').fadeTo(100, 0.01, function () { + vm.commentFigureOutItemsToDisplay(function () { + $timeout(function () { + $('#comment-list-div').fadeTo(400, 1, function () { + if (autoScroll) { + //window.scrollTo(0, element[0].offsetTop - 30); + $('html,body').animate({scrollTop: element[0].offsetTop - 30}, 200); + } + }); + }, 100); + }); + }); + }; $scope.$watch('vm.torrentLocalInfo', function (newValue, oldValue) { if (vm.torrentLocalInfo && vm.torrentLocalInfo._replies) { + + var hasme = false; + var meitem = null; if (newValue._replies.length > oldValue._replies.length) { - var totalPages = vm.commentItemsPerPage < 1 ? 1 : Math.ceil(newValue._replies.length / vm.commentItemsPerPage); - vm.commentCurrentPage = Math.max(totalPages || 0, 1); + + angular.forEach(newValue._replies, function (n) { + if (oldValue._replies.indexOf(n) < 0) { + if (n.user._id.toString() === vm.user._id) { + hasme = true; + meitem = n; + } + } + }); + } + if (hasme) { + var totalPages = vm.commentItemsPerPage < 1 ? 1 : Math.ceil(newValue._replies.length / vm.commentItemsPerPage); + var p = Math.max(totalPages || 0, 1); + if (vm.commentCurrentPage !== p) { + vm.commentCurrentPage = p; + vm.commentPageChanged(false); + vm.scrollToId = meitem._id; + } else { + vm.commentFigureOutItemsToDisplay(); + } + } else { + vm.commentFigureOutItemsToDisplay(); } - vm.commentFigureOutItemsToDisplay(); } }); diff --git a/modules/torrents/client/controllers/torrents.client.controller.js b/modules/torrents/client/controllers/torrents.client.controller.js index e23b2430..5edab329 100644 --- a/modules/torrents/client/controllers/torrents.client.controller.js +++ b/modules/torrents/client/controllers/torrents.client.controller.js @@ -30,30 +30,36 @@ } //page init - vm.torrentBuildPager = torrentBuildPager; - vm.torrentFigureOutItemsToDisplay = torrentFigureOutItemsToDisplay; - vm.torrentPageChanged = torrentPageChanged; - - function torrentBuildPager() { + vm.torrentBuildPager = function () { vm.torrentPagedItems = []; vm.torrentItemsPerPage = 8; vm.torrentCurrentPage = 1; vm.torrentFigureOutItemsToDisplay(); - } + }; - function torrentFigureOutItemsToDisplay() { + vm.torrentFigureOutItemsToDisplay = function (callback) { vm.getMoviePageInfo(vm.torrentCurrentPage, function (items) { vm.torrentFilterLength = items.total; vm.torrentPagedItems = items.rows; - }); - } - function torrentPageChanged() { + if (callback) callback(); + }); + }; + + vm.torrentPageChanged = function () { var element = angular.element('#top_of_torrent_list'); - vm.torrentFigureOutItemsToDisplay(); - window.scrollTo(0, element[0].offsetTop - 60); - } + $('.tb-v-middle').fadeTo(100, 0.01, function () { + vm.torrentFigureOutItemsToDisplay(function () { + $timeout(function () { + $('.tb-v-middle').fadeTo(400, 1, function () { + //window.scrollTo(0, element[0].offsetTop - 60); + $('html,body').animate({scrollTop: element[0].offsetTop - 60}, 200); + }); + }, 100); + }); + }); + }; /** * getMovieTopInfo diff --git a/modules/torrents/client/views/movie-list.client.view.html b/modules/torrents/client/views/movie-list.client.view.html index 1675eec9..ef25297d 100644 --- a/modules/torrents/client/views/movie-list.client.view.html +++ b/modules/torrents/client/views/movie-list.client.view.html @@ -180,7 +180,10 @@
+ ng-model="vm.torrentCurrentPage" ng-change="vm.torrentPageChanged()" + first-text="{{ 'PAGE_TEXT_FIRST' | translate}}" previous-text="{{ 'PAGE_TEXT_PREVIOUS' | translate}}" + next-text="{{ 'PAGE_TEXT_NEXT' | translate}}" last-text="{{ 'PAGE_TEXT_LAST' | translate}}"> +
\ No newline at end of file diff --git a/modules/torrents/client/views/view-torrent.client.view.html b/modules/torrents/client/views/view-torrent.client.view.html index e61cbb6e..2ef95364 100644 --- a/modules/torrents/client/views/view-torrent.client.view.html +++ b/modules/torrents/client/views/view-torrent.client.view.html @@ -155,74 +155,78 @@ class="badge badge_info">{{vm.torrentLocalInfo._replies.length}}
+ ng-model="vm.commentCurrentPage" ng-change="vm.commentPageChanged(true)" + ng-if="vm.torrentLocalInfo._replies.length > 0" + first-text="{{ 'PAGE_TEXT_FIRST' | translate}}" previous-text="{{ 'PAGE_TEXT_PREVIOUS' | translate}}" + next-text="{{ 'PAGE_TEXT_NEXT' | translate}}" last-text="{{ 'PAGE_TEXT_LAST' | translate}}"> + -
-
- - - +
+
+
+ + + -
-
-
{{item.user.displayName}} - - ({{item.user.uploaded | bytes}} - {{item.user.downloaded | bytes}} - ) - +
+
+
{{item.user.displayName}} + + ({{item.user.uploaded | bytes}} + {{item.user.downloaded | bytes}} + ) + +
+ {{item.createdat | date:'yyyy-MM-dd HH:mm:ss'}}
- {{item.createdat | date:'yyyy-MM-dd HH:mm:ss'}} -
-
-
-
-

[ {{item.editedby}} {{ 'COMMENT_EDITED_INFO' | translate}} {{item.editedat | date:'yyyy-MM-dd HH:mm:ss'}} ]

-
-
-
-
- - - +
+
+
+

[ {{item.editedby}} {{ 'COMMENT_EDITED_INFO' | translate}} {{item.editedat | date:'yyyy-MM-dd HH:mm:ss'}} ]

+
+
+
+
+ + + -
- {{sitem.comment}} - - - @{{sitem.user.displayName}} - - {{sitem.createdat | date: 'yyyy-MM-dd HH:mm:ss'}} +
+ {{sitem.comment}} + - + @{{sitem.user.displayName}} + + {{sitem.createdat | date: 'yyyy-MM-dd HH:mm:ss'}} - - - - - + + + + +
-
- @@ -230,8 +234,11 @@
+ ng-model="vm.commentCurrentPage" ng-change="vm.commentPageChanged(true)" + ng-if="vm.torrentLocalInfo._replies.length > 0" + first-text="{{ 'PAGE_TEXT_FIRST' | translate}}" previous-text="{{ 'PAGE_TEXT_PREVIOUS' | translate}}" + next-text="{{ 'PAGE_TEXT_NEXT' | translate}}" last-text="{{ 'PAGE_TEXT_LAST' | translate}}"> +