fix #1133 by increasing delay before remotely fetching for autocomplete. Also remove selectFirst jquery plugin since this is now part of jquery itself

This commit is contained in:
Reinier Balt 2011-04-14 10:49:04 +02:00
parent 6e8e082542
commit 6f1292b515
3 changed files with 18 additions and 33 deletions

View file

@ -6,7 +6,7 @@
<%= stylesheet_link_tag "print", :media => "print" %>
<%= javascript_include_tag 'jquery-1.5.1.min', 'jquery-ui-1.8.11.custom.min',
'jquery.truncator','jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI',
'jquery.form','jquery.ui.autocomplete.selectFirst',
'jquery.form',
:cache => 'jquery-cached' %>
<%= javascript_tag_for_i18n_datepicker %>
<%= javascript_include_tag 'hoverIntent','superfish','application',

View file

@ -189,7 +189,9 @@ var TracksPages = {
}
})
.autocomplete({
minLength: 0,
minLength: 2,
autoFocus: true,
delay: 400, /* increase a bit over dthe default of 300 */
source: function( request, response ) {
var last_term = extractLast( request.term );
if (last_term != "" && last_term != " ")
@ -224,8 +226,7 @@ var TracksPages = {
//terms.push( "" );
this.value = terms.join( ", " );
return false;
},
selectFirst: true
}
});
},
setup_all_autocompleters: function() {
@ -419,7 +420,9 @@ var TodoItems = {
}
})
.autocomplete({
minLength: 0,
minLength: 2,
autoFocus: true,
delay: 400, /* delay a bit more than the default of 300 */
source: function( request, response ) {
var term = request.term;
if (term != "" && term != " ")
@ -459,8 +462,7 @@ var TodoItems = {
$(form).find('input[name=predecessor_input]').val('');
$(form).find('input[name=predecessor_input]').focus();
return false;
},
selectFirst: true
}
});
},
drag_todo: function() {
@ -594,7 +596,9 @@ var ContextItems = {
setup_autocomplete_for_contexts: function(id) {
$(id).autocomplete({
source: relative_to_root('contexts.autocomplete'),
selectFirst: true
autoFocus: true,
minLength: 1,
delay: 400 /* increase a bit. default was 300 */
});
}
}
@ -603,7 +607,9 @@ var ProjectItems = {
setup_autocomplete_for_projects: function(id) {
$(id).autocomplete({
source: relative_to_root('projects.autocomplete'),
selectFirst: true
autoFocus: true,
minLength: 1,
delay: 400 /* increase a bit. default was 300 */
});
}
}
@ -1056,7 +1062,9 @@ function default_ajax_options_for_submit(ajax_type, element_to_block) {
$(this.block_element).unblock();
}
// delay a bit to wait for animations to finish
setTimeout(function(){enable_rich_interaction();}, 500);
setTimeout(function(){
enable_rich_interaction();
}, 500);
}],
error: function(req, status) {
TracksPages.page_notify('error', i18n['common.ajaxError']+': '+status, 8);

View file

@ -1,23 +0,0 @@
/*
* jQuery UI Autocomplete Select First Extension
*
* Copyright 2010, Scott González (http://scottgonzalez.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* http://github.com/scottgonzalez/jquery-ui-extensions
*/
(function( $ ) {
$( ".ui-autocomplete-input" ).live( "autocompleteopen", function() {
var autocomplete = $( this ).data( "autocomplete" ),
menu = autocomplete.menu;
if ( !autocomplete.options.selectFirst ) {
return;
}
menu.activate( $.Event({ type: "mouseenter" }), menu.element.children().first() );
});
}( jQuery ));