mirror of https://github.com/twbs/bootstrap.git
				
				
				
			Merge pull request #13954 from hnrch02/persist-preview-theme
Save "Preview theme" state; resolves #13940
This commit is contained in:
		
						commit
						018114fc09
					
				| 
						 | 
				
			
			@ -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')
 | 
			
		||||
| 
						 | 
				
			
			@ -62,15 +60,25 @@
 | 
			
		|||
    ;(function () {
 | 
			
		||||
      var stylesheetLink = $('#bs-theme-stylesheet')
 | 
			
		||||
      var themeBtn = $('.bs-docs-theme-toggle')
 | 
			
		||||
      themeBtn.click(function () {
 | 
			
		||||
        var href = stylesheetLink.attr('href');
 | 
			
		||||
        if (!href || href.indexOf('data') === 0) {
 | 
			
		||||
 | 
			
		||||
      var activateTheme = function () {
 | 
			
		||||
        stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
 | 
			
		||||
        themeBtn.text('Disable theme preview')
 | 
			
		||||
        localStorage.setItem('previewTheme', true)
 | 
			
		||||
      }
 | 
			
		||||
        else {
 | 
			
		||||
 | 
			
		||||
      if (localStorage.getItem('previewTheme')) {
 | 
			
		||||
        activateTheme()
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      themeBtn.click(function () {
 | 
			
		||||
        var href = stylesheetLink.attr('href')
 | 
			
		||||
        if (!href || href.indexOf('data') === 0) {
 | 
			
		||||
          activateTheme()
 | 
			
		||||
        } else {
 | 
			
		||||
          stylesheetLink.attr('href', '')
 | 
			
		||||
          themeBtn.text('Preview theme')
 | 
			
		||||
          localStorage.removeItem('previewTheme')
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    })();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue