Vulcan/client/templates/settings.js

69 lines
2 KiB
JavaScript
Raw Normal View History

2012-09-06 19:42:11 +09:00
Template.settings.events = {
'click input[type=submit]': function(e){
e.preventDefault();
if(!Meteor.user()) throw 'You must be logged in.';
var title= $('#title').val();
var theme = $('#theme').val();
2012-09-24 15:36:37 +09:00
var footerCode=$("#footer_code").val();
2012-09-24 16:12:50 +09:00
console.log(footerCode);
2012-09-24 15:36:37 +09:00
var analyticsCode = $('#analytics_code').val();
var tlkioChannel = $('#tlkio_channel').val();
var mixpanelId= $('#mixpanel_id').val();
var proxinoKey=$('#proxino_key').val();
2012-09-06 19:42:11 +09:00
var prevSetting=Settings.find().fetch()[0];
2012-09-24 15:36:37 +09:00
2012-09-06 19:42:11 +09:00
if(prevSetting){
Settings.update(prevSetting._id,{
$set: {
title: title,
theme: theme,
2012-09-24 15:36:37 +09:00
footerCode: footerCode,
analyticsCode: analyticsCode,
tlkioChannel: tlkioChannel,
mixpanelId: mixpanelId,
proxinoKey: proxinoKey
2012-09-06 19:42:11 +09:00
}
}, function(){
throwError("Settings have been updated");
2012-09-06 19:42:11 +09:00
});
}else{
var settingId = Settings.insert({
2012-09-24 15:36:37 +09:00
title: title,
theme: theme,
footerCode: footerCode,
analyticsCode: analyticsCode,
tlkioChannel: tlkioChannel,
mixpanelId: mixpanelId,
proxinoKey: proxinoKey
}, function(){
throwError("Settings have been created");
});
2012-09-06 19:42:11 +09:00
}
}
};
2012-09-24 14:29:54 +09:00
Template.settings.currentUserIsAdmin = function(){
return currentUserIsAdmin();
}
2012-09-06 19:42:11 +09:00
Template.settings.no_settings = function(){
if(Settings.find().fetch()[0]){
return false;
}
return true;
}
Template.settings.setting = function(){
var setting = Settings.find().fetch()[0];
return setting;
};
Template.settings.is_theme = function(theme){
if(theme==this.setting.theme){
return true;
}
return false;
};
Template.settings.is_ascndr = function(){return this.theme=="ascndr" ? true : false;}
Template.settings.is_telescope = function(){return this.theme=="telescope" ? true : false;}
Template.settings.is_default = function(){return this.theme=="default" ? true : false;}