121 |
function hide_searching() { |
function hide_searching() { |
122 |
Logger.debug('hide_searching'); |
Logger.debug('hide_searching'); |
123 |
Element.hide('searching'); |
Element.hide('searching'); |
124 |
new Effect.Highlight('results'); |
// new Effect.Highlight('results'); |
125 |
// new Effect.Appear('results', { duration: 0.3 }); |
// new Effect.Appear('results', { duration: 0.3 }); |
126 |
return false; |
return false; |
127 |
} |
} |
128 |
|
|
129 |
|
/* |
130 |
|
load record nr in some template |
131 |
|
*/ |
132 |
|
|
133 |
|
function load_rec(record_uri, tmp_template_filename) { |
134 |
|
if (! tmp_template_filename) tmp_template_filename = template_filename; |
135 |
|
Logger.info('load_rec '+record_uri+' in '+tmp_template_filename); |
136 |
|
|
137 |
|
var results_form = $('results_form'); |
138 |
|
|
139 |
|
if (results_form) { |
140 |
|
var args = '?record_uri='+record_uri+'&template_filename='+tmp_template_filename; |
141 |
|
Logger.debug('Ajax.Updater(results,/search/record) '+args); |
142 |
|
|
143 |
|
new Ajax.Updater( 'results', '/search/record'+args, { |
144 |
|
asynchronous: 1, |
145 |
|
onLoading: function(request) { |
146 |
|
show_searching(); |
147 |
|
}, |
148 |
|
onLoaded: function(request) { |
149 |
|
hide_searching(); |
150 |
|
} |
151 |
|
} ) ; |
152 |
|
return false; |
153 |
|
} else { |
154 |
|
Logger.debug('no results_form element'); |
155 |
|
return undef; |
156 |
|
} |
157 |
|
return false; |
158 |
|
} |
159 |
|
|
160 |
|
var WebPAC = { }; |
161 |
|
|
162 |
|
/* |
163 |
|
autocompleter which isn't (a suggest box) |
164 |
|
- don't just on first option on appear |
165 |
|
- removed fade-in/out effect |
166 |
|
- added configurable width (content width? centered?) |
167 |
|
- add icon which means suggest |
168 |
|
|
169 |
|
hopefully, this implementation won't break (much) when I update |
170 |
|
prototype next time :-) |
171 |
|
*/ |
172 |
|
|
173 |
|
|
174 |
|
WebPAC.Suggest = Class.create(); |
175 |
|
Logger.debug('Created WebPAC.Suggest Class'); |
176 |
|
Object.extend(Object.extend(WebPAC.Suggest.prototype, Ajax.Autocompleter.prototype), { |
177 |
|
initialize: function(element, update, url, options) { |
178 |
|
this.baseInitialize(element, update, options); |
179 |
|
this.options.asynchronous = true; |
180 |
|
this.options.onComplete = this.onComplete.bind(this); |
181 |
|
this.options.defaultParams = this.options.parameters || null; |
182 |
|
this.url = url; |
183 |
|
this.ignoreReturn = true; |
184 |
|
|
185 |
|
Logger.debug('WebPAC.Sugget initialize '+element+','+update+','+url); |
186 |
|
|
187 |
|
this.options.onShow = function(element, update) { |
188 |
|
if(!update.style.position || update.style.position=='absolute') { |
189 |
|
update.style.position = 'absolute'; |
190 |
|
Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); |
191 |
|
} |
192 |
|
new Element.show(update); |
193 |
|
Logger.debug('WebPAC.Suggest.onShow'); |
194 |
|
}; |
195 |
|
|
196 |
|
this.options.onHide = function(element, update) { |
197 |
|
new Element.hide(update); |
198 |
|
Logger.debug('WebPAC.Suggest.onHide'); |
199 |
|
}; |
200 |
|
}, |
201 |
|
|
202 |
|
getUpdatedChoices: function() { |
203 |
|
entry = encodeURIComponent(this.options.paramName) + '=' + |
204 |
|
encodeURIComponent(this.getToken()); |
205 |
|
|
206 |
|
this.options.parameters = this.options.callback ? |
207 |
|
this.options.callback(this.element, entry) : entry; |
208 |
|
|
209 |
|
if(this.options.defaultParams) |
210 |
|
this.options.parameters += '&' + this.options.defaultParams; |
211 |
|
|
212 |
|
Logger.debug('WebPAC.Suggest called '+this.url); |
213 |
|
new Ajax.Request(this.url, this.options); |
214 |
|
}, |
215 |
|
|
216 |
|
onComplete: function(request) { |
217 |
|
Logger.debug('WebPAC.Suggest onComplete called'); |
218 |
|
this.updateChoices(request.responseText); |
219 |
|
}, |
220 |
|
|
221 |
|
markPrevious: function() { |
222 |
|
if(this.index > 0) this.index-- |
223 |
|
// else this.index = this.entryCount-1; |
224 |
|
}, |
225 |
|
|
226 |
|
markNext: function() { |
227 |
|
if(this.index < this.entryCount-1) this.index++ |
228 |
|
// else this.index = 0; |
229 |
|
} |
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 |
|
|