|
90 | 90 | { label: 'FAQ', href: '{{ "/faq/" | relative_url }}' }, |
91 | 91 | { label: 'Scripts', href: '{{ "/scripts/" | relative_url }}' }, |
92 | 92 | { label: 'Details', href: '{{ "/details/" | relative_url }}' }, |
| 93 | + { label: 'IntelliJ IDEA', href: '{{ "/docs/intellij-idea/" | relative_url }}' }, |
93 | 94 | { label: 'Details - VS Code', href: '{{ "/docs/vscode-info/" | relative_url }}' } |
94 | 95 | ]; |
95 | 96 |
|
|
176 | 177 | }); |
177 | 178 | </script> |
178 | 179 |
|
| 180 | +{% if page.fork_ribbon != false %} |
179 | 181 | <!-- Fork ribbon styles + injector --> |
180 | 182 | <style> |
181 | | - /* Ribbon container positioned near top-left to avoid colliding with the site menu */ |
| 183 | + /* Ribbon container positioned near top-left or top-right to avoid colliding with the site menu */ |
182 | 184 | .fork-ribbon { |
183 | 185 | position: fixed; |
184 | 186 | top: 12px; |
185 | | - left: -52px; |
186 | 187 | z-index: 10000; |
187 | 188 | pointer-events: none; /* let underlying controls receive clicks except the link */ |
| 189 | + overflow: visible; |
188 | 190 | } |
189 | 191 |
|
190 | 192 | .fork-ribbon a { |
191 | 193 | pointer-events: auto; |
192 | 194 | display: block; |
193 | | - width: 220px; |
| 195 | + width: 160px; /* width tuned for visibility */ |
194 | 196 | background: #151513; /* GitHub-like dark ribbon */ |
195 | 197 | color: #fff; |
196 | 198 | text-decoration: none; |
|
199 | 201 | line-height: 1.4; |
200 | 202 | padding: 6px 0; |
201 | 203 | text-align: center; |
202 | | - transform: rotate(-45deg); |
203 | 204 | box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2); |
204 | 205 | border-radius: 2px; |
205 | 206 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; |
206 | | - } |
207 | | - |
208 | | - .fork-ribbon a:hover, |
209 | | - .fork-ribbon a:focus { |
210 | | - background: #0b0b0b; |
| 207 | + transform-origin: 0 0; |
211 | 208 | } |
212 | 209 |
|
213 | 210 | /* Hide ribbon on small screens where it can obstruct content */ |
|
217 | 214 | </style> |
218 | 215 |
|
219 | 216 | <script> |
220 | | - document.addEventListener('DOMContentLoaded', function () { |
221 | | - // Avoid inserting multiple times |
222 | | - if (document.querySelector('.fork-ribbon')) return; |
| 217 | + (function () { |
| 218 | + function injectForkRibbon() { |
| 219 | + // Avoid inserting multiple times |
| 220 | + if (document.querySelector('.fork-ribbon')) return; |
223 | 221 |
|
224 | | - // Prefer site.social.github (format: owner/repo), fall back to site.github if present |
225 | | - var repo = "{{ site.social.github | default: site.github | escape }}"; |
226 | | - if (!repo) return; |
| 222 | + // Prefer site.social.github (format: owner/repo), fall back to site.github if present |
| 223 | + var repo = "{{ site.social.github | default: site.github | escape }}"; |
| 224 | + if (!repo) return; |
227 | 225 |
|
228 | | - var url = 'https://github.com/' + repo; |
| 226 | + var url = 'https://github.com/' + repo; |
229 | 227 |
|
230 | | - var container = document.createElement('div'); |
231 | | - container.className = 'fork-ribbon'; |
| 228 | + var container = document.createElement('div'); |
| 229 | + container.className = 'fork-ribbon'; |
232 | 230 |
|
233 | | - var anchor = document.createElement('a'); |
234 | | - anchor.href = url; |
235 | | - anchor.target = '_blank'; |
236 | | - anchor.rel = 'noopener noreferrer'; |
237 | | - anchor.setAttribute('aria-label', 'Fork me on GitHub'); |
238 | | - anchor.textContent = 'Fork me on GitHub'; |
| 231 | + var anchor = document.createElement('a'); |
| 232 | + anchor.href = url; |
| 233 | + anchor.target = '_blank'; |
| 234 | + anchor.rel = 'noopener noreferrer'; |
| 235 | + anchor.setAttribute('aria-label', 'Fork me on GitHub'); |
| 236 | + |
| 237 | + // Detect floating site menu to avoid collision |
| 238 | + var hasSiteMenu = !!document.querySelector('[data-site-menu]'); |
| 239 | + |
| 240 | + // Build the inner HTML (SVG icon + text) |
| 241 | + var svg = '<svg aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" style="vertical-align:middle;fill:currentColor;">\n <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.539 2.292 6.532 5.47 7.594.4.073.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.225.483-2.695-1.073-2.695-1.073-.364-.924-.89-1.171-.89-1.171-.727-.497.055-.487.055-.487.803.056 1.226.825 1.226.825.714 1.223 1.872.87 2.329.665.072-.517.28-.87.508-1.07-1.777-.202-3.644-.888-3.644-3.952 0-.873.312-1.587.824-2.148-.083-.203-.357-1.019.078-2.124 0 0 .672-.215 2.2.82.638-.177 1.322-.266 2.003-.269.68.003 1.365.092 2.004.269 1.527-1.035 2.198-.82 2.198-.82.437 1.105.163 1.92.08 2.124.513.561.823 1.275.823 2.148 0 3.073-1.87 3.748-3.65 3.946.287.247.543.733.543 1.479 0 1.068-.01 1.932-.01 2.196 0 .214.145.462.55.384C13.71 14.53 16 11.538 16 8c0-4.42-3.58-8-8-8z"/></svg>'; |
| 242 | + anchor.innerHTML = svg + '<span class="fork-text">Fork me</span>'; |
| 243 | + |
| 244 | + // Add small icon/text styles |
| 245 | + anchor.style.display = 'inline-flex'; |
| 246 | + anchor.style.alignItems = 'center'; |
| 247 | + anchor.style.justifyContent = 'center'; |
| 248 | + anchor.style.gap = '8px'; |
| 249 | + anchor.style.color = '#fff'; |
| 250 | + anchor.style.textDecoration = 'none'; |
| 251 | + |
| 252 | + if (hasSiteMenu) { |
| 253 | + // Place on left and rotate -45deg |
| 254 | + container.style.left = '-44px'; |
| 255 | + anchor.style.transform = 'rotate(-45deg)'; |
| 256 | + anchor.style.transformOrigin = '0 0'; |
| 257 | + } else { |
| 258 | + // Place on right and rotate 45deg |
| 259 | + container.style.right = '-44px'; |
| 260 | + anchor.style.transform = 'rotate(45deg)'; |
| 261 | + anchor.style.transformOrigin = '100% 0'; |
| 262 | + } |
239 | 263 |
|
240 | | - container.appendChild(anchor); |
241 | | - document.body.appendChild(container); |
242 | | - }); |
243 | | -</script> |
| 264 | + container.appendChild(anchor); |
| 265 | + |
| 266 | + // If body exists, append normally |
| 267 | + if (document.body) { |
| 268 | + document.body.appendChild(container); |
| 269 | + return; |
| 270 | + } |
| 271 | + |
| 272 | + // If document isn't parsed yet, attempt document.write as a fallback so the element ends up in the document |
| 273 | + try { |
| 274 | + if (typeof document.write === 'function' && document.readyState === 'loading') { |
| 275 | + var posAttr = hasSiteMenu ? 'left:-44px' : 'right:-44px'; |
| 276 | + var rotation = hasSiteMenu ? 'transform:rotate(-45deg);transform-origin:0 0;' : 'transform:rotate(45deg);transform-origin:100% 0;'; |
| 277 | + var html = '<div class="fork-ribbon" style="top:12px;' + posAttr + '"><a style="display:block;width:160px;' + rotation + '" href="' + url + '" target="_blank" rel="noopener noreferrer">' + svg + '<span style="display:inline-block;margin-left:8px;vertical-align:middle;color:#fff">Fork me</span></a></div>'; |
| 278 | + document.write(html); |
| 279 | + return; |
| 280 | + } |
| 281 | + } catch (e) { |
| 282 | + // ignore and continue to last-resort append below |
| 283 | + } |
| 284 | + |
| 285 | + // As a last resort, append to documentElement |
| 286 | + (document.documentElement || document).appendChild(container); |
| 287 | + } |
244 | 288 |
|
| 289 | + // Run immediately if DOM is already available, otherwise wait for DOMContentLoaded. |
| 290 | + if (document.readyState === 'loading') { |
| 291 | + document.addEventListener('DOMContentLoaded', function () { |
| 292 | + injectForkRibbon(); |
| 293 | + }); |
| 294 | + // Also run on window.load to catch pages that defer document modifications |
| 295 | + window.addEventListener('load', function () { injectForkRibbon(); }); |
| 296 | + // Fallback in case DOMContentLoaded doesn't fire for some reason in certain pages |
| 297 | + setTimeout(function () { injectForkRibbon(); }, 3000); |
| 298 | + } else { |
| 299 | + try { |
| 300 | + injectForkRibbon(); |
| 301 | + } catch (e) { |
| 302 | + // If anything goes wrong, try again shortly |
| 303 | + setTimeout(injectForkRibbon, 3000); |
| 304 | + } |
| 305 | + } |
| 306 | + })(); |
| 307 | +</script> |
| 308 | +{% endif %} |
0 commit comments