Skip to content

Commit

Permalink
Save "Preview theme" state; resolves twbs#13940
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrch02 committed Jun 27, 2014
1 parent 2b6f00c commit 92ca842
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docs/assets/js/_src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
$body.scrollspy('refresh')
})


// Kill links
$('.bs-docs-container [href=#]').click(function (e) {
e.preventDefault()
})


// Sidenav affixing
setTimeout(function () {
var $sideBar = $('.bs-docs-sidebar')
Expand Down Expand Up @@ -62,15 +60,25 @@
;(function () {
var stylesheetLink = $('#bs-theme-stylesheet')
var themeBtn = $('.bs-docs-theme-toggle')

var activateTheme = function () {
stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
themeBtn.text('Disable theme preview')
localStorage.setItem('previewTheme', true)
}

if (localStorage.getItem('previewTheme')) {
activateTheme()
}

themeBtn.click(function () {
var href = stylesheetLink.attr('href');
var href = stylesheetLink.attr('href')
if (!href || href.indexOf('data') === 0) {
stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
themeBtn.text('Disable theme preview')
}
else {
activateTheme()
} else {
stylesheetLink.attr('href', '')
themeBtn.text('Preview theme')
localStorage.removeItem('previewTheme')
}
})
})();
Expand Down

0 comments on commit 92ca842

Please sign in to comment.