Vulcan/client/grid.js

122 lines
3.2 KiB
JavaScript
Raw Normal View History

2012-08-22 21:27:22 -04:00
Posts = new Meteor.Collection('posts');
Meteor.subscribe('posts');
2012-08-22 23:24:33 -04:00
Comments = new Meteor.Collection('comments');
Meteor.subscribe('comments');
2012-08-23 00:15:48 -04:00
2012-08-30 21:35:48 -04:00
MyVotes = new Meteor.Collection('myvotes');
Meteor.subscribe('myvotes');
2012-08-23 00:15:48 -04:00
Session.set('state', 'list');
2012-09-02 23:51:18 +09:00
if (Meteor.is_client) {
SimpleRouter = FilteredRouter.extend({
initialize: function() {
FilteredRouter.prototype.initialize.call(this);
this.filter(this.require_login, {only: ['submit']});
},
require_login: function(page) {
console.log(Meteor.user());
if (Meteor.user()) {
return page;
} else {
return 'signin';
2012-09-02 23:51:18 +09:00
}
},
routes: {
'': 'top',
'test':'test',
'signin':'signin',
'signup':'signup',
'submit':'submit',
2012-09-05 11:55:06 +09:00
'posts/:id':'post',
'posts/:id/edit':'post_edit',
2012-09-05 11:55:06 +09:00
'comments/:id':'comment'
},
top: function() { console.log("top"); this.goto('top'); },
test: function() {console.log("test"); this.goto('test'); },
signup: function() {console.log("signup"); this.goto('signup'); },
signin: function() {console.log("signin"); this.goto('signin'); },
submit: function() {console.log("submit"); this.goto('submit'); },
2012-09-05 11:55:06 +09:00
post: function(id) {
console.log("post, id="+id);
Session.set('selected_post_id', id);
this.goto('post_page');
},
post_edit: function(id) {
console.log("post_edit, id="+id);
Session.set('selected_post_id', id);
this.goto('post_edit');
},
2012-09-05 11:55:06 +09:00
comment: function(id) {
console.log("comment, id="+id);
Session.set('selected_comment_id', id);
this.goto('comment_page');
2012-09-05 11:55:06 +09:00
},
});
var Router = new SimpleRouter();
Meteor.startup(function() {
Backbone.history.start({pushState: true});
});
2012-09-02 23:51:18 +09:00
}
// Template.sign_in.events = {
// 'submit form': function(e) {
// e.preventDefault();
// Session.set('username', $(event.target).find('[name=username]').val())
// }
// }
// Template.home.events = {
// 'click .welcome': function(e) {
// e.preventDefault();
// Router.navigate('welcome', {trigger: true});
// }
// }
// Template.welcome.username = function() { return Session.get('username'); }
// Template.welcome.events = {
// 'click .logout': function(e) {
// e.preventDefault();
// Session.set('username', false);
// },
// 'click .home': function(e) {
// e.preventDefault();
// Router.navigate('', {trigger: true});
// }
// }
// if (Meteor.is_client) {
// Meteor.startup(function () {
// $(document).ready(function (){
// console.log($('#mobile-menu'));
// $('#mobile-menu').pageslide({
// iframe: false
// });
// if($(window).width()>400){ //do not load social media plugin on mobile
// console.log($('.share-replace'));
// $('.share-replace').sharrre({
// share: {
// googlePlus: true,
// facebook: true,
// twitter: true,
// },
// buttons: {
// googlePlus: {size: 'tall'},
// facebook: {layout: 'box_count'},
// twitter: {count: 'vertical'},
// },
// enableHover: false,
// enableCounter: false,
// enableTracking: true
// });
// }
// });
// });
// }