Skip to content

Commit

Permalink
Added recursive merging to setOptions. Updated documentation. Now on …
Browse files Browse the repository at this point in the history
…version 1.2.
  • Loading branch information
agarzola committed Nov 19, 2010
1 parent 0622996 commit 675e1d5
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 187 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,28 @@
#jQuery Autocomplete Plugin 1.1.1# #jQuery Autocomplete Plugin 1.2#


##About this jQuery plugin## ##About this jQuery plugin##
Jörn Zaefferer’s (now deprecated into jQuery UI) [jQuery Autocomplete Plugin](http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/), with a small modification to enable UP/DOWN arrow keys, allowing navigation of input element text. This is particularly useful in cases where autocomplete is used in a textarea element where navigation of text via UP/DOWN arrow keys may be necessary. The tiny fix is documented with comments in the relevant lines on the development file (jquery.autocomplete.js). The .min and .pack files have the fix without specific annotation within the code. Jörn Zaefferer’s (now deprecated into jQuery UI) [jQuery Autocomplete Plugin](http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/), with a small modification to enable UP/DOWN arrow keys, allowing navigation of input element text. This is particularly useful in cases where autocomplete is used in a textarea element where navigation of text via UP/DOWN arrow keys may be necessary. The tiny fix is documented with comments in the relevant lines on the development file (jquery.autocomplete.js). The .min and .pack files have the fix without specific annotation within the code.


We use it in Claritty.com for when a user wants to write a twitter username or a previously used hashtag within a new tweet, so “@” and “#” are trigger the script. While not triggered, though, the plugin still hijacks the UP/DOWN arrow keys making navigation of the text a pain in the ass when the user has multiple lines. This modification prevents this behavior, hijacking the arrow keys only when the autocomplete script has been triggered. We use it in Claritty.com for when a user wants to write a twitter username or a previously used hashtag within a new tweet, so “@” and “#” are trigger the script. While not triggered, though, the plugin still hijacks the UP/DOWN arrow keys making navigation of the text a pain in the ass when the user has multiple lines. This modification prevents this behavior, hijacking the arrow keys only when the autocomplete script has been triggered.


The original plugin is now deprecated, but it —and this mod works well (at least up to jQuery 1.4.3). The original plugin is now deprecated, but this mod works well with jQuery 1.3.2 thru 1.4.4.


##Documentation## ##Documentation##
Introduction to the original plugin, and an explanation of original plugin options are included in the docs folder. (Documentation at the jQuery site is expected to shut down eventually.) Introduction to the original plugin, and an explanation of original plugin options are included in the docs folder. (Documentation at the jQuery site is expected to shut down eventually.)


This modification shouldn’t break any of the options discussed at the these documentation files. This modification shouldn’t break any of the options discussed at the these documentation files.


##Abridged Changelog##
1.2 --AGA
---
* Use recursive merging when extending setOptions. (Request/recommendation by smarques.)

1.1.1 --AGA
---
* Changed hijacking of UP/DOWN arrow keys to prevent default behavior only when selections list is visible. Helps text navigation inside input element.

_See changelog.txt for pre-1.1.1 entries by original author._

##Licensing## ##Licensing##
As with the original Plugin, this modification is dual licensed under the MIT and GPL licenses: As with the original Plugin, this modification is dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php http://www.opensource.org/licenses/mit-license.php
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
1.2 --AGA
---
* Use recursive merging when extending setOptions. (Request/recommendation by smarques.)

1.1.1 --AGA 1.1.1 --AGA
--- ---
* Changed hijacking of UP/DOWN arrow keys to prevent default behavior only when selections list is visible. Helps text navigation inside input element. * Changed hijacking of UP/DOWN arrow keys to prevent default behavior only when selections list is visible. Helps text navigation inside input element.
Expand Down
11 changes: 4 additions & 7 deletions jquery.autocomplete.js
Original file line number Original file line Diff line number Diff line change
@@ -1,18 +1,15 @@
/* /*
* jQuery Autocomplete plugin 1.1.1 * jQuery Autocomplete plugin 1.2
* *
* Copyright (c) 2009 Jörn Zaefferer * Copyright (c) 2009 Jörn Zaefferer
* *
* Dual licensed under the MIT and GPL licenses: * Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
* *
* With a small modification by Alfonso Gómez-Arzola to * With a small modifications by Alfonso Gómez-Arzola.
* enable UP/DOWN arrow keys when navigating text within * See changelog for details.
* input element. Particularly useful for textareas.
* Only lines 105-106 & 114-115 were changed.
* *
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
*/ */


;(function($) { ;(function($) {
Expand Down Expand Up @@ -194,7 +191,7 @@ $.Autocompleter = function(input, options) {
}).bind("flushCache", function() { }).bind("flushCache", function() {
cache.flush(); cache.flush();
}).bind("setOptions", function() { }).bind("setOptions", function() {
$.extend(options, arguments[1]); $.extend(true, options, arguments[1]);
// if we've updated the data, repopulate // if we've updated the data, repopulate
if ( "data" in arguments[1] ) if ( "data" in arguments[1] )
cache.populate(); cache.populate();
Expand Down
10 changes: 4 additions & 6 deletions jquery.autocomplete.min.js

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions jquery.autocomplete.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 675e1d5

Please sign in to comment.