diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb index 88729618..78d41d6e 100644 --- a/app/views/layouts/standard.html.erb +++ b/app/views/layouts/standard.html.erb @@ -7,7 +7,7 @@ <%= javascript_include_tag 'jquery-1.5.min', 'jquery-ui-1.8.9.custom.min', 'jquery.truncator', 'jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI', 'jquery.form', :cache => 'jquery-cached' %> <%= javascript_include_tag 'hoverIntent','superfish','application', - 'accesskey-hints','niftycube','swfobject', :cache => 'tracks-cached' %> + 'accesskey-hints','niftycube','swfobject','jquery.ui.autocomplete.selectFirst', :cache => 'tracks-cached' %> <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> <%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %> <%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %> diff --git a/app/views/todos/edit.js.erb b/app/views/todos/edit.js.erb index a836ca32..64c0d0c4 100644 --- a/app/views/todos/edit.js.erb +++ b/app/views/todos/edit.js.erb @@ -14,4 +14,6 @@ function replace_placeholder_with_form() { function html_for_edit_form() { return "<%= escape_javascript(render(:partial => 'todos/edit_form', :object => @todo)) %>" -} \ No newline at end of file +} + + diff --git a/public/javascripts/application.js b/public/javascripts/application.js index d1e24a5e..24ba3393 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -914,13 +914,16 @@ function enable_rich_interaction(){ /* Autocomplete */ $('input[name=context_name]').autocomplete({ - source: relative_to_root('contexts.autocomplete') + source: relative_to_root('contexts.autocomplete'), + selectFirst: true }); $('input[name=project_name]').autocomplete({ - source: relative_to_root('projects.autocomplete') + source: relative_to_root('projects.autocomplete'), + selectFirst: true }); $('input[name="project[default_context_name]"]').autocomplete({ - source: relative_to_root('contexts.autocomplete') + source: relative_to_root('contexts.autocomplete'), + selectFirst: true }); $('input[name=tag_list]:not(.ac_input)') diff --git a/public/javascripts/jquery.ui.autocomplete.selectFirst.js b/public/javascripts/jquery.ui.autocomplete.selectFirst.js new file mode 100644 index 00000000..10be3ba4 --- /dev/null +++ b/public/javascripts/jquery.ui.autocomplete.selectFirst.js @@ -0,0 +1,23 @@ +/* +* 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 )); +