Changeset 569

add token example, remove debug code

Apr 06 2008 * 09:02 (7 months ago)
Committed by seb

Affected files:

trunk/src/auto_complete/auto_complete.js (Unified diff)

r568r569
6767 // Close button
6868 var close = new Element('a', {'href': '#', 'class': 'closebutton'});
6969 li.insert(new Element("span").update(text).insert(close));
70 if (value)
71 li.writeAttribute("pui-autocomplete:value", value);
72
7073 close.observe("click", this.remove.bind(this, li));
7174
7275 this.input.parentNode.insert({before: li});
------
144147 if (!element)
145148 this.input.blur();
146149
147 // this.hideAutocomplete();
150 this.hideAutocomplete();
148151 return this.fire("element:blur", {element: element});
149152 },
150153
------
294297 runRequest: function(search) {
295298 this.autocompletionContainer.hide();
296299 this.fire("request:started");
300
297301 new Ajax.Request(this.options.url, {parameters: {search: search, max: this.options.max.selection}, onComplete: function(transport) {
298302 this.setAutocompleteList(transport.responseText.evalJSON());
299303 this.timer = null;
------
424428 this.selectedList.each(function(entry) {
425429 var li = new Element("li").update(this.options.highlight ? entry.text.gsub(value, "<em>" + value +
"</em>") : entry.text);
426430 li.observe("mouseover", this.moveSelection.bindAsEventListener(this, li))
427 .observe("mousedown", this.addCurrentSelected.bindAsEventListener(this));
431 .observe("mousedown", this.addCurrentSelected.bindAsEventListener(this));
428432 this.autocompletionContainer.insert(li);
429433 }.bind(this));
430434 this.autocompletionContainer.show();

trunk/test/functional/auto_complete/test_auto_complete_ajax.html (Unified diff)

r568r569
77
88 <script src="../../../lib/prototype.js" type="text/javascript"></script>
99 <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>
1111 <link href="../../../themes/auto_complete/default.css" rel="stylesheet" type="text/css" />
1212 <link href="../../../themes/shadow/drop_shadow.css" rel="stylesheet" type="text/css">
1313 <style>
------
3535
3636 <button onclick="return false;">Submit</button>
3737 <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
3854 Event.observe(window, "load", function() {
3955 ac = new UI.AutoComplete('pui-demo', { url: "../../fixtures/auto_complete.json",
4056 shadow: "drop_shadow"