diff --git a/assets/style/timeline.scss b/assets/style/timeline.scss index 75e03de7..a798400c 100644 --- a/assets/style/timeline.scss +++ b/assets/style/timeline.scss @@ -167,4 +167,31 @@ } } } +} + +.timeline-end{ + width: 50%; + margin: 0 auto; + text-align: center; + + button.more{ + position: relative; + top: -2px; + + width: 100px; + height: 40px; + border: 2px solid black; + padding: 0 10px; + background: none; + + font-size: 14pt; + + &:hover{ + background: gainsboro; + } + + &:active{ + top: 0; + } + } } \ No newline at end of file diff --git a/bower.json b/bower.json index bb2fac89..3c92adb7 100644 --- a/bower.json +++ b/bower.json @@ -25,6 +25,7 @@ "angular-route": "~1.3.3", "angular-animate": "~1.3.3", "angular": "~1.3.3", - "angulartics": "~0.17.2" + "angulartics": "~0.17.2", + "angular-spinner": "~0.6.1" } } diff --git a/client/api/news.js b/client/api/news.js index 870efecb..7433df61 100644 --- a/client/api/news.js +++ b/client/api/news.js @@ -2,12 +2,14 @@ * Created by tmshv on 22/11/14. */ +var query = require("../../utils/net").query; + function APIFeed(http){ this.request = http; } -APIFeed.prototype.feed = function() { - return this.request.get("/news"); +APIFeed.prototype.feed = function(count, portion) { + return this.request.get("/news?"+query([["count", count], ["portion", portion]])); }; module.exports = APIFeed; \ No newline at end of file diff --git a/client/app.js b/client/app.js index 9d42888a..1e2d3a50 100644 --- a/client/app.js +++ b/client/app.js @@ -6,7 +6,8 @@ var app = angular.module("hudozhka", [ "hudozhka.data", "ngRoute", "angulartics", - "angulartics.google.analytics" + "angulartics.google.analytics", + "angularSpinner" ]); app.config(function ($locationProvider, $routeProvider) { diff --git a/client/ui/timeline.js b/client/ui/timeline.js index a0fa2bdf..87b8baf9 100644 --- a/client/ui/timeline.js +++ b/client/ui/timeline.js @@ -38,34 +38,60 @@ module.exports = function(app) { return index % 2 === 1; } }, - controller: function($scope, api){ + controller: function($scope, $timeout, usSpinnerService, api){ + var portion = 0; + var count = 10; + $scope.feed = []; + + $scope.timelineUpdating = false; + usSpinnerService.stop("timelineMore"); + //usSpinnerService.spin("timelineMore"); + $scope.recordClass = function (i) { return i['type']; }; - api.news.feed() - .success(function (list) { - var feed = list.map(function (post) { - if(post.type == "instagram"){ - var author_id = personByInstagram(team.team, post.data.author); - var name = author_id ? team.short(author_id) : post.data.author; + $scope.loadNext = function () { + $scope.timelineUpdating = true; + usSpinnerService.spin("timelineMore"); - return { - date: post.date, - image: post.data.image.standard_resolution.url, - url: post.data.url, - username: name, - //userpic: post.data.user.profile_picture, - text: post.body, - //text: postText(post), - type: post.type - }; - }else{ - return post; - } + api.news.feed(count, portion) + .error(function(error) { + console.log(error); + }) + .success(function (list) { + $scope.timelineUpdating = false; + usSpinnerService.stop("timelineMore"); + //$timeout(function () { + // + //}, 5000); + + var feed = list.map(function (post) { + if(post.type == "instagram"){ + var author_id = personByInstagram(team.team, post.data.author); + var name = author_id ? team.short(author_id) : post.data.author; + + return { + date: post.date, + image: post.data.image.standard_resolution.url, + url: post.data.url, + username: name, + //userpic: post.data.user.profile_picture, + text: post.body, + //text: postText(post), + type: post.type + }; + }else{ + return post; + } + }); + + portion++; + $scope.feed = $scope.feed.concat(feed); }); - $scope.feed = feed; - }); + }; + + $scope.loadNext(); } }; }); @@ -81,7 +107,6 @@ module.exports = function(app) { } function linkGram(scope, element, attrs) { - scope.lal = "LAL"; } return { diff --git a/templates/index.html b/templates/index.html index 3a936a9a..d2d80187 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,6 +18,8 @@ + + diff --git a/templates/views/timeline.html b/templates/views/timeline.html index aefe83b5..15ce61e6 100644 --- a/templates/views/timeline.html +++ b/templates/views/timeline.html @@ -1,8 +1,16 @@