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

Contents of /Webpacus/root/js/webpac.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 323 - (show annotations)
Sun Dec 25 23:32:01 2005 UTC (18 years, 4 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 /*
2 WebPAC AJAX class
3 */
4
5 var WebPAC = { };
6
7 /*
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 hopefully, this implementation won't break (much) when I update
15 prototype next time :-)
16 */
17
18
19 WebPAC.Suggest = Class.create();
20 Logger.debug('Created WebPAC.Suggest Class');
21 Object.extend(Object.extend(WebPAC.Suggest.prototype, Ajax.Autocompleter.prototype), {
22 initialize: function(element, update, url, options) {
23 this.baseInitialize(element, update, options);
24 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 Logger.debug('WebPAC.Sugget initialize '+element+','+update+','+url);
31
32 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 Logger.debug('WebPAC.Suggest.onShow');
39 };
40
41 this.options.onHide = function(element, update) {
42 new Element.hide(update);
43 Logger.debug('WebPAC.Suggest.onHide');
44 };
45 },
46
47 getUpdatedChoices: function() {
48 var entry = encodeURIComponent(this.options.paramName) + '=' +
49 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 Logger.debug('WebPAC.Suggest called '+this.url);
58 new Ajax.Request(this.url, this.options);
59 },
60
61 onComplete: function(request) {
62 Logger.debug('WebPAC.Suggest onComplete called');
63 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 }
75
76 });
77
78 /*
79 WebPAC.Updater
80 */
81
82 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 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 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