parlement 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CHANGES +11 -0
  2. data/MEMORY +9 -1
  3. data/README +5 -4
  4. data/app/controllers/account_controller.rb +10 -13
  5. data/app/controllers/application.rb +4 -5
  6. data/app/controllers/elt_controller.rb +9 -7
  7. data/app/controllers/person_controller.rb +1 -3
  8. data/app/controllers/subscriber_controller.rb +10 -10
  9. data/app/helpers/elt_helper.rb +2 -0
  10. data/app/models/elt.rb +28 -19
  11. data/app/models/mail.rb +26 -14
  12. data/app/models/mail_notify.rb +5 -4
  13. data/app/models/person.rb +11 -2
  14. data/app/views/account/_login.rhtml +3 -3
  15. data/app/views/account/_show.rhtml +12 -14
  16. data/app/views/elt/_choice.rhtml +3 -3
  17. data/app/views/elt/_elt.rhtml +4 -4
  18. data/app/views/elt/_list.rhtml +2 -2
  19. data/app/views/elt/_listByDate.rhtml +1 -1
  20. data/app/views/elt/_listByVote.rhtml +1 -1
  21. data/app/views/elt/new.rhtml +3 -3
  22. data/app/views/elt/show.rhtml +2 -2
  23. data/app/views/layouts/top.rhtml +6 -0
  24. data/app/views/mail_notify/publish.text.html.rhtml +1 -1
  25. data/app/views/person/_listElts.rhtml +5 -3
  26. data/app/views/person/show.rhtml +1 -2
  27. data/config/boot.rb +5 -4
  28. data/config/environment.rb +6 -4
  29. data/config/routes.rb +3 -2
  30. data/db/development_structure.sql +15 -4
  31. data/db/migrate/006_last_activity.rb +10 -0
  32. data/db/schema.rb +67 -49
  33. data/public/dispatch.fcgi +1 -0
  34. data/public/javascripts/controls.js +41 -23
  35. data/public/javascripts/dragdrop.js +317 -99
  36. data/public/javascripts/effects.js +301 -166
  37. data/public/javascripts/prototype.js +932 -402
  38. data/public/stylesheets/default.css +3 -2
  39. data/test/unit/elt_test.rb +13 -0
  40. data/test/unit/mail_test.rb +3 -1
  41. data/vendor/plugins/engines/CHANGELOG +203 -99
  42. data/vendor/plugins/engines/MIT-LICENSE +1 -1
  43. data/vendor/plugins/engines/README +32 -384
  44. data/vendor/plugins/engines/Rakefile +14 -0
  45. data/vendor/plugins/engines/UPGRADING +93 -0
  46. data/vendor/plugins/engines/about.yml +7 -0
  47. data/vendor/plugins/engines/generators/plugin_migration/USAGE +45 -0
  48. data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +79 -0
  49. data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +13 -0
  50. data/vendor/plugins/engines/init.rb +34 -47
  51. data/vendor/plugins/engines/install.rb +32 -0
  52. data/vendor/plugins/engines/lib/engines/{ruby_extensions.rb → deprecated_config_support.rb} +135 -113
  53. data/vendor/plugins/engines/lib/engines/plugin.rb +214 -0
  54. data/vendor/plugins/engines/lib/engines/plugin_list.rb +31 -0
  55. data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +60 -0
  56. data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +19 -0
  57. data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +143 -0
  58. data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +155 -0
  59. data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +116 -0
  60. data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +20 -0
  61. data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +86 -0
  62. data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +77 -0
  63. data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +140 -0
  64. data/vendor/plugins/engines/lib/engines/rails_extensions.rb +6 -0
  65. data/vendor/plugins/engines/lib/engines/testing.rb +88 -0
  66. data/vendor/plugins/engines/lib/engines.rb +281 -425
  67. data/vendor/plugins/engines/tasks/engines.rake +108 -137
  68. metadata +218 -250
  69. data/db/ROOT/perso.txt +0 -214
  70. data/public/images/indicator.gif +0 -0
  71. data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
  72. data/public/images/smile.png +0 -0
  73. data/vendor/plugins/engines/generators/engine/USAGE +0 -26
  74. data/vendor/plugins/engines/generators/engine/engine_generator.rb +0 -199
  75. data/vendor/plugins/engines/generators/engine/templates/README +0 -85
  76. data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +0 -15
  77. data/vendor/plugins/engines/generators/engine/templates/install.erb +0 -4
  78. data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +0 -6
  79. data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +0 -18
  80. data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +0 -19
  81. data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +0 -22
  82. data/vendor/plugins/engines/generators/engine/templates/licenses/None +0 -1
  83. data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
  84. data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
  85. data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
  86. data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +0 -17
  87. data/vendor/plugins/engines/lib/bundles/require_resource.rb +0 -124
  88. data/vendor/plugins/engines/lib/bundles.rb +0 -77
  89. data/vendor/plugins/engines/lib/engines/action_mailer_extensions.rb +0 -140
  90. data/vendor/plugins/engines/lib/engines/action_view_extensions.rb +0 -141
  91. data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +0 -21
  92. data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +0 -129
  93. data/vendor/plugins/engines/lib/engines/migration_extensions.rb +0 -53
  94. data/vendor/plugins/engines/lib/engines/routing_extensions.rb +0 -28
  95. data/vendor/plugins/engines/lib/engines/testing_extensions.rb +0 -327
  96. data/vendor/plugins/engines/tasks/deprecated_engines.rake +0 -7
  97. data/vendor/plugins/engines/test/action_view_extensions_test.rb +0 -9
  98. data/vendor/plugins/engines/test/ruby_extensions_test.rb +0 -115
  99. data/vendor/plugins/guid/README.TXT +0 -29
  100. data/vendor/plugins/guid/init.rb +0 -30
  101. data/vendor/plugins/guid/lib/usesguid.rb +0 -37
  102. data/vendor/plugins/guid/lib/uuid22.rb +0 -43
  103. data/vendor/plugins/guid/lib/uuidtools.rb +0 -572
  104. data/vendor/plugins/responds_to_parent/MIT-LICENSE +0 -20
  105. data/vendor/plugins/responds_to_parent/README +0 -42
  106. data/vendor/plugins/responds_to_parent/Rakefile +0 -22
  107. data/vendor/plugins/responds_to_parent/init.rb +0 -1
  108. data/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +0 -46
  109. data/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +0 -115
@@ -1,15 +1,16 @@
1
- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
1
+ // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
2
  // Contributors:
3
3
  // Justin Palmer (http://encytemedia.com/)
4
4
  // Mark Pilgrim (http://diveintomark.org/)
5
5
  // Martin Bialasinki
6
6
  //
7
- // See scriptaculous.js for full license.
7
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
8
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
8
9
 
9
10
  // converts rgb() and #xxx to #xxxxxx format,
10
11
  // returns self (or first argument) if not convertable
11
12
  String.prototype.parseColor = function() {
12
- var color = '#';
13
+ var color = '#';
13
14
  if(this.slice(0,4) == 'rgb(') {
14
15
  var cols = this.slice(4,this.length-1).split(',');
15
16
  var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
@@ -41,15 +42,17 @@ Element.collectTextNodesIgnoreClass = function(element, className) {
41
42
 
42
43
  Element.setContentZoom = function(element, percent) {
43
44
  element = $(element);
44
- Element.setStyle(element, {fontSize: (percent/100) + 'em'});
45
+ element.setStyle({fontSize: (percent/100) + 'em'});
45
46
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
47
+ return element;
46
48
  }
47
49
 
48
- Element.getOpacity = function(element){
50
+ Element.getOpacity = function(element){
51
+ element = $(element);
49
52
  var opacity;
50
- if (opacity = Element.getStyle(element, 'opacity'))
53
+ if (opacity = element.getStyle('opacity'))
51
54
  return parseFloat(opacity);
52
- if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
55
+ if (opacity = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
53
56
  if(opacity[1]) return parseFloat(opacity[1]) / 100;
54
57
  return 1.0;
55
58
  }
@@ -57,31 +60,26 @@ Element.getOpacity = function(element){
57
60
  Element.setOpacity = function(element, value){
58
61
  element= $(element);
59
62
  if (value == 1){
60
- Element.setStyle(element, { opacity:
63
+ element.setStyle({ opacity:
61
64
  (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
62
- 0.999999 : null });
63
- if(/MSIE/.test(navigator.userAgent))
64
- Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
65
+ 0.999999 : 1.0 });
66
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
67
+ element.setStyle({filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
65
68
  } else {
66
69
  if(value < 0.00001) value = 0;
67
- Element.setStyle(element, {opacity: value});
68
- if(/MSIE/.test(navigator.userAgent))
69
- Element.setStyle(element,
70
- { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
71
- 'alpha(opacity='+value*100+')' });
70
+ element.setStyle({opacity: value});
71
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
72
+ element.setStyle(
73
+ { filter: element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
74
+ 'alpha(opacity='+value*100+')' });
72
75
  }
76
+ return element;
73
77
  }
74
78
 
75
79
  Element.getInlineOpacity = function(element){
76
80
  return $(element).style.opacity || '';
77
81
  }
78
82
 
79
- Element.childrenWithClassName = function(element, className, findFirst) {
80
- return [$A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {
81
- return c.className ? Element.hasClassName(c, className) : false;
82
- })].flatten();
83
- }
84
-
85
83
  Element.forceRerendering = function(element) {
86
84
  try {
87
85
  element = $(element);
@@ -91,11 +89,6 @@ Element.forceRerendering = function(element) {
91
89
  } catch(e) { }
92
90
  };
93
91
 
94
- ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
95
- 'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(
96
- function(f) { Element.Methods[f] = Element[f]; }
97
- );
98
-
99
92
  /*--------------------------------------------------------------------------*/
100
93
 
101
94
  Array.prototype.call = function() {
@@ -106,9 +99,17 @@ Array.prototype.call = function() {
106
99
  /*--------------------------------------------------------------------------*/
107
100
 
108
101
  var Effect = {
102
+ _elementDoesNotExistError: {
103
+ name: 'ElementDoesNotExistError',
104
+ message: 'The specified DOM element does not exist, but is required for this effect to operate'
105
+ },
109
106
  tagifyText: function(element) {
107
+ if(typeof Builder == 'undefined')
108
+ throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
109
+
110
110
  var tagifyStyle = 'position:relative';
111
- if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
111
+ if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
112
+
112
113
  element = $(element);
113
114
  $A(element.childNodes).each( function(child) {
114
115
  if(child.nodeType==3) {
@@ -161,33 +162,35 @@ var Effect2 = Effect; // deprecated
161
162
 
162
163
  /* ------------- transitions ------------- */
163
164
 
164
- Effect.Transitions = {}
165
-
166
- Effect.Transitions.linear = function(pos) {
167
- return pos;
168
- }
169
- Effect.Transitions.sinoidal = function(pos) {
170
- return (-Math.cos(pos*Math.PI)/2) + 0.5;
171
- }
172
- Effect.Transitions.reverse = function(pos) {
173
- return 1-pos;
174
- }
175
- Effect.Transitions.flicker = function(pos) {
176
- return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
177
- }
178
- Effect.Transitions.wobble = function(pos) {
179
- return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
180
- }
181
- Effect.Transitions.pulse = function(pos) {
182
- return (Math.floor(pos*10) % 2 == 0 ?
183
- (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
184
- }
185
- Effect.Transitions.none = function(pos) {
186
- return 0;
187
- }
188
- Effect.Transitions.full = function(pos) {
189
- return 1;
190
- }
165
+ Effect.Transitions = {
166
+ linear: Prototype.K,
167
+ sinoidal: function(pos) {
168
+ return (-Math.cos(pos*Math.PI)/2) + 0.5;
169
+ },
170
+ reverse: function(pos) {
171
+ return 1-pos;
172
+ },
173
+ flicker: function(pos) {
174
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
175
+ },
176
+ wobble: function(pos) {
177
+ return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
178
+ },
179
+ pulse: function(pos, pulses) {
180
+ pulses = pulses || 5;
181
+ return (
182
+ Math.round((pos % (1/pulses)) * pulses) == 0 ?
183
+ ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :
184
+ 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
185
+ );
186
+ },
187
+ none: function(pos) {
188
+ return 0;
189
+ },
190
+ full: function(pos) {
191
+ return 1;
192
+ }
193
+ };
191
194
 
192
195
  /* ------------- core effects ------------- */
193
196
 
@@ -214,6 +217,9 @@ Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
214
217
  e.finishOn += effect.finishOn;
215
218
  });
216
219
  break;
220
+ case 'with-last':
221
+ timestamp = this.effects.pluck('startOn').max() || timestamp;
222
+ break;
217
223
  case 'end':
218
224
  // start effect after last queued effect has finished
219
225
  timestamp = this.effects.pluck('finishOn').max() || timestamp;
@@ -350,12 +356,24 @@ Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
350
356
  }
351
357
  });
352
358
 
359
+ Effect.Event = Class.create();
360
+ Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
361
+ initialize: function() {
362
+ var options = Object.extend({
363
+ duration: 0
364
+ }, arguments[0] || {});
365
+ this.start(options);
366
+ },
367
+ update: Prototype.emptyFunction
368
+ });
369
+
353
370
  Effect.Opacity = Class.create();
354
371
  Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
355
372
  initialize: function(element) {
356
373
  this.element = $(element);
374
+ if(!this.element) throw(Effect._elementDoesNotExistError);
357
375
  // make this work on IE on elements without 'layout'
358
- if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
376
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
359
377
  this.element.setStyle({zoom: 1});
360
378
  var options = Object.extend({
361
379
  from: this.element.getOpacity() || 0.0,
@@ -372,6 +390,7 @@ Effect.Move = Class.create();
372
390
  Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
373
391
  initialize: function(element) {
374
392
  this.element = $(element);
393
+ if(!this.element) throw(Effect._elementDoesNotExistError);
375
394
  var options = Object.extend({
376
395
  x: 0,
377
396
  y: 0,
@@ -395,8 +414,8 @@ Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
395
414
  },
396
415
  update: function(position) {
397
416
  this.element.setStyle({
398
- left: this.options.x * position + this.originalLeft + 'px',
399
- top: this.options.y * position + this.originalTop + 'px'
417
+ left: Math.round(this.options.x * position + this.originalLeft) + 'px',
418
+ top: Math.round(this.options.y * position + this.originalTop) + 'px'
400
419
  });
401
420
  }
402
421
  });
@@ -410,7 +429,8 @@ Effect.MoveBy = function(element, toTop, toLeft) {
410
429
  Effect.Scale = Class.create();
411
430
  Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
412
431
  initialize: function(element, percent) {
413
- this.element = $(element)
432
+ this.element = $(element);
433
+ if(!this.element) throw(Effect._elementDoesNotExistError);
414
434
  var options = Object.extend({
415
435
  scaleX: true,
416
436
  scaleY: true,
@@ -435,7 +455,7 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
435
455
  this.originalLeft = this.element.offsetLeft;
436
456
 
437
457
  var fontSize = this.element.getStyle('font-size') || '100%';
438
- ['em','px','%'].each( function(fontSizeType) {
458
+ ['em','px','%','pt'].each( function(fontSizeType) {
439
459
  if(fontSize.indexOf(fontSizeType)>0) {
440
460
  this.fontSize = parseFloat(fontSize);
441
461
  this.fontSizeType = fontSizeType;
@@ -460,12 +480,12 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
460
480
  this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
461
481
  },
462
482
  finish: function(position) {
463
- if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
483
+ if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
464
484
  },
465
485
  setDimensions: function(height, width) {
466
486
  var d = {};
467
- if(this.options.scaleX) d.width = width + 'px';
468
- if(this.options.scaleY) d.height = height + 'px';
487
+ if(this.options.scaleX) d.width = Math.round(width) + 'px';
488
+ if(this.options.scaleY) d.height = Math.round(height) + 'px';
469
489
  if(this.options.scaleFromCenter) {
470
490
  var topd = (height - this.dims[0])/2;
471
491
  var leftd = (width - this.dims[1])/2;
@@ -485,6 +505,7 @@ Effect.Highlight = Class.create();
485
505
  Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
486
506
  initialize: function(element) {
487
507
  this.element = $(element);
508
+ if(!this.element) throw(Effect._elementDoesNotExistError);
488
509
  var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
489
510
  this.start(options);
490
511
  },
@@ -549,8 +570,7 @@ Effect.Fade = function(element) {
549
570
  to: 0.0,
550
571
  afterFinishInternal: function(effect) {
551
572
  if(effect.options.to!=0) return;
552
- effect.element.hide();
553
- effect.element.setStyle({opacity: oldOpacity});
573
+ effect.element.hide().setStyle({opacity: oldOpacity});
554
574
  }}, arguments[1] || {});
555
575
  return new Effect.Opacity(element,options);
556
576
  }
@@ -565,25 +585,31 @@ Effect.Appear = function(element) {
565
585
  effect.element.forceRerendering();
566
586
  },
567
587
  beforeSetup: function(effect) {
568
- effect.element.setOpacity(effect.options.from);
569
- effect.element.show();
588
+ effect.element.setOpacity(effect.options.from).show();
570
589
  }}, arguments[1] || {});
571
590
  return new Effect.Opacity(element,options);
572
591
  }
573
592
 
574
593
  Effect.Puff = function(element) {
575
594
  element = $(element);
576
- var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') };
595
+ var oldStyle = {
596
+ opacity: element.getInlineOpacity(),
597
+ position: element.getStyle('position'),
598
+ top: element.style.top,
599
+ left: element.style.left,
600
+ width: element.style.width,
601
+ height: element.style.height
602
+ };
577
603
  return new Effect.Parallel(
578
604
  [ new Effect.Scale(element, 200,
579
605
  { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
580
606
  new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
581
607
  Object.extend({ duration: 1.0,
582
608
  beforeSetupInternal: function(effect) {
583
- effect.effects[0].element.setStyle({position: 'absolute'}); },
609
+ Position.absolutize(effect.effects[0].element)
610
+ },
584
611
  afterFinishInternal: function(effect) {
585
- effect.effects[0].element.hide();
586
- effect.effects[0].element.setStyle(oldStyle); }
612
+ effect.effects[0].element.hide().setStyle(oldStyle); }
587
613
  }, arguments[1] || {})
588
614
  );
589
615
  }
@@ -591,13 +617,12 @@ Effect.Puff = function(element) {
591
617
  Effect.BlindUp = function(element) {
592
618
  element = $(element);
593
619
  element.makeClipping();
594
- return new Effect.Scale(element, 0,
620
+ return new Effect.Scale(element, 0,
595
621
  Object.extend({ scaleContent: false,
596
622
  scaleX: false,
597
623
  restoreAfterFinish: true,
598
624
  afterFinishInternal: function(effect) {
599
- effect.element.hide();
600
- effect.element.undoClipping();
625
+ effect.element.hide().undoClipping();
601
626
  }
602
627
  }, arguments[1] || {})
603
628
  );
@@ -606,28 +631,25 @@ Effect.BlindUp = function(element) {
606
631
  Effect.BlindDown = function(element) {
607
632
  element = $(element);
608
633
  var elementDimensions = element.getDimensions();
609
- return new Effect.Scale(element, 100,
610
- Object.extend({ scaleContent: false,
611
- scaleX: false,
612
- scaleFrom: 0,
613
- scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
614
- restoreAfterFinish: true,
615
- afterSetup: function(effect) {
616
- effect.element.makeClipping();
617
- effect.element.setStyle({height: '0px'});
618
- effect.element.show();
619
- },
620
- afterFinishInternal: function(effect) {
621
- effect.element.undoClipping();
622
- }
623
- }, arguments[1] || {})
624
- );
634
+ return new Effect.Scale(element, 100, Object.extend({
635
+ scaleContent: false,
636
+ scaleX: false,
637
+ scaleFrom: 0,
638
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
639
+ restoreAfterFinish: true,
640
+ afterSetup: function(effect) {
641
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
642
+ },
643
+ afterFinishInternal: function(effect) {
644
+ effect.element.undoClipping();
645
+ }
646
+ }, arguments[1] || {}));
625
647
  }
626
648
 
627
649
  Effect.SwitchOff = function(element) {
628
650
  element = $(element);
629
651
  var oldOpacity = element.getInlineOpacity();
630
- return new Effect.Appear(element, {
652
+ return new Effect.Appear(element, Object.extend({
631
653
  duration: 0.4,
632
654
  from: 0,
633
655
  transition: Effect.Transitions.flicker,
@@ -636,18 +658,14 @@ Effect.SwitchOff = function(element) {
636
658
  duration: 0.3, scaleFromCenter: true,
637
659
  scaleX: false, scaleContent: false, restoreAfterFinish: true,
638
660
  beforeSetup: function(effect) {
639
- effect.element.makePositioned();
640
- effect.element.makeClipping();
661
+ effect.element.makePositioned().makeClipping();
641
662
  },
642
663
  afterFinishInternal: function(effect) {
643
- effect.element.hide();
644
- effect.element.undoClipping();
645
- effect.element.undoPositioned();
646
- effect.element.setStyle({opacity: oldOpacity});
664
+ effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
647
665
  }
648
666
  })
649
667
  }
650
- });
668
+ }, arguments[1] || {}));
651
669
  }
652
670
 
653
671
  Effect.DropOut = function(element) {
@@ -665,9 +683,7 @@ Effect.DropOut = function(element) {
665
683
  effect.effects[0].element.makePositioned();
666
684
  },
667
685
  afterFinishInternal: function(effect) {
668
- effect.effects[0].element.hide();
669
- effect.effects[0].element.undoPositioned();
670
- effect.effects[0].element.setStyle(oldStyle);
686
+ effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
671
687
  }
672
688
  }, arguments[1] || {}));
673
689
  }
@@ -689,54 +705,42 @@ Effect.Shake = function(element) {
689
705
  { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
690
706
  new Effect.Move(effect.element,
691
707
  { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
692
- effect.element.undoPositioned();
693
- effect.element.setStyle(oldStyle);
708
+ effect.element.undoPositioned().setStyle(oldStyle);
694
709
  }}) }}) }}) }}) }}) }});
695
710
  }
696
711
 
697
712
  Effect.SlideDown = function(element) {
698
- element = $(element);
699
- element.cleanWhitespace();
713
+ element = $(element).cleanWhitespace();
700
714
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
701
- var oldInnerBottom = $(element.firstChild).getStyle('bottom');
715
+ var oldInnerBottom = element.down().getStyle('bottom');
702
716
  var elementDimensions = element.getDimensions();
703
717
  return new Effect.Scale(element, 100, Object.extend({
704
718
  scaleContent: false,
705
719
  scaleX: false,
706
- scaleFrom: 0,
720
+ scaleFrom: window.opera ? 0 : 1,
707
721
  scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
708
722
  restoreAfterFinish: true,
709
723
  afterSetup: function(effect) {
710
724
  effect.element.makePositioned();
711
- effect.element.firstChild.makePositioned();
725
+ effect.element.down().makePositioned();
712
726
  if(window.opera) effect.element.setStyle({top: ''});
713
- effect.element.makeClipping();
714
- effect.element.setStyle({height: '0px'});
715
- effect.element.show(); },
727
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
728
+ },
716
729
  afterUpdateInternal: function(effect) {
717
- effect.element.firstChild.setStyle({bottom:
730
+ effect.element.down().setStyle({bottom:
718
731
  (effect.dims[0] - effect.element.clientHeight) + 'px' });
719
732
  },
720
733
  afterFinishInternal: function(effect) {
721
- effect.element.undoClipping();
722
- // IE will crash if child is undoPositioned first
723
- if(/MSIE/.test(navigator.userAgent)){
724
- effect.element.undoPositioned();
725
- effect.element.firstChild.undoPositioned();
726
- }else{
727
- effect.element.firstChild.undoPositioned();
728
- effect.element.undoPositioned();
729
- }
730
- effect.element.firstChild.setStyle({bottom: oldInnerBottom}); }
734
+ effect.element.undoClipping().undoPositioned();
735
+ effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
731
736
  }, arguments[1] || {})
732
737
  );
733
738
  }
734
-
739
+
735
740
  Effect.SlideUp = function(element) {
736
- element = $(element);
737
- element.cleanWhitespace();
738
- var oldInnerBottom = $(element.firstChild).getStyle('bottom');
739
- return new Effect.Scale(element, 0,
741
+ element = $(element).cleanWhitespace();
742
+ var oldInnerBottom = element.down().getStyle('bottom');
743
+ return new Effect.Scale(element, window.opera ? 0 : 1,
740
744
  Object.extend({ scaleContent: false,
741
745
  scaleX: false,
742
746
  scaleMode: 'box',
@@ -744,32 +748,32 @@ Effect.SlideUp = function(element) {
744
748
  restoreAfterFinish: true,
745
749
  beforeStartInternal: function(effect) {
746
750
  effect.element.makePositioned();
747
- effect.element.firstChild.makePositioned();
751
+ effect.element.down().makePositioned();
748
752
  if(window.opera) effect.element.setStyle({top: ''});
749
- effect.element.makeClipping();
750
- effect.element.show(); },
753
+ effect.element.makeClipping().show();
754
+ },
751
755
  afterUpdateInternal: function(effect) {
752
- effect.element.firstChild.setStyle({bottom:
753
- (effect.dims[0] - effect.element.clientHeight) + 'px' }); },
756
+ effect.element.down().setStyle({bottom:
757
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
758
+ },
754
759
  afterFinishInternal: function(effect) {
755
- effect.element.hide();
756
- effect.element.undoClipping();
757
- effect.element.firstChild.undoPositioned();
758
- effect.element.undoPositioned();
759
- effect.element.setStyle({bottom: oldInnerBottom}); }
760
+ effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
761
+ effect.element.down().undoPositioned();
762
+ }
760
763
  }, arguments[1] || {})
761
764
  );
762
765
  }
763
766
 
764
767
  // Bug in opera makes the TD containing this element expand for a instance after finish
765
768
  Effect.Squish = function(element) {
766
- return new Effect.Scale(element, window.opera ? 1 : 0,
767
- { restoreAfterFinish: true,
768
- beforeSetup: function(effect) {
769
- effect.element.makeClipping(effect.element); },
770
- afterFinishInternal: function(effect) {
771
- effect.element.hide(effect.element);
772
- effect.element.undoClipping(effect.element); }
769
+ return new Effect.Scale(element, window.opera ? 1 : 0, {
770
+ restoreAfterFinish: true,
771
+ beforeSetup: function(effect) {
772
+ effect.element.makeClipping();
773
+ },
774
+ afterFinishInternal: function(effect) {
775
+ effect.element.hide().undoClipping();
776
+ }
773
777
  });
774
778
  }
775
779
 
@@ -825,9 +829,7 @@ Effect.Grow = function(element) {
825
829
  y: initialMoveY,
826
830
  duration: 0.01,
827
831
  beforeSetup: function(effect) {
828
- effect.element.hide();
829
- effect.element.makeClipping();
830
- effect.element.makePositioned();
832
+ effect.element.hide().makeClipping().makePositioned();
831
833
  },
832
834
  afterFinishInternal: function(effect) {
833
835
  new Effect.Parallel(
@@ -838,13 +840,10 @@ Effect.Grow = function(element) {
838
840
  sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
839
841
  ], Object.extend({
840
842
  beforeSetup: function(effect) {
841
- effect.effects[0].element.setStyle({height: '0px'});
842
- effect.effects[0].element.show();
843
+ effect.effects[0].element.setStyle({height: '0px'}).show();
843
844
  },
844
845
  afterFinishInternal: function(effect) {
845
- effect.effects[0].element.undoClipping();
846
- effect.effects[0].element.undoPositioned();
847
- effect.effects[0].element.setStyle(oldStyle);
846
+ effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
848
847
  }
849
848
  }, options)
850
849
  )
@@ -898,13 +897,10 @@ Effect.Shrink = function(element) {
898
897
  new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
899
898
  ], Object.extend({
900
899
  beforeStartInternal: function(effect) {
901
- effect.effects[0].element.makePositioned();
902
- effect.effects[0].element.makeClipping(); },
900
+ effect.effects[0].element.makePositioned().makeClipping();
901
+ },
903
902
  afterFinishInternal: function(effect) {
904
- effect.effects[0].element.hide();
905
- effect.effects[0].element.undoClipping();
906
- effect.effects[0].element.undoPositioned();
907
- effect.effects[0].element.setStyle(oldStyle); }
903
+ effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
908
904
  }, options)
909
905
  );
910
906
  }
@@ -914,10 +910,10 @@ Effect.Pulsate = function(element) {
914
910
  var options = arguments[1] || {};
915
911
  var oldOpacity = element.getInlineOpacity();
916
912
  var transition = options.transition || Effect.Transitions.sinoidal;
917
- var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
913
+ var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
918
914
  reverser.bind(transition);
919
915
  return new Effect.Opacity(element,
920
- Object.extend(Object.extend({ duration: 3.0, from: 0,
916
+ Object.extend(Object.extend({ duration: 2.0, from: 0,
921
917
  afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
922
918
  }, options), {transition: reverser}));
923
919
  }
@@ -929,7 +925,7 @@ Effect.Fold = function(element) {
929
925
  left: element.style.left,
930
926
  width: element.style.width,
931
927
  height: element.style.height };
932
- Element.makeClipping(element);
928
+ element.makeClipping();
933
929
  return new Effect.Scale(element, 5, Object.extend({
934
930
  scaleContent: false,
935
931
  scaleX: false,
@@ -938,16 +934,155 @@ Effect.Fold = function(element) {
938
934
  scaleContent: false,
939
935
  scaleY: false,
940
936
  afterFinishInternal: function(effect) {
941
- effect.element.hide();
942
- effect.element.undoClipping();
943
- effect.element.setStyle(oldStyle);
937
+ effect.element.hide().undoClipping().setStyle(oldStyle);
944
938
  } });
945
939
  }}, arguments[1] || {}));
946
- }
940
+ };
941
+
942
+ Effect.Morph = Class.create();
943
+ Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
944
+ initialize: function(element) {
945
+ this.element = $(element);
946
+ if(!this.element) throw(Effect._elementDoesNotExistError);
947
+ var options = Object.extend({
948
+ style: ''
949
+ }, arguments[1] || {});
950
+ this.start(options);
951
+ },
952
+ setup: function(){
953
+ function parseColor(color){
954
+ if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
955
+ color = color.parseColor();
956
+ return $R(0,2).map(function(i){
957
+ return parseInt( color.slice(i*2+1,i*2+3), 16 )
958
+ });
959
+ }
960
+ this.transforms = this.options.style.parseStyle().map(function(property){
961
+ var originalValue = this.element.getStyle(property[0]);
962
+ return $H({
963
+ style: property[0],
964
+ originalValue: property[1].unit=='color' ?
965
+ parseColor(originalValue) : parseFloat(originalValue || 0),
966
+ targetValue: property[1].unit=='color' ?
967
+ parseColor(property[1].value) : property[1].value,
968
+ unit: property[1].unit
969
+ });
970
+ }.bind(this)).reject(function(transform){
971
+ return (
972
+ (transform.originalValue == transform.targetValue) ||
973
+ (
974
+ transform.unit != 'color' &&
975
+ (isNaN(transform.originalValue) || isNaN(transform.targetValue))
976
+ )
977
+ )
978
+ });
979
+ },
980
+ update: function(position) {
981
+ var style = $H(), value = null;
982
+ this.transforms.each(function(transform){
983
+ value = transform.unit=='color' ?
984
+ $R(0,2).inject('#',function(m,v,i){
985
+ return m+(Math.round(transform.originalValue[i]+
986
+ (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :
987
+ transform.originalValue + Math.round(
988
+ ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
989
+ style[transform.style] = value;
990
+ });
991
+ this.element.setStyle(style);
992
+ }
993
+ });
994
+
995
+ Effect.Transform = Class.create();
996
+ Object.extend(Effect.Transform.prototype, {
997
+ initialize: function(tracks){
998
+ this.tracks = [];
999
+ this.options = arguments[1] || {};
1000
+ this.addTracks(tracks);
1001
+ },
1002
+ addTracks: function(tracks){
1003
+ tracks.each(function(track){
1004
+ var data = $H(track).values().first();
1005
+ this.tracks.push($H({
1006
+ ids: $H(track).keys().first(),
1007
+ effect: Effect.Morph,
1008
+ options: { style: data }
1009
+ }));
1010
+ }.bind(this));
1011
+ return this;
1012
+ },
1013
+ play: function(){
1014
+ return new Effect.Parallel(
1015
+ this.tracks.map(function(track){
1016
+ var elements = [$(track.ids) || $$(track.ids)].flatten();
1017
+ return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) });
1018
+ }).flatten(),
1019
+ this.options
1020
+ );
1021
+ }
1022
+ });
1023
+
1024
+ Element.CSS_PROPERTIES = ['azimuth', 'backgroundAttachment', 'backgroundColor', 'backgroundImage',
1025
+ 'backgroundPosition', 'backgroundRepeat', 'borderBottomColor', 'borderBottomStyle',
1026
+ 'borderBottomWidth', 'borderCollapse', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth',
1027
+ 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderSpacing', 'borderTopColor',
1028
+ 'borderTopStyle', 'borderTopWidth', 'bottom', 'captionSide', 'clear', 'clip', 'color', 'content',
1029
+ 'counterIncrement', 'counterReset', 'cssFloat', 'cueAfter', 'cueBefore', 'cursor', 'direction',
1030
+ 'display', 'elevation', 'emptyCells', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch',
1031
+ 'fontStyle', 'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight',
1032
+ 'listStyleImage', 'listStylePosition', 'listStyleType', 'marginBottom', 'marginLeft', 'marginRight',
1033
+ 'marginTop', 'markerOffset', 'marks', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'opacity',
1034
+ 'orphans', 'outlineColor', 'outlineOffset', 'outlineStyle', 'outlineWidth', 'overflowX', 'overflowY',
1035
+ 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'page', 'pageBreakAfter', 'pageBreakBefore',
1036
+ 'pageBreakInside', 'pauseAfter', 'pauseBefore', 'pitch', 'pitchRange', 'position', 'quotes',
1037
+ 'richness', 'right', 'size', 'speakHeader', 'speakNumeral', 'speakPunctuation', 'speechRate', 'stress',
1038
+ 'tableLayout', 'textAlign', 'textDecoration', 'textIndent', 'textShadow', 'textTransform', 'top',
1039
+ 'unicodeBidi', 'verticalAlign', 'visibility', 'voiceFamily', 'volume', 'whiteSpace', 'widows',
1040
+ 'width', 'wordSpacing', 'zIndex'];
1041
+
1042
+ Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
1043
+
1044
+ String.prototype.parseStyle = function(){
1045
+ var element = Element.extend(document.createElement('div'));
1046
+ element.innerHTML = '<div style="' + this + '"></div>';
1047
+ var style = element.down().style, styleRules = $H();
1048
+
1049
+ Element.CSS_PROPERTIES.each(function(property){
1050
+ if(style[property]) styleRules[property] = style[property];
1051
+ });
1052
+
1053
+ var result = $H();
1054
+
1055
+ styleRules.each(function(pair){
1056
+ var property = pair[0], value = pair[1], unit = null;
1057
+
1058
+ if(value.parseColor('#zzzzzz') != '#zzzzzz') {
1059
+ value = value.parseColor();
1060
+ unit = 'color';
1061
+ } else if(Element.CSS_LENGTH.test(value))
1062
+ var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
1063
+ value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null;
1064
+
1065
+ result[property.underscore().dasherize()] = $H({ value:value, unit:unit });
1066
+ }.bind(this));
1067
+
1068
+ return result;
1069
+ };
1070
+
1071
+ Element.morph = function(element, style) {
1072
+ new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
1073
+ return element;
1074
+ };
1075
+
1076
+ ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
1077
+ 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
1078
+ function(f) { Element.Methods[f] = Element[f]; }
1079
+ );
947
1080
 
948
1081
  Element.Methods.visualEffect = function(element, effect, options) {
949
1082
  s = effect.gsub(/_/, '-').camelize();
950
1083
  effect_class = s.charAt(0).toUpperCase() + s.substring(1);
951
1084
  new Effect[effect_class](element, options);
952
1085
  return $(element);
953
- };
1086
+ };
1087
+
1088
+ Element.addMethods();