2010-12-10 05:27:41 +00:00
|
|
|
function changeTheme(theme, setCookie) {
|
2010-11-23 06:09:18 +00:00
|
|
|
el = $('html');
|
|
|
|
|
|
|
|
if (!theme) theme = el.hasClass('dark') ? 'light': 'dark';
|
|
|
|
else if (el.hasClass(theme)) return;
|
|
|
|
|
|
|
|
el.removeClass('light');
|
|
|
|
el.removeClass('dark');
|
|
|
|
el.addClass(theme);
|
|
|
|
setThemePreference(theme);
|
|
|
|
}
|
|
|
|
|
2010-12-10 05:27:41 +00:00
|
|
|
function changeSyntax(style, setCookie){
|
2010-11-24 17:59:48 +00:00
|
|
|
el = $('html');
|
2010-12-10 05:27:41 +00:00
|
|
|
el.removeClass('scss'); el.removeClass('sass');
|
|
|
|
el.addClass(style);
|
|
|
|
setStyleSyntaxPreference(style);
|
|
|
|
}
|
2010-11-23 06:09:18 +00:00
|
|
|
|
2010-12-10 05:27:41 +00:00
|
|
|
function changeExampleStyleSyntax(style, setCookie){
|
|
|
|
el = $('html');
|
|
|
|
el.removeClass('scss'); el.removeClass('sass'); el.removeClass('css');
|
|
|
|
el.addClass(style);
|
|
|
|
setExampleStyleSyntaxPreference(style);
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeExampleMarkupSyntax(markup){
|
|
|
|
el = $('html');
|
|
|
|
el.removeClass('haml'); el.removeClass('html');
|
|
|
|
el.addClass(markup);
|
|
|
|
setExampleMarkupSyntaxPreference(markup);
|
2010-11-23 06:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setThemePreference(theme) {
|
|
|
|
$.cookie("compass-theme", null);
|
|
|
|
$.cookie("compass-theme", theme, {
|
|
|
|
expires: 60 * 60 * 24 * 365 * 10,
|
|
|
|
path: '/'
|
|
|
|
});
|
|
|
|
}
|
2010-12-10 05:27:41 +00:00
|
|
|
|
2010-11-23 06:09:18 +00:00
|
|
|
function getThemePreference(defaultTheme) {
|
|
|
|
theme = $.cookie("compass-theme");
|
|
|
|
if (theme) {
|
2010-12-10 05:27:41 +00:00
|
|
|
changeTheme(theme, false);
|
2010-11-23 06:09:18 +00:00
|
|
|
} else {
|
2010-12-10 05:27:41 +00:00
|
|
|
changeTheme(defaultTheme, true);
|
2010-11-23 06:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-10 05:27:41 +00:00
|
|
|
|
|
|
|
function setStyleSyntaxPreference (mainSyntax) {
|
2010-11-23 06:09:18 +00:00
|
|
|
$.cookie("compass-syntax", null);
|
2010-12-10 05:27:41 +00:00
|
|
|
$.cookie("compass-syntax", mainSyntax, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
|
2010-11-23 06:09:18 +00:00
|
|
|
}
|
2010-12-10 05:27:41 +00:00
|
|
|
|
|
|
|
function setExampleStyleSyntaxPreference (exampleStyle) {
|
|
|
|
$.cookie("compass-example-style", null);
|
|
|
|
$.cookie("compass-example-style", exampleStyle, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
|
|
|
|
}
|
|
|
|
|
|
|
|
function setExampleMarkupSyntaxPreference (exampleMarkup) {
|
|
|
|
$.cookie("compass-example-markup", null);
|
|
|
|
$.cookie("compass-example-markup", exampleMarkup, { expires: 60 * 60 * 24 * 365 * 10, path: '/' });
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSyntaxPreference(defaultSyntax, defaultMarkup) {
|
|
|
|
mainSyntaxCookie = $.cookie("compass-syntax");
|
|
|
|
mainSyntax = (mainSyntaxCookie) ? mainSyntaxCookie : defaultSyntax;
|
|
|
|
changeSyntax(mainSyntax);
|
|
|
|
|
|
|
|
// add example styling preferences
|
|
|
|
if ($('body').hasClass('demo')){
|
|
|
|
markupCookie = $.cookie("compass-example-markup");
|
|
|
|
styleCookie = $.cookie("compass-example-style");
|
|
|
|
|
|
|
|
markup = (markupCookie) ? markupCookie : defaultMarkup;
|
|
|
|
style = (styleCookie) ? styleCookie : defaultSyntax;
|
|
|
|
|
|
|
|
changeExampleStyleSyntax(style)
|
|
|
|
changeExampleMarkupSyntax(markup);
|
2010-11-23 06:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-24 17:59:48 +00:00
|
|
|
getThemePreference('dark');
|
|
|
|
|
2010-11-23 06:09:18 +00:00
|
|
|
$('document').ready(function(){
|
2010-12-10 05:27:41 +00:00
|
|
|
getSyntaxPreference('scss', 'html');
|
|
|
|
|
2010-11-23 06:09:18 +00:00
|
|
|
$('#page').click(function(event){
|
|
|
|
var target = $(event.target);
|
2010-12-10 05:27:41 +00:00
|
|
|
|
|
|
|
// Set Main Syntax Preference
|
2010-11-23 06:09:18 +00:00
|
|
|
if (target.parent().is('#syntax_pref')) {
|
2010-12-10 05:27:41 +00:00
|
|
|
changeSyntax(target.attr("rel"), true);
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
// Set Demo page syntax preferences
|
|
|
|
} else if (target.parent().is('.syntax_pref')) {
|
2010-11-23 06:09:18 +00:00
|
|
|
event.preventDefault();
|
2010-12-10 05:27:41 +00:00
|
|
|
if (target.parent().parent().is('#markup')) {
|
|
|
|
changeExampleMarkupSyntax(target.attr("rel"), true);
|
|
|
|
} else {
|
|
|
|
changeExampleStyleSyntax(target.attr("rel"), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set Theme preference
|
2010-11-23 06:09:18 +00:00
|
|
|
} else if (target.is('#theme_pref') || target.parent().is('#theme_pref')) {
|
|
|
|
changeTheme();
|
|
|
|
event.preventDefault();
|
2010-12-10 05:27:41 +00:00
|
|
|
|
|
|
|
// View source for mixins
|
2010-11-23 06:09:18 +00:00
|
|
|
} else if (target.attr("rel") == "view source") {
|
|
|
|
$(target.attr("href")).toggle();
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
2010-12-10 05:27:41 +00:00
|
|
|
});
|