Changeset 299c79c in ammosreader for doc/html/_static/doctools.js
- Timestamp:
- 06/30/22 13:28:16 (3 years ago)
- Branches:
- AmmosSource, guix
- Children:
- 93661be
- Parents:
- eab48d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/html/_static/doctools.js
reab48d0 r299c79c 155 155 this.highlightSearchWords(); 156 156 this.initIndexTable(); 157 if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) { 158 this.initOnKeyListeners(); 159 } 157 this.initOnKeyListeners(); 160 158 }, 161 159 … … 270 268 }, 271 269 270 /** 271 * helper function to focus on search bar 272 */ 273 focusSearchBar : function() { 274 $('input[name=q]').first().focus(); 275 }, 276 272 277 /** 273 278 * make the url absolute … … 292 297 293 298 initOnKeyListeners: function() { 299 // only install a listener if it is really needed 300 if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS && 301 !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) 302 return; 303 294 304 $(document).keydown(function(event) { 295 305 var activeElementType = document.activeElement.tagName; 296 306 // don't navigate when in search box, textarea, dropdown or button 297 307 if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' 298 && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey 299 && !event.shiftKey) { 300 switch (event.keyCode) { 301 case 37: // left 302 var prevHref = $('link[rel="prev"]').prop('href'); 303 if (prevHref) { 304 window.location.href = prevHref; 305 return false; 306 } 307 break; 308 case 39: // right 309 var nextHref = $('link[rel="next"]').prop('href'); 310 if (nextHref) { 311 window.location.href = nextHref; 312 return false; 313 } 314 break; 308 && activeElementType !== 'BUTTON') { 309 if (event.altKey || event.ctrlKey || event.metaKey) 310 return; 311 312 if (!event.shiftKey) { 313 switch (event.key) { 314 case 'ArrowLeft': 315 if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) 316 break; 317 var prevHref = $('link[rel="prev"]').prop('href'); 318 if (prevHref) { 319 window.location.href = prevHref; 320 return false; 321 } 322 break; 323 case 'ArrowRight': 324 if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) 325 break; 326 var nextHref = $('link[rel="next"]').prop('href'); 327 if (nextHref) { 328 window.location.href = nextHref; 329 return false; 330 } 331 break; 332 case 'Escape': 333 if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) 334 break; 335 Documentation.hideSearchWords(); 336 return false; 337 } 338 } 339 340 // some keyboard layouts may need Shift to get / 341 switch (event.key) { 342 case '/': 343 if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) 344 break; 345 Documentation.focusSearchBar(); 346 return false; 315 347 } 316 348 }
Note:
See TracChangeset
for help on using the changeset viewer.