|
1 | 1 | jQuery(function() {
|
| 2 | + if (RT.Config.KeyBoardShortcuts) { |
2 | 3 | var goBack = function() {
|
3 | 4 | window.history.back();
|
4 | 5 | };
|
@@ -68,110 +69,115 @@ jQuery(function() {
|
68 | 69 | Mousetrap.bind('g h', goHome);
|
69 | 70 | Mousetrap.bind('/', simpleSearch);
|
70 | 71 | Mousetrap.bind('?', openHelp);
|
| 72 | + } |
71 | 73 | });
|
72 | 74 |
|
73 | 75 | jQuery(function() {
|
74 |
| - // Only load these shortcuts if there is a ticket list on the page |
75 |
| - var hasTicketList = jQuery('table.ticket-list').length; |
76 |
| - if (!hasTicketList) return; |
77 |
| - |
78 |
| - var currentRow; |
79 |
| - |
80 |
| - var nextTicket = function() { |
81 |
| - var nextRow; |
82 |
| - var searchResultsTable = jQuery('.ticket-list.collection-as-table'); |
83 |
| - if (!currentRow || !(nextRow = currentRow.next('tbody.list-item')).length) { |
84 |
| - nextRow = searchResultsTable.find('tbody.list-item').first(); |
85 |
| - } |
86 |
| - setNewRow(nextRow); |
87 |
| - }; |
88 |
| - |
89 |
| - var setNewRow = function(newRow) { |
90 |
| - if (currentRow) currentRow.removeClass('selected-row'); |
91 |
| - currentRow = newRow; |
92 |
| - currentRow.addClass('selected-row'); |
93 |
| - scrollToJQueryObject(currentRow); |
94 |
| - }; |
95 |
| - |
96 |
| - var prevTicket = function() { |
97 |
| - var prevRow, searchResultsTable = jQuery('.ticket-list.collection-as-table'); |
98 |
| - if (!currentRow || !(prevRow = currentRow.prev('tbody.list-item')).length) { |
99 |
| - prevRow = searchResultsTable.find('tbody.list-item').last(); |
100 |
| - } |
101 |
| - setNewRow(prevRow); |
102 |
| - }; |
103 |
| - |
104 |
| - var generateTicketLink = function(ticketId) { |
105 |
| - if (!ticketId) return ''; |
106 |
| - return RT.Config.WebHomePath + '/Ticket/Display.html?id=' + ticketId; |
107 |
| - }; |
108 |
| - |
109 |
| - var generateUpdateLink = function(ticketId, action) { |
110 |
| - if (!ticketId) return ''; |
111 |
| - return RT.Config.WebHomePath + '/Ticket/Update.html?Action=' + action + '&id=' + ticketId; |
112 |
| - }; |
113 |
| - |
114 |
| - var navigateToCurrentTicket = function() { |
115 |
| - if (!currentRow) return; |
116 |
| - |
117 |
| - var ticketId = currentRow.closest('tbody').data('recordId'); |
118 |
| - var ticketLink = generateTicketLink(ticketId); |
119 |
| - if (!ticketLink) return; |
120 |
| - |
121 |
| - window.location.href = ticketLink; |
122 |
| - }; |
123 |
| - |
124 |
| - var toggleTicketCheckbox = function() { |
125 |
| - if (!currentRow) return; |
126 |
| - var ticketCheckBox = currentRow.find('input[type=checkbox]'); |
127 |
| - if (!ticketCheckBox.length) return; |
128 |
| - ticketCheckBox.prop("checked", !ticketCheckBox.prop("checked")); |
129 |
| - }; |
130 |
| - |
131 |
| - var replyToTicket = function() { |
132 |
| - if (!currentRow) return; |
133 |
| - |
134 |
| - var ticketId = currentRow.closest('tbody').data('recordId'); |
135 |
| - var replyLink = generateUpdateLink(ticketId, 'Respond'); |
136 |
| - if (!replyLink) return; |
137 |
| - |
138 |
| - window.location.href = replyLink; |
139 |
| - }; |
140 |
| - |
141 |
| - var commentOnTicket = function() { |
142 |
| - if (!currentRow) return; |
143 |
| - |
144 |
| - var ticketId = currentRow.closest('tbody').data('recordId'); |
145 |
| - var commentLink = generateUpdateLink(ticketId, 'Comment'); |
146 |
| - if (!commentLink) return; |
147 |
| - |
148 |
| - window.location.href = commentLink; |
149 |
| - }; |
150 |
| - |
151 |
| - Mousetrap.bind('j', nextTicket); |
152 |
| - Mousetrap.bind('k', prevTicket); |
153 |
| - Mousetrap.bind(['enter','o'], navigateToCurrentTicket); |
154 |
| - Mousetrap.bind('r', replyToTicket); |
155 |
| - Mousetrap.bind('c', commentOnTicket); |
156 |
| - Mousetrap.bind('x', toggleTicketCheckbox); |
| 76 | + if (RT.Config.KeyBoardShortcuts) { |
| 77 | + // Only load these shortcuts if there is a ticket list on the page |
| 78 | + var hasTicketList = jQuery('table.ticket-list').length; |
| 79 | + if (!hasTicketList) return; |
| 80 | + |
| 81 | + var currentRow; |
| 82 | + |
| 83 | + var nextTicket = function() { |
| 84 | + var nextRow; |
| 85 | + var searchResultsTable = jQuery('.ticket-list.collection-as-table'); |
| 86 | + if (!currentRow || !(nextRow = currentRow.next('tbody.list-item')).length) { |
| 87 | + nextRow = searchResultsTable.find('tbody.list-item').first(); |
| 88 | + } |
| 89 | + setNewRow(nextRow); |
| 90 | + }; |
| 91 | + |
| 92 | + var setNewRow = function(newRow) { |
| 93 | + if (currentRow) currentRow.removeClass('selected-row'); |
| 94 | + currentRow = newRow; |
| 95 | + currentRow.addClass('selected-row'); |
| 96 | + scrollToJQueryObject(currentRow); |
| 97 | + }; |
| 98 | + |
| 99 | + var prevTicket = function() { |
| 100 | + var prevRow, searchResultsTable = jQuery('.ticket-list.collection-as-table'); |
| 101 | + if (!currentRow || !(prevRow = currentRow.prev('tbody.list-item')).length) { |
| 102 | + prevRow = searchResultsTable.find('tbody.list-item').last(); |
| 103 | + } |
| 104 | + setNewRow(prevRow); |
| 105 | + }; |
| 106 | + |
| 107 | + var generateTicketLink = function(ticketId) { |
| 108 | + if (!ticketId) return ''; |
| 109 | + return RT.Config.WebHomePath + '/Ticket/Display.html?id=' + ticketId; |
| 110 | + }; |
| 111 | + |
| 112 | + var generateUpdateLink = function(ticketId, action) { |
| 113 | + if (!ticketId) return ''; |
| 114 | + return RT.Config.WebHomePath + '/Ticket/Update.html?Action=' + action + '&id=' + ticketId; |
| 115 | + }; |
| 116 | + |
| 117 | + var navigateToCurrentTicket = function() { |
| 118 | + if (!currentRow) return; |
| 119 | + |
| 120 | + var ticketId = currentRow.closest('tbody').data('recordId'); |
| 121 | + var ticketLink = generateTicketLink(ticketId); |
| 122 | + if (!ticketLink) return; |
| 123 | + |
| 124 | + window.location.href = ticketLink; |
| 125 | + }; |
| 126 | + |
| 127 | + var toggleTicketCheckbox = function() { |
| 128 | + if (!currentRow) return; |
| 129 | + var ticketCheckBox = currentRow.find('input[type=checkbox]'); |
| 130 | + if (!ticketCheckBox.length) return; |
| 131 | + ticketCheckBox.prop("checked", !ticketCheckBox.prop("checked")); |
| 132 | + }; |
| 133 | + |
| 134 | + var replyToTicket = function() { |
| 135 | + if (!currentRow) return; |
| 136 | + |
| 137 | + var ticketId = currentRow.closest('tbody').data('recordId'); |
| 138 | + var replyLink = generateUpdateLink(ticketId, 'Respond'); |
| 139 | + if (!replyLink) return; |
| 140 | + |
| 141 | + window.location.href = replyLink; |
| 142 | + }; |
| 143 | + |
| 144 | + var commentOnTicket = function() { |
| 145 | + if (!currentRow) return; |
| 146 | + |
| 147 | + var ticketId = currentRow.closest('tbody').data('recordId'); |
| 148 | + var commentLink = generateUpdateLink(ticketId, 'Comment'); |
| 149 | + if (!commentLink) return; |
| 150 | + |
| 151 | + window.location.href = commentLink; |
| 152 | + }; |
| 153 | + |
| 154 | + Mousetrap.bind('j', nextTicket); |
| 155 | + Mousetrap.bind('k', prevTicket); |
| 156 | + Mousetrap.bind(['enter','o'], navigateToCurrentTicket); |
| 157 | + Mousetrap.bind('r', replyToTicket); |
| 158 | + Mousetrap.bind('c', commentOnTicket); |
| 159 | + Mousetrap.bind('x', toggleTicketCheckbox); |
| 160 | + } |
157 | 161 | });
|
158 | 162 |
|
159 | 163 | jQuery(function() {
|
160 |
| - // Only load these shortcuts if reply or comment action is on page |
161 |
| - var ticket_reply = jQuery('a#page-actions-reply'); |
162 |
| - var ticket_comment = jQuery('a#page-actions-comment'); |
163 |
| - if (!ticket_reply.length && !ticket_comment.length) return; |
164 |
| - |
165 |
| - var replyToTicket = function() { |
166 |
| - if (!ticket_reply.length) return; |
167 |
| - window.location.href = ticket_reply.attr('href'); |
168 |
| - }; |
169 |
| - |
170 |
| - var commentOnTicket = function() { |
171 |
| - if (!ticket_comment.length) return; |
172 |
| - window.location.href = ticket_comment.attr('href'); |
173 |
| - }; |
174 |
| - |
175 |
| - Mousetrap.bind('r', replyToTicket); |
176 |
| - Mousetrap.bind('c', commentOnTicket); |
| 164 | + if (RT.Config.KeyBoardShortcuts) { |
| 165 | + // Only load these shortcuts if reply or comment action is on page |
| 166 | + var ticket_reply = jQuery('a#page-actions-reply'); |
| 167 | + var ticket_comment = jQuery('a#page-actions-comment'); |
| 168 | + if (!ticket_reply.length && !ticket_comment.length) return; |
| 169 | + |
| 170 | + var replyToTicket = function() { |
| 171 | + if (!ticket_reply.length) return; |
| 172 | + window.location.href = ticket_reply.attr('href'); |
| 173 | + }; |
| 174 | + |
| 175 | + var commentOnTicket = function() { |
| 176 | + if (!ticket_comment.length) return; |
| 177 | + window.location.href = ticket_comment.attr('href'); |
| 178 | + }; |
| 179 | + |
| 180 | + Mousetrap.bind('r', replyToTicket); |
| 181 | + Mousetrap.bind('c', commentOnTicket); |
| 182 | + } |
177 | 183 | });
|
0 commit comments