157 |
return false; |
return false; |
158 |
} |
} |
159 |
|
|
160 |
|
var WebPAC = { }; |
161 |
|
|
162 |
/* |
/* |
163 |
autocompleter which isn't (a suggest box) |
autocompleter which isn't (a suggest box) |
164 |
- don't just on first option on appear |
- don't just on first option on appear |
166 |
- added configurable width (content width? centered?) |
- added configurable width (content width? centered?) |
167 |
- add icon which means suggest |
- add icon which means suggest |
168 |
|
|
169 |
hopefully, this implementation won't break when I update prototype next time :-) |
hopefully, this implementation won't break (much) when I update |
170 |
|
prototype next time :-) |
171 |
*/ |
*/ |
172 |
|
|
173 |
|
|
174 |
Ajax.Suggest = Class.create(); |
WebPAC.Suggest = Class.create(); |
175 |
Logger.debug('Created Ajax.Suggest Class'); |
Logger.debug('Created WebPAC.Suggest Class'); |
176 |
Object.extend(Object.extend(Ajax.Suggest.prototype, Ajax.Autocompleter.prototype), { |
Object.extend(Object.extend(WebPAC.Suggest.prototype, Ajax.Autocompleter.prototype), { |
177 |
initialize: function(element, update, url, options) { |
initialize: function(element, update, url, options) { |
178 |
this.baseInitialize(element, update, options); |
this.baseInitialize(element, update, options); |
179 |
this.options.asynchronous = true; |
this.options.asynchronous = true; |
180 |
this.options.onComplete = this.onComplete.bind(this); |
this.options.onComplete = this.onComplete.bind(this); |
181 |
this.options.defaultParams = this.options.parameters || null; |
this.options.defaultParams = this.options.parameters || null; |
182 |
this.url = url; |
this.url = url; |
183 |
this.ignoreReturn = true; |
this.ignoreReturn = true; |
184 |
|
|
185 |
Logger.debug('Ajax.Sugget initialize '+element+','+update+','+url); |
Logger.debug('WebPAC.Sugget initialize '+element+','+update+','+url); |
186 |
|
|
187 |
this.options.onShow = function(element, update) { |
this.options.onShow = function(element, update) { |
188 |
if(!update.style.position || update.style.position=='absolute') { |
if(!update.style.position || update.style.position=='absolute') { |
190 |
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); |
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); |
191 |
} |
} |
192 |
new Element.show(update); |
new Element.show(update); |
193 |
Logger.debug('Ajax.Suggest.onShow'); |
Logger.debug('WebPAC.Suggest.onShow'); |
194 |
}; |
}; |
195 |
|
|
196 |
this.options.onHide = function(element, update) { |
this.options.onHide = function(element, update) { |
197 |
new Element.hide(update); |
new Element.hide(update); |
198 |
Logger.debug('Ajax.Suggest.onHide'); |
Logger.debug('WebPAC.Suggest.onHide'); |
199 |
}; |
}; |
200 |
}, |
}, |
201 |
|
|
209 |
if(this.options.defaultParams) |
if(this.options.defaultParams) |
210 |
this.options.parameters += '&' + this.options.defaultParams; |
this.options.parameters += '&' + this.options.defaultParams; |
211 |
|
|
212 |
Logger.debug('Ajax.Suggest called '+this.url); |
Logger.debug('WebPAC.Suggest called '+this.url); |
213 |
new Ajax.Request(this.url, this.options); |
new Ajax.Request(this.url, this.options); |
214 |
}, |
}, |
215 |
|
|
216 |
onComplete: function(request) { |
onComplete: function(request) { |
217 |
Logger.debug('Ajax.Suggest onComplete called'); |
Logger.debug('WebPAC.Suggest onComplete called'); |
218 |
this.updateChoices(request.responseText); |
this.updateChoices(request.responseText); |
219 |
}, |
}, |
220 |
|
|
230 |
|
|
231 |
}); |
}); |
232 |
|
|
233 |
|
/* |
234 |
|
WebPAC.Updater |
235 |
|
*/ |
236 |
|
|
237 |
|
WebPAC.Updater = Class.create(); |
238 |
|
Logger.debug('Created WebPAC.Updater Class'); |
239 |
|
Object.extend(WebPAC.Updater.prototype, { |
240 |
|
initialize: function(container, url, options) { |
241 |
|
Logger.debug('WebPAC.Updater initialize '+container+','+url+','+options); |
242 |
|
this.updater = new Ajax.Updater(container, url, options); |
243 |
|
$('_ajax').value = 1; |
244 |
|
if ($('_ajax').value) Logger.info("using AJAX"); |
245 |
|
} |
246 |
|
}); |
247 |
|
|