Commit 4a8d3b27 authored by Kushal Pandya's avatar Kushal Pandya

Add Ctrl+Click support for tabs

parent e665ea05
...@@ -82,12 +82,18 @@ require('./flash'); ...@@ -82,12 +82,18 @@ require('./flash');
$(document) $(document)
.on('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown) .on('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown)
.on('click', '.js-show-tab', this.showTab); .on('click', '.js-show-tab', this.showTab);
$('.merge-request-tabs a[data-toggle="tab"]')
.on('click', this.clickTab);
} }
unbindEvents() { unbindEvents() {
$(document) $(document)
.off('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown) .off('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown)
.off('click', '.js-show-tab', this.showTab); .off('click', '.js-show-tab', this.showTab);
$('.merge-request-tabs a[data-toggle="tab"]')
.off('click', this.clickTab);
} }
showTab(e) { showTab(e) {
...@@ -95,6 +101,14 @@ require('./flash'); ...@@ -95,6 +101,14 @@ require('./flash');
this.activateTab($(e.target).data('action')); this.activateTab($(e.target).data('action'));
} }
clickTab(e) {
const targetLink = $(e.target).attr('href');
if (e.metaKey || e.ctrlKey || e.which === 2) {
e.stopImmediatePropagation();
window.open(targetLink, '_blank');
}
}
tabShown(e) { tabShown(e) {
const $target = $(e.target); const $target = $(e.target);
const action = $target.data('action'); const action = $target.data('action');
......
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