• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MarkUsProject / Markus / 19015621437

02 Nov 2025 05:21PM UTC coverage: 91.565% (-0.005%) from 91.57%
19015621437

Pull #7726

github

web-flow
Merge ce09d631e into 487a41c23
Pull Request #7726: Refactor Active Criterion Component Logic

843 of 1701 branches covered (49.56%)

Branch coverage included in aggregate %.

42 of 56 new or added lines in 5 files covered. (75.0%)

15 existing lines in 1 file now uncovered.

42793 of 45955 relevant lines covered (93.12%)

121.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

13.19
/app/javascript/Components/Result/keybinding.js
1
// Open the keyboard shortcuts help modal
2
import Mousetrap from "mousetrap";
3

4
export function bind_keybindings() {
5
  Mousetrap.bind("?", function () {
31✔
6
    modal_help.open();
×
7
  });
8

9
  function is_text_selected() {
10
    return "getSelection" in window && window.getSelection().type === "Range";
×
11
  }
12

13
  // Go to the previous submission with <
14
  Mousetrap.bind("shift+left", function () {
31✔
15
    // Don't override range selection keybindings
16
    if (!is_text_selected()) {
×
17
      $(".button.previous")[0].click();
×
18
    }
19
  });
20

21
  // Go to next submission with >
22
  Mousetrap.bind("shift+right", function () {
31✔
23
    if (!is_text_selected()) {
×
24
      $(".button.next")[0].click();
×
25
    }
26
  });
27

28
  // Go to a random incomplete submission with ctrl + shift + right
29
  Mousetrap.bind("ctrl+shift+right", function () {
31✔
30
    // Don't override range selection keybindings
31
    if (!is_text_selected()) {
×
32
      $(".button.random-incomplete-submission")[0].click();
×
33
    }
34
  });
35

36
  // Go to the previous criterion with shift + up
37
  Mousetrap.bind("shift+up", function (e) {
31✔
38
    if (!is_text_selected()) {
×
39
      e.preventDefault();
×
NEW
40
      window.prevCriterion();
×
41
      return false;
×
42
    }
43
  });
44

45
  // Go to the next criterion with shift + down
46
  Mousetrap.bind("shift+down", function (e) {
31✔
47
    if (!is_text_selected()) {
×
48
      e.preventDefault();
×
NEW
49
      window.nextCriterion();
×
50
      return false;
×
51
    }
52
  });
53

54
  // When on rubric criterion, use the arrow keys to hover over the next rubric
55
  Mousetrap.bind("up", function (e) {
31✔
56
    let $current_criteria = $(".active-criterion");
×
57
    if (
×
58
      $current_criteria.length &&
×
59
      $current_criteria.hasClass("rubric_criterion") &&
60
      !$current_criteria.hasClass("unassigned")
61
    ) {
62
      e.preventDefault();
×
63
      let $selected = $(".active-rubric");
×
64
      if ($selected.length) {
×
65
        let $next = $selected.parent().prev();
×
66
        if (!$next.length) {
×
67
          // if no next element exists, loop back to the last of the list
68
          $next = $selected.parent().siblings().last();
×
69
        }
70
        $selected.removeClass("active-rubric");
×
71
        $next.children().addClass("active-rubric");
×
72
      }
73
      return false;
×
74
    }
75
  });
76

77
  // When on rubric criteria, use the arrow keys to hover over the next rubric
78
  Mousetrap.bind("down", function (e) {
31✔
79
    let $current_criteria = $(".active-criterion");
×
80
    if (
×
81
      $current_criteria.length &&
×
82
      $current_criteria.hasClass("rubric_criterion") &&
83
      !$current_criteria.hasClass("unassigned")
84
    ) {
85
      e.preventDefault();
×
86
      let $selected = $(".active-rubric");
×
87
      if ($selected.length) {
×
88
        let $next = $selected.parent().next();
×
89
        if (!$next.length) {
×
90
          // if no next element exists, loop back to the front of the list
91
          $next = $selected.parent().siblings().first();
×
92
        }
93
        $selected.removeClass("active-rubric");
×
94
        $next.children().addClass("active-rubric");
×
95
      }
96
      return false;
×
97
    }
98
  });
99

100
  // When enter is pressed, and there is an active rubric selected, trigger select and collapse
101
  Mousetrap.bind("enter", function (e) {
31✔
102
    if ($(".active-rubric").length) {
×
103
      e.preventDefault();
×
104
      $(".active-rubric")[0].click();
×
105
    }
106
  });
107

108
  // Press shift+n for new annotation modal to appear
109
  Mousetrap.bind("shift+n", () => {
31✔
110
    if ($("#annotation_dialog:visible").length == 0) {
×
111
      resultComponent.current.newAnnotation();
×
112
      return false;
×
113
    }
114
  });
115

116
  // When alt+enter is pressed, toggle fullscreen mode
117
  Mousetrap.bind("alt+enter", () => {
31✔
118
    resultComponent.current.toggleFullscreen();
×
119
  });
120
}
121

122
export function unbind_all_keybindings() {
123
  Mousetrap.reset();
32✔
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc