Vulcan/client/app.js

75 lines
2.2 KiB
JavaScript
Raw Normal View History

2012-10-08 10:44:13 +09:00
Errors = new Meteor.Collection(null);
Meteor.subscribe('users');
2012-09-06 15:28:58 +09:00
2012-08-22 21:27:22 -04:00
Posts = new Meteor.Collection('posts');
2012-10-08 16:12:47 +02:00
Session.set('page_size', 8);
Session.set('current_page', 1);
Session.set('sort_order', JSON.stringify({score: -1}));
Meteor.autosubscribe(function() {
Meteor.subscribe('posts', Session.get('page_size'), Session.get('current_page'), Session.get('sort_order'), function() {
var newPostsCount = Posts.find().count();
if (Session.equals('posts_count', newPostsCount)) {
// We didn't fetch any new post, so hide the "View more" button:
$('button.more').hide();
}
else {
Session.set('posts_count', newPostsCount);
$('button.more').show();
}
});
});
2012-08-22 21:27:22 -04:00
2012-08-22 23:24:33 -04:00
Comments = new Meteor.Collection('comments');
Meteor.subscribe('comments', function() {
StyleNewRecords = new Date();
});
2012-08-23 00:15:48 -04:00
Notifications = new Meteor.Collection('notifications');
Meteor.subscribe('notifications');
2012-08-30 21:35:48 -04:00
2012-09-06 19:42:11 +09:00
Settings = new Meteor.Collection('settings');
2012-09-24 15:36:37 +09:00
Meteor.subscribe('settings', function(){
2012-10-01 12:23:35 +09:00
// runs once on site load
2012-10-08 16:49:01 +09:00
window.settingsLoaded=true;
if((proxinoKey=getSetting('proxinoKey'))){
2012-09-24 15:36:37 +09:00
Proxino.key = proxinoKey;
Proxino.track_errors();
}
2012-10-08 16:49:01 +09:00
// window.Router = new SimpleRouter();
window.Backbone.history.start({pushState: true});
2012-09-24 15:36:37 +09:00
});
2012-09-06 19:42:11 +09:00
2012-09-15 18:41:08 +09:00
$.fn.exists = function () {
return this.length !== 0;
}
2012-10-01 14:52:32 +09:00
2012-10-04 14:54:26 +09:00
$(document).bind('keyup', 'ctrl+n', function(){
$('.notifications').toggleClass('hidden');
2012-10-05 22:09:13 +09:00
});
Handlebars.registerHelper('canView', function(action) {
2012-10-08 16:49:01 +09:00
var action=(typeof action !== 'string') ? null : action;
return canView(Meteor.user(), action);
2012-10-05 22:09:13 +09:00
});
Handlebars.registerHelper('canPost', function(action) {
2012-10-08 16:49:01 +09:00
var action=(typeof action !== 'string') ? null : action;
return canPost(Meteor.user(), action);
2012-10-05 22:09:13 +09:00
});
Handlebars.registerHelper('canComment', function(action) {
2012-10-08 16:49:01 +09:00
var action=(typeof action !== 'string') ? null : action;
return canComment(Meteor.user(), action);
2012-10-05 22:09:13 +09:00
});
Handlebars.registerHelper('canUpvote', function(collection, action) {
2012-10-08 16:49:01 +09:00
var action=(typeof action !== 'string') ? null : action;
return canUpvote(Meteor.user()), collection, action;
2012-10-05 22:09:13 +09:00
});
Handlebars.registerHelper('canDownvote', function(collection, action) {
2012-10-08 16:49:01 +09:00
var action=(typeof action !== 'string') ? null : action;
return canDownvote(Meteor.user(), collection, action);
2012-10-04 14:54:26 +09:00
});