| 103 | } |
| 104 | |
| 105 | function setActiveLink(activeElm) { |
| 106 | var activeHref = activeElm.getAttribute('href'); |
| 107 | var activeTitle = activeElm.getAttribute('title'); |
| 108 | var inactiveElms = document.querySelectorAll('link[title]:not([href*="' + activeHref + '"]):not([title="' + activeTitle + '"])'); |
| 109 | |
| 110 | // Remove "alternate" keyword |
| 111 | activeElm.setAttribute('rel', (activeElm.rel || '').replace(/\s*alternate/g, '').trim()); |
| 112 | |
| 113 | // Force enable stylesheet (required for some browsers) |
| 114 | activeElm.disabled = true; |
| 115 | activeElm.disabled = false; |
| 116 | |
| 117 | // Store active style sheet |
| 118 | sessionStorage.setItem(sessionStorageKey, activeHref); |
| 119 | |
| 120 | // Disable other elms |
| 121 | for (var i = 0; i < inactiveElms.length; i++) { |
| 122 | var elm = inactiveElms[i]; |
| 123 | |
| 124 | elm.disabled = true; |
| 125 | |
| 126 | // Fix for browsersync and alternate stylesheet updates. Will |
| 127 | // cause FOUC when switching stylesheets during development, but |
| 128 | // required to properly apply style updates when alternate |
| 129 | // stylesheets are enabled. |
| 130 | if (window.browsersyncObserver) { |
| 131 | var linkRel = elm.getAttribute('rel') || ''; |
| 132 | var linkRelAlt = linkRel.indexOf('alternate') > -1 ? linkRel : (linkRel + ' alternate').trim(); |
| 133 | |
| 134 | elm.setAttribute('rel', linkRelAlt); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // CSS custom property ponyfil |
| 139 | if ((window.$docsify || {}).themeable) { |
| 140 | window.$docsify.themeable.util.cssVars(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // Event listeners |
| 145 | if (!isInitialzed) { |