Skip to content

Instantly share code, notes, and snippets.

@jon-adams
Forked from TuckerWhitehouse/bootswatchlet.js
Created March 19, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jon-adams/d7708d84f1af10241dd5 to your computer and use it in GitHub Desktop.
Save jon-adams/d7708d84f1af10241dd5 to your computer and use it in GitHub Desktop.
Switch bootswatch templates via a bookmarklet
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