2012-09-29 12:28:51 +09:00
|
|
|
Template.nav.helpers({
|
|
|
|
site_title: function(){
|
|
|
|
return getSetting('title');
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
logo_url: function(){
|
2012-09-29 12:28:51 +09:00
|
|
|
return getSetting('logoUrl');
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
logo_height: function(){
|
2012-09-29 12:28:51 +09:00
|
|
|
return getSetting('logoHeight');
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
logo_width: function(){
|
2012-09-29 12:28:51 +09:00
|
|
|
return getSetting('logoWidth');
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
logo_top: function(){
|
2012-09-29 12:28:51 +09:00
|
|
|
return Math.floor((70-getSetting('logoHeight'))/2);
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
logo_offset: function(){
|
2012-09-29 12:28:51 +09:00
|
|
|
return -Math.floor(getSetting('logoWidth')/2);
|
2012-10-05 11:02:03 +09:00
|
|
|
},
|
|
|
|
intercom: function(){
|
|
|
|
return !!getSetting('intercomId');
|
2012-10-05 13:59:40 +09:00
|
|
|
},
|
|
|
|
canPost: function(){
|
|
|
|
return canPost(Meteor.user());
|
2012-10-24 11:04:42 +09:00
|
|
|
},
|
|
|
|
requirePostsApproval: function(){
|
|
|
|
return getSetting('requirePostsApproval');
|
2013-04-06 16:50:40 +09:00
|
|
|
},
|
|
|
|
hasCategories: function(){
|
|
|
|
return Categories.find().count();
|
|
|
|
},
|
|
|
|
categories: function(){
|
|
|
|
return Categories.find();
|
2013-10-24 21:07:55 +09:00
|
|
|
},
|
|
|
|
categoryLink: function () {
|
|
|
|
return getCategoryUrl(this.slug);
|
2013-11-14 23:01:59 -05:00
|
|
|
},
|
|
|
|
query: function () {
|
|
|
|
return Session.get("query");
|
2013-11-15 15:29:39 +09:00
|
|
|
},
|
|
|
|
queryEmpty: function () {
|
|
|
|
return !!Session.get("query") ? '' : 'empty';
|
2013-04-06 16:50:40 +09:00
|
|
|
}
|
2013-11-14 23:01:59 -05:00
|
|
|
});
|
2013-11-15 15:29:39 +09:00
|
|
|
|
|
|
|
Template.nav.preserve({
|
|
|
|
'input#search': function (node) { return node.id; }
|
|
|
|
});
|
|
|
|
|
|
|
|
Template.nav.rendered=function(){
|
|
|
|
|
|
|
|
if(!Meteor.user()){
|
|
|
|
$('.login-link-text').text("Sign Up/Sign In");
|
|
|
|
}else{
|
|
|
|
$('#login-buttons-logout').before('<a href="/users/'+Meteor.user().slug+'" class="account-link button">View Profile</a>');
|
|
|
|
$('#login-buttons-logout').before('<a href="/account" class="account-link button">Edit Account</a>');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Template.nav.events = {
|
|
|
|
'click #logout': function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
Meteor.logout();
|
|
|
|
},
|
|
|
|
'click #mobile-menu': function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
$('body').toggleClass('mobile-nav-open');
|
|
|
|
},
|
|
|
|
'click .login-header': function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
Router.go('/account');
|
|
|
|
},
|
2013-11-16 12:51:33 +09:00
|
|
|
'keyup, change, search .search-field': function(e){
|
2013-11-15 15:29:39 +09:00
|
|
|
e.preventDefault();
|
|
|
|
var val = $(e.target).val(),
|
|
|
|
$search = $('.search');
|
|
|
|
if(val==''){
|
|
|
|
$search.addClass('empty');
|
|
|
|
}else{
|
|
|
|
$search.removeClass('empty');
|
|
|
|
}
|
|
|
|
Session.set('query', val);
|
|
|
|
}
|
|
|
|
};
|