public
Description: Branch of Dan Webb's JavaScript DOM event library. Small JavaScript library built as an extension to Prototype that makes unobtrusive DOM scripting much easier
Homepage: http://groups.google.co.uk/group/low-pro
Clone URL: git://github.com/brianjlandau/lowpro.git
Fix syntax error where possible.
Add ability for Remote behaviors to accept a confirm option.
Handles specifying a specific parameters option being passed to 
Remote.Form and still getting all the other parameters properly.
brianjlandau (author)
Wed Jun 18 13:04:32 -0700 2008
commit  202f5a230bb251833e8b0abf618e667d5296ea2e
tree    7d6d4c16de489632f2faf115286801fd5fa388fa
parent  d6493d2d0e75e9f49963f409c06fb503f8be87b2
...
124
125
126
127
 
128
129
130
...
156
157
158
159
 
160
161
162
...
124
125
126
 
127
128
129
130
...
156
157
158
 
159
160
161
162
0
@@ -124,7 +124,7 @@ Calendar = Behavior.create({
0
           if (this._compareDate(this.selector.date, year, month, day)) classes.push('selected');
0
           
0
           html += '<td class="' + classes.join(' ') + '">' +
0
- '<a href="#">' + day++ + '</a>' +
0
+ '<a href="#">' + (day++) + '</a>' +
0
                   '</td>';
0
         } else html += '<td></td>';
0
       }
0
@@ -156,7 +156,7 @@ DateSelector.DEFAULTS = {
0
     if (!isNaN(parsed)) return new Date(parsed);
0
     else return null;
0
   }
0
-}
0
+};
0
 
0
 Object.extend(Calendar, {
0
   DAYS : $w('S M T W T F S'),
...
28
29
30
31
 
32
33
34
...
28
29
30
 
31
32
33
34
0
@@ -28,7 +28,7 @@ Draggable = Behavior.create({
0
   drag : function(e) {
0
     this.clientX = e.clientX;
0
     this.clientY = e.clientY;
0
- this.move(this.clientX - this.lastMouseX, this.clientY - this.lastMouseY)
0
+ this.move(this.clientX - this.lastMouseX, this.clientY - this.lastMouseY);
0
     this.set(e);
0
     return false;
0
   },
...
7
8
9
10
 
11
12
13
...
24
25
26
27
 
28
29
30
...
97
98
99
100
 
101
102
103
...
114
115
116
117
118
 
 
119
120
121
...
163
164
165
166
 
167
168
169
...
278
279
280
281
282
283
 
 
 
 
 
 
 
 
 
 
 
284
285
286
...
288
289
290
291
 
292
293
294
...
307
308
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
311
312
313
 
314
315
316
...
7
8
9
 
10
11
12
13
...
24
25
26
 
27
28
29
30
...
97
98
99
 
100
101
102
103
...
114
115
116
 
 
117
118
119
120
121
...
163
164
165
 
166
167
168
169
...
278
279
280
 
 
 
281
282
283
284
285
286
287
288
289
290
291
292
293
294
...
296
297
298
 
299
300
301
302
...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
 
336
337
338
339
0
@@ -7,7 +7,7 @@ if (Prototype.Version.indexOf(LowPro.CompatibleWithPrototype) != 0 && window.con
0
                   " it may not work as expected with this version (" + Prototype.Version + ")");
0
 
0
 if (!Element.addMethods)
0
- Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
0
+ Element.addMethods = function(o) { Object.extend(Element.Methods, o); };
0
 
0
 // Simple utility methods for working with the DOM
0
 DOM = {};
0
@@ -24,7 +24,7 @@ DOM.Builder = {
0
        } else {
0
          children = arguments;
0
        };
0
- children = $A(children).flatten()
0
+ children = $A(children).flatten();
0
      }
0
      return DOM.Builder.create(tag, attrs, children);
0
     };
0
@@ -97,7 +97,7 @@ Event.addBehavior = function(rules) {
0
     Ajax.Responders.register({
0
       onComplete : function() {
0
         if (Event.addBehavior.reassignAfterAjax)
0
- setTimeout(function() { ab.reload() }, 10);
0
+ setTimeout(function() { ab.reload(); }, 10);
0
       }
0
     });
0
     ab.responderApplied = true;
0
@@ -114,8 +114,8 @@ Event.delegate = function(rules) {
0
       var element = $(e.element());
0
       for (var selector in rules)
0
         if (element.match(selector)) return rules[selector].apply(this, $A(arguments));
0
- }
0
-}
0
+ };
0
+};
0
 
0
 Object.extend(Event.addBehavior, {
0
   rules : {}, cache : [],
0
@@ -163,7 +163,7 @@ Object.extend(Event.addBehavior, {
0
   _wrapObserver: function(observer) {
0
     return function(event) {
0
       if (observer.call(this, event) === false) event.stop();
0
- }
0
+ };
0
   }
0
   
0
 });
0
@@ -278,9 +278,17 @@ Remote.Base = {
0
     this._bindCallbacks();
0
   },
0
   _makeRequest : function(options) {
0
- if (options.update) new Ajax.Updater(options.update, options.url, options);
0
- else new Ajax.Request(options.url, options);
0
- return false;
0
+ if (options.confirm) {
0
+ if (confirm(options.confirm)) {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
+ } else {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
   },
0
   _bindCallbacks: function() {
0
     $w('onCreate onComplete onException onFailure onInteractive onLoading onLoaded onSuccess').each(function(cb) {
0
@@ -288,7 +296,7 @@ Remote.Base = {
0
         this.options[cb] = this.options[cb].bind(this);
0
     }.bind(this));
0
   }
0
-}
0
+};
0
 
0
 Remote.Link = Behavior.create(Remote.Base, {
0
   onclick : function() {
0
@@ -307,10 +315,25 @@ Remote.Form = Behavior.create(Remote.Base, {
0
       this._submitButton = sourceElement;
0
   },
0
   onsubmit : function() {
0
+ var parameters = this.element.serialize();
0
+
0
+ if (parameters.blank()) {
0
+ parameters = this.options.parameters;
0
+ } else {
0
+ parameters = parameters + '&' + this.options.parameters;
0
+ }
0
+ delete this.options.parameters;
0
+ if (this._submitButton) {
0
+ if (parameters.blank()) {
0
+ parameters = this._submitButton.name + "=" + this._submitButton.value;
0
+ } else {
0
+ parameters = parameters + '&' + this._submitButton.name + "=" + this._submitButton.value;
0
+ }
0
+ }
0
     var options = Object.extend({
0
       url : this.element.action,
0
       method : this.element.method || 'get',
0
- parameters : this.element.serialize({ submit: this._submitButton.name })
0
+ parameters : parameters
0
     }, this.options);
0
     this._submitButton = null;
0
     return this._makeRequest(options);
...
19
20
21
22
 
23
24
25
...
36
37
38
39
40
 
 
41
42
43
...
85
86
87
88
 
89
90
91
...
19
20
21
 
22
23
24
25
...
36
37
38
 
 
39
40
41
42
43
...
85
86
87
 
88
89
90
91
0
@@ -19,7 +19,7 @@ Event.addBehavior = function(rules) {
0
     Ajax.Responders.register({
0
       onComplete : function() {
0
         if (Event.addBehavior.reassignAfterAjax)
0
- setTimeout(function() { ab.reload() }, 10);
0
+ setTimeout(function() { ab.reload(); }, 10);
0
       }
0
     });
0
     ab.responderApplied = true;
0
@@ -36,8 +36,8 @@ Event.delegate = function(rules) {
0
       var element = $(e.element());
0
       for (var selector in rules)
0
         if (element.match(selector)) return rules[selector].apply(this, $A(arguments));
0
- }
0
-}
0
+ };
0
+};
0
 
0
 Object.extend(Event.addBehavior, {
0
   rules : {}, cache : [],
0
@@ -85,7 +85,7 @@ Object.extend(Event.addBehavior, {
0
   _wrapObserver: function(observer) {
0
     return function(event) {
0
       if (observer.call(this, event) === false) event.stop();
0
- }
0
+ };
0
   }
0
   
0
 });
...
14
15
16
17
18
19
 
 
 
 
 
 
 
 
 
 
 
20
21
22
...
24
25
26
27
 
28
29
30
...
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
49
 
50
51
52
...
14
15
16
 
 
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
...
32
33
34
 
35
36
37
38
...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
72
73
74
75
0
@@ -14,9 +14,17 @@ Remote.Base = {
0
     this._bindCallbacks();
0
   },
0
   _makeRequest : function(options) {
0
- if (options.update) new Ajax.Updater(options.update, options.url, options);
0
- else new Ajax.Request(options.url, options);
0
- return false;
0
+ if (options.confirm) {
0
+ if (confirm(options.confirm)) {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
+ } else {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
   },
0
   _bindCallbacks: function() {
0
     $w('onCreate onComplete onException onFailure onInteractive onLoading onLoaded onSuccess').each(function(cb) {
0
@@ -24,7 +32,7 @@ Remote.Base = {
0
         this.options[cb] = this.options[cb].bind(this);
0
     }.bind(this));
0
   }
0
-}
0
+};
0
 
0
 Remote.Link = Behavior.create(Remote.Base, {
0
   onclick : function() {
0
@@ -43,10 +51,25 @@ Remote.Form = Behavior.create(Remote.Base, {
0
       this._submitButton = sourceElement;
0
   },
0
   onsubmit : function() {
0
+ var parameters = this.element.serialize();
0
+
0
+ if (parameters.blank()) {
0
+ parameters = this.options.parameters;
0
+ } else {
0
+ parameters = parameters + '&' + this.options.parameters;
0
+ }
0
+ delete this.options.parameters;
0
+ if (this._submitButton) {
0
+ if (parameters.blank()) {
0
+ parameters = this._submitButton.name + "=" + this._submitButton.value;
0
+ } else {
0
+ parameters = parameters + '&' + this._submitButton.name + "=" + this._submitButton.value;
0
+ }
0
+ }
0
     var options = Object.extend({
0
       url : this.element.action,
0
       method : this.element.method || 'get',
0
- parameters : this.element.serialize({ submit: this._submitButton.name })
0
+ parameters : parameters
0
     }, this.options);
0
     this._submitButton = null;
0
     return this._makeRequest(options);
...
52
53
54
55
 
56
57
58
...
52
53
54
 
55
56
57
58
0
@@ -52,6 +52,6 @@ BehaviorDebugger = {
0
     });
0
     return false;
0
   }
0
-}
0
+};
0
 
0
 //Event.onReady(BehaviorDebugger.open.bind(BehaviorDebugger));
0
\ No newline at end of file
...
13
14
15
16
 
17
18
19
...
13
14
15
 
16
17
18
19
0
@@ -13,7 +13,7 @@ DOM.Builder = {
0
        } else {
0
          children = arguments;
0
        };
0
- children = $A(children).flatten()
0
+ children = $A(children).flatten();
0
      }
0
      return DOM.Builder.create(tag, attrs, children);
0
     };
...
7
8
9
10
11
 
12
...
7
8
9
 
10
11
12
0
@@ -7,4 +7,4 @@ if (Prototype.Version.indexOf(LowPro.CompatibleWithPrototype) != 0 && window.con
0
                   " it may not work as expected with this version (" + Prototype.Version + ")");
0
 
0
 if (!Element.addMethods)
0
- Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
0
\ No newline at end of file
0
+ Element.addMethods = function(o) { Object.extend(Element.Methods, o); };
0
\ No newline at end of file
...
7
8
9
10
 
11
12
13
...
24
25
26
27
 
28
29
30
...
97
98
99
100
 
101
102
103
...
114
115
116
117
118
 
 
119
120
121
...
163
164
165
166
 
167
168
169
...
278
279
280
281
282
283
 
 
 
 
 
 
 
 
 
 
 
284
285
286
...
288
289
290
291
 
292
293
294
...
307
308
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
311
312
313
 
314
315
316
...
7
8
9
 
10
11
12
13
...
24
25
26
 
27
28
29
30
...
97
98
99
 
100
101
102
103
...
114
115
116
 
 
117
118
119
120
121
...
163
164
165
 
166
167
168
169
...
278
279
280
 
 
 
281
282
283
284
285
286
287
288
289
290
291
292
293
294
...
296
297
298
 
299
300
301
302
...
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
 
336
337
338
339
0
@@ -7,7 +7,7 @@ if (Prototype.Version.indexOf(LowPro.CompatibleWithPrototype) != 0 && window.con
0
                   " it may not work as expected with this version (" + Prototype.Version + ")");
0
 
0
 if (!Element.addMethods)
0
- Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
0
+ Element.addMethods = function(o) { Object.extend(Element.Methods, o); };
0
 
0
 // Simple utility methods for working with the DOM
0
 DOM = {};
0
@@ -24,7 +24,7 @@ DOM.Builder = {
0
        } else {
0
          children = arguments;
0
        };
0
- children = $A(children).flatten()
0
+ children = $A(children).flatten();
0
      }
0
      return DOM.Builder.create(tag, attrs, children);
0
     };
0
@@ -97,7 +97,7 @@ Event.addBehavior = function(rules) {
0
     Ajax.Responders.register({
0
       onComplete : function() {
0
         if (Event.addBehavior.reassignAfterAjax)
0
- setTimeout(function() { ab.reload() }, 10);
0
+ setTimeout(function() { ab.reload(); }, 10);
0
       }
0
     });
0
     ab.responderApplied = true;
0
@@ -114,8 +114,8 @@ Event.delegate = function(rules) {
0
       var element = $(e.element());
0
       for (var selector in rules)
0
         if (element.match(selector)) return rules[selector].apply(this, $A(arguments));
0
- }
0
-}
0
+ };
0
+};
0
 
0
 Object.extend(Event.addBehavior, {
0
   rules : {}, cache : [],
0
@@ -163,7 +163,7 @@ Object.extend(Event.addBehavior, {
0
   _wrapObserver: function(observer) {
0
     return function(event) {
0
       if (observer.call(this, event) === false) event.stop();
0
- }
0
+ };
0
   }
0
   
0
 });
0
@@ -278,9 +278,17 @@ Remote.Base = {
0
     this._bindCallbacks();
0
   },
0
   _makeRequest : function(options) {
0
- if (options.update) new Ajax.Updater(options.update, options.url, options);
0
- else new Ajax.Request(options.url, options);
0
- return false;
0
+ if (options.confirm) {
0
+ if (confirm(options.confirm)) {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
+ } else {
0
+ if (options.update) new Ajax.Updater(options.update, options.url, options);
0
+ else new Ajax.Request(options.url, options);
0
+ return false;
0
+ }
0
   },
0
   _bindCallbacks: function() {
0
     $w('onCreate onComplete onException onFailure onInteractive onLoading onLoaded onSuccess').each(function(cb) {
0
@@ -288,7 +296,7 @@ Remote.Base = {
0
         this.options[cb] = this.options[cb].bind(this);
0
     }.bind(this));
0
   }
0
-}
0
+};
0
 
0
 Remote.Link = Behavior.create(Remote.Base, {
0
   onclick : function() {
0
@@ -307,10 +315,25 @@ Remote.Form = Behavior.create(Remote.Base, {
0
       this._submitButton = sourceElement;
0
   },
0
   onsubmit : function() {
0
+ var parameters = this.element.serialize();
0
+
0
+ if (parameters.blank()) {
0
+ parameters = this.options.parameters;
0
+ } else {
0
+ parameters = parameters + '&' + this.options.parameters;
0
+ }
0
+ delete this.options.parameters;
0
+ if (this._submitButton) {
0
+ if (parameters.blank()) {
0
+ parameters = this._submitButton.name + "=" + this._submitButton.value;
0
+ } else {
0
+ parameters = parameters + '&' + this._submitButton.name + "=" + this._submitButton.value;
0
+ }
0
+ }
0
     var options = Object.extend({
0
       url : this.element.action,
0
       method : this.element.method || 'get',
0
- parameters : this.element.serialize({ submit: this._submitButton.name })
0
+ parameters : parameters
0
     }, this.options);
0
     this._submitButton = null;
0
     return this._makeRequest(options);

Comments

    No one has commented yet.