Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Last active June 8, 2016 05:00
Show Gist options
  • Select an option

  • Save delphinpro/40060d6979fa418e2d3c1addaed8924c to your computer and use it in GitHub Desktop.

Select an option

Save delphinpro/40060d6979fa418e2d3c1addaed8924c to your computer and use it in GitHub Desktop.
$(function () {
if (location.hash == '#dev') {
$('body').addClass('dev').attr('id', 'dev');
$btn = $('<button/>', {
text: 'Toggle'
}).css({
position: 'fixed',
right : 0,
bottom : 0,
zIndex : 2147483647,
fontSize: '30px'
});
$btn.appendTo('body');
var old = true;
var $link = $('head').find('link[href="assets/templates/101/style.css"]');
var toggleStyles = function() {
if (old) {
var time = new Date();
v = time.getTime();
$link.attr('href', 'assets/templates/101/style2.css' + '?v=' + v);
} else {
$link.attr('href', 'assets/templates/101/style.css');
}
old = !old;
}
toggleStyles();
$btn.on('click', toggleStyles);
$('a[href]').each(function () {
var href = $(this).attr('href');
if (href.substr(0, 1) != '#') {
$(this).attr('href', href + '#dev');
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment