BigW Consortium Gitlab

shortcuts_navigation.js 2.92 KB
Newer Older
1
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, prefer-arrow-callback, consistent-return, no-return-assign */
2 3
/* global Mousetrap */
/* global Shortcuts */
Fatih Acet committed
4

5
require('./shortcuts');
Fatih Acet committed
6 7 8 9 10 11 12 13 14 15 16 17 18

(function() {
  var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  this.ShortcutsNavigation = (function(superClass) {
    extend(ShortcutsNavigation, superClass);

    function ShortcutsNavigation() {
      ShortcutsNavigation.__super__.constructor.call(this);
      Mousetrap.bind('g p', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-project');
      });
19 20 21
      Mousetrap.bind('g e', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-project-activity');
      });
Fatih Acet committed
22 23 24 25 26 27 28 29 30 31 32 33
      Mousetrap.bind('g f', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-tree');
      });
      Mousetrap.bind('g c', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-commits');
      });
      Mousetrap.bind('g b', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-builds');
      });
      Mousetrap.bind('g n', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-network');
      });
34 35 36
      Mousetrap.bind('g g', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-repository-charts');
      });
Fatih Acet committed
37 38 39
      Mousetrap.bind('g i', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-issues');
      });
40 41 42
      Mousetrap.bind('g l', function() {
        ShortcutsNavigation.findAndFollowLink('.shortcuts-issue-boards');
      });
Fatih Acet committed
43 44 45
      Mousetrap.bind('g m', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-merge_requests');
      });
46 47 48
      Mousetrap.bind('g t', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-todos');
      });
Fatih Acet committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
      Mousetrap.bind('g w', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-wiki');
      });
      Mousetrap.bind('g s', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-snippets');
      });
      Mousetrap.bind('i', function() {
        return ShortcutsNavigation.findAndFollowLink('.shortcuts-new-issue');
      });
      this.enabledHelp.push('.hidden-shortcut.project');
    }

    ShortcutsNavigation.findAndFollowLink = function(selector) {
      var link;
      link = $(selector).attr('href');
      if (link) {
        return window.location = link;
      }
    };

    return ShortcutsNavigation;
  })(Shortcuts);
71
}).call(window);