-
-
Save brh55/5629850a14ded5a35453 to your computer and use it in GitHub Desktop.
Client-Side Stylesheet Replacer with jQuery--Simple, not efficient, but works.
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
<select name="theme-menu" id="themes" > | |
<option value="override">Default Theme</option> | |
<option value="penn-theme">Penn Theme</option> | |
<option value="neutral-theme">Neutral Theme</option> | |
</select> |
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
$( document ).ready(function() { | |
var theme; | |
function setTheme(theme){ | |
switch (theme) { | |
case "override": | |
$('link[rel=stylesheet][href$="penntheme.css"]').remove(); | |
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove(); | |
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />'); | |
break; | |
case "penn": | |
$('link[rel=stylesheet][href$="override.css"]').remove(); | |
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove(); | |
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />'); | |
break; | |
case "neutral": | |
$('link[rel=stylesheet][href$="override.css"]').remove(); | |
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove(); | |
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />'); | |
break; | |
} | |
} | |
$('select[name="theme-menu"]').change(function() { | |
theme = $('#themes').val(); | |
setTheme(theme); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment