From 554bc210161f0162f68746b559024e86620ab311 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Thu, 14 Apr 2011 10:49:04 +0200 Subject: [PATCH] fix #1133 by increasing delay before remotely fetching for autocomplete. Also remove selectFirst jquery plugin since this is now part of jquery itself --- app/views/layouts/standard.html.erb | 2 +- public/javascripts/application.js | 26 ++++++++++++------- .../jquery.ui.autocomplete.selectFirst.js | 23 ---------------- 3 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 public/javascripts/jquery.ui.autocomplete.selectFirst.js diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb index 1bb6741d..f9a01632 100644 --- a/app/views/layouts/standard.html.erb +++ b/app/views/layouts/standard.html.erb @@ -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', diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 592909ec..fd7af758 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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); diff --git a/public/javascripts/jquery.ui.autocomplete.selectFirst.js b/public/javascripts/jquery.ui.autocomplete.selectFirst.js deleted file mode 100644 index 10be3ba4..00000000 --- a/public/javascripts/jquery.ui.autocomplete.selectFirst.js +++ /dev/null @@ -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 )); -