/[webpac2]/Webpacus/root/js/webpac.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/root/js/webpac.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 183 by dpavlin, Sun Nov 27 20:03:51 2005 UTC revision 242 by dpavlin, Wed Dec 14 18:56:17 2005 UTC
# Line 121  function show_searching() { Line 121  function show_searching() {
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    /*
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    
171    Ajax.Suggest = Class.create();
172    Logger.debug('Created Ajax.Suggest Class');
173    Object.extend(Object.extend(Ajax.Suggest.prototype, Ajax.Autocompleter.prototype), {
174      initialize: function(element, update, url, options) {
175              this.baseInitialize(element, update, options);
176        this.options.asynchronous  = true;
177        this.options.onComplete    = this.onComplete.bind(this);
178        this.options.defaultParams = this.options.parameters || null;
179        this.url                   = url;
180        this.ignoreReturn = true;
181    
182        Logger.debug('Ajax.Sugget initialize '+element+','+update+','+url);
183    
184        this.options.onShow = function(element, update) {
185          if(!update.style.position || update.style.position=='absolute') {
186            update.style.position = 'absolute';
187            Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
188          }
189          new Element.show(update);
190          Logger.debug('Ajax.Suggest.onShow');
191        };
192    
193        this.options.onHide = function(element, update) {
194            new Element.hide(update);
195            Logger.debug('Ajax.Suggest.onHide');
196        };
197      },
198    
199      getUpdatedChoices: function() {
200        entry = encodeURIComponent(this.options.paramName) + '=' +
201          encodeURIComponent(this.getToken());
202    
203        this.options.parameters = this.options.callback ?
204          this.options.callback(this.element, entry) : entry;
205    
206        if(this.options.defaultParams)
207          this.options.parameters += '&' + this.options.defaultParams;
208    
209        Logger.debug('Ajax.Suggest called '+this.url);
210        new Ajax.Request(this.url, this.options);
211      },
212    
213      onComplete: function(request) {
214        Logger.debug('Ajax.Suggest onComplete called');
215        this.updateChoices(request.responseText);
216      },
217    
218      markPrevious: function() {
219        if(this.index > 0) this.index--
220        //  else this.index = this.entryCount-1;
221      },
222    
223      markNext: function() {
224        if(this.index < this.entryCount-1) this.index++
225        //  else this.index = 0;
226      }
227    
228    });
229    
230    

Legend:
Removed from v.183  
changed lines
  Added in v.242

  ViewVC Help
Powered by ViewVC 1.1.26