Last active
January 4, 2016 01:48
-
-
Save digilord/8550332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Collection: | |
Site = new Meteor.Collection('site'); | |
// Publication: | |
Meteor.publish('site', function () { | |
var host = headers.get(this, 'host'); | |
return Site.find({'domain': host}); | |
}); | |
// helper for all templates. | |
Handlebars.registerHelper("site", function(){ | |
site = Site.findOne(); | |
theme = site.theme; | |
Session.set("theme", theme); | |
return site; | |
}); | |
Handlebars.registerHelper("siteTheme", function(){ | |
return Session.get('theme'); | |
}); | |
//theme = this._theme; // Help here. | |
//Session.set("theme", theme); | |
// Add theme class to html | |
siteTheme0 = function(){ | |
$('html').addClass('theme0'); | |
}; | |
siteTheme1 = function(){ | |
$('html').addClass('theme1'); | |
}; | |
siteTheme2 = function(){ | |
$('html').addClass('theme2'); | |
}; | |
siteTheme3 = function(){ | |
$('html').addClass('theme3'); | |
}; | |
// Change theme on change to db | |
Deps.autorun(function (c) { | |
if (Session.equals("theme", "1")){ | |
siteTheme1(); | |
} | |
else if (Session.equals("theme", "2")){ | |
siteTheme2(); | |
} | |
else if (Session.equals("theme", "3")){ | |
siteTheme3(); | |
} | |
else { | |
Session.set("theme", "0"); | |
siteTheme0(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment