We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/josh/rails.git
Updated to prototype.js 1.1.0

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1012 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Sat Mar 26 15:16:55 -0800 2005
commit  4c3d52ad66c2db582ad24e55adf88fa7cfdb39e6
tree    e0e4347d9321b047e936549d24dcb461dddaab89
parent  5d6bedb383024df2596a560de6d67337ff6cdb2f
...
159
160
161
162
163
 
 
164
165
166
...
159
160
161
 
 
162
163
164
165
166
0
@@ -159,8 +159,8 @@ module ActionView
0
         
0
         js_options['asynchronous'] = options[:type] != :synchronous
0
         js_options['method'] = options[:method] if options[:method]
0
- js_options['position'] = options[:position] ? "'#{options[:position].to_s}'" : "'replace'"
0
- js_options['effect'] = ("\'" + options[:effect].to_s + "\'") if options[:effect]
0
+ js_options['insertion'] = "Insertion.#{options[:position].to_s.camelize}" if options[:position]
0
+ js_options['effect'] = "Effect.#{options[:effect].to_s.camelize}" if options[:effect]
0
   
0
         if options[:form]
0
           js_options['parameters'] = 'Form.serialize(this)'
...
5
6
7
8
9
 
 
10
11
12
 
13
14
15
...
17
18
19
20
 
21
22
23
...
40
41
42
43
 
 
 
 
 
 
 
44
45
46
...
56
57
58
59
 
60
61
62
...
85
86
87
88
89
 
 
90
91
92
93
94
 
 
 
 
 
 
 
 
 
 
95
96
 
97
98
99
100
101
102
 
103
104
105
...
117
118
119
120
121
 
122
123
124
...
186
187
188
189
 
 
 
190
191
192
 
 
193
194
195
196
 
 
197
198
199
 
 
 
200
201
202
203
204
205
 
206
207
208
...
221
222
223
224
 
225
226
227
...
280
281
282
 
283
284
285
...
339
340
341
 
342
343
344
345
346
347
 
 
348
349
350
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
353
354
355
 
356
357
358
359
360
 
 
361
362
363
 
364
365
366
367
 
 
368
369
370
 
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
...
5
6
7
 
 
8
9
10
11
 
12
13
14
15
...
17
18
19
 
20
21
22
23
...
40
41
42
 
43
44
45
46
47
48
49
50
51
52
...
62
63
64
 
65
66
67
68
...
91
92
93
 
 
94
95
96
 
 
 
 
97
98
99
100
101
102
103
104
105
106
107
 
108
109
110
111
112
113
 
114
115
116
117
...
129
130
131
 
 
132
133
134
135
...
197
198
199
 
200
201
202
203
204
 
205
206
207
208
 
 
209
210
211
212
 
213
214
215
216
217
218
219
220
 
221
222
223
224
...
237
238
239
 
240
241
242
243
...
296
297
298
299
300
301
302
...
356
357
358
359
360
361
 
 
 
 
362
363
364
365
 
 
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
 
 
 
438
439
440
441
442
 
443
444
445
446
 
447
448
449
450
 
451
452
453
454
455
456
457
458
459
460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
0
@@ -5,11 +5,11 @@
0
  * For details, see http://prototype.conio.net/
0
  */
0
 
0
-Prototype = {
0
- Version: '1.0.1'
0
+var Prototype = {
0
+ Version: '1.1.0'
0
 }
0
 
0
-Class = {
0
+var Class = {
0
   create: function() {
0
     return function() {
0
       this.initialize.apply(this, arguments);
0
@@ -17,7 +17,7 @@ Class = {
0
   }
0
 }
0
 
0
-Abstract = new Object();
0
+var Abstract = new Object();
0
 
0
 Object.prototype.extend = function(object) {
0
   for (property in object) {
0
@@ -40,7 +40,13 @@ Function.prototype.bindAsEventListener = function(object) {
0
   }
0
 }
0
 
0
-Try = {
0
+Number.prototype.toColorPart = function() {
0
+ var digits = this.toString(16);
0
+ if (this < 16) return '0' + digits;
0
+ return digits;
0
+}
0
+
0
+var Try = {
0
   these: function() {
0
     var returnValue;
0
     
0
@@ -56,7 +62,7 @@ Try = {
0
   }
0
 }
0
 
0
-Toggle = {
0
+var Toggle = {
0
   display: function() {
0
     for (var i = 0; i < arguments.length; i++) {
0
       var element = $(arguments[i]);
0
@@ -85,21 +91,27 @@ function $() {
0
   return elements;
0
 }
0
 
0
-function getElementsByClassName(className, element) {
0
- var all = document.all ? document.all : document.getElementsByTagName(element);
0
+function getElementsByClassName(className) {
0
+ var children = document.getElementsByTagName('*') || document.all;
0
   var elements = new Array();
0
-
0
- for (var e = 0; e < all.length; e++) {
0
- if (all[e].className == className)
0
- elements[elements.length] = all[e];
0
+
0
+ for (var i = 0; i < children.length; i++) {
0
+ var child = children[i];
0
+ var classNames = child.className.split(' ');
0
+ for (var j = 0; j < classNames.length; j++) {
0
+ if (classNames[j] == className) {
0
+ elements.push(child);
0
+ break;
0
+ }
0
+ }
0
   }
0
-
0
+
0
   return elements;
0
 }
0
 
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Ajax = {
0
+var Ajax = {
0
   getTransport: function() {
0
     return Try.these(
0
       function() {return new ActiveXObject('Msxml2.XMLHTTP')},
0
@@ -117,8 +129,7 @@ Ajax.Base.prototype = {
0
     this.options = {
0
       method: 'post',
0
       asynchronous: true,
0
- parameters: '',
0
- position: 'replace'
0
+ parameters: ''
0
     }.extend(options || {});
0
   }
0
 }
0
@@ -186,23 +197,28 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
0
   },
0
   
0
   updateContent: function() {
0
- if (this.options.position.toLowerCase() == 'replace') {
0
+ this.container.innerHTML = this.request.transport.responseText;
0
+
0
+ if (this.options.insertion) {
0
       this.container.innerHTML = this.request.transport.responseText;
0
     } else {
0
- Insert[this.options.position.toLowerCase()](this.container, this.request.transport.responseText);
0
+ new this.options.insertion(this.container,
0
+ this.request.transport.responseText);
0
     }
0
 
0
- switch(this.options.effect) {
0
- case 'highlight': new YellowFader(this.container); break;
0
+ if (this.options.effect) {
0
+ new this.options.effect(this.container);
0
     }
0
 
0
- if (this.onComplete) this.onComplete(this.request);
0
+ if (this.onComplete) {
0
+ setTimeout((function() {this.onComplete(this.request)}).bind(this), 10);
0
+ }
0
   }
0
 });
0
 
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Field = {
0
+var Field = {
0
   clear: function() {
0
     for (var i = 0; i < arguments.length; i++)
0
       $(arguments[i]).value = '';
0
@@ -221,7 +237,7 @@ Field = {
0
 
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Form = {
0
+var Form = {
0
   serialize: function(form) {
0
     var elements = Form.getElements($(form));
0
     var queryComponents = new Array();
0
@@ -280,6 +296,7 @@ Form.Element.Serializers = {
0
       case 'radio':
0
         return Form.Element.Serializers.inputSelector(element);
0
     }
0
+ return false;
0
   },
0
 
0
   inputSelector: function(element) {
0
@@ -339,91 +356,105 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
0
   }
0
 });
0
 
0
+
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Number.prototype.toColorPart = function() {
0
- var digits = this.toString(16);
0
- if (this < 16) return '0' + digits;
0
- return digits;
0
+Abstract.Insertion = function(adjacency) {
0
+ this.adjacency = adjacency;
0
 }
0
 
0
-var YellowFader = Class.create();
0
-YellowFader.prototype = {
0
+Abstract.Insertion.prototype = {
0
+ initialize: function(element, content) {
0
+ this.element = $(element);
0
+ this.content = content;
0
+
0
+ if (this.adjacency && this.element.insertAdjacentHTML) {
0
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
0
+ } else {
0
+ this.range = this.element.ownerDocument.createRange();
0
+ if (this.initializeRange) this.initializeRange();
0
+ this.fragment = this.range.createContextualFragment(this.content);
0
+ this.insertContent();
0
+ }
0
+ }
0
+}
0
+
0
+var Insertion = new Object();
0
+
0
+Insertion.Before = Class.create();
0
+Insertion.Before.prototype = (new Abstract.Insertion('beforeBegin')).extend({
0
+ initializeRange: function() {
0
+ this.range.setStartBefore(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.parentNode.insertBefore(this.fragment, this.element);
0
+ }
0
+});
0
+
0
+Insertion.Top = Class.create();
0
+Insertion.Top.prototype = (new Abstract.Insertion('afterBegin')).extend({
0
+ initializeRange: function() {
0
+ this.range.selectNodeContents(this.element);
0
+ this.range.collapse(true);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.insertBefore(this.fragment, this.element.firstChild);
0
+ }
0
+});
0
+
0
+Insertion.Bottom = Class.create();
0
+Insertion.Bottom.prototype = (new Abstract.Insertion('beforeEnd')).extend({
0
+ initializeRange: function() {
0
+ this.range.selectNodeContents(this.element);
0
+ this.range.collapse(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.appendChild(this.fragment);
0
+ }
0
+});
0
+
0
+Insertion.After = Class.create();
0
+Insertion.After.prototype = (new Abstract.Insertion('afterEnd')).extend({
0
+ initializeRange: function() {
0
+ this.range.setStartAfter(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.parentNode.insertBefore(this.fragment,
0
+ this.element.nextSibling);
0
+ }
0
+});
0
+
0
+/*--------------------------------------------------------------------------*/
0
+
0
+var Effect = new Object();
0
+
0
+Effect.Highlight = Class.create();
0
+Effect.Highlight.prototype = {
0
   initialize: function(element) {
0
- if (typeof element == 'string') element = $(element);
0
- if (!element) return;
0
- this.element = element;
0
+ this.element = $(element);
0
     this.start = 153;
0
     this.finish = 255;
0
     this.current = this.start;
0
     this.fade();
0
- },
0
+ },
0
+
0
   fade: function() {
0
     if (this.isFinished()) return;
0
- if (this.timer) clearTimeout(this.timer); // prevent flicker
0
+ if (this.timer) clearTimeout(this.timer);
0
     this.highlight(this.element, this.current);
0
     this.current += 17;
0
     this.timer = setTimeout(this.fade.bind(this), 250);
0
- },
0
+ },
0
+
0
   isFinished: function() {
0
     return this.current > this.finish;
0
   },
0
+
0
   highlight: function(element, current) {
0
     element.style.backgroundColor = "#ffff" + current.toColorPart();
0
   }
0
 }
0
-
0
-
0
-/*--------------------------------------------------------------------------*/
0
-
0
-Insert = {
0
- before: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.setStartBefore(dom);
0
- var df = r.createContextualFragment(html);
0
- dom.parentNode.insertBefore(df, dom);
0
- }
0
- },
0
-
0
- top: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('AfterBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.selectNodeContents(dom);
0
- r.collapse(true);
0
- var df = r.createContextualFragment( html );
0
- dom.insertBefore(df, dom.firstChild );
0
- }
0
- },
0
-
0
- bottom: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeEnd', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.selectNodeContents(dom);
0
- r.collapse(dom);
0
- var df = r.createContextualFragment(html);
0
- dom.appendChild(df);
0
- }
0
- },
0
-
0
- after: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.setStartAfter(dom);
0
- var df = r.createContextualFragment( html );
0
- dom.parentNode.insertBefore(df, dom.nextSibling);
0
- }
0
- }
0
-};
0
\ No newline at end of file
...
5
6
7
8
9
 
 
10
11
12
 
13
14
15
...
17
18
19
20
 
21
22
23
...
40
41
42
43
 
 
 
 
 
 
 
44
45
46
...
56
57
58
59
 
60
61
62
...
85
86
87
88
89
 
 
90
91
92
93
94
 
 
 
 
 
 
 
 
 
 
95
96
 
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
121
122
123
...
135
136
137
138
139
 
140
141
142
...
206
207
208
209
 
210
211
212
 
 
213
214
215
216
 
 
217
218
219
 
 
 
220
221
222
223
224
225
 
226
227
228
...
241
242
243
244
 
245
246
247
...
300
301
302
 
303
304
305
...
359
360
361
 
362
363
364
365
366
367
 
 
368
369
370
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
373
374
375
 
376
377
378
379
380
 
 
381
382
383
 
384
385
386
387
 
 
388
389
390
 
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
5
6
7
 
 
8
9
10
11
 
12
13
14
15
...
17
18
19
 
20
21
22
23
...
40
41
42
 
43
44
45
46
47
48
49
50
51
52
...
62
63
64
 
65
66
67
68
...
91
92
93
 
 
94
95
96
 
 
 
 
97
98
99
100
101
102
103
104
105
106
107
 
108
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
113
 
114
115
116
117
...
129
130
131
 
 
132
133
134
135
...
199
200
201
 
202
203
204
 
205
206
207
208
 
 
209
210
211
212
 
213
214
215
216
217
218
219
220
 
221
222
223
224
...
237
238
239
 
240
241
242
243
...
296
297
298
299
300
301
302
...
356
357
358
359
360
361
 
 
 
 
362
363
364
365
 
 
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
 
 
 
438
439
440
441
442
 
443
444
445
446
 
447
448
449
450
 
451
452
453
454
455
456
457
458
459
460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
0
@@ -5,11 +5,11 @@
0
  * For details, see http://prototype.conio.net/
0
  */
0
 
0
-Prototype = {
0
- Version: '1.0.1'
0
+var Prototype = {
0
+ Version: '1.1.0'
0
 }
0
 
0
-Class = {
0
+var Class = {
0
   create: function() {
0
     return function() {
0
       this.initialize.apply(this, arguments);
0
@@ -17,7 +17,7 @@ Class = {
0
   }
0
 }
0
 
0
-Abstract = new Object();
0
+var Abstract = new Object();
0
 
0
 Object.prototype.extend = function(object) {
0
   for (property in object) {
0
@@ -40,7 +40,13 @@ Function.prototype.bindAsEventListener = function(object) {
0
   }
0
 }
0
 
0
-Try = {
0
+Number.prototype.toColorPart = function() {
0
+ var digits = this.toString(16);
0
+ if (this < 16) return '0' + digits;
0
+ return digits;
0
+}
0
+
0
+var Try = {
0
   these: function() {
0
     var returnValue;
0
     
0
@@ -56,7 +62,7 @@ Try = {
0
   }
0
 }
0
 
0
-Toggle = {
0
+var Toggle = {
0
   display: function() {
0
     for (var i = 0; i < arguments.length; i++) {
0
       var element = $(arguments[i]);
0
@@ -85,39 +91,27 @@ function $() {
0
   return elements;
0
 }
0
 
0
-function getElementsByClassName(className, element) {
0
- var all = document.all ? document.all : document.getElementsByTagName(element);
0
+function getElementsByClassName(className) {
0
+ var children = document.getElementsByTagName('*') || document.all;
0
   var elements = new Array();
0
-
0
- for (var e = 0; e < all.length; e++) {
0
- if (all[e].className == className)
0
- elements[elements.length] = all[e];
0
+
0
+ for (var i = 0; i < children.length; i++) {
0
+ var child = children[i];
0
+ var classNames = child.className.split(' ');
0
+ for (var j = 0; j < classNames.length; j++) {
0
+ if (classNames[j] == className) {
0
+ elements.push(child);
0
+ break;
0
+ }
0
+ }
0
   }
0
-
0
+
0
   return elements;
0
 }
0
 
0
-// function getElementsByClassName(className, element) {
0
-// var children = (element || document).getElementsByTagName('*');
0
-// var elements = new Array();
0
-//
0
-// for (var i = 0; i < children.length; i++) {
0
-// var child = children[i];
0
-// var classNames = child.className.split(' ');
0
-// for (var j = 0; j < classNames.length; j++) {
0
-// if (classNames[j] == className) {
0
-// elements.push(child);
0
-// break;
0
-// }
0
-// }
0
-// }
0
-//
0
-// return elements;
0
-// }
0
-
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Ajax = {
0
+var Ajax = {
0
   getTransport: function() {
0
     return Try.these(
0
       function() {return new ActiveXObject('Msxml2.XMLHTTP')},
0
@@ -135,8 +129,7 @@ Ajax.Base.prototype = {
0
     this.options = {
0
       method: 'post',
0
       asynchronous: true,
0
- parameters: '',
0
- position: 'replace'
0
+ parameters: ''
0
     }.extend(options || {});
0
   }
0
 }
0
@@ -206,23 +199,26 @@ Ajax.Updater.prototype = (new Ajax.Base()).extend({
0
   updateContent: function() {
0
     this.container.innerHTML = this.request.transport.responseText;
0
 
0
- if (this.options.position.toLowerCase() == 'replace') {
0
+ if (this.options.insertion) {
0
       this.container.innerHTML = this.request.transport.responseText;
0
     } else {
0
- Insert[this.options.position.toLowerCase()]( this.container, this.request.transport.responseText );
0
+ new this.options.insertion(this.container,
0
+ this.request.transport.responseText);
0
     }
0
 
0
- switch(this.options.effect) {
0
- case 'highlight': new YellowFader(this.container); break;
0
+ if (this.options.effect) {
0
+ new this.options.effect(this.container);
0
     }
0
 
0
- if (this.onComplete) this.onComplete(this.request);
0
+ if (this.onComplete) {
0
+ setTimeout((function() {this.onComplete(this.request)}).bind(this), 10);
0
+ }
0
   }
0
 });
0
 
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Field = {
0
+var Field = {
0
   clear: function() {
0
     for (var i = 0; i < arguments.length; i++)
0
       $(arguments[i]).value = '';
0
@@ -241,7 +237,7 @@ Field = {
0
 
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Form = {
0
+var Form = {
0
   serialize: function(form) {
0
     var elements = Form.getElements($(form));
0
     var queryComponents = new Array();
0
@@ -300,6 +296,7 @@ Form.Element.Serializers = {
0
       case 'radio':
0
         return Form.Element.Serializers.inputSelector(element);
0
     }
0
+ return false;
0
   },
0
 
0
   inputSelector: function(element) {
0
@@ -359,90 +356,105 @@ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
0
   }
0
 });
0
 
0
+
0
 /*--------------------------------------------------------------------------*/
0
 
0
-Number.prototype.toColorPart = function() {
0
- var digits = this.toString(16);
0
- if (this < 16) return '0' + digits;
0
- return digits;
0
+Abstract.Insertion = function(adjacency) {
0
+ this.adjacency = adjacency;
0
 }
0
 
0
-var YellowFader = Class.create();
0
-YellowFader.prototype = {
0
+Abstract.Insertion.prototype = {
0
+ initialize: function(element, content) {
0
+ this.element = $(element);
0
+ this.content = content;
0
+
0
+ if (this.adjacency && this.element.insertAdjacentHTML) {
0
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
0
+ } else {
0
+ this.range = this.element.ownerDocument.createRange();
0
+ if (this.initializeRange) this.initializeRange();
0
+ this.fragment = this.range.createContextualFragment(this.content);
0
+ this.insertContent();
0
+ }
0
+ }
0
+}
0
+
0
+var Insertion = new Object();
0
+
0
+Insertion.Before = Class.create();
0
+Insertion.Before.prototype = (new Abstract.Insertion('beforeBegin')).extend({
0
+ initializeRange: function() {
0
+ this.range.setStartBefore(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.parentNode.insertBefore(this.fragment, this.element);
0
+ }
0
+});
0
+
0
+Insertion.Top = Class.create();
0
+Insertion.Top.prototype = (new Abstract.Insertion('afterBegin')).extend({
0
+ initializeRange: function() {
0
+ this.range.selectNodeContents(this.element);
0
+ this.range.collapse(true);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.insertBefore(this.fragment, this.element.firstChild);
0
+ }
0
+});
0
+
0
+Insertion.Bottom = Class.create();
0
+Insertion.Bottom.prototype = (new Abstract.Insertion('beforeEnd')).extend({
0
+ initializeRange: function() {
0
+ this.range.selectNodeContents(this.element);
0
+ this.range.collapse(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.appendChild(this.fragment);
0
+ }
0
+});
0
+
0
+Insertion.After = Class.create();
0
+Insertion.After.prototype = (new Abstract.Insertion('afterEnd')).extend({
0
+ initializeRange: function() {
0
+ this.range.setStartAfter(this.element);
0
+ },
0
+
0
+ insertContent: function() {
0
+ this.element.parentNode.insertBefore(this.fragment,
0
+ this.element.nextSibling);
0
+ }
0
+});
0
+
0
+/*--------------------------------------------------------------------------*/
0
+
0
+var Effect = new Object();
0
+
0
+Effect.Highlight = Class.create();
0
+Effect.Highlight.prototype = {
0
   initialize: function(element) {
0
- if (typeof element == 'string') element = $(element);
0
- if (!element) return;
0
- this.element = element;
0
+ this.element = $(element);
0
     this.start = 153;
0
     this.finish = 255;
0
     this.current = this.start;
0
     this.fade();
0
- },
0
+ },
0
+
0
   fade: function() {
0
     if (this.isFinished()) return;
0
- if (this.timer) clearTimeout(this.timer); // prevent flicker
0
+ if (this.timer) clearTimeout(this.timer);
0
     this.highlight(this.element, this.current);
0
     this.current += 17;
0
     this.timer = setTimeout(this.fade.bind(this), 250);
0
- },
0
+ },
0
+
0
   isFinished: function() {
0
     return this.current > this.finish;
0
   },
0
+
0
   highlight: function(element, current) {
0
     element.style.backgroundColor = "#ffff" + current.toColorPart();
0
   }
0
 }
0
-
0
-/*--------------------------------------------------------------------------*/
0
-
0
-Insert = {
0
- before_begin: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.setStartBefore(dom);
0
- var df = r.createContextualFragment(html);
0
- dom.parentNode.insertBefore(df, dom);
0
- }
0
- },
0
-
0
- after_begin: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('AfterBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.selectNodeContents(dom);
0
- r.collapse(true);
0
- var df = r.createContextualFragment( html );
0
- dom.insertBefore(df, dom.firstChild );
0
- }
0
- },
0
-
0
- before_end: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeEnd', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.selectNodeContents(dom);
0
- r.collapse(dom);
0
- var df = r.createContextualFragment(html);
0
- dom.appendChild(df);
0
- }
0
- },
0
-
0
- after_end: function(dom, html) {
0
- dom = $(dom);
0
- if (dom.insertAdjacentHTML) {
0
- dom.insertAdjacentHTML('BeforeBegin', html);
0
- } else {
0
- var r = dom.ownerDocument.createRange();
0
- r.setStartAfter(dom);
0
- var df = r.createContextualFragment( html );
0
- dom.parentNode.insertBefore(df, dom.nextSibling);
0
- }
0
- }
0
-};
0
\ No newline at end of file

Comments

    No one has commented yet.