Commit e220eecb authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray Committed by Jacob Schatz

Switch global shortcuts to shift; reuse key styles from help menu

parent 610ea22e
...@@ -20,48 +20,37 @@ ...@@ -20,48 +20,37 @@
}; };
})(this)); })(this));
function gotoMenu(menu){ const globalDropdownMenu = $('.global-dropdown-menu');
window.location.href = $('.js-dashboard-shortcuts-'+menu).attr('href');
}
$('.global-dropdown').on('hide.bs.dropdown', function() { $('.global-dropdown').on('hide.bs.dropdown', function() {
$('.global-dropdown-menu').removeClass('shortcuts'); globalDropdownMenu.removeClass('shortcuts');
Mousetrap.unbind(['p', 'a', 'r', 'l', 'i', 'm', 'e']);
});
$('.global-dropdown').on('show.bs.dropdown', function() {
Mousetrap.bind('p', function() {
gotoMenu('projects');
}); });
Mousetrap.bind('a', function() { Mousetrap.bind('n', function() {
gotoMenu('activity'); globalDropdownMenu.addClass('shortcuts');
$('.global-dropdown-toggle').trigger('click');
}); });
Mousetrap.bind('r', function() { Mousetrap.bind('shift+a', function() {
gotoMenu('groups'); return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-activity');
}); });
Mousetrap.bind('shift+i', function() {
Mousetrap.bind('l', function() { return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-issues');
gotoMenu('milestones');
}); });
Mousetrap.bind('shift+m', function() {
Mousetrap.bind('i', function() { return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-merge_requests');
gotoMenu('issues');
}); });
Mousetrap.bind('shift+p', function() {
Mousetrap.bind('m', function() { return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-projects');
gotoMenu('merge_requests');
}); });
Mousetrap.bind('shift+g', function() {
Mousetrap.bind('e', function() { return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-groups');
gotoMenu('snippets');
}); });
Mousetrap.bind('shift+l', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-milestones');
}); });
Mousetrap.bind('shift+s', function() {
Mousetrap.bind('n', function() { return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-snippets');
$('.global-dropdown-menu').addClass('shortcuts');
$('.global-dropdown-toggle').trigger('click');
}); });
Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], this.toggleMarkdownPreview); Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], this.toggleMarkdownPreview);
......
...@@ -13,21 +13,6 @@ require('./shortcuts'); ...@@ -13,21 +13,6 @@ require('./shortcuts');
function ShortcutsDashboardNavigation() { function ShortcutsDashboardNavigation() {
ShortcutsDashboardNavigation.__super__.constructor.call(this); ShortcutsDashboardNavigation.__super__.constructor.call(this);
Mousetrap.bind('g a', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-activity');
});
Mousetrap.bind('g i', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-issues');
});
Mousetrap.bind('g m', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-merge_requests');
});
Mousetrap.bind('g t', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.shortcuts-todos');
});
Mousetrap.bind('g p', function() {
return ShortcutsDashboardNavigation.findAndFollowLink('.dashboard-shortcuts-projects');
});
} }
ShortcutsDashboardNavigation.findAndFollowLink = function(selector) { ShortcutsDashboardNavigation.findAndFollowLink = function(selector) {
......
...@@ -31,7 +31,7 @@ require('./shortcuts'); ...@@ -31,7 +31,7 @@ require('./shortcuts');
Mousetrap.bind('g n', function() { Mousetrap.bind('g n', function() {
return ShortcutsNavigation.findAndFollowLink('.shortcuts-network'); return ShortcutsNavigation.findAndFollowLink('.shortcuts-network');
}); });
Mousetrap.bind('g g', function() { Mousetrap.bind('g d', function() {
return ShortcutsNavigation.findAndFollowLink('.shortcuts-repository-charts'); return ShortcutsNavigation.findAndFollowLink('.shortcuts-repository-charts');
}); });
Mousetrap.bind('g i', function() { Mousetrap.bind('g i', function() {
......
...@@ -187,24 +187,13 @@ ...@@ -187,24 +187,13 @@
} }
} }
.kbd { .shortcut-mappings {
display: none; display: none;
} }
&.shortcuts .kbd { &.shortcuts .shortcut-mappings {
background-color: $gray-light;
color: $gl-text-color;
border: 1px solid $gray-darkest;
box-shadow: 0 -1px 0 $gray-darkest inset;
display: inline-block; display: inline-block;
vertical-align: top;
padding: 3px 0;
margin-right: 5px; margin-right: 5px;
font-size: 11px;
line-height: 10px;
border-radius: 3px;
width: 20px;
text-align: center;
} }
ul { ul {
......
...@@ -100,34 +100,39 @@ ...@@ -100,34 +100,39 @@
%th Global Dashboard %th Global Dashboard
%tr %tr
%td.shortcut %td.shortcut
.key g .key shift a
.key a
%td %td
Go to the activity feed Go to the activity feed
%tr %tr
%td.shortcut %td.shortcut
.key g .key shift p
.key p
%td %td
Go to projects Go to projects
%tr %tr
%td.shortcut %td.shortcut
.key g .key shift i
.key i
%td %td
Go to issues Go to issues
%tr %tr
%td.shortcut %td.shortcut
.key g .key shift m
.key m
%td %td
Go to merge requests Go to merge requests
%tr %tr
%td.shortcut %td.shortcut
.key g .key shift g
.key t %td
Go to groups
%tr
%td.shortcut
.key shift l
%td %td
Go to todos Go to milestones
%tr
%td.shortcut
.key shift s
%td
Go to snippets
%tbody %tbody
%tr %tr
%th %th
...@@ -159,7 +164,7 @@ ...@@ -159,7 +164,7 @@
%tr %tr
%td.shortcut %td.shortcut
.key g .key g
.key b .key j
%td %td
Go to jobs Go to jobs
%tr %tr
...@@ -171,7 +176,7 @@ ...@@ -171,7 +176,7 @@
%tr %tr
%td.shortcut %td.shortcut
.key g .key g
.key g .key d
%td %td
Go to repository charts Go to repository charts
%tr %tr
...@@ -183,7 +188,7 @@ ...@@ -183,7 +188,7 @@
%tr %tr
%td.shortcut %td.shortcut
.key g .key g
.key l .key b
%td %td
Go to issue boards Go to issue boards
%tr %tr
...@@ -198,6 +203,12 @@ ...@@ -198,6 +203,12 @@
.key s .key s
%td %td
Go to snippets Go to snippets
%tr
%td.shortcut
.key g
.key w
%td
Go to wiki
%tr %tr
%td.shortcut %td.shortcut
.key t .key t
......
%ul %ul
= nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'dashboard/projects#index'], html_options: {class: "#{project_tab_class} home"}) do = nav_link(path: ['root#index', 'projects#trending', 'projects#starred', 'dashboard/projects#index'], html_options: {class: "#{project_tab_class} home"}) do
= link_to dashboard_projects_path, title: 'Projects', class: 'js-dashboard-shortcuts-projects' do = link_to dashboard_projects_path, title: 'Projects', class: 'dashboard-shortcuts-projects' do
.kbd .shortcut-mappings
p .key shift p
%span %span
Projects Projects
= nav_link(path: 'dashboard#activity') do = nav_link(path: 'dashboard#activity') do
= link_to activity_dashboard_path, class: 'js-dashboard-shortcuts-activity', title: 'Activity' do = link_to activity_dashboard_path, class: 'dashboard-shortcuts-activity', title: 'Activity' do
.kbd .shortcut-mappings
a .key shift a
%span %span
Activity Activity
- if koding_enabled? - if koding_enabled?
...@@ -17,35 +17,35 @@ ...@@ -17,35 +17,35 @@
%span %span
Koding Koding
= nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do = nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do
= link_to dashboard_groups_path, class: 'js-dashboard-shortcuts-groups', title: 'Groups' do = link_to dashboard_groups_path, class: 'dashboard-shortcuts-groups', title: 'Groups' do
.kbd .shortcut-mappings
r .key shift l
%span %span
Groups Groups
= nav_link(controller: 'dashboard/milestones') do = nav_link(controller: 'dashboard/milestones') do
= link_to dashboard_milestones_path, class: 'js-dashboard-shortcuts-milestones', title: 'Milestones' do = link_to dashboard_milestones_path, class: 'dashboard-shortcuts-milestones', title: 'Milestones' do
.kbd .shortcut-mappings
l .key shift w
%span %span
Milestones Milestones
= nav_link(path: 'dashboard#issues') do = nav_link(path: 'dashboard#issues') do
= link_to assigned_issues_dashboard_path, title: 'Issues', class: 'js-dashboard-shortcuts-issues' do = link_to assigned_issues_dashboard_path, title: 'Issues', class: 'dashboard-shortcuts-issues' do
.kbd .shortcut-mappings
i .key shift i
%span %span
Issues Issues
.badge= number_with_delimiter(cached_assigned_issuables_count(current_user, :issues, :opened)) .badge= number_with_delimiter(cached_assigned_issuables_count(current_user, :issues, :opened))
= nav_link(path: 'dashboard#merge_requests') do = nav_link(path: 'dashboard#merge_requests') do
= link_to assigned_mrs_dashboard_path, title: 'Merge Requests', class: 'js-dashboard-shortcuts-merge_requests' do = link_to assigned_mrs_dashboard_path, title: 'Merge Requests', class: 'dashboard-shortcuts-merge_requests' do
.kbd .shortcut-mappings
m .key shift m
%span %span
Merge Requests Merge Requests
.badge= number_with_delimiter(cached_assigned_issuables_count(current_user, :merge_requests, :opened)) .badge= number_with_delimiter(cached_assigned_issuables_count(current_user, :merge_requests, :opened))
= nav_link(controller: 'dashboard/snippets') do = nav_link(controller: 'dashboard/snippets') do
= link_to dashboard_snippets_path, class: 'js-dashboard-shortcuts-snippets', title: 'Snippets' do = link_to dashboard_snippets_path, class: 'dashboard-shortcuts-snippets', title: 'Snippets' do
.kbd .shortcut-mappings
e .key shift s
%span %span
Snippets Snippets
%li.divider %li.divider
......
--- ---
title: Add keyboard shortcuts to main menu title: Add keyboard shortcuts to main menu
merge_request: merge_request:
author: Jacob Schatz author:
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment