Make stability checkbox sticky

This commit is contained in:
Tim Schaub
2014-11-11 20:06:26 -08:00
parent 84889d9dc5
commit 39010238b9

View File

@@ -54,11 +54,25 @@ $(function () {
_onResize();
// show/hide unstable items
var links = $('a[href^="ol."');
var unstable = $('.unstable');
var stabilityToggle = $('#stability-toggle');
stabilityToggle.change(function() {
unstable.toggleClass('hidden', this.checked);
var search = this.checked ? '' : '?unstable=true';
links.each(function(i, el) {
this.href = this.pathname + search + this.hash;
});
if (history.replaceState) {
var url = window.location.pathname + search + window.location.hash;
history.replaceState({}, '', url);
}
return false;
});
var search = window.location.search;
links.each(function(i, el) {
this.href = this.pathname + search + this.hash;
});
stabilityToggle.prop('checked', search !== '?unstable=true');
unstable.toggleClass('hidden', stabilityToggle[0].checked);
});