diff options
-rw-r--r-- | demos/autocomplete/categories.html | 40 | ||||
-rw-r--r-- | demos/autocomplete/combobox.html | 50 | ||||
-rw-r--r-- | demos/autocomplete/custom-data.html | 74 | ||||
-rw-r--r-- | demos/autocomplete/default.html | 55 | ||||
-rw-r--r-- | demos/autocomplete/folding.html | 34 | ||||
-rw-r--r-- | demos/autocomplete/index.html | 4 | ||||
-rw-r--r-- | demos/autocomplete/maxheight.html | 53 | ||||
-rw-r--r-- | demos/autocomplete/multiple-remote.html | 60 | ||||
-rw-r--r-- | demos/autocomplete/multiple.html | 76 | ||||
-rw-r--r-- | demos/autocomplete/remote-jsonp.html | 65 | ||||
-rw-r--r-- | demos/autocomplete/remote-with-cache.html | 32 | ||||
-rw-r--r-- | demos/autocomplete/remote.html | 46 | ||||
-rw-r--r-- | demos/autocomplete/xml.html | 58 |
13 files changed, 350 insertions, 297 deletions
diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html index bb59bf31e..693886d66 100644 --- a/demos/autocomplete/categories.html +++ b/demos/autocomplete/categories.html @@ -1,25 +1,25 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Autocomplete Custom Data Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-category { - font-weight:bold; - padding:.2em .4em; - margin:.8em 0 .2em; - line-height:1.5; + font-weight: bold; + padding: .2em .4em; + margin: .8em 0 .2em; + line-height: 1.5; } </style> - <script type="text/javascript"> - $.widget("custom.catcomplete", $.ui.autocomplete, { + <script> + $.widget( "custom.catcomplete", $.ui.autocomplete, { _renderMenu: function( ul, items ) { var self = this, currentCategory = ""; @@ -33,7 +33,7 @@ } }); </script> - <script type="text/javascript"> + <script> $(function() { var data = [ { label: "anders", category: "" }, @@ -47,7 +47,7 @@ { label: "andreas johnson", category: "People" } ]; - $('#search').catcomplete({ + $( "#search" ).catcomplete({ delay: 0, source: data }); @@ -61,10 +61,10 @@ <input id="search" /> </div><!-- End demo --> + + <div class="demo-description"> -<p> - A categorized search result. Try typing "a" or "n". -</p> +<p>A categorized search result. Try typing "a" or "n".</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index b5309888e..d78d12155 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -1,27 +1,27 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Combobox Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> - .ui-button { margin-left: -1px; } - .ui-button-icon-only .ui-button-text { padding: 0.35em; } - .ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; } + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> + .ui-button { margin-left: -1px; } + .ui-button-icon-only .ui-button-text { padding: 0.35em; } + .ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; } </style> - <script type="text/javascript"> + <script> (function( $ ) { $.widget( "ui.combobox", { _create: function() { - var self = this; - var select = this.element.hide(), + var self = this, + select = this.element.hide(), selected = select.children( ":selected" ), value = selected.val() ? selected.text() : ""; var input = $( "<input>" ) @@ -106,12 +106,12 @@ }); } }); - })(jQuery); + })( jQuery ); $(function() { - $("#combobox").combobox(); - $("#toggle").click(function() { - $("#combobox").toggle(); + $( "#combobox" ).combobox(); + $( "#toggle" ).click(function() { + $( "#combobox" ).toggle(); }); }); </script> @@ -152,13 +152,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -A custom widget built by composition of Autocomplete and Button. You can either type something into the field to get filtered suggestions based on your input, or use the button to get the full list of selections. -</p> -<p> -The input is read from an existing select-element for progressive enhancement, passed to Autocomplete with a customized source-option. -</p> +<p>A custom widget built by composition of Autocomplete and Button. You can either type something into the field to get filtered suggestions based on your input, or use the button to get the full list of selections.</p> +<p>The input is read from an existing select-element for progressive enhancement, passed to Autocomplete with a customized source-option.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/custom-data.html b/demos/autocomplete/custom-data.html index b9de20576..aa097fd58 100644 --- a/demos/autocomplete/custom-data.html +++ b/demos/autocomplete/custom-data.html @@ -1,16 +1,16 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Custom Data Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> #project-label { display: block; font-weight: bold; @@ -26,42 +26,42 @@ padding: 0; } </style> - <script type="text/javascript"> + <script> $(function() { var projects = [ { - value: 'jquery', - label: 'jQuery', - desc: 'the write less, do more, JavaScript library', - icon: 'jquery_32x32.png' + value: "jquery", + label: "jQuery", + desc: "the write less, do more, JavaScript library", + icon: "jquery_32x32.png" }, { - value: 'jquery-ui', - label: 'jQuery UI', - desc: 'the official user interface library for jQuery', - icon: 'jqueryui_32x32.png' + value: "jquery-ui", + label: "jQuery UI", + desc: "the official user interface library for jQuery", + icon: "jqueryui_32x32.png" }, { - value: 'sizzlejs', - label: 'Sizzle JS', - desc: 'a pure-JavaScript CSS selector engine', - icon: 'sizzlejs_32x32.png' + value: "sizzlejs", + label: "Sizzle JS", + desc: "a pure-JavaScript CSS selector engine", + icon: "sizzlejs_32x32.png" } ]; - - $('#project').autocomplete({ + + $( "#project" ).autocomplete({ minLength: 0, source: projects, - focus: function(event, ui) { - $('#project').val(ui.item.label); + focus: function( event, ui ) { + $( "#project" ).val( ui.item.label ); return false; }, - select: function(event, ui) { - $('#project').val(ui.item.label); - $('#project-id').val(ui.item.value); - $('#project-description').html(ui.item.desc); - $('#project-icon').attr('src', 'images/' + ui.item.icon); - + select: function( event, ui ) { + $( "#project" ).val( ui.item.label ); + $( "#project-id" ).val( ui.item.value ); + $( "#project-description" ).html( ui.item.desc ); + $( "#project-icon" ).attr( "src", "images/" + ui.item.icon ); + return false; } }) @@ -84,13 +84,11 @@ <p id="project-description"></p> </div><!-- End demo --> + + <div class="demo-description"> -<p> -You can use your own custom data formats and displays by simply overriding the default focus and select actions. -</p> -<p> -Try typing "j" to get a list of projects or just press the down arrow. -</p> +<p>You can use your own custom data formats and displays by simply overriding the default focus and select actions.</p> +<p>Try typing "j" to get a list of projects or just press the down arrow.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/default.html b/demos/autocomplete/default.html index 110263dac..658d06fd2 100644 --- a/demos/autocomplete/default.html +++ b/demos/autocomplete/default.html @@ -1,19 +1,42 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Default Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <script type="text/javascript"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> $(function() { - var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"]; - $("#tags").autocomplete({ + var availableTags = [ + "ActionScript", + "AppleScript", + "Asp", + "BASIC", + "C", + "C++", + "Clojure", + "COBOL", + "ColdFusion", + "Erlang", + "Fortran", + "Groovy", + "Haskell", + "Java", + "JavaScript", + "Lisp", + "Perl", + "PHP", + "Python", + "Ruby", + "Scala", + "Scheme" + ]; + $( "#tags" ).autocomplete({ source: availableTags }); }); @@ -30,13 +53,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try. -</p> -<p> -The datasource is a simple JavaScript array, provided to the widget using the source-option. -</p> +<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p> +<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/folding.html b/demos/autocomplete/folding.html index d5bc71e9d..8fd813ffd 100644 --- a/demos/autocomplete/folding.html +++ b/demos/autocomplete/folding.html @@ -1,25 +1,25 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Accent Folding Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <script type="text/javascript"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> $(function() { var names = [ "Jörn Zaefferer", "Scott González", "John Resig" ]; var accentMap = { - 'á':'a', - 'ö':'o' + "á": "a", + "ö": "o" }; var normalize = function( term ) { - var ret = ''; + var ret = ""; for ( var i = 0; i < term.length; i++ ) { ret += accentMap[ term.charAt(i) ] || term.charAt(i); } @@ -51,13 +51,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -The autocomplete field uses a custom source option which will match results that have accented characters even when the text field doesn't contain accented characters. However if the you type in accented characters in the text field it is smart enough not to show results that aren't accented. -</p> -<p> -Try typing "Jo" to see "John" and "Jörn", then type "Jö" to see only "Jörn". -</p> +<p>The autocomplete field uses a custom source option which will match results that have accented characters even when the text field doesn't contain accented characters. However if the you type in accented characters in the text field it is smart enough not to show results that aren't accented.</p> +<p>Try typing "Jo" to see "John" and "Jörn", then type "Jö" to see only "Jörn".</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/index.html b/demos/autocomplete/index.html index 9d5ba3a87..d97c817fb 100644 --- a/demos/autocomplete/index.html +++ b/demos/autocomplete/index.html @@ -1,9 +1,9 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Demos</title> - <link type="text/css" href="../demos.css" rel="stylesheet" /> + <link rel="stylesheet" href="../demos.css"> </head> <body> <div class="demos-nav"> diff --git a/demos/autocomplete/maxheight.html b/demos/autocomplete/maxheight.html index 97de724ba..955fed897 100644 --- a/demos/autocomplete/maxheight.html +++ b/demos/autocomplete/maxheight.html @@ -1,16 +1,16 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Scrollable Results Demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete { max-height: 100px; overflow-y: auto; @@ -22,10 +22,33 @@ height: 100px; } </style> - <script type="text/javascript"> + <script> $(function() { - var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"]; - $("#tags").autocomplete({ + var availableTags = [ + "ActionScript", + "AppleScript", + "Asp", + "BASIC", + "C", + "C++", + "Clojure", + "COBOL", + "ColdFusion", + "Erlang", + "Fortran", + "Groovy", + "Haskell", + "Java", + "JavaScript", + "Lisp", + "Perl", + "PHP", + "Python", + "Ruby", + "Scala", + "Scheme" + ]; + $( "#tags" ).autocomplete({ source: availableTags }); }); @@ -42,10 +65,10 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through. -</p> +<p>When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html index 0f77e795d..b0313e1d0 100644 --- a/demos/autocomplete/multiple-remote.html +++ b/demos/autocomplete/multiple-remote.html @@ -1,37 +1,37 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Autocomplete multiple demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } </style> - <script type="text/javascript"> + <script> $(function() { - function split(val) { - return val.split(/,\s*/); + function split( val ) { + return val.split( /,\s*/ ); } - function extractLast(term) { - return split(term).pop(); + function extractLast( term ) { + return split( term ).pop(); } - - $("#birds").autocomplete({ - source: function(request, response) { - $.getJSON("search.php", { - term: extractLast(request.term) - }, response); + + $( "#birds" ).autocomplete({ + source: function( request, response ) { + $.getJSON( "search.php", { + term: extractLast( request.term ) + }, response ); }, search: function() { // custom minLength - var term = extractLast(this.value); - if (term.length < 2) { + var term = extractLast( this.value ); + if ( term.length < 2 ) { return false; } }, @@ -39,15 +39,15 @@ // prevent value inserted on focus return false; }, - select: function(event, ui) { + select: function( event, ui ) { var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end - terms.push(""); - this.value = terms.join(", "); + terms.push( "" ); + this.value = terms.join( ", " ); return false; } }); @@ -65,13 +65,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -Usage: Enter at least two characters to get bird name suggestions. Select a value to continue adding more names. -</p> -<p> -This is an example showing how to use the source-option along with some events to enable autocompleting multiple values into a single field. -</p> +<p>Usage: Enter at least two characters to get bird name suggestions. Select a value to continue adding more names.</p> +<p>This is an example showing how to use the source-option along with some events to enable autocompleting multiple values into a single field.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/multiple.html b/demos/autocomplete/multiple.html index 1f9243bf2..d14fac375 100644 --- a/demos/autocomplete/multiple.html +++ b/demos/autocomplete/multiple.html @@ -1,44 +1,68 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete multiple demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <script type="text/javascript"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> $(function() { - var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"]; - function split(val) { - return val.split(/,\s*/); + var availableTags = [ + "ActionScript", + "AppleScript", + "Asp", + "BASIC", + "C", + "C++", + "Clojure", + "COBOL", + "ColdFusion", + "Erlang", + "Fortran", + "Groovy", + "Haskell", + "Java", + "JavaScript", + "Lisp", + "Perl", + "PHP", + "Python", + "Ruby", + "Scala", + "Scheme" + ]; + function split( val ) { + return val.split( /,\s*/ ); } - function extractLast(term) { - return split(term).pop(); + function extractLast( term ) { + return split( term ).pop(); } - - $("#tags").autocomplete({ + + $( "#tags" ).autocomplete({ minLength: 0, - source: function(request, response) { + source: function( request, response ) { // delegate back to autocomplete, but extract the last term - response($.ui.autocomplete.filter(availableTags, extractLast(request.term))); + response( $.ui.autocomplete.filter( + availableTags, extractLast( request.term ) ) ); }, focus: function() { // prevent value inserted on focus return false; }, - select: function(event, ui) { + select: function( event, ui ) { var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end - terms.push(""); - this.value = terms.join(", "); + terms.push( "" ); + this.value = terms.join( ", " ); return false; } }); @@ -56,13 +80,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -Usage: Type something, eg. "j" to see suggestions for tagging with programming languages. Select a value, then continue typing to add more. -</p> -<p> -This is an example showing how to use the source-option along with some events to enable autocompleting multiple values into a single field. -</p> +<p>Usage: Type something, eg. "j" to see suggestions for tagging with programming languages. Select a value, then continue typing to add more.</p> +<p>This is an example showing how to use the source-option along with some events to enable autocompleting multiple values into a single field.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/remote-jsonp.html b/demos/autocomplete/remote-jsonp.html index 127298e36..738bee522 100644 --- a/demos/autocomplete/remote-jsonp.html +++ b/demos/autocomplete/remote-jsonp.html @@ -1,27 +1,28 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Remote JSONP datasource demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } + #city { width: 25em; } </style> - <script type="text/javascript"> + <script> $(function() { - function log(message) { - $("<div/>").text(message).prependTo("#log"); - $("#log").attr("scrollTop", 0); + function log( message ) { + $( "<div/>" ).text( message ).prependTo( "#log" ); + $( "#log" ).attr( "scrollTop", 0 ); } - - $("#city").autocomplete({ - source: function(request, response) { + + $( "#city" ).autocomplete({ + source: function( request, response ) { $.ajax({ url: "http://ws.geonames.org/searchJSON", dataType: "jsonp", @@ -31,33 +32,31 @@ maxRows: 12, name_startsWith: request.term }, - success: function(data) { - response($.map(data.geonames, function(item) { + success: function( data ) { + response( $.map( data.geonames, function( item ) { return { label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name } - })) + })); } - }) + }); }, minLength: 2, - select: function(event, ui) { - log(ui.item ? ("Selected: " + ui.item.label) : "Nothing selected, input was " + this.value); + select: function( event, ui ) { + log( ui.item ? + "Selected: " + ui.item.label : + "Nothing selected, input was " + this.value); }, open: function() { - $(this).removeClass("ui-corner-all").addClass("ui-corner-top"); + $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { - $(this).removeClass("ui-corner-top").addClass("ui-corner-all"); + $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); }); </script> - <style> - .ui-autocomplete-loading { background: url(indicator.gif) no-repeat right; } - #city { width: 25em; } - </style> </head> <body> @@ -76,13 +75,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least two characters are entered into the field. -</p> -<p> -In this case, the datasource is the <a href="http://geonames.org">geonames.org webservice</a>. While only the city name itself ends up in the input after selecting an element, more info is displayed in the suggestions to help find the right entry. That data is also available in callbacks, as illustrated by the Result area below the input. -</p> +<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least two characters are entered into the field.</p> +<p>In this case, the datasource is the <a href="http://geonames.org">geonames.org webservice</a>. While only the city name itself ends up in the input after selecting an element, more info is displayed in the suggestions to help find the right entry. That data is also available in callbacks, as illustrated by the Result area below the input.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/remote-with-cache.html b/demos/autocomplete/remote-with-cache.html index 77741fbe9..09eb6c0d3 100644 --- a/demos/autocomplete/remote-with-cache.html +++ b/demos/autocomplete/remote-with-cache.html @@ -1,25 +1,25 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Remote with caching demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } </style> - <script type="text/javascript"> + <script> $(function() { var cache = {}, lastXhr; $( "#birds" ).autocomplete({ minLength: 2, - source: function(request, response) { + source: function( request, response ) { var term = request.term; if ( term in cache ) { response( cache[ term ] ); @@ -48,13 +48,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field. -</p> -<p> -Similar to the remote datasource demo, though this adds some local caching to improve performance. The cache here saves just one query, and could be extended to cache multiple values, one for each term. -</p> +<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p> +<p>Similar to the remote datasource demo, though this adds some local caching to improve performance. The cache here saves just one query, and could be extended to cache multiple values, one for each term.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/remote.html b/demos/autocomplete/remote.html index 2dd0eb733..6c924fe91 100644 --- a/demos/autocomplete/remote.html +++ b/demos/autocomplete/remote.html @@ -1,30 +1,32 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Remote datasource demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } </style> - <script type="text/javascript"> + <script> $(function() { - function log(message) { - $("<div/>").text(message).prependTo("#log"); - $("#log").attr("scrollTop", 0); + function log( message ) { + $( "<div/>" ).text( message ).prependTo( "#log" ); + $( "#log" ).attr( "scrollTop", 0 ); } - - $("#birds").autocomplete({ + + $( "#birds" ).autocomplete({ source: "search.php", minLength: 2, - select: function(event, ui) { - log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value); + select: function( event, ui ) { + log( ui.item ? + "Selected: " + ui.item.value + " aka " + ui.item.id : + "Nothing selected, input was " + this.value ); } }); }); @@ -46,13 +48,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field. -</p> -<p> -The datasource is a server-side script which returns JSON data, specified via a simple URL for the source-option. In addition, the minLength-option is set to 2 to avoid queries that would return too many results and the select-event is used to display some feedback. -</p> +<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p> +<p>The datasource is a server-side script which returns JSON data, specified via a simple URL for the source-option. In addition, the minLength-option is set to 2 to avoid queries that would return too many results and the select-event is used to display some feedback.</p> </div><!-- End demo-description --> </body> diff --git a/demos/autocomplete/xml.html b/demos/autocomplete/xml.html index c00868cac..5ed68b70b 100644 --- a/demos/autocomplete/xml.html +++ b/demos/autocomplete/xml.html @@ -1,45 +1,47 @@ <!DOCTYPE html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8" /> <title>jQuery UI Autocomplete Remote datasource demo</title> - <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> - <script type="text/javascript" src="../../jquery-1.4.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <link type="text/css" href="../demos.css" rel="stylesheet" /> - <style type="text/css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.4.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.autocomplete.js"></script> + <link rel="stylesheet" href="../demos.css"> + <style> .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } </style> - <script type="text/javascript"> + <script> $(function() { - function log(message) { - $("<div/>").text(message).prependTo("#log"); - $("#log").attr("scrollTop", 0); + function log( message ) { + $( "<div/>" ).text( message ).prependTo( "#log" ); + $( "#log" ).attr( "scrollTop", 0 ); } - + $.ajax({ url: "london.xml", dataType: "xml", - success: function(xmlResponse) { - var data = $("geoname", xmlResponse).map(function() { + success: function( xmlResponse ) { + var data = $( "geoname", xmlResponse ).map(function() { return { - value: $("name", this).text() + ", " + ($.trim($("countryName", this).text()) || "(unknown country)"), - id: $("geonameId", this).text() + value: $( "name", this ).text() + ", " + + ( $.trim( $( "countryName", this ).text() ) || "(unknown country)" ), + id: $( "geonameId", this ).text() }; }).get(); - $("#birds").autocomplete({ + $( "#birds" ).autocomplete({ source: data, minLength: 0, - select: function(event, ui) { - log(ui.item ? ("Selected: " + ui.item.value + ", geonameId: " + ui.item.id) : "Nothing selected, input was " + this.value); + select: function( event, ui ) { + log( ui.item ? + "Selected: " + ui.item.value + ", geonameId: " + ui.item.id : + "Nothing selected, input was " + this.value ); } }); } - }) - + }); }); </script> </head> @@ -59,13 +61,11 @@ </div><!-- End demo --> + + <div class="demo-description"> -<p> -This demo shows how to retrieve some XML data, parse it using jQuery's methods, then provide it to the autocomplete as the datasource. -</p> -<p> -This should also serve as a reference on how to parse a remote XML datasource - the parsing would just happen for each request within the source-callback. -</p> +<p>This demo shows how to retrieve some XML data, parse it using jQuery's methods, then provide it to the autocomplete as the datasource.</p> +<p>This should also serve as a reference on how to parse a remote XML datasource - the parsing would just happen for each request within the source-callback.</p> </div><!-- End demo-description --> </body> |