-
-
Save joellesenne/3683316 to your computer and use it in GitHub Desktop.
Bootswatch bookmarklet
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
if($('.bootswatcher')[0]){ | |
$('.bootswatcher').remove(); | |
} else { | |
var $e = $('<select class="bootswatcher"><option>Amelia</option><option>Cerulean</option><option>Cyborg</option><option>Journal</option><option>Readable</option><option>Simplex</option><option>Slate</option><option>Spacelab</option><option>Spruce</option><option>Superhero</option><option>United</option></select>'); | |
var l = 1 + Math.floor(Math.random() * $e.children().length); | |
$e.css({'z-index': '99999', 'position': 'fixed', 'top': '5px', 'right': '5px', 'opacity': '0.5'} | |
).hover( | |
function(){$(this).css('opacity', '1');}, | |
function(){$(this).css('opacity', '0.5');} | |
).change(function(){ | |
if(!$('link.bootswatcher')[0]){ | |
$('head').append('<link rel="stylesheet" class="bootswatcher">'); | |
} | |
$('link.bootswatcher').attr('href', 'http://bootswatch.com/' + $(this).find(':selected').text().toLowerCase() + '/bootstrap.min.css'); | |
}) | |
.find('option:nth-child(' + l + ')').attr('selected', 'selected').end() | |
.trigger('change'); | |
$('body').append($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment