156 |
} |
} |
157 |
return false; |
return false; |
158 |
} |
} |
159 |
|
|
160 |
|
/* |
161 |
|
autocompleter which isn't (a suggest box) |
162 |
|
- don't just on first option on appear |
163 |
|
- removed fade-in/out effect |
164 |
|
- added configurable width (content width? centered?) |
165 |
|
- add icon which means suggest |
166 |
|
|
167 |
|
hopefully, this implementation won't break when I update prototype next time :-) |
168 |
|
*/ |
169 |
|
|
170 |
|
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { |
171 |
|
initialize: function(element, update, url, options) { |
172 |
|
this.baseInitialize(element, update, options); |
173 |
|
this.options.asynchronous = true; |
174 |
|
this.options.onComplete = this.onComplete.bind(this); |
175 |
|
this.options.defaultParams = this.options.parameters || null; |
176 |
|
this.url = url; |
177 |
|
this.ignoreReturn = true; |
178 |
|
|
179 |
|
this.options.onShow = function(element, update) { |
180 |
|
if(!update.style.position || update.style.position=='absolute') { |
181 |
|
update.style.position = 'absolute'; |
182 |
|
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); |
183 |
|
} |
184 |
|
new Element.show(update); |
185 |
|
Logger.debug('Ajax.Suggest.onShow'); |
186 |
|
}; |
187 |
|
|
188 |
|
this.options.onHide = function(element, update) { |
189 |
|
new Element.hide(update); |
190 |
|
Logger.debug('Ajax.Suggest.onHide'); |
191 |
|
}; |
192 |
|
}, |
193 |
|
|
194 |
|
getUpdatedChoices: function() { |
195 |
|
entry = encodeURIComponent(this.options.paramName) + '=' + |
196 |
|
encodeURIComponent(this.getToken()); |
197 |
|
|
198 |
|
this.options.parameters = this.options.callback ? |
199 |
|
this.options.callback(this.element, entry) : entry; |
200 |
|
|
201 |
|
if(this.options.defaultParams) |
202 |
|
this.options.parameters += '&' + this.options.defaultParams; |
203 |
|
|
204 |
|
Logger.debug('Ajax.Suggest called '+this.url); |
205 |
|
new Ajax.Request(this.url, this.options); |
206 |
|
}, |
207 |
|
|
208 |
|
onComplete: function(request) { |
209 |
|
Logger.debug('Ajax.Suggest onComplete called'); |
210 |
|
this.updateChoices(request.responseText); |
211 |
|
}, |
212 |
|
|
213 |
|
markPrevious: function() { |
214 |
|
if(this.index > 0) this.index-- |
215 |
|
// else this.index = this.entryCount-1; |
216 |
|
}, |
217 |
|
|
218 |
|
markNext: function() { |
219 |
|
if(this.index < this.entryCount-1) this.index++ |
220 |
|
// else this.index = 0; |
221 |
|
}, |
222 |
|
|
223 |
|
}); |