Changeset 93661be in ammosreader for public/_static/doctools.js


Ignore:
Timestamp:
06/30/22 13:32:20 (3 years ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
AmmosSource, guix
Children:
1491313
Parents:
299c79c
Message:

sphinx-apidoc run again

File:
1 moved

Legend:

Unmodified
Added
Removed
  • public/_static/doctools.js

    r299c79c r93661be  
    155155    this.highlightSearchWords();
    156156    this.initIndexTable();
    157     if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
    158       this.initOnKeyListeners();
    159     }
     157    this.initOnKeyListeners();
    160158  },
    161159
     
    270268  },
    271269
     270   /**
     271   * helper function to focus on search bar
     272   */
     273  focusSearchBar : function() {
     274    $('input[name=q]').first().focus();
     275  },
     276
    272277  /**
    273278   * make the url absolute
     
    292297
    293298  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
    294304    $(document).keydown(function(event) {
    295305      var activeElementType = document.activeElement.tagName;
    296306      // don't navigate when in search box, textarea, dropdown or button
    297307      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;
    315347        }
    316348      }
Note: See TracChangeset for help on using the changeset viewer.