-
-
Save jon-adams/d7708d84f1af10241dd5 to your computer and use it in GitHub Desktop.
Switch bootswatch templates via a 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
javascript: (function (w) { | |
if (!w.jQuery) { | |
alert('jQuery is required.'); | |
return; | |
} | |
if ($('#bootswatch').length) { | |
alert('Bookmaklet already loaded.'); | |
return; | |
} | |
var $link = $('<link>', { | |
rel: 'stylesheet', | |
id: 'bootswatch' | |
}).appendTo('head'); | |
var $select = $('<select>', { | |
css: { | |
top: 8, | |
right: 8, | |
position: 'fixed', | |
zIndex: 999999 | |
}, | |
html: '<option value="null">Bootswatch</option>' | |
}).appendTo('body'); | |
$select.on('change', function (e) { | |
var value = $select.val(); | |
value && $link.attr('href', value); | |
}); | |
$.ajax({ | |
url: '//api.bootswatch.com/3/' | |
}).done(function (data, status, xhr) { | |
data.themes.forEach(function (val, key) { | |
$select.append('<option value="' + val.cssCdn + '">' + val.name + '</option>'); | |
}); | |
}); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment