Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save "Preview theme" state; resolves #13940 #13954

Merged
merged 1 commit into from
Jun 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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