[Rt-commit] rt branch, 4.4/keyboard-shortcuts, repushed
Dustin Graves
dustin at bestpractical.com
Tue Oct 6 13:48:26 EDT 2015
The branch 4.4/keyboard-shortcuts was deleted and repushed:
was 967fc2fefcbf27d7d40e0f29ad2c126bd00de301
now 1ea35fa8e81f911e2012dde3e05ac2bc09e0f1cc
1: 967fc2f ! 1: 1ea35fa add global / page-specific keyboard shortcuts
@@ -12,8 +12,6 @@
k/j - up/down through search results
o or <Enter> - view highlighted ticket
x - toggle highlighted ticket's checkbox (on bulk update)
-
- ticket display shortcuts:
t - reply to ticket
c - comment on ticket
@@ -1059,39 +1057,36 @@
dropzone.min.js
}, RT->Config->Get('JSFiles');
-diff --git a/share/html/Elements/CollectionList b/share/html/Elements/CollectionList
---- a/share/html/Elements/CollectionList
-+++ b/share/html/Elements/CollectionList
+diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
+--- a/share/html/Elements/CollectionAsTable/Row
++++ b/share/html/Elements/CollectionAsTable/Row
@@
- $Class =~ s/:/_/g;
+ $Classes => ''
+ </%ARGS>
+ <%init>
++$m->out( '<tbody class="list-item"' . ( $record->can('id') ? ' data-record-id="'.$record->id.'"' : '' ) . '>' );
++
+ $m->out( '<tr class="' . $Classes . ' '
+ . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >'
+ . "\n" );
+@@
+ $m->out( '</td>' . "\n" );
}
+ $m->out('</tr>');
++$m->out('</tbody>');
+ </%init>
+
+diff --git a/share/html/Elements/JavascriptConfig b/share/html/Elements/JavascriptConfig
+--- a/share/html/Elements/JavascriptConfig
++++ b/share/html/Elements/JavascriptConfig
+@@
+ my $Catalog = {
+ quote_in_filename => "Filenames with double quotes can not be uploaded.", #loc
+ attachment_warning_regex => "\\battach", #loc
++ shortcut_help_error => "Unable to open shortcut help. Reason: ", #loc
+ };
+ $_ = loc($_) for values %$Catalog;
-+my $is_ticket_collection = $Collection->isa('RT::Tickets');
-+
- $m->out('<table cellspacing="0" class="' .
-- ($Collection->isa('RT::Tickets') ? 'ticket-list' : 'collection') . ' collection-as-table">');
-+ ($is_ticket_collection ? 'ticket-list' : 'collection') . ' collection-as-table">');
-
- if ( $ShowHeader ) {
- $m->comp('/Elements/CollectionAsTable/Header',
-@@
- Format => \@Format,
- );
-
-+ $m->out('<tbody class="list-item"' . ($is_ticket_collection ? ' data-ticket-id="'.$record->id.'"' : '') . '>');
-+
- $m->comp('/Elements/CollectionAsTable/Row',
- i => $i,
- Format => \@Format,
-@@
- Warning => $warning,
- Classes => $Classes,
- );
-+
-+ $m->out('</tbody>');
- }
-
- $m->out('</table>');
diff --git a/share/html/Helpers/ShortcutHelp b/share/html/Helpers/ShortcutHelp
new file mode 100644
@@ -1158,15 +1153,15 @@
+ <table>
+ <tr>
+ <td class="key-column"><span class="keyboard-shortcuts-key">/</span></td>
-+ <td><&|/l&>Quick Search</&></td>
++ <td><&|/l&>Quick search</&></td>
+ </tr>
+ <tr>
+ <td><span class="keyboard-shortcuts-key">gh</span></td>
-+ <td><&|/l&>Return Home</&></td>
++ <td><&|/l&>Return home</&></td>
+ </tr>
+ <tr>
+ <td><span class="keyboard-shortcuts-key">gb</span> <span class="keyboard-shortcuts-separator">/</span> <span class="keyboard-shortcuts-key">gf</span></td>
-+ <td><&|/l&>Go Back / Forward</&></td>
++ <td><&|/l&>Go back / forward</&></td>
+ </tr>
+ </table>
+ </div>
@@ -1182,28 +1177,12 @@
+ <table>
+ <tr>
+ <td class="key-column"><span class="keyboard-shortcuts-key">k</span><span class="keyboard-shortcuts-separator"> / </span><span class="keyboard-shortcuts-key">j</span></td>
-+ <td><&|/l&>Move up/down the list of results</&></td>
++ <td><&|/l&>Move up / down the list of results</&></td>
+ </tr>
+ <tr>
+ <td><span class="keyboard-shortcuts-key">o</span> <span class="keyboard-shortcuts-separator">or</span> <span class="keyboard-shortcuts-key"><<&|/l&>Enter</&>></span></td>
+ <td><&|/l&>View highlighted ticket</&></td>
+ </tr>
-+ <tr>
-+ <td><span class="keyboard-shortcuts-key">x</span></td>
-+ <td><&|/l&>Toggle highlighted ticket's checkbox (for bulk update)</&></td>
-+ </tr>
-+ </table>
-+ </div>
-+ </div>
-+
-+ <div class="titlebox">
-+ <div class="titlebox-title">
-+ <span class="left"><&|/l&>Ticket Display</&></span>
-+ <span class="right-empty"></span>
-+ </div>
-+ <div class="titlebox-content">
-+ <hr class="clear">
-+ <table>
+ <tr>
+ <td class="key-column"><span class="keyboard-shortcuts-key">r</span></td>
+ <td><&|/l&>Reply to ticket</&></td>
@@ -1211,6 +1190,10 @@
+ <tr>
+ <td><span class="keyboard-shortcuts-key">c</span></td>
+ <td><&|/l&>Comment on ticket</&></td>
++ </tr>
++ <tr>
++ <td><span class="keyboard-shortcuts-key">x</span></td>
++ <td><&|/l&>Toggle highlighted ticket's checkbox (for bulk update)</&></td>
+ </tr>
+ </table>
+ </div>
@@ -1253,14 +1236,11 @@
$m->callback( ARGSRef => \%ARGS, CallbackName => 'Initial' );
-diff --git a/share/static/css/base/misc.css b/share/static/css/base/misc.css
---- a/share/static/css/base/misc.css
-+++ b/share/static/css/base/misc.css
+diff --git a/share/static/css/base/keyboard-shortcuts.css b/share/static/css/base/keyboard-shortcuts.css
+new file mode 100644
+--- /dev/null
++++ b/share/static/css/base/keyboard-shortcuts.css
@@
- .dashboard-subscription tr.frequency .value input {
- margin-bottom: 0.75em;
- }
-+
+.keyboard-shortcuts td {
+ text-align: left;
+}
@@ -1285,6 +1265,20 @@
+.keyboard-shortcuts .keyboard-shortcuts-separator {
+ font-size: 75%;
+}
++
++.ticket-list .selected-row tr {
++ border-left-color: #3858a3;
++ border-left-width: 3px;
++}
+
+diff --git a/share/static/css/base/main.css b/share/static/css/base/main.css
+--- a/share/static/css/base/main.css
++++ b/share/static/css/base/main.css
+@@
+ @import "print.css";
+ @import "dropzone.css";
+ @import "dropzone.customized.css";
++ at import "keyboard-shortcuts.css";
diff --git a/share/static/js/keyboard-shortcuts.js b/share/static/js/keyboard-shortcuts.js
new file mode 100644
@@ -1292,20 +1286,18 @@
+++ b/share/static/js/keyboard-shortcuts.js
@@
+jQuery(function() {
-+ Mousetrap.bind('g b', function() {
++ var goBack = function() {
+ window.history.back();
-+ });
-+
-+ Mousetrap.bind('g f', function() {
++ };
++
++ var goForward = function() {
+ window.history.forward();
-+ });
++ };
+
+ var goHome = function() {
+ var homeLink = jQuery('a#home');
+ window.location.href = homeLink.attr('href');
-+ }
-+
-+ Mousetrap.bind('g h', goHome);
++ };
+
+ var simpleSearch = function() {
+ var searchInput = jQuery('#simple-search').find('input');
@@ -1313,12 +1305,28 @@
+
+ searchInput.focus();
+ searchInput.select();
-+ }
-+
-+ Mousetrap.bind('/', function() {
-+ simpleSearch();
++
+ return false; // prevent '/' character from being typed in search box
-+ });
++ };
++
++ var openHelp = function() {
++ var modal = jQuery('.modal');
++ if (modal.length) {
++ jQuery.modal.close();
++ return;
++ }
++
++ jQuery.ajax({
++ url: RT.Config.WebHomePath + "/Helpers/ShortcutHelp",
++ success: showModal,
++ error: function(xhr, reason) {
++ // give the browser a chance to redraw the readout
++ setTimeout(function () {
++ alert(loc_key("shortcut_help_error") + reason);
++ }, 100);
++ }
++ });
++ };
+
+ var showModal = function(html) {
+ jQuery("<div class='modal'></div>")
@@ -1327,18 +1335,11 @@
+ .modal();
+ };
+
-+ Mousetrap.bind('?', function() {
-+ var modal = jQuery('.modal');
-+ if (modal.length) {
-+ jQuery.modal.close();
-+ return;
-+ }
-+
-+ jQuery.get(
-+ RT.Config.WebHomePath + "/Helpers/ShortcutHelp",
-+ showModal
-+ );
-+ });
++ Mousetrap.bind('g b', goBack);
++ Mousetrap.bind('g f', goForward);
++ Mousetrap.bind('g h', goHome);
++ Mousetrap.bind('/', simpleSearch);
++ Mousetrap.bind('?', openHelp);
+});
+
+jQuery(function() {
@@ -1347,29 +1348,6 @@
+ if (!hasTicketList) return;
+
+ var currentRow;
-+
-+ function generateTicketLink(ticketId) {
-+ if (!ticketId) return '';
-+ return RT.Config.WebHomePath + '/Ticket/Display.html?id=' + ticketId;
-+ }
-+
-+ var navigateToCurrentTicket = function() {
-+ if (!currentRow) return;
-+
-+ var ticketId = currentRow.closest('tbody').data('ticketId');
-+ var ticketLink = generateTicketLink(ticketId);
-+ if (!ticketLink) return;
-+
-+ window.location.href = ticketLink;
-+ }
-+ Mousetrap.bind(['enter','o'], navigateToCurrentTicket);
-+
-+ function setNewRow(newRow) {
-+ if (currentRow) currentRow.find('tr').attr('style', '');
-+ currentRow = newRow;
-+ currentRow.find('tr').attr('style', 'border-left-color: #3858a3; border-left-width: 3px;');
-+ scrollToJQueryObject(currentRow);
-+ }
+
+ var nextTicket = function() {
+ var nextRow;
@@ -1378,8 +1356,14 @@
+ nextRow = searchResultsTable.find('tbody.list-item').first();
+ }
+ setNewRow(nextRow);
-+ }
-+ Mousetrap.bind('j', nextTicket);
++ };
++
++ var setNewRow = function(newRow) {
++ if (currentRow) currentRow.removeClass('selected-row');
++ currentRow = newRow;
++ currentRow.addClass('selected-row');
++ scrollToJQueryObject(currentRow);
++ };
+
+ var prevTicket = function() {
+ var prevRow, searchResultsTable = jQuery('.ticket-list.collection-as-table');
@@ -1387,34 +1371,61 @@
+ prevRow = searchResultsTable.find('tbody.list-item').last();
+ }
+ setNewRow(prevRow);
-+ }
-+ Mousetrap.bind('k', prevTicket);
++ };
++
++ var navigateToCurrentTicket = function() {
++ if (!currentRow) return;
++
++ var ticketId = currentRow.closest('tbody').data('recordId');
++ var ticketLink = generateTicketLink(ticketId);
++ if (!ticketLink) return;
++
++ window.location.href = ticketLink;
++ };
++
++ var generateTicketLink = function(ticketId) {
++ if (!ticketId) return '';
++ return RT.Config.WebHomePath + '/Ticket/Display.html?id=' + ticketId;
++ };
+
+ var toggleTicketCheckbox = function() {
+ if (!currentRow) return;
+ var ticketCheckBox = currentRow.find('input[type=checkbox]');
+ if (!ticketCheckBox.length) return;
+ ticketCheckBox.prop("checked", !ticketCheckBox.prop("checked"));
-+ }
++ };
++
++ var replyToTicket = function() {
++ if (!currentRow) return;
++
++ var ticketId = currentRow.closest('tbody').data('recordId');
++ var replyLink = generateUpdateLink(ticketId, 'Respond');
++ if (!replyLink) return;
++
++ window.location.href = replyLink;
++ };
++
++ var generateUpdateLink = function(ticketId, action) {
++ if (!ticketId) return '';
++ return RT.Config.WebHomePath + '/Ticket/Update.html?Action=' + action + '&id=' + ticketId;
++ };
++
++ var commentOnTicket = function() {
++ if (!currentRow) return;
++
++ var ticketId = currentRow.closest('tbody').data('recordId');
++ var commentLink = generateUpdateLink(ticketId, 'Comment');
++ if (!commentLink) return;
++
++ window.location.href = commentLink;
++ };
++
++ Mousetrap.bind('j', nextTicket);
++ Mousetrap.bind('k', prevTicket);
++ Mousetrap.bind(['enter','o'], navigateToCurrentTicket);
++ Mousetrap.bind('r', replyToTicket);
++ Mousetrap.bind('c', commentOnTicket);
+ Mousetrap.bind('x', toggleTicketCheckbox);
-+});
-+
-+jQuery(function() {
-+ // Only load these shortcuts if we are viewing a ticket
-+ var isTicketDisplay = jQuery('#comp-Ticket-Display').length;
-+ if (!isTicketDisplay) return;
-+
-+ var replyToTicket = function() {
-+ var replyLink = jQuery('#page-actions-reply');
-+ window.location.href = replyLink.attr('href');
-+ }
-+ Mousetrap.bind('r', replyToTicket);
-+
-+ var commentOnTicket = function() {
-+ var commentLink = jQuery('#page-actions-comment');
-+ window.location.href = commentLink.attr('href');
-+ }
-+ Mousetrap.bind('c', commentOnTicket);
+});
+
More information about the rt-commit
mailing list