/[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

Annotation of /Webpacus/root/js/webpac.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 323 - (hide annotations)
Sun Dec 25 23:32:01 2005 UTC (18 years, 5 months ago) by dpavlin
File MIME type: text/cpp
File size: 2940 byte(s)
 r12481@llin:  dpavlin | 2005-12-26 00:16:49 +0100
 fix warning

1 dpavlin 159 /*
2 dpavlin 283 WebPAC AJAX class
3 dpavlin 159 */
4 dpavlin 101
5 dpavlin 270 var WebPAC = { };
6    
7 dpavlin 203 /*
8     autocompleter which isn't (a suggest box)
9     - don't just on first option on appear
10     - removed fade-in/out effect
11     - added configurable width (content width? centered?)
12     - add icon which means suggest
13    
14 dpavlin 270 hopefully, this implementation won't break (much) when I update
15     prototype next time :-)
16 dpavlin 203 */
17    
18 dpavlin 205
19 dpavlin 270 WebPAC.Suggest = Class.create();
20     Logger.debug('Created WebPAC.Suggest Class');
21     Object.extend(Object.extend(WebPAC.Suggest.prototype, Ajax.Autocompleter.prototype), {
22 dpavlin 203 initialize: function(element, update, url, options) {
23 dpavlin 270 this.baseInitialize(element, update, options);
24 dpavlin 203 this.options.asynchronous = true;
25     this.options.onComplete = this.onComplete.bind(this);
26     this.options.defaultParams = this.options.parameters || null;
27     this.url = url;
28     this.ignoreReturn = true;
29    
30 dpavlin 270 Logger.debug('WebPAC.Sugget initialize '+element+','+update+','+url);
31 dpavlin 205
32 dpavlin 203 this.options.onShow = function(element, update) {
33     if(!update.style.position || update.style.position=='absolute') {
34     update.style.position = 'absolute';
35     Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
36     }
37     new Element.show(update);
38 dpavlin 270 Logger.debug('WebPAC.Suggest.onShow');
39 dpavlin 203 };
40    
41     this.options.onHide = function(element, update) {
42     new Element.hide(update);
43 dpavlin 270 Logger.debug('WebPAC.Suggest.onHide');
44 dpavlin 203 };
45     },
46    
47     getUpdatedChoices: function() {
48 dpavlin 323 var entry = encodeURIComponent(this.options.paramName) + '=' +
49 dpavlin 203 encodeURIComponent(this.getToken());
50    
51     this.options.parameters = this.options.callback ?
52     this.options.callback(this.element, entry) : entry;
53    
54     if(this.options.defaultParams)
55     this.options.parameters += '&' + this.options.defaultParams;
56    
57 dpavlin 270 Logger.debug('WebPAC.Suggest called '+this.url);
58 dpavlin 203 new Ajax.Request(this.url, this.options);
59     },
60    
61     onComplete: function(request) {
62 dpavlin 270 Logger.debug('WebPAC.Suggest onComplete called');
63 dpavlin 203 this.updateChoices(request.responseText);
64     },
65    
66     markPrevious: function() {
67     if(this.index > 0) this.index--
68     // else this.index = this.entryCount-1;
69     },
70    
71     markNext: function() {
72     if(this.index < this.entryCount-1) this.index++
73     // else this.index = 0;
74 dpavlin 205 }
75 dpavlin 203
76     });
77 dpavlin 205
78 dpavlin 270 /*
79     WebPAC.Updater
80     */
81 dpavlin 205
82 dpavlin 270 WebPAC.Updater = Class.create();
83     Logger.debug('Created WebPAC.Updater Class');
84     Object.extend(WebPAC.Updater.prototype, {
85     initialize: function(container, url, options) {
86     Logger.debug('WebPAC.Updater initialize '+container+','+url+','+options);
87 dpavlin 279 if (url.indexOf('/ajax') == -1) {
88     var pos = url.indexOf('?');
89     if (pos == -1) {
90     url += '/ajax';
91     } else {
92     url = url.substring(0,pos) + '/ajax' + url.substring(pos);
93     }
94     Logger.debug('added /ajax to '+url+' pos:'+pos);
95     }
96     Logger.info('using AJAX to update "'+container+'" from '+url);
97 dpavlin 270 this.updater = new Ajax.Updater(container, url, options);
98     }
99     });
100    

Properties

Name Value
svn:mime-type text/cpp

  ViewVC Help
Powered by ViewVC 1.1.26