nitro 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG +410 -0
  2. data/ProjectInfo +36 -44
  3. data/README +5 -5
  4. data/doc/AUTHORS +6 -0
  5. data/doc/RELEASES +159 -2
  6. data/lib/glue/sweeper.rb +2 -2
  7. data/lib/glue/webfile.rb +14 -1
  8. data/lib/nitro.rb +6 -9
  9. data/lib/nitro/adapter/mongrel.rb +36 -43
  10. data/lib/nitro/adapter/scgi.rb +1 -1
  11. data/lib/nitro/adapter/webrick.rb +96 -24
  12. data/lib/nitro/caching/actions.rb +2 -1
  13. data/lib/nitro/caching/fragments.rb +1 -8
  14. data/lib/nitro/caching/output.rb +14 -4
  15. data/lib/nitro/cgi.rb +19 -21
  16. data/lib/nitro/cgi/cookie.rb +5 -1
  17. data/lib/nitro/cgi/request.rb +20 -4
  18. data/lib/nitro/compiler.rb +74 -28
  19. data/lib/nitro/compiler/cleanup.rb +1 -1
  20. data/lib/nitro/compiler/elements.rb +1 -2
  21. data/lib/nitro/compiler/localization.rb +1 -1
  22. data/lib/nitro/compiler/markup.rb +1 -1
  23. data/lib/nitro/compiler/script.rb +52 -44
  24. data/lib/nitro/compiler/squeeze.rb +4 -3
  25. data/lib/nitro/compiler/xslt.rb +7 -6
  26. data/lib/nitro/context.rb +39 -20
  27. data/lib/nitro/controller.rb +24 -5
  28. data/lib/nitro/dispatcher.rb +13 -5
  29. data/lib/nitro/global.rb +63 -0
  30. data/lib/nitro/helper/feed.rb +432 -0
  31. data/lib/nitro/helper/form.rb +11 -3
  32. data/lib/nitro/helper/form/builder.rb +140 -0
  33. data/lib/nitro/helper/form/controls.rb +2 -1
  34. data/lib/nitro/helper/javascript.rb +6 -0
  35. data/lib/nitro/helper/javascript/morphing.rb +13 -6
  36. data/lib/nitro/helper/xhtml.rb +42 -6
  37. data/lib/nitro/helper/xml.rb +3 -0
  38. data/lib/nitro/part.rb +2 -2
  39. data/lib/nitro/render.rb +7 -2
  40. data/lib/nitro/router.rb +57 -16
  41. data/lib/nitro/scaffolding.rb +29 -20
  42. data/lib/nitro/server.rb +4 -10
  43. data/lib/nitro/server/drb.rb +1 -1
  44. data/lib/nitro/server/runner.rb +10 -0
  45. data/lib/nitro/session.rb +31 -12
  46. data/lib/nitro/session/drb.rb +13 -1
  47. data/lib/nitro/session/file.rb +1 -1
  48. data/lib/nitro/session/memcached.rb +1 -1
  49. data/lib/nitro/session/memory.rb +1 -1
  50. data/lib/nitro/session/og.rb +1 -1
  51. data/lib/nitro/test/testcase.rb +3 -0
  52. data/proto/public/error.xhtml +5 -5
  53. data/proto/public/js/controls.js +2 -2
  54. data/proto/public/js/dragdrop.js +320 -79
  55. data/proto/public/js/effects.js +200 -152
  56. data/proto/public/js/prototype.js +284 -63
  57. data/proto/public/js/scriptaculous.js +7 -5
  58. data/proto/public/js/unittest.js +11 -0
  59. data/proto/public/scaffold/advanced_search.xhtml +30 -0
  60. data/proto/public/scaffold/list.xhtml +8 -1
  61. data/proto/public/scaffold/search.xhtml +2 -1
  62. data/proto/script/scgi_service +1 -1
  63. data/src/part/admin/controller.rb +1 -1
  64. data/src/part/admin/skin.rb +1 -1
  65. data/test/nitro/CONFIG.rb +3 -0
  66. data/test/nitro/adapter/tc_webrick.rb +1 -1
  67. data/test/nitro/cgi/tc_cookie.rb +1 -1
  68. data/test/nitro/cgi/tc_request.rb +5 -5
  69. data/test/nitro/compiler/tc_client_morpher.rb +47 -0
  70. data/test/nitro/compiler/tc_compiler.rb +2 -0
  71. data/test/nitro/helper/tc_feed.rb +138 -0
  72. data/test/nitro/helper/tc_pager.rb +1 -1
  73. data/test/nitro/helper/tc_rss.rb +1 -1
  74. data/test/nitro/helper/tc_table.rb +1 -1
  75. data/test/nitro/helper/tc_xhtml.rb +1 -1
  76. data/test/nitro/tc_caching.rb +1 -1
  77. data/test/nitro/tc_cgi.rb +1 -1
  78. data/test/nitro/tc_context.rb +1 -1
  79. data/test/nitro/tc_controller.rb +31 -3
  80. data/test/nitro/tc_controller_aspect.rb +1 -1
  81. data/test/nitro/tc_dispatcher.rb +1 -1
  82. data/test/nitro/tc_element.rb +1 -1
  83. data/test/nitro/tc_flash.rb +1 -1
  84. data/test/nitro/tc_helper.rb +1 -1
  85. data/test/nitro/tc_render.rb +6 -6
  86. data/test/nitro/tc_router.rb +8 -4
  87. data/test/nitro/tc_server.rb +1 -3
  88. data/test/nitro/tc_session.rb +1 -3
  89. metadata +107 -104
  90. data/Rakefile +0 -232
  91. data/lib/nitro/adapter/acgi.rb +0 -237
  92. data/proto/public/Makefile.acgi +0 -40
  93. data/proto/public/acgi.c +0 -138
@@ -6,8 +6,6 @@
6
6
  //
7
7
  // See scriptaculous.js for full license.
8
8
 
9
- /* ------------- element ext -------------- */
10
-
11
9
  // converts rgb() and #xxx to #xxxxxx format,
12
10
  // returns self (or first argument) if not convertable
13
11
  String.prototype.parseColor = function() {
@@ -24,6 +22,8 @@ String.prototype.parseColor = function() {
24
22
  return(color.length==7 ? color : (arguments[0] || this));
25
23
  }
26
24
 
25
+ /*--------------------------------------------------------------------------*/
26
+
27
27
  Element.collectTextNodes = function(element) {
28
28
  return $A($(element).childNodes).collect( function(node) {
29
29
  return (node.nodeType==3 ? node.nodeValue :
@@ -39,14 +39,10 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
39
39
  }).flatten().join('');
40
40
  }
41
41
 
42
- Element.setStyle = function(element, style) {
43
- element = $(element);
44
- for(k in style) element.style[k.camelize()] = style[k];
45
- }
46
-
47
- Element.setContentZoom = function(element, percent) {
42
+ Element.setContentZoom = function(element, percent) {
43
+ element = $(element);
48
44
  Element.setStyle(element, {fontSize: (percent/100) + 'em'});
49
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
45
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
50
46
  }
51
47
 
52
48
  Element.getOpacity = function(element){
@@ -73,18 +69,33 @@ Element.setOpacity = function(element, value){
73
69
  Element.setStyle(element,
74
70
  { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
75
71
  'alpha(opacity='+value*100+')' });
76
- }
72
+ }
77
73
  }
78
74
 
79
75
  Element.getInlineOpacity = function(element){
80
76
  return $(element).style.opacity || '';
81
77
  }
82
78
 
83
- Element.childrenWithClassName = function(element, className) {
84
- return $A($(element).getElementsByTagName('*')).select(
85
- function(c) { return Element.hasClassName(c, className) });
79
+ Element.childrenWithClassName = function(element, className, findFirst) {
80
+ var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");
81
+ var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
82
+ return (c.className && c.className.match(classNameRegExp));
83
+ });
84
+ if(!results) results = [];
85
+ return results;
86
86
  }
87
87
 
88
+ Element.forceRerendering = function(element) {
89
+ try {
90
+ element = $(element);
91
+ var n = document.createTextNode(' ');
92
+ element.appendChild(n);
93
+ element.removeChild(n);
94
+ } catch(e) { }
95
+ };
96
+
97
+ /*--------------------------------------------------------------------------*/
98
+
88
99
  Array.prototype.call = function() {
89
100
  var args = arguments;
90
101
  this.each(function(f){ f.apply(this, args) });
@@ -139,7 +150,7 @@ var Effect = {
139
150
  var options = Object.extend({
140
151
  queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
141
152
  }, arguments[2] || {});
142
- Effect[Element.visible(element) ?
153
+ Effect[element.visible() ?
143
154
  Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
144
155
  }
145
156
  };
@@ -343,15 +354,15 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
343
354
  this.element = $(element);
344
355
  // make this work on IE on elements without 'layout'
345
356
  if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
346
- Element.setStyle(this.element, {zoom: 1});
357
+ this.element.setStyle({zoom: 1});
347
358
  var options = Object.extend({
348
- from: Element.getOpacity(this.element) || 0.0,
359
+ from: this.element.getOpacity() || 0.0,
349
360
  to: 1.0
350
361
  }, arguments[1] || {});
351
362
  this.start(options);
352
363
  },
353
364
  update: function(position) {
354
- Element.setOpacity(this.element, position);
365
+ this.element.setOpacity(position);
355
366
  }
356
367
  });
357
368
 
@@ -371,9 +382,9 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
371
382
  // relative element that does not have top/left explicitly set.
372
383
  // ==> Always set top and left for position relative elements in your stylesheets
373
384
  // (to 0 if you do not need them)
374
- Element.makePositioned(this.element);
375
- this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
376
- this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
385
+ this.element.makePositioned();
386
+ this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
387
+ this.originalTop = parseFloat(this.element.getStyle('top') || '0');
377
388
  if(this.options.mode == 'absolute') {
378
389
  // absolute movement, so we need to calc deltaX and deltaY
379
390
  this.options.x = this.options.x - this.originalLeft;
@@ -381,7 +392,7 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
381
392
  }
382
393
  },
383
394
  update: function(position) {
384
- Element.setStyle(this.element, {
395
+ this.element.setStyle({
385
396
  left: this.options.x * position + this.originalLeft + 'px',
386
397
  top: this.options.y * position + this.originalTop + 'px'
387
398
  });
@@ -411,7 +422,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
411
422
  },
412
423
  setup: function() {
413
424
  this.restoreAfterFinish = this.options.restoreAfterFinish || false;
414
- this.elementPositioning = Element.getStyle(this.element,'position');
425
+ this.elementPositioning = this.element.getStyle('position');
415
426
 
416
427
  this.originalStyle = {};
417
428
  ['top','left','width','height','fontSize'].each( function(k) {
@@ -421,7 +432,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
421
432
  this.originalTop = this.element.offsetTop;
422
433
  this.originalLeft = this.element.offsetLeft;
423
434
 
424
- var fontSize = Element.getStyle(this.element,'font-size') || '100%';
435
+ var fontSize = this.element.getStyle('font-size') || '100%';
425
436
  ['em','px','%'].each( function(fontSizeType) {
426
437
  if(fontSize.indexOf(fontSizeType)>0) {
427
438
  this.fontSize = parseFloat(fontSize);
@@ -443,11 +454,11 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
443
454
  update: function(position) {
444
455
  var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
445
456
  if(this.options.scaleContent && this.fontSize)
446
- Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
457
+ this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
447
458
  this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
448
459
  },
449
460
  finish: function(position) {
450
- if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
461
+ if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
451
462
  },
452
463
  setDimensions: function(height, width) {
453
464
  var d = {};
@@ -464,7 +475,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
464
475
  if(this.options.scaleX) d.left = -leftd + 'px';
465
476
  }
466
477
  }
467
- Element.setStyle(this.element, d);
478
+ this.element.setStyle(d);
468
479
  }
469
480
  });
470
481
 
@@ -477,25 +488,25 @@ Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype),
477
488
  },
478
489
  setup: function() {
479
490
  // Prevent executing on elements not in the layout flow
480
- if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
491
+ if(this.element.getStyle('display')=='none') { this.cancel(); return; }
481
492
  // Disable background image during the effect
482
493
  this.oldStyle = {
483
- backgroundImage: Element.getStyle(this.element, 'background-image') };
484
- Element.setStyle(this.element, {backgroundImage: 'none'});
494
+ backgroundImage: this.element.getStyle('background-image') };
495
+ this.element.setStyle({backgroundImage: 'none'});
485
496
  if(!this.options.endcolor)
486
- this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
497
+ this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
487
498
  if(!this.options.restorecolor)
488
- this.options.restorecolor = Element.getStyle(this.element, 'background-color');
499
+ this.options.restorecolor = this.element.getStyle('background-color');
489
500
  // init color calculations
490
501
  this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
491
502
  this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
492
503
  },
493
504
  update: function(position) {
494
- Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
505
+ this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
495
506
  return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
496
507
  },
497
508
  finish: function() {
498
- Element.setStyle(this.element, Object.extend(this.oldStyle, {
509
+ this.element.setStyle(Object.extend(this.oldStyle, {
499
510
  backgroundColor: this.options.restorecolor
500
511
  }));
501
512
  }
@@ -529,75 +540,83 @@ Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
529
540
  /* ------------- combination effects ------------- */
530
541
 
531
542
  Effect.Fade = function(element) {
532
- var oldOpacity = Element.getInlineOpacity(element);
543
+ element = $(element);
544
+ var oldOpacity = element.getInlineOpacity();
533
545
  var options = Object.extend({
534
- from: Element.getOpacity(element) || 1.0,
546
+ from: element.getOpacity() || 1.0,
535
547
  to: 0.0,
536
- afterFinishInternal: function(effect) { with(Element) {
548
+ afterFinishInternal: function(effect) {
537
549
  if(effect.options.to!=0) return;
538
- hide(effect.element);
539
- setStyle(effect.element, {opacity: oldOpacity}); }}
540
- }, arguments[1] || {});
550
+ effect.element.hide();
551
+ effect.element.setStyle({opacity: oldOpacity});
552
+ }}, arguments[1] || {});
541
553
  return new Effect.Opacity(element,options);
542
554
  }
543
555
 
544
556
  Effect.Appear = function(element) {
557
+ element = $(element);
545
558
  var options = Object.extend({
546
- from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
559
+ from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
547
560
  to: 1.0,
548
- beforeSetup: function(effect) { with(Element) {
549
- setOpacity(effect.element, effect.options.from);
550
- show(effect.element); }}
551
- }, arguments[1] || {});
561
+ // force Safari to render floated elements properly
562
+ afterFinishInternal: function(effect) {
563
+ effect.element.forceRerendering();
564
+ },
565
+ beforeSetup: function(effect) {
566
+ effect.element.setOpacity(effect.options.from);
567
+ effect.element.show();
568
+ }}, arguments[1] || {});
552
569
  return new Effect.Opacity(element,options);
553
570
  }
554
571
 
555
572
  Effect.Puff = function(element) {
556
573
  element = $(element);
557
- var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
574
+ var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') };
558
575
  return new Effect.Parallel(
559
576
  [ new Effect.Scale(element, 200,
560
577
  { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
561
578
  new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
562
579
  Object.extend({ duration: 1.0,
563
- beforeSetupInternal: function(effect) { with(Element) {
564
- setStyle(effect.effects[0].element, {position: 'absolute'}); }},
565
- afterFinishInternal: function(effect) { with(Element) {
566
- hide(effect.effects[0].element);
567
- setStyle(effect.effects[0].element, oldStyle); }}
580
+ beforeSetupInternal: function(effect) {
581
+ effect.effects[0].element.setStyle({position: 'absolute'}); },
582
+ afterFinishInternal: function(effect) {
583
+ effect.effects[0].element.hide();
584
+ effect.effects[0].element.setStyle(oldStyle); }
568
585
  }, arguments[1] || {})
569
586
  );
570
587
  }
571
588
 
572
589
  Effect.BlindUp = function(element) {
573
590
  element = $(element);
574
- Element.makeClipping(element);
591
+ element.makeClipping();
575
592
  return new Effect.Scale(element, 0,
576
593
  Object.extend({ scaleContent: false,
577
594
  scaleX: false,
578
595
  restoreAfterFinish: true,
579
- afterFinishInternal: function(effect) { with(Element) {
580
- [hide, undoClipping].call(effect.element); }}
596
+ afterFinishInternal: function(effect) {
597
+ effect.element.hide();
598
+ effect.element.undoClipping();
599
+ }
581
600
  }, arguments[1] || {})
582
601
  );
583
602
  }
584
603
 
585
604
  Effect.BlindDown = function(element) {
586
605
  element = $(element);
587
- var elementDimensions = Element.getDimensions(element);
606
+ var elementDimensions = element.getDimensions();
588
607
  return new Effect.Scale(element, 100,
589
608
  Object.extend({ scaleContent: false,
590
609
  scaleX: false,
591
610
  scaleFrom: 0,
592
611
  scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
593
612
  restoreAfterFinish: true,
594
- afterSetup: function(effect) { with(Element) {
595
- makeClipping(effect.element);
596
- setStyle(effect.element, {height: '0px'});
597
- show(effect.element);
598
- }},
613
+ afterSetup: function(effect) {
614
+ effect.element.makeClipping();
615
+ effect.element.setStyle({height: '0px'});
616
+ effect.element.show();
617
+ },
599
618
  afterFinishInternal: function(effect) {
600
- Element.undoClipping(effect.element);
619
+ effect.element.undoClipping();
601
620
  }
602
621
  }, arguments[1] || {})
603
622
  );
@@ -605,7 +624,7 @@ Effect.BlindDown = function(element) {
605
624
 
606
625
  Effect.SwitchOff = function(element) {
607
626
  element = $(element);
608
- var oldOpacity = Element.getInlineOpacity(element);
627
+ var oldOpacity = element.getInlineOpacity();
609
628
  return new Effect.Appear(element, {
610
629
  duration: 0.4,
611
630
  from: 0,
@@ -614,13 +633,16 @@ Effect.SwitchOff = function(element) {
614
633
  new Effect.Scale(effect.element, 1, {
615
634
  duration: 0.3, scaleFromCenter: true,
616
635
  scaleX: false, scaleContent: false, restoreAfterFinish: true,
617
- beforeSetup: function(effect) { with(Element) {
618
- [makePositioned,makeClipping].call(effect.element);
619
- }},
620
- afterFinishInternal: function(effect) { with(Element) {
621
- [hide,undoClipping,undoPositioned].call(effect.element);
622
- setStyle(effect.element, {opacity: oldOpacity});
623
- }}
636
+ beforeSetup: function(effect) {
637
+ effect.element.makePositioned();
638
+ effect.element.makeClipping();
639
+ },
640
+ afterFinishInternal: function(effect) {
641
+ effect.element.hide();
642
+ effect.element.undoClipping();
643
+ effect.element.undoPositioned();
644
+ effect.element.setStyle({opacity: oldOpacity});
645
+ }
624
646
  })
625
647
  }
626
648
  });
@@ -629,27 +651,30 @@ Effect.SwitchOff = function(element) {
629
651
  Effect.DropOut = function(element) {
630
652
  element = $(element);
631
653
  var oldStyle = {
632
- top: Element.getStyle(element, 'top'),
633
- left: Element.getStyle(element, 'left'),
634
- opacity: Element.getInlineOpacity(element) };
654
+ top: element.getStyle('top'),
655
+ left: element.getStyle('left'),
656
+ opacity: element.getInlineOpacity() };
635
657
  return new Effect.Parallel(
636
658
  [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
637
659
  new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
638
660
  Object.extend(
639
661
  { duration: 0.5,
640
- beforeSetup: function(effect) { with(Element) {
641
- makePositioned(effect.effects[0].element); }},
642
- afterFinishInternal: function(effect) { with(Element) {
643
- [hide, undoPositioned].call(effect.effects[0].element);
644
- setStyle(effect.effects[0].element, oldStyle); }}
662
+ beforeSetup: function(effect) {
663
+ effect.effects[0].element.makePositioned();
664
+ },
665
+ afterFinishInternal: function(effect) {
666
+ effect.effects[0].element.hide();
667
+ effect.effects[0].element.undoPositioned();
668
+ effect.effects[0].element.setStyle(oldStyle);
669
+ }
645
670
  }, arguments[1] || {}));
646
671
  }
647
672
 
648
673
  Effect.Shake = function(element) {
649
674
  element = $(element);
650
675
  var oldStyle = {
651
- top: Element.getStyle(element, 'top'),
652
- left: Element.getStyle(element, 'left') };
676
+ top: element.getStyle('top'),
677
+ left: element.getStyle('left') };
653
678
  return new Effect.Move(element,
654
679
  { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
655
680
  new Effect.Move(effect.element,
@@ -661,73 +686,75 @@ Effect.Shake = function(element) {
661
686
  new Effect.Move(effect.element,
662
687
  { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
663
688
  new Effect.Move(effect.element,
664
- { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
665
- undoPositioned(effect.element);
666
- setStyle(effect.element, oldStyle);
667
- }}}) }}) }}) }}) }}) }});
689
+ { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
690
+ effect.element.undoPositioned();
691
+ effect.element.setStyle(oldStyle);
692
+ }}) }}) }}) }}) }}) }});
668
693
  }
669
694
 
670
695
  Effect.SlideDown = function(element) {
671
696
  element = $(element);
672
- Element.cleanWhitespace(element);
697
+ element.cleanWhitespace();
673
698
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
674
- var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
675
- var elementDimensions = Element.getDimensions(element);
699
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
700
+ var elementDimensions = element.getDimensions();
676
701
  return new Effect.Scale(element, 100, Object.extend({
677
702
  scaleContent: false,
678
703
  scaleX: false,
679
- scaleFrom: 0,
704
+ scaleFrom: window.opera ? 0 : 1,
680
705
  scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
681
706
  restoreAfterFinish: true,
682
- afterSetup: function(effect) { with(Element) {
683
- makePositioned(effect.element);
684
- makePositioned(effect.element.firstChild);
685
- if(window.opera) setStyle(effect.element, {top: ''});
686
- makeClipping(effect.element);
687
- setStyle(effect.element, {height: '0px'});
688
- show(element); }},
689
- afterUpdateInternal: function(effect) { with(Element) {
690
- setStyle(effect.element.firstChild, {bottom:
691
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
692
- afterFinishInternal: function(effect) { with(Element) {
693
- undoClipping(effect.element);
707
+ afterSetup: function(effect) {
708
+ effect.element.makePositioned();
709
+ effect.element.firstChild.makePositioned();
710
+ if(window.opera) effect.element.setStyle({top: ''});
711
+ effect.element.makeClipping();
712
+ effect.element.setStyle({height: '0px'});
713
+ effect.element.show(); },
714
+ afterUpdateInternal: function(effect) {
715
+ effect.element.firstChild.setStyle({bottom:
716
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
717
+ },
718
+ afterFinishInternal: function(effect) {
719
+ effect.element.undoClipping();
694
720
  // IE will crash if child is undoPositioned first
695
721
  if(/MSIE/.test(navigator.userAgent)){
696
- undoPositioned(effect.element);
697
- undoPositioned(effect.element.firstChild);
722
+ effect.element.undoPositioned();
723
+ effect.element.firstChild.undoPositioned();
698
724
  }else{
699
- undoPositioned(effect.element.firstChild);
700
- undoPositioned(effect.element);
725
+ effect.element.firstChild.undoPositioned();
726
+ effect.element.undoPositioned();
701
727
  }
702
- setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
728
+ effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
703
729
  }, arguments[1] || {})
704
730
  );
705
731
  }
706
732
 
707
733
  Effect.SlideUp = function(element) {
708
734
  element = $(element);
709
- Element.cleanWhitespace(element);
710
- var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
711
- return new Effect.Scale(element, 0,
735
+ element.cleanWhitespace();
736
+ var oldInnerBottom = $(element.firstChild).getStyle('bottom');
737
+ return new Effect.Scale(element, window.opera ? 0 : 1,
712
738
  Object.extend({ scaleContent: false,
713
739
  scaleX: false,
714
740
  scaleMode: 'box',
715
741
  scaleFrom: 100,
716
742
  restoreAfterFinish: true,
717
- beforeStartInternal: function(effect) { with(Element) {
718
- makePositioned(effect.element);
719
- makePositioned(effect.element.firstChild);
720
- if(window.opera) setStyle(effect.element, {top: ''});
721
- makeClipping(effect.element);
722
- show(element); }},
723
- afterUpdateInternal: function(effect) { with(Element) {
724
- setStyle(effect.element.firstChild, {bottom:
725
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
726
- afterFinishInternal: function(effect) { with(Element) {
727
- [hide, undoClipping].call(effect.element);
728
- undoPositioned(effect.element.firstChild);
729
- undoPositioned(effect.element);
730
- setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
743
+ beforeStartInternal: function(effect) {
744
+ effect.element.makePositioned();
745
+ effect.element.firstChild.makePositioned();
746
+ if(window.opera) effect.element.setStyle({top: ''});
747
+ effect.element.makeClipping();
748
+ effect.element.show(); },
749
+ afterUpdateInternal: function(effect) {
750
+ effect.element.firstChild.setStyle({bottom:
751
+ (effect.dims[0] - effect.element.clientHeight) + 'px' }); },
752
+ afterFinishInternal: function(effect) {
753
+ effect.element.hide();
754
+ effect.element.undoClipping();
755
+ effect.element.firstChild.undoPositioned();
756
+ effect.element.undoPositioned();
757
+ effect.element.setStyle({bottom: oldInnerBottom}); }
731
758
  }, arguments[1] || {})
732
759
  );
733
760
  }
@@ -736,11 +763,11 @@ Effect.SlideUp = function(element) {
736
763
  Effect.Squish = function(element) {
737
764
  return new Effect.Scale(element, window.opera ? 1 : 0,
738
765
  { restoreAfterFinish: true,
739
- beforeSetup: function(effect) { with(Element) {
740
- makeClipping(effect.element); }},
741
- afterFinishInternal: function(effect) { with(Element) {
742
- hide(effect.element);
743
- undoClipping(effect.element); }}
766
+ beforeSetup: function(effect) {
767
+ effect.element.makeClipping(effect.element); },
768
+ afterFinishInternal: function(effect) {
769
+ effect.element.hide(effect.element);
770
+ effect.element.undoClipping(effect.element); }
744
771
  });
745
772
  }
746
773
 
@@ -757,9 +784,9 @@ Effect.Grow = function(element) {
757
784
  left: element.style.left,
758
785
  height: element.style.height,
759
786
  width: element.style.width,
760
- opacity: Element.getInlineOpacity(element) };
787
+ opacity: element.getInlineOpacity() };
761
788
 
762
- var dims = Element.getDimensions(element);
789
+ var dims = element.getDimensions();
763
790
  var initialMoveX, initialMoveY;
764
791
  var moveX, moveY;
765
792
 
@@ -795,11 +822,11 @@ Effect.Grow = function(element) {
795
822
  x: initialMoveX,
796
823
  y: initialMoveY,
797
824
  duration: 0.01,
798
- beforeSetup: function(effect) { with(Element) {
799
- hide(effect.element);
800
- makeClipping(effect.element);
801
- makePositioned(effect.element);
802
- }},
825
+ beforeSetup: function(effect) {
826
+ effect.element.hide();
827
+ effect.element.makeClipping();
828
+ effect.element.makePositioned();
829
+ },
803
830
  afterFinishInternal: function(effect) {
804
831
  new Effect.Parallel(
805
832
  [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
@@ -808,12 +835,15 @@ Effect.Grow = function(element) {
808
835
  scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
809
836
  sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
810
837
  ], Object.extend({
811
- beforeSetup: function(effect) { with(Element) {
812
- setStyle(effect.effects[0].element, {height: '0px'});
813
- show(effect.effects[0].element); }},
814
- afterFinishInternal: function(effect) { with(Element) {
815
- [undoClipping, undoPositioned].call(effect.effects[0].element);
816
- setStyle(effect.effects[0].element, oldStyle); }}
838
+ beforeSetup: function(effect) {
839
+ effect.effects[0].element.setStyle({height: '0px'});
840
+ effect.effects[0].element.show();
841
+ },
842
+ afterFinishInternal: function(effect) {
843
+ effect.effects[0].element.undoClipping();
844
+ effect.effects[0].element.undoPositioned();
845
+ effect.effects[0].element.setStyle(oldStyle);
846
+ }
817
847
  }, options)
818
848
  )
819
849
  }
@@ -833,9 +863,9 @@ Effect.Shrink = function(element) {
833
863
  left: element.style.left,
834
864
  height: element.style.height,
835
865
  width: element.style.width,
836
- opacity: Element.getInlineOpacity(element) };
866
+ opacity: element.getInlineOpacity() };
837
867
 
838
- var dims = Element.getDimensions(element);
868
+ var dims = element.getDimensions();
839
869
  var moveX, moveY;
840
870
 
841
871
  switch (options.direction) {
@@ -865,11 +895,14 @@ Effect.Shrink = function(element) {
865
895
  new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
866
896
  new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
867
897
  ], Object.extend({
868
- beforeStartInternal: function(effect) { with(Element) {
869
- [makePositioned, makeClipping].call(effect.effects[0].element) }},
870
- afterFinishInternal: function(effect) { with(Element) {
871
- [hide, undoClipping, undoPositioned].call(effect.effects[0].element);
872
- setStyle(effect.effects[0].element, oldStyle); }}
898
+ beforeStartInternal: function(effect) {
899
+ effect.effects[0].element.makePositioned();
900
+ effect.effects[0].element.makeClipping(); },
901
+ afterFinishInternal: function(effect) {
902
+ effect.effects[0].element.hide();
903
+ effect.effects[0].element.undoClipping();
904
+ effect.effects[0].element.undoPositioned();
905
+ effect.effects[0].element.setStyle(oldStyle); }
873
906
  }, options)
874
907
  );
875
908
  }
@@ -877,13 +910,13 @@ Effect.Shrink = function(element) {
877
910
  Effect.Pulsate = function(element) {
878
911
  element = $(element);
879
912
  var options = arguments[1] || {};
880
- var oldOpacity = Element.getInlineOpacity(element);
913
+ var oldOpacity = element.getInlineOpacity();
881
914
  var transition = options.transition || Effect.Transitions.sinoidal;
882
915
  var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
883
916
  reverser.bind(transition);
884
917
  return new Effect.Opacity(element,
885
918
  Object.extend(Object.extend({ duration: 3.0, from: 0,
886
- afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
919
+ afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
887
920
  }, options), {transition: reverser}));
888
921
  }
889
922
 
@@ -902,9 +935,24 @@ Effect.Fold = function(element) {
902
935
  new Effect.Scale(element, 1, {
903
936
  scaleContent: false,
904
937
  scaleY: false,
905
- afterFinishInternal: function(effect) { with(Element) {
906
- [hide, undoClipping].call(effect.element);
907
- setStyle(effect.element, oldStyle);
908
- }} });
938
+ afterFinishInternal: function(effect) {
939
+ effect.element.hide();
940
+ effect.element.undoClipping();
941
+ effect.element.setStyle(oldStyle);
942
+ } });
909
943
  }}, arguments[1] || {}));
910
- }
944
+ };
945
+
946
+ ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
947
+ 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
948
+ function(f) { Element.Methods[f] = Element[f]; }
949
+ );
950
+
951
+ Element.Methods.visualEffect = function(element, effect, options) {
952
+ s = effect.gsub(/_/, '-').camelize();
953
+ effect_class = s.charAt(0).toUpperCase() + s.substring(1);
954
+ new Effect[effect_class](element, options);
955
+ return $(element);
956
+ };
957
+
958
+ Element.addMethods();