-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyboard shortcuts for 'Accept/Revert url/test' buttons #360
Changes from 3 commits
e82aced
424fb59
58c9460
c4f4cdd
ba7e7a4
6704a6f
b26bc0d
01d2484
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) { | |
code 81 - q | ||
code 219 - [ | ||
code 221 - ] | ||
code 65 - a | ||
code 82 - r | ||
*/ | ||
|
||
var shortcuts = { | ||
|
@@ -60,14 +62,16 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) { | |
}, | ||
'221': function () { | ||
scope.traverseTree('down'); | ||
} | ||
}, | ||
'65': accept, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually we don't need to use ASCII codes at all and we can use event.key property instead of event.keyCode which is returning single character that identify keyboard buttons. I added new shortcuts using existing convention. If it is necessarily I can quick refactor it. |
||
'82': revert | ||
}; | ||
|
||
$(document).on('keydown', function (e) { | ||
if ($('body').hasClass('modal-open')) { | ||
if ($('body').hasClass('modal-open') || $(e.target).hasClass('search-input')) { | ||
return true; | ||
} else if (shortcuts[e.keyCode]) { | ||
shortcuts[e.keyCode](); | ||
shortcuts[e.keyCode](e); | ||
} | ||
}); | ||
|
||
|
@@ -86,6 +90,20 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) { | |
} | ||
}; | ||
|
||
function clickButton(buttonClass, event) { | ||
var $tab = (event.shiftKey) ? $('.tab-content-toolbar') : $('.toolbar-bottom'); | ||
var $btns = $tab.find('.toolbar-btns'); | ||
$btns.find(buttonClass).click(); | ||
} | ||
|
||
function accept(event) { | ||
clickButton('.button-blue', event); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assumption is that only buttons inside |
||
} | ||
|
||
function revert(event) { | ||
clickButton('.button-red', event); | ||
} | ||
|
||
function goToTab(direction) { | ||
var $tabs = $('.test-tabs'), | ||
$active = $tabs.find('.active'); | ||
|
@@ -251,7 +269,7 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) { | |
var $nextTestTabs = $('.nav-tabs').children(); | ||
$nextTestTabs.each(function() { | ||
if($(this).text().replace(/\s/g, '') === currentTabLabel) { | ||
$(this).find('a').click(); | ||
$(this).find('a').click(); | ||
currentTabLabel = null; | ||
} | ||
}); | ||
|
@@ -260,15 +278,15 @@ define(['angularAMD', 'userSettingsService'], function (angularAMD) { | |
//MutationObserver fires a callback every time something changes on the page | ||
//and here it's used to click a tab before the page is actually rendered to get rid of flickering effect | ||
var mutationObserver = new MutationObserver(callback); | ||
|
||
function callback(mutList) { | ||
function findElement(element) { | ||
if($(element.target).hasClass('nav-tabs')) { | ||
clickOnTab(); | ||
return true; | ||
} | ||
} | ||
mutList.find(findElement); | ||
mutList.find(findElement); | ||
} | ||
|
||
mutationObserver.observe(document, { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update only
SuiteReportFeatures.md
. I think that it isn't a good idea to update historical documentation ;)