Changeset 569
add token example, remove debug code
Apr 06 2008 * 09:02 (7 months ago)
Committed by seb
Affected files:
trunk/test/functional/auto_complete/test_auto_complete_token.html
trunk/src/auto_complete/auto_complete.js (Quick diff)
trunk/test/functional/auto_complete/test_auto_complete_ajax.html (Quick diff)
trunk/src/auto_complete/auto_complete.js (Unified diff)
| r568 | r569 | |
|---|---|---|
| 67 | 67 | // Close button |
| 68 | 68 | var close = new Element('a', {'href': '#', 'class': 'closebutton'}); |
| 69 | 69 | li.insert(new Element("span").update(text).insert(close)); |
| 70 | if (value) | |
| 71 | li.writeAttribute("pui-autocomplete:value", value); | |
| 72 | ||
| 70 | 73 | close.observe("click", this.remove.bind(this, li)); |
| 71 | 74 | |
| 72 | 75 | this.input.parentNode.insert({before: li}); |
| --- | --- | |
| 144 | 147 | if (!element) |
| 145 | 148 | this.input.blur(); |
| 146 | 149 | |
| 147 | // this.hideAutocomplete(); | |
| 150 | this.hideAutocomplete(); | |
| 148 | 151 | return this.fire("element:blur", {element: element}); |
| 149 | 152 | }, |
| 150 | 153 | |
| --- | --- | |
| 294 | 297 | runRequest: function(search) { |
| 295 | 298 | this.autocompletionContainer.hide(); |
| 296 | 299 | this.fire("request:started"); |
| 300 | ||
| 297 | 301 | new Ajax.Request(this.options.url, {parameters: {search: search, max: this.options.max.selection}, onComplete: function(transport) { |
| 298 | 302 | this.setAutocompleteList(transport.responseText.evalJSON()); |
| 299 | 303 | this.timer = null; |
| --- | --- | |
| 424 | 428 | this.selectedList.each(function(entry) { |
| 425 | 429 | var li = new Element("li").update(this.options.highlight ? entry.text.gsub(value, "<em>" + value + "</em>") : entry.text); |
| 426 | 430 | li.observe("mouseover", this.moveSelection.bindAsEventListener(this, li)) |
| 427 | .observe("mousedown", this.addCurrentSelected.bindAsEventListener(this)); | |
| 431 | .observe("mousedown", this.addCurrentSelected.bindAsEventListener(this)); | |
| 428 | 432 | this.autocompletionContainer.insert(li); |
| 429 | 433 | }.bind(this)); |
| 430 | 434 | this.autocompletionContainer.show(); |
trunk/test/functional/auto_complete/test_auto_complete_ajax.html (Unified diff)
| r568 | r569 | |
|---|---|---|
| 7 | 7 | |
| 8 | 8 | <script src="../../../lib/prototype.js" type="text/javascript"></script> |
| 9 | 9 | <script src="../../../lib/effects.js" type="text/javascript"></script> |
| 10 | <script src="../../../dist/auto_complete.js" type="text/javascript"></script> | |
| 10 | <script src="../../../dist/prototype-ui.js" type="text/javascript"></script> | |
| 11 | 11 | <link href="../../../themes/auto_complete/default.css" rel="stylesheet" type="text/css" /> |
| 12 | 12 | <link href="../../../themes/shadow/drop_shadow.css" rel="stylesheet" type="text/css"> |
| 13 | 13 | <style> |
| --- | --- | |
| 35 | 35 | |
| 36 | 36 | <button onclick="return false;">Submit</button> |
| 37 | 37 | <script type="text/javascript"> |
| 38 | ||
| 39 | ||
| 40 | Ajax.Request.prototype.originalInitialize = Ajax.Request.prototype.initialize; | |
| 41 | Ajax.Request.prototype.initialize = function(url, options) { | |
| 42 | options.onComplete = options.onComplete.wrap(function(proceed, request, json) { | |
| 43 | //console.log(request.responseText) | |
| 44 | var list = request.responseText.evalJSON(); | |
| 45 | var value = $("pui-demo").value; | |
| 46 | list = list.findAll(function(entry) {return entry.text.match(value)}); | |
| 47 | proceed.curry(request, json).delay(0.1); | |
| 48 | }); | |
| 49 | this.originalInitialize(url, options); | |
| 50 | } | |
| 51 | ||
| 52 | // Mock ajax response | |
| 53 | ||
| 38 | 54 | Event.observe(window, "load", function() { |
| 39 | 55 | ac = new UI.AutoComplete('pui-demo', { url: "../../fixtures/auto_complete.json", |
| 40 | 56 | shadow: "drop_shadow" |


RSS feeds