summaryrefslogtreecommitdiffstats
path: root/public/javascripts/application.js
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-22 06:41:48 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-22 06:41:48 +0000
commit916b4c14590bd30b0d2e4f365823f465217c9d72 (patch)
tree8bc579cbd0b7a1876ce1f4abe730f45490ad6481 /public/javascripts/application.js
parent469107a541de188c6f62e62f1d5e742e8ea3c364 (diff)
downloadredmine-916b4c14590bd30b0d2e4f365823f465217c9d72.tar.gz
redmine-916b4c14590bd30b0d2e4f365823f465217c9d72.zip
Jump to project autocomplete: focus selected project (#26395).
Patch by Gabriel Cardoso. git-svn-id: http://svn.redmine.org/redmine/trunk@16842 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public/javascripts/application.js')
-rw-r--r--public/javascripts/application.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index ac8c38862..b6352fd2a 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -120,7 +120,7 @@ function initFilters() {
function addFilter(field, operator, values) {
var fieldId = field.replace('.', '_');
var tr = $('#tr_'+fieldId);
-
+
var filterOptions = availableFilters[field];
if (!filterOptions) return;
@@ -587,6 +587,8 @@ function observeSearchfield(fieldId, targetId, url) {
$(document).ready(function(){
$(".drdn .autocomplete").val('');
+ // This variable is used to focus selected project
+ var selected;
$(".drdn-trigger").click(function(e){
var drdn = $(this).closest(".drdn");
if (drdn.hasClass("expanded")) {
@@ -594,6 +596,8 @@ $(document).ready(function(){
} else {
$(".drdn").removeClass("expanded");
drdn.addClass("expanded");
+ selected = $('.drdn-items a.selected'); // Store selected project
+ selected.focus(); // Calling focus to scroll to selected project
if (!isMobile()) {
drdn.find(".autocomplete").focus();
}
@@ -603,14 +607,22 @@ $(document).ready(function(){
$(document).click(function(e){
if ($(e.target).closest(".drdn").length < 1) {
$(".drdn.expanded").removeClass("expanded");
- }
+ }
});
observeSearchfield('projects-quick-search', null, $('#projects-quick-search').data('automcomplete-url'));
$(".drdn-content").keydown(function(event){
var items = $(this).find(".drdn-items");
- var focused = items.find("a:focus");
+
+ // If a project is selected set focused to selected only once
+ if (selected && selected.length > 0) {
+ var focused = selected;
+ selected = undefined;
+ }
+ else {
+ var focused = items.find("a:focus");
+ }
switch (event.which) {
case 40: //down
if (focused.length > 0) {