nitro 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGELOG +94 -1
  2. data/INSTALL +3 -0
  3. data/README +9 -1
  4. data/Rakefile +2 -1
  5. data/doc/RELEASES +183 -2
  6. data/examples/blog/run.rb +4 -9
  7. data/examples/blog/src/controller.rb +1 -5
  8. data/examples/blog/src/models/blog.rb +1 -5
  9. data/examples/blog/src/models/content.rb +0 -5
  10. data/examples/blog/src/views/comments.xhtml +6 -11
  11. data/examples/blog/src/views/index.xhtml +2 -3
  12. data/examples/blog/src/views/recent_posts.xhtml +1 -1
  13. data/examples/no_xsl_blog/lib/blog/controller.rb +1 -5
  14. data/examples/no_xsl_blog/lib/blog/model.rb +2 -6
  15. data/examples/no_xsl_blog/lib/blog.rb +0 -4
  16. data/examples/no_xsl_blog/lib/content.rb +7 -11
  17. data/examples/no_xsl_blog/public/comments.xhtml +6 -11
  18. data/examples/no_xsl_blog/public/index.xhtml +2 -2
  19. data/examples/no_xsl_blog/public/recent_posts.xhtml +1 -1
  20. data/examples/no_xsl_blog/run.rb +2 -9
  21. data/lib/nitro/adapters/cgi.rb +7 -8
  22. data/lib/nitro/adapters/fastcgi.rb +17 -19
  23. data/lib/nitro/adapters/webrick.rb +3 -3
  24. data/lib/nitro/buffering.rb +0 -4
  25. data/lib/nitro/builders/form.rb +3 -3
  26. data/lib/nitro/builders/rss.rb +33 -4
  27. data/lib/nitro/builders/xhtml.rb +1 -1
  28. data/lib/nitro/builders/xml.rb +1 -1
  29. data/lib/nitro/context.rb +0 -4
  30. data/lib/nitro/controller.rb +0 -4
  31. data/lib/nitro/dispatcher.rb +5 -5
  32. data/lib/nitro/element.rb +151 -0
  33. data/lib/nitro/part.rb +0 -4
  34. data/lib/nitro/render.rb +79 -40
  35. data/lib/nitro/request.rb +15 -4
  36. data/lib/nitro/scaffold.rb +2 -6
  37. data/lib/nitro/shaders.rb +4 -3
  38. data/lib/nitro/template.rb +3 -1
  39. data/lib/nitro.rb +7 -6
  40. data/proto/public/error.xhtml +1 -1
  41. data/proto/public/js/prototype.js +764 -0
  42. data/test/nitro/adapters/tc_cgi.rb +1 -0
  43. data/test/nitro/tc_element.rb +46 -0
  44. metadata +27 -6
  45. data/examples/blog/cache/entriesadmintrue +0 -3
@@ -0,0 +1,764 @@
1
+ /* Prototype: an object-oriented Javascript library, version 1.2.0
2
+ * (c) 2005 Sam Stephenson <sam@conio.net>
3
+ *
4
+ * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
5
+ * against the source tree, available from the Prototype darcs repository.
6
+ *
7
+ * Prototype is freely distributable under the terms of an MIT-style license.
8
+ *
9
+ * For details, see the Prototype web site: http://prototype.conio.net/
10
+ *
11
+ /*--------------------------------------------------------------------------*/
12
+
13
+ var Prototype = {
14
+ Version: '1.2.0'
15
+ }
16
+
17
+ var Class = {
18
+ create: function() {
19
+ return function() {
20
+ this.initialize.apply(this, arguments);
21
+ }
22
+ }
23
+ }
24
+
25
+ var Abstract = new Object();
26
+
27
+ Object.prototype.extend = function(object) {
28
+ for (property in object) {
29
+ this[property] = object[property];
30
+ }
31
+ return this;
32
+ }
33
+
34
+ Function.prototype.bind = function(object) {
35
+ var method = this;
36
+ return function() {
37
+ method.apply(object, arguments);
38
+ }
39
+ }
40
+
41
+ Function.prototype.bindAsEventListener = function(object) {
42
+ var method = this;
43
+ return function(event) {
44
+ method.call(object, event || window.event);
45
+ }
46
+ }
47
+
48
+ Number.prototype.toColorPart = function() {
49
+ var digits = this.toString(16);
50
+ if (this < 16) return '0' + digits;
51
+ return digits;
52
+ }
53
+
54
+ var Try = {
55
+ these: function() {
56
+ var returnValue;
57
+
58
+ for (var i = 0; i < arguments.length; i++) {
59
+ var lambda = arguments[i];
60
+ try {
61
+ returnValue = lambda();
62
+ break;
63
+ } catch (e) {}
64
+ }
65
+
66
+ return returnValue;
67
+ }
68
+ }
69
+
70
+ /*--------------------------------------------------------------------------*/
71
+
72
+ var PeriodicalExecuter = Class.create();
73
+ PeriodicalExecuter.prototype = {
74
+ initialize: function(callback, frequency) {
75
+ this.callback = callback;
76
+ this.frequency = frequency;
77
+ this.currentlyExecuting = false;
78
+
79
+ this.registerCallback();
80
+ },
81
+
82
+ registerCallback: function() {
83
+ setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
84
+ },
85
+
86
+ onTimerEvent: function() {
87
+ if (!this.currentlyExecuting) {
88
+ try {
89
+ this.currentlyExecuting = true;
90
+ this.callback();
91
+ } finally {
92
+ this.currentlyExecuting = false;
93
+ }
94
+ }
95
+
96
+ this.registerCallback();
97
+ }
98
+ }
99
+
100
+ /*--------------------------------------------------------------------------*/
101
+
102
+ function $() {
103
+ var elements = new Array();
104
+
105
+ for (var i = 0; i < arguments.length; i++) {
106
+ var element = arguments[i];
107
+ if (typeof element == 'string')
108
+ element = document.getElementById(element);
109
+
110
+ if (arguments.length == 1)
111
+ return element;
112
+
113
+ elements.push(element);
114
+ }
115
+
116
+ return elements;
117
+ }
118
+
119
+ /*--------------------------------------------------------------------------*/
120
+
121
+ if (!Array.prototype.push) {
122
+ Array.prototype.push = function() {
123
+ var startLength = this.length;
124
+ for (var i = 0; i < arguments.length; i++)
125
+ this[startLength + i] = arguments[i];
126
+ return this.length;
127
+ }
128
+ }
129
+
130
+ if (!Function.prototype.apply) {
131
+ // Based on code from http://www.youngpup.net/
132
+ Function.prototype.apply = function(object, parameters) {
133
+ var parameterStrings = new Array();
134
+ if (!object) object = window;
135
+ if (!parameters) parameters = new Array();
136
+
137
+ for (var i = 0; i < parameters.length; i++)
138
+ parameterStrings[i] = 'x[' + i + ']';
139
+
140
+ object.__apply__ = this;
141
+ var result = eval('obj.__apply__(' +
142
+ parameterStrings[i].join(', ') + ')');
143
+ object.__apply__ = null;
144
+
145
+ return result;
146
+ }
147
+ }
148
+
149
+ /*--------------------------------------------------------------------------*/
150
+
151
+ var Ajax = {
152
+ getTransport: function() {
153
+ return Try.these(
154
+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
155
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')},
156
+ function() {return new XMLHttpRequest()}
157
+ ) || false;
158
+ },
159
+
160
+ emptyFunction: function() {}
161
+ }
162
+
163
+ Ajax.Base = function() {};
164
+ Ajax.Base.prototype = {
165
+ setOptions: function(options) {
166
+ this.options = {
167
+ method: 'post',
168
+ asynchronous: true,
169
+ parameters: ''
170
+ }.extend(options || {});
171
+ }
172
+ }
173
+
174
+ Ajax.Request = Class.create();
175
+ Ajax.Request.Events =
176
+ ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
177
+
178
+ Ajax.Request.prototype = (new Ajax.Base()).extend({
179
+ initialize: function(url, options) {
180
+ this.transport = Ajax.getTransport();
181
+ this.setOptions(options);
182
+
183
+ try {
184
+ if (this.options.method == 'get')
185
+ url += '?' + this.options.parameters + '&_=';
186
+
187
+ this.transport.open(this.options.method, url, true);
188
+
189
+ if (this.options.asynchronous) {
190
+ this.transport.onreadystatechange = this.onStateChange.bind(this);
191
+ setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
192
+ }
193
+
194
+ this.transport.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
195
+ this.transport.setRequestHeader('X-Prototype-Version', Prototype.Version);
196
+
197
+ if (this.options.method == 'post') {
198
+ this.transport.setRequestHeader('Connection', 'close');
199
+ this.transport.setRequestHeader('Content-type',
200
+ 'application/x-www-form-urlencoded');
201
+ }
202
+
203
+ this.transport.send(this.options.method == 'post' ?
204
+ this.options.parameters + '&_=' : null);
205
+
206
+ } catch (e) {
207
+ }
208
+ },
209
+
210
+ onStateChange: function() {
211
+ var readyState = this.transport.readyState;
212
+ if (readyState != 1)
213
+ this.respondToReadyState(this.transport.readyState);
214
+ },
215
+
216
+ respondToReadyState: function(readyState) {
217
+ var event = Ajax.Request.Events[readyState];
218
+ (this.options['on' + event] || Ajax.emptyFunction)(this.transport);
219
+ }
220
+ });
221
+
222
+ Ajax.Updater = Class.create();
223
+ Ajax.Updater.prototype = (new Ajax.Base()).extend({
224
+ initialize: function(container, url, options) {
225
+ this.container = $(container);
226
+ this.setOptions(options);
227
+
228
+ if (this.options.asynchronous) {
229
+ this.onComplete = this.options.onComplete;
230
+ this.options.onComplete = this.updateContent.bind(this);
231
+ }
232
+
233
+ this.request = new Ajax.Request(url, this.options);
234
+
235
+ if (!this.options.asynchronous)
236
+ this.updateContent();
237
+ },
238
+
239
+ updateContent: function() {
240
+ if (this.options.insertion) {
241
+ new this.options.insertion(this.container,
242
+ this.request.transport.responseText);
243
+ } else {
244
+ this.container.innerHTML = this.request.transport.responseText;
245
+ }
246
+
247
+ if (this.onComplete) {
248
+ setTimeout((function() {this.onComplete(this.request)}).bind(this), 10);
249
+ }
250
+ }
251
+ });
252
+
253
+ /*--------------------------------------------------------------------------*/
254
+
255
+ var Field = {
256
+ clear: function() {
257
+ for (var i = 0; i < arguments.length; i++)
258
+ $(arguments[i]).value = '';
259
+ },
260
+
261
+ focus: function(element) {
262
+ $(element).focus();
263
+ },
264
+
265
+ present: function() {
266
+ for (var i = 0; i < arguments.length; i++)
267
+ if ($(arguments[i]).value == '') return false;
268
+ return true;
269
+ },
270
+
271
+ select: function(element) {
272
+ $(element).select();
273
+ },
274
+
275
+ activate: function(element) {
276
+ $(element).focus();
277
+ $(element).select();
278
+ }
279
+ }
280
+
281
+ /*--------------------------------------------------------------------------*/
282
+
283
+ var Form = {
284
+ serialize: function(form) {
285
+ var elements = Form.getElements($(form));
286
+ var queryComponents = new Array();
287
+
288
+ for (var i = 0; i < elements.length; i++) {
289
+ var queryComponent = Form.Element.serialize(elements[i]);
290
+ if (queryComponent)
291
+ queryComponents.push(queryComponent);
292
+ }
293
+
294
+ return queryComponents.join('&');
295
+ },
296
+
297
+ getElements: function(form) {
298
+ form = $(form);
299
+ var elements = new Array();
300
+
301
+ for (tagName in Form.Element.Serializers) {
302
+ var tagElements = form.getElementsByTagName(tagName);
303
+ for (var j = 0; j < tagElements.length; j++)
304
+ elements.push(tagElements[j]);
305
+ }
306
+ return elements;
307
+ },
308
+
309
+ disable: function(form) {
310
+ var elements = Form.getElements(form);
311
+ for (var i = 0; i < elements.length; i++) {
312
+ var element = elements[i];
313
+ element.blur();
314
+ element.disable = 'true';
315
+ }
316
+ },
317
+
318
+ focusFirstElement: function(form) {
319
+ form = $(form);
320
+ var elements = Form.getElements(form);
321
+ for (var i = 0; i < elements.length; i++) {
322
+ var element = elements[i];
323
+ if (element.type != 'hidden' && !element.disabled) {
324
+ Field.activate(element);
325
+ break;
326
+ }
327
+ }
328
+ },
329
+
330
+ reset: function(form) {
331
+ $(form).reset();
332
+ }
333
+ }
334
+
335
+ Form.Element = {
336
+ serialize: function(element) {
337
+ element = $(element);
338
+ var method = element.tagName.toLowerCase();
339
+ var parameter = Form.Element.Serializers[method](element);
340
+
341
+ if (parameter)
342
+ return encodeURIComponent(parameter[0]) + '=' +
343
+ encodeURIComponent(parameter[1]);
344
+ },
345
+
346
+ getValue: function(element) {
347
+ element = $(element);
348
+ var method = element.tagName.toLowerCase();
349
+ var parameter = Form.Element.Serializers[method](element);
350
+
351
+ if (parameter)
352
+ return parameter[1];
353
+ }
354
+ }
355
+
356
+ Form.Element.Serializers = {
357
+ input: function(element) {
358
+ switch (element.type.toLowerCase()) {
359
+ case 'hidden':
360
+ case 'password':
361
+ case 'text':
362
+ return Form.Element.Serializers.textarea(element);
363
+ case 'checkbox':
364
+ case 'radio':
365
+ return Form.Element.Serializers.inputSelector(element);
366
+ }
367
+ return false;
368
+ },
369
+
370
+ inputSelector: function(element) {
371
+ if (element.checked)
372
+ return [element.name, element.value];
373
+ },
374
+
375
+ textarea: function(element) {
376
+ return [element.name, element.value];
377
+ },
378
+
379
+ select: function(element) {
380
+ var index = element.selectedIndex;
381
+ var value = element.options[index].value || element.options[index].text;
382
+ return [element.name, (index >= 0) ? value : ''];
383
+ }
384
+ }
385
+
386
+ /*--------------------------------------------------------------------------*/
387
+
388
+ var $F = Form.Element.getValue;
389
+
390
+ /*--------------------------------------------------------------------------*/
391
+
392
+ Abstract.TimedObserver = function() {}
393
+ Abstract.TimedObserver.prototype = {
394
+ initialize: function(element, frequency, callback) {
395
+ this.frequency = frequency;
396
+ this.element = $(element);
397
+ this.callback = callback;
398
+
399
+ this.lastValue = this.getValue();
400
+ this.registerCallback();
401
+ },
402
+
403
+ registerCallback: function() {
404
+ setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
405
+ },
406
+
407
+ onTimerEvent: function() {
408
+ var value = this.getValue();
409
+ if (this.lastValue != value) {
410
+ this.callback(this.element, value);
411
+ this.lastValue = value;
412
+ }
413
+
414
+ this.registerCallback();
415
+ }
416
+ }
417
+
418
+ Form.Element.Observer = Class.create();
419
+ Form.Element.Observer.prototype = (new Abstract.TimedObserver()).extend({
420
+ getValue: function() {
421
+ return Form.Element.getValue(this.element);
422
+ }
423
+ });
424
+
425
+ Form.Observer = Class.create();
426
+ Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
427
+ getValue: function() {
428
+ return Form.serialize(this.element);
429
+ }
430
+ });
431
+
432
+
433
+ /*--------------------------------------------------------------------------*/
434
+
435
+ document.getElementsByClassName = function(className) {
436
+ var children = document.getElementsByTagName('*') || document.all;
437
+ var elements = new Array();
438
+
439
+ for (var i = 0; i < children.length; i++) {
440
+ var child = children[i];
441
+ var classNames = child.className.split(' ');
442
+ for (var j = 0; j < classNames.length; j++) {
443
+ if (classNames[j] == className) {
444
+ elements.push(child);
445
+ break;
446
+ }
447
+ }
448
+ }
449
+
450
+ return elements;
451
+ }
452
+
453
+ /*--------------------------------------------------------------------------*/
454
+
455
+ var Element = {
456
+ toggle: function() {
457
+ for (var i = 0; i < arguments.length; i++) {
458
+ var element = $(arguments[i]);
459
+ element.style.display =
460
+ (element.style.display == 'none' ? '' : 'none');
461
+ }
462
+ },
463
+
464
+ hide: function() {
465
+ for (var i = 0; i < arguments.length; i++) {
466
+ var element = $(arguments[i]);
467
+ element.style.display = 'none';
468
+ }
469
+ },
470
+
471
+ show: function() {
472
+ for (var i = 0; i < arguments.length; i++) {
473
+ var element = $(arguments[i]);
474
+ element.style.display = '';
475
+ }
476
+ },
477
+
478
+ remove: function(element) {
479
+ element = $(element);
480
+ element.parentNode.removeChild(element);
481
+ },
482
+
483
+ getHeight: function(element) {
484
+ element = $(element);
485
+ return element.offsetHeight;
486
+ }
487
+ }
488
+
489
+ var Toggle = new Object();
490
+ Toggle.display = Element.toggle;
491
+
492
+ /*--------------------------------------------------------------------------*/
493
+
494
+ Abstract.Insertion = function(adjacency) {
495
+ this.adjacency = adjacency;
496
+ }
497
+
498
+ Abstract.Insertion.prototype = {
499
+ initialize: function(element, content) {
500
+ this.element = $(element);
501
+ this.content = content;
502
+
503
+ if (this.adjacency && this.element.insertAdjacentHTML) {
504
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
505
+ } else {
506
+ this.range = this.element.ownerDocument.createRange();
507
+ if (this.initializeRange) this.initializeRange();
508
+ this.fragment = this.range.createContextualFragment(this.content);
509
+ this.insertContent();
510
+ }
511
+ }
512
+ }
513
+
514
+ var Insertion = new Object();
515
+
516
+ Insertion.Before = Class.create();
517
+ Insertion.Before.prototype = (new Abstract.Insertion('beforeBegin')).extend({
518
+ initializeRange: function() {
519
+ this.range.setStartBefore(this.element);
520
+ },
521
+
522
+ insertContent: function() {
523
+ this.element.parentNode.insertBefore(this.fragment, this.element);
524
+ }
525
+ });
526
+
527
+ Insertion.Top = Class.create();
528
+ Insertion.Top.prototype = (new Abstract.Insertion('afterBegin')).extend({
529
+ initializeRange: function() {
530
+ this.range.selectNodeContents(this.element);
531
+ this.range.collapse(true);
532
+ },
533
+
534
+ insertContent: function() {
535
+ this.element.insertBefore(this.fragment, this.element.firstChild);
536
+ }
537
+ });
538
+
539
+ Insertion.Bottom = Class.create();
540
+ Insertion.Bottom.prototype = (new Abstract.Insertion('beforeEnd')).extend({
541
+ initializeRange: function() {
542
+ this.range.selectNodeContents(this.element);
543
+ this.range.collapse(this.element);
544
+ },
545
+
546
+ insertContent: function() {
547
+ this.element.appendChild(this.fragment);
548
+ }
549
+ });
550
+
551
+ Insertion.After = Class.create();
552
+ Insertion.After.prototype = (new Abstract.Insertion('afterEnd')).extend({
553
+ initializeRange: function() {
554
+ this.range.setStartAfter(this.element);
555
+ },
556
+
557
+ insertContent: function() {
558
+ this.element.parentNode.insertBefore(this.fragment,
559
+ this.element.nextSibling);
560
+ }
561
+ });
562
+
563
+ /*--------------------------------------------------------------------------*/
564
+
565
+ var Effect = new Object();
566
+
567
+ Effect.Highlight = Class.create();
568
+ Effect.Highlight.prototype = {
569
+ initialize: function(element) {
570
+ this.element = $(element);
571
+ this.start = 153;
572
+ this.finish = 255;
573
+ this.current = this.start;
574
+ this.fade();
575
+ },
576
+
577
+ fade: function() {
578
+ if (this.isFinished()) return;
579
+ if (this.timer) clearTimeout(this.timer);
580
+ this.highlight(this.element, this.current);
581
+ this.current += 17;
582
+ this.timer = setTimeout(this.fade.bind(this), 250);
583
+ },
584
+
585
+ isFinished: function() {
586
+ return this.current > this.finish;
587
+ },
588
+
589
+ highlight: function(element, current) {
590
+ element.style.backgroundColor = "#ffff" + current.toColorPart();
591
+ }
592
+ }
593
+
594
+
595
+ Effect.Fade = Class.create();
596
+ Effect.Fade.prototype = {
597
+ initialize: function(element) {
598
+ this.element = $(element);
599
+ this.start = 100;
600
+ this.finish = 0;
601
+ this.current = this.start;
602
+ this.fade();
603
+ },
604
+
605
+ fade: function() {
606
+ if (this.isFinished()) { this.element.style.display = 'none'; return; }
607
+ if (this.timer) clearTimeout(this.timer);
608
+ this.setOpacity(this.element, this.current);
609
+ this.current -= 10;
610
+ this.timer = setTimeout(this.fade.bind(this), 50);
611
+ },
612
+
613
+ isFinished: function() {
614
+ return this.current <= this.finish;
615
+ },
616
+
617
+ setOpacity: function(element, opacity) {
618
+ opacity = (opacity == 100) ? 99.999 : opacity;
619
+ element.style.filter = "alpha(opacity:"+opacity+")";
620
+ element.style.opacity = opacity/100 /*//*/;
621
+ }
622
+ }
623
+
624
+ Effect.Scale = Class.create();
625
+ Effect.Scale.prototype = {
626
+ initialize: function(element, percent) {
627
+ this.element = $(element);
628
+ this.startScale = 1.0;
629
+ this.startHeight = this.element.offsetHeight;
630
+ this.startWidth = this.element.offsetWidth;
631
+ this.currentHeight = this.startHeight;
632
+ this.currentWidth = this.startWidth;
633
+ this.finishScale = (percent/100) /*//*/;
634
+ if (this.element.style.fontSize=="") this.sizeEm = 1.0;
635
+ if (this.element.style.fontSize.indexOf("em")>0)
636
+ this.sizeEm = parseFloat(this.element.style.fontSize);
637
+ if(this.element.effect_scale) {
638
+ clearTimeout(this.element.effect_scale.timer);
639
+ this.startScale = this.element.effect_scale.currentScale;
640
+ this.startHeight = this.element.effect_scale.startHeight;
641
+ this.startWidth = this.element.effect_scale.startWidth;
642
+ if(this.element.effect_scale.sizeEm)
643
+ this.sizeEm = this.element.effect_scale.sizeEm;
644
+ }
645
+ this.element.effect_scale = this;
646
+ this.currentScale = this.startScale;
647
+ this.factor = this.finishScale - this.startScale;
648
+ this.options = arguments[2] || {};
649
+ this.scale();
650
+ },
651
+
652
+ scale: function() {
653
+ if (this.isFinished()) {
654
+ this.setDimensions(this.element, this.startWidth*this.finishScale, this.startHeight*this.finishScale);
655
+ if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.finishScale + "em";
656
+ if(this.options.complete) this.options.complete(this);
657
+ return;
658
+ }
659
+ if (this.timer) clearTimeout(this.timer);
660
+ if (this.options.step) this.options.step(this);
661
+ this.setDimensions(this.element, this.currentWidth, this.currentHeight);
662
+ if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.currentScale + "em";
663
+ this.currentScale += (this.factor/10) /*//*/;
664
+ this.currentWidth = this.startWidth * this.currentScale;
665
+ this.currentHeight = this.startHeight * this.currentScale;
666
+ this.timer = setTimeout(this.scale.bind(this), 50);
667
+ },
668
+
669
+ isFinished: function() {
670
+ return (this.factor < 0) ?
671
+ this.currentScale <= this.finishScale : this.currentScale >= this.finishScale;
672
+ },
673
+
674
+ setDimensions: function(element, width, height) {
675
+ element.style.width = width + 'px';
676
+ element.style.height = height + 'px';
677
+ }
678
+ }
679
+
680
+ Effect.Squish = Class.create();
681
+ Effect.Squish.prototype = {
682
+ initialize: function(element) {
683
+ this.element = $(element);
684
+ new Effect.Scale(this.element, 1, { complete: this.hide.bind(this) } );
685
+ },
686
+ hide: function() {
687
+ this.element.style.display = 'none';
688
+ }
689
+ }
690
+
691
+ Effect.Puff = Class.create();
692
+ Effect.Puff.prototype = {
693
+ initialize: function(element) {
694
+ this.element = $(element);
695
+ this.opacity = 100;
696
+ this.startTop = this.element.top || this.element.offsetTop;
697
+ this.startLeft = this.element.left || this.element.offsetLeft;
698
+ new Effect.Scale(this.element, 200, { step: this.fade.bind(this), complete: this.hide.bind(this) } );
699
+ },
700
+ fade: function(effect) {
701
+ topd = (((effect.currentScale)*effect.startHeight) - effect.startHeight)/2;
702
+ leftd = (((effect.currentScale)*effect.startWidth) - effect.startWidth)/2;
703
+ this.element.style.position='absolute';
704
+ this.element.style.top = this.startTop-topd + "px";
705
+ this.element.style.left = this.startLeft-leftd + "px";
706
+ this.opacity -= 10;
707
+ this.setOpacity(this.element, this.opacity);
708
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) this.element.innerHTML += ''; //force redraw on safari
709
+ },
710
+ hide: function() {
711
+ this.element.style.display = 'none';
712
+ },
713
+ setOpacity: function(element, opacity) {
714
+ opacity = (opacity == 100) ? 99.999 : opacity;
715
+ element.style.filter = "alpha(opacity:"+opacity+")";
716
+ element.style.opacity = opacity/100 /*//*/;
717
+ }
718
+ }
719
+
720
+ Effect.Appear = Class.create();
721
+ Effect.Appear.prototype = {
722
+ initialize: function(element) {
723
+ this.element = $(element);
724
+ this.start = 0;
725
+ this.finish = 100;
726
+ this.current = this.start;
727
+ this.fade();
728
+ },
729
+
730
+ fade: function() {
731
+ if (this.isFinished()) return;
732
+ if (this.timer) clearTimeout(this.timer);
733
+ this.setOpacity(this.element, this.current);
734
+ this.current += 10;
735
+ this.timer = setTimeout(this.fade.bind(this), 50);
736
+ },
737
+
738
+ isFinished: function() {
739
+ return this.current > this.finish;
740
+ },
741
+
742
+ setOpacity: function(element, opacity) {
743
+ opacity = (opacity == 100) ? 99.999 : opacity;
744
+ element.style.filter = "alpha(opacity:"+opacity+")";
745
+ element.style.opacity = opacity/100 /*//*/;
746
+ element.style.display = '';
747
+ }
748
+ }
749
+
750
+ Effect.ContentZoom = Class.create();
751
+ Effect.ContentZoom.prototype = {
752
+ initialize: function(element, percent) {
753
+ this.element = $(element);
754
+ if (this.element.style.fontSize=="") this.sizeEm = 1.0;
755
+ if (this.element.style.fontSize.indexOf("em")>0)
756
+ this.sizeEm = parseFloat(this.element.style.fontSize);
757
+ if(this.element.effect_contentzoom) {
758
+ this.sizeEm = this.element.effect_contentzoom.sizeEm;
759
+ }
760
+ this.element.effect_contentzoom = this;
761
+ this.element.style.fontSize = this.sizeEm*(percent/100) + "em" /*//*/;
762
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) { this.element.scrollTop -= 1; };
763
+ }
764
+ }