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 09:52:53 +09:00
|
|
|
var footer_code=$("#footer_code").val();
|
2012-09-21 07:51:47 +09:00
|
|
|
var analytics_code = $('#analytics_code').val();
|
2012-09-24 08:53:13 +09:00
|
|
|
var tlkio_channel = $('#tlkio_channel').val();
|
2012-09-24 11:31:45 +09:00
|
|
|
var mixpanel_id= $('#mixpanel_id').val();
|
2012-09-06 19:42:11 +09:00
|
|
|
var prevSetting=Settings.find().fetch()[0];
|
|
|
|
|
|
|
|
if(prevSetting){
|
|
|
|
Settings.update(prevSetting._id,{
|
|
|
|
$set: {
|
|
|
|
title: title,
|
2012-09-21 07:51:47 +09:00
|
|
|
theme: theme,
|
2012-09-24 09:41:15 +09:00
|
|
|
footer_code: footer_code,
|
2012-09-24 08:53:13 +09:00
|
|
|
analytics_code: analytics_code,
|
2012-09-24 11:31:45 +09:00
|
|
|
tlkio_channel: tlkio_channel,
|
|
|
|
mixpanel_id: mixpanel_id
|
2012-09-06 19:42:11 +09:00
|
|
|
}
|
2012-09-21 07:51:47 +09:00
|
|
|
}, function(){
|
|
|
|
throwError("Settings have been updated");
|
2012-09-06 19:42:11 +09:00
|
|
|
});
|
|
|
|
}else{
|
|
|
|
var settingId = Settings.insert({
|
|
|
|
title: title,
|
2012-09-21 07:51:47 +09:00
|
|
|
theme: theme,
|
2012-09-24 09:45:34 +09:00
|
|
|
footer_code: footer_code,
|
2012-09-24 08:53:13 +09:00
|
|
|
analytics_code: analytics_code,
|
2012-09-24 11:31:45 +09:00
|
|
|
tlkio_channel: tlkio_channel,
|
|
|
|
mixpanel_id: mixpanel_id
|
2012-09-21 07:51:47 +09:00
|
|
|
}, function(){
|
|
|
|
throwError("Settings have been created");
|
|
|
|
});
|
2012-09-06 19:42:11 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-09-24 12:12:14 +09:00
|
|
|
Template.settings.currentUserIsAdmin(){
|
|
|
|
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;}
|