mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
adds juery.ui autocomplete extension selectFirst to select the first matching entry
This commit is contained in:
parent
564f209800
commit
1a42f00a0a
4 changed files with 33 additions and 5 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
<%= javascript_include_tag 'jquery-1.5.min', 'jquery-ui-1.8.9.custom.min', 'jquery.truncator',
|
<%= 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' %>
|
'jquery.jeditable.mini', 'jquery.cookie', 'jquery.blockUI', 'jquery.form', :cache => 'jquery-cached' %>
|
||||||
<%= javascript_include_tag 'hoverIntent','superfish','application',
|
<%= 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 AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
|
||||||
<%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %>
|
<%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %>
|
||||||
<%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %>
|
<%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %>
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,5 @@ function replace_placeholder_with_form() {
|
||||||
function html_for_edit_form() {
|
function html_for_edit_form() {
|
||||||
return "<%= escape_javascript(render(:partial => 'todos/edit_form', :object => @todo)) %>"
|
return "<%= escape_javascript(render(:partial => 'todos/edit_form', :object => @todo)) %>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -914,13 +914,16 @@ function enable_rich_interaction(){
|
||||||
|
|
||||||
/* Autocomplete */
|
/* Autocomplete */
|
||||||
$('input[name=context_name]').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({
|
$('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({
|
$('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)')
|
$('input[name=tag_list]:not(.ac_input)')
|
||||||
|
|
|
||||||
23
public/javascripts/jquery.ui.autocomplete.selectFirst.js
Normal file
23
public/javascripts/jquery.ui.autocomplete.selectFirst.js
Normal file
|
|
@ -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 ));
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue