Replaces project jump select with custom dropdown (#23310).

git-svn-id: http://svn.redmine.org/redmine/trunk@15994 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2016-11-26 08:16:15 +00:00
parent bac3ac738a
commit 62823442d3
9 changed files with 245 additions and 57 deletions

View File

@@ -572,6 +572,69 @@ function observeSearchfield(fieldId, targetId, url) {
});
}
$(document).ready(function(){
$(".drdn .autocomplete").val('');
$(".drdn-trigger").click(function(e){
var drdn = $(this).closest(".drdn");
if (drdn.hasClass("expanded")) {
drdn.removeClass("expanded");
} else {
$(".drdn").removeClass("expanded");
drdn.addClass("expanded");
if (!isMobile()) {
drdn.find(".autocomplete").focus();
}
e.stopPropagation();
}
});
$(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");
switch (event.which) {
case 40: //down
if (focused.length > 0) {
focused.nextAll("a").first().focus();;
} else {
items.find("a").first().focus();;
}
event.preventDefault();
break;
case 38: //up
if (focused.length > 0) {
var prev = focused.prevAll("a");
if (prev.length > 0) {
prev.first().focus();
} else {
$(this).find(".autocomplete").focus();
}
event.preventDefault();
}
break;
case 35: //end
if (focused.length > 0) {
focused.nextAll("a").last().focus();
event.preventDefault();
}
break;
case 36: //home
if (focused.length > 0) {
focused.prevAll("a").last().focus();
event.preventDefault();
}
break;
}
});
});
function beforeShowDatePicker(input, inst) {
var default_date = null;
switch ($(input).attr("id")) {