mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
added incoming posts notification button
This commit is contained in:
parent
d85d65f485
commit
d54bd804e4
8 changed files with 58 additions and 8 deletions
|
@ -67,4 +67,9 @@ UI.registerHelper("sanitize", function(content) {
|
|||
console.log('cleaning up…')
|
||||
console.log(content)
|
||||
return cleanUp(content);
|
||||
});
|
||||
|
||||
UI.registerHelper('pluralize', function(count, string) {
|
||||
string = count === 1 ? string : string + 's';
|
||||
return i18n.t(string);
|
||||
});
|
|
@ -11,6 +11,9 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{> postsListIncoming count=postsIncoming.count}}
|
||||
|
||||
{{#if hasPosts}}
|
||||
<div class="posts grid list">
|
||||
{{#each posts}}
|
||||
|
|
|
@ -60,3 +60,7 @@ Template[getTemplate('posts_digest')].rendered = function(){
|
|||
$('body').css('min-height',distanceFromTop+160);
|
||||
$('.more-button').css('top', distanceFromTop+"px");
|
||||
}
|
||||
|
||||
Template[getTemplate('posts_digest')].created = function() {
|
||||
Session.set('listPopulatedAt', new Date());
|
||||
};
|
|
@ -1,9 +1,10 @@
|
|||
<template name="posts_list">
|
||||
{{> postsListIncoming count=postsListIncoming.count}}
|
||||
<div class="posts-wrapper grid grid-module">
|
||||
<div class="posts list">
|
||||
{{#each posts}}
|
||||
{{> UI.dynamic template=post_item}}
|
||||
{{/each}}
|
||||
<div class="posts list">
|
||||
{{#each posts}}
|
||||
{{> UI.dynamic template=post_item}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
{{> UI.dynamic template=postsLoadMore}}
|
||||
|
|
|
@ -14,5 +14,12 @@ Template[getTemplate('posts_list')].helpers({
|
|||
},
|
||||
postsLoadMore: function () {
|
||||
return getTemplate('postsLoadMore');
|
||||
},
|
||||
postsIncoming: function () {
|
||||
return getTemplate('postsIncoming');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template[getTemplate('posts_list')].created = function() {
|
||||
Session.set('listPopulatedAt', new Date());
|
||||
};
|
9
client/views/posts/posts_list_incoming.html
Normal file
9
client/views/posts/posts_list_incoming.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<template name="postsListIncoming">
|
||||
{{#if count}}
|
||||
<a class="more-button show-new grid-module" href="">
|
||||
<span>
|
||||
{{i18n "View"}} {{count}} {{i18n "new"}} {{pluralize count "post"}}
|
||||
</span>
|
||||
</a>
|
||||
{{/if}}
|
||||
</template>
|
5
client/views/posts/posts_list_incoming.js
Normal file
5
client/views/posts/posts_list_incoming.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
Template[getTemplate('postsListIncoming')].events({
|
||||
'click .show-new': function(e, instance) {
|
||||
Session.set('listPopulatedAt', new Date());
|
||||
}
|
||||
});
|
|
@ -308,12 +308,19 @@ PostsListController = FastRender.RouteController.extend({
|
|||
}
|
||||
|
||||
var parameters = getParameters(this._terms),
|
||||
posts = Posts.find(parameters.find, parameters.options);
|
||||
postsCount = posts.count();
|
||||
postsCount = Posts.find(parameters.find, parameters.options).count();
|
||||
|
||||
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
|
||||
// Incoming posts
|
||||
parameters.find.createdAt = { $gt: Session.get('listPopulatedAt') };
|
||||
var postsIncoming = Posts.find(parameters.find, parameters.options);
|
||||
|
||||
Session.set('postsLimit', this._terms.limit);
|
||||
|
||||
return {
|
||||
postsListIncoming: postsIncoming,
|
||||
postsList: posts,
|
||||
postsCount: postsCount,
|
||||
ready: this.postsListSub.ready
|
||||
|
@ -366,8 +373,17 @@ PostsDigestController = FastRender.RouteController.extend({
|
|||
},
|
||||
parameters = getParameters(terms);
|
||||
Session.set('currentDate', currentDate);
|
||||
|
||||
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
|
||||
// Incoming posts
|
||||
parameters.find.createdAt = { $gt: Session.get('listPopulatedAt') };
|
||||
var postsIncoming = Posts.find(parameters.find, parameters.options);
|
||||
|
||||
return {
|
||||
posts: Posts.find(parameters.find, parameters.options)
|
||||
postsIncoming: postsIncoming,
|
||||
posts: posts
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue