From 39010238b9c6d4ceec80740e8df8ce92b4e86c07 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 11 Nov 2014 20:06:26 -0800 Subject: [PATCH] Make stability checkbox sticky --- config/jsdoc/api/template/static/scripts/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/jsdoc/api/template/static/scripts/main.js b/config/jsdoc/api/template/static/scripts/main.js index 9a368453c6..637f6d7e65 100644 --- a/config/jsdoc/api/template/static/scripts/main.js +++ b/config/jsdoc/api/template/static/scripts/main.js @@ -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); });