parlement 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/CHANGES +14 -4
  2. data/README +25 -5
  3. data/Rakefile +21 -21
  4. data/app/controllers/account_controller.rb +5 -1
  5. data/app/controllers/elt_controller.rb +7 -10
  6. data/app/controllers/person_controller.rb +9 -0
  7. data/app/controllers/subscriber_controller.rb +21 -0
  8. data/app/helpers/elt_helper.rb +25 -13
  9. data/app/helpers/mailman.rb +9 -92
  10. data/app/helpers/subscriber_helper.rb +2 -0
  11. data/app/models/attachment.rb +2 -0
  12. data/app/models/elt.rb +64 -2
  13. data/app/models/mail.rb +198 -0
  14. data/app/models/mail_notify.rb +63 -0
  15. data/app/models/person.rb +8 -1
  16. data/app/views/account/_login.rhtml +31 -28
  17. data/app/views/account/_show.rhtml +4 -4
  18. data/app/views/elt/_elt.rhtml +23 -28
  19. data/app/views/elt/_list.rhtml +6 -2
  20. data/app/views/elt/new.rhtml +1 -1
  21. data/app/views/elt/show.rhtml +32 -10
  22. data/app/views/layouts/top.rhtml +16 -10
  23. data/app/views/mail_notify/publish.text.html.rhtml +46 -0
  24. data/app/views/mail_notify/publish.text.plain.rhtml +2 -0
  25. data/app/views/person/_listElts.rhtml +33 -0
  26. data/app/views/person/show.rhtml +21 -19
  27. data/config/boot.rb +2 -0
  28. data/config/environment.rb +19 -13
  29. data/config/environments/development.rb +3 -1
  30. data/config/environments/production.rb +2 -0
  31. data/config/environments/test.rb +2 -0
  32. data/config/routes.rb +5 -2
  33. data/db/ROOT/mail.txt +2 -0
  34. data/db/ROOT/parlement/news/release0.2.txt +8 -0
  35. data/db/ROOT/parlement/news/release0.3.txt +11 -0
  36. data/db/ROOT/parlement/test.txt +6 -1
  37. data/db/ROOT/parlement.txt +23 -30
  38. data/db/ROOT/perso.txt +17 -18
  39. data/db/development_structure.sql +133 -217
  40. data/db/schema.rb +83 -0
  41. data/db/schema.sql +11 -15
  42. data/lib/data_import.rb +3 -1
  43. data/public/attachment/file/architecture.png +0 -0
  44. data/public/attachment/file/architecture.svg +8972 -0
  45. data/public/attachment/file/security.svg +8960 -0
  46. data/public/images/Sleep-Deprivation-5.JPG +0 -0
  47. data/public/images/eltBackground.png +0 -0
  48. data/public/images/eltBackground.svg +89 -0
  49. data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
  50. data/public/images/rails.png +0 -0
  51. data/public/images/smile.png +0 -0
  52. data/public/images/smile.svg +257 -0
  53. data/public/images/world.png +0 -0
  54. data/public/images/world.svg +170 -0
  55. data/public/javascripts/controls.js +30 -1
  56. data/public/javascripts/dragdrop.js +210 -145
  57. data/public/javascripts/effects.js +261 -399
  58. data/public/javascripts/ie7.js +6 -0
  59. data/public/javascripts/prototype.js +131 -72
  60. data/public/oldindex.html +270 -71
  61. data/public/stylesheets/default.css +189 -215
  62. data/script/about +1 -1
  63. data/script/breakpointer +1 -1
  64. data/script/console +1 -1
  65. data/script/destroy +1 -1
  66. data/script/generate +1 -1
  67. data/script/performance/benchmarker +1 -1
  68. data/script/performance/profiler +1 -1
  69. data/script/plugin +1 -1
  70. data/script/process/reaper +1 -1
  71. data/script/process/spawner +1 -1
  72. data/script/process/spinner +1 -1
  73. data/script/runner +1 -1
  74. data/script/server +1 -1
  75. data/test/fixtures/elts.yml +2 -0
  76. data/test/fixtures/mail/mail_ruby +27 -0
  77. data/test/fixtures/mail/mail_rubyChild +28 -0
  78. data/test/fixtures/mail/mail_rubyWithAttachment +7932 -0
  79. data/test/fixtures/mail/mail_rubyWithSubject +27 -0
  80. data/test/fixtures/mails.yml +7 -1
  81. data/test/fixtures/people.yml +5 -0
  82. data/test/fixtures/subscribers.yml +11 -0
  83. data/test/functional/account_controller_test.rb +38 -37
  84. data/test/functional/subscriber_controller_test.rb +128 -0
  85. data/test/test_helper.rb +44 -0
  86. data/test/unit/attachment_test.rb +1 -1
  87. data/test/unit/elt_test.rb +3 -2
  88. data/test/unit/mail_notify_test.rb +37 -0
  89. data/test/unit/mail_test.rb +124 -1
  90. data/test/unit/notifier_test.rb +0 -14
  91. data/test/unit/person_test.rb +2 -1
  92. data/test/unit/subscriber_test.rb +35 -0
  93. data/test/unit/user_test.rb +3 -3
  94. data/vendor/plugins/file_column/CHANGELOG +64 -0
  95. data/vendor/plugins/file_column/README +54 -0
  96. data/vendor/plugins/file_column/Rakefile +36 -0
  97. data/vendor/plugins/file_column/TODO +6 -0
  98. data/vendor/plugins/file_column/init.rb +12 -0
  99. data/vendor/plugins/file_column/lib/file_column.rb +719 -0
  100. data/vendor/plugins/file_column/lib/file_column_helper.rb +145 -0
  101. data/vendor/plugins/file_column/lib/file_compat.rb +28 -0
  102. data/vendor/plugins/file_column/lib/magick_file_column.rb +188 -0
  103. data/vendor/plugins/file_column/lib/validations.rb +112 -0
  104. data/vendor/plugins/file_column/test/abstract_unit.rb +90 -0
  105. data/vendor/plugins/file_column/test/connection.rb +17 -0
  106. data/vendor/plugins/file_column/test/file_column_helper_test.rb +97 -0
  107. data/vendor/plugins/file_column/test/file_column_test.rb +630 -0
  108. data/vendor/plugins/file_column/test/fixtures/entry.rb +32 -0
  109. data/vendor/plugins/file_column/test/fixtures/invalid-image.jpg +1 -0
  110. data/vendor/plugins/file_column/test/fixtures/kerb.jpg +0 -0
  111. data/vendor/plugins/file_column/test/fixtures/mysql.sql +25 -0
  112. data/vendor/plugins/file_column/test/fixtures/schema.rb +10 -0
  113. data/vendor/plugins/file_column/test/fixtures/skanthak.png +0 -0
  114. data/vendor/plugins/file_column/test/magick_test.rb +251 -0
  115. data/vendor/plugins/file_column/test/magick_view_only_test.rb +21 -0
  116. data/vendor/plugins/guid/README.TXT +19 -0
  117. data/vendor/plugins/guid/init.rb +23 -0
  118. data/vendor/plugins/guid/lib/usesguid.rb +37 -0
  119. data/vendor/plugins/guid/lib/uuid22.rb +43 -0
  120. data/vendor/plugins/guid/lib/uuidtools.rb +565 -0
  121. metadata +83 -15
  122. data/db/ROOT/CV.txt +0 -166
  123. data/lib/file_column.rb +0 -263
  124. data/lib/file_column_helper.rb +0 -45
  125. /data/{lib → vendor/plugins/file_column/lib}/rails_file_column.rb +0 -0
@@ -11,8 +11,8 @@
11
11
  // converts rgb() and #xxx to #xxxxxx format,
12
12
  // returns self (or first argument) if not convertable
13
13
  String.prototype.parseColor = function() {
14
- color = "#";
15
- if(this.slice(0,4) == "rgb(") {
14
+ var color = '#';
15
+ if(this.slice(0,4) == 'rgb(') {
16
16
  var cols = this.slice(4,this.length-1).split(',');
17
17
  var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
18
18
  } else {
@@ -26,8 +26,8 @@ String.prototype.parseColor = function() {
26
26
 
27
27
  Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
28
28
  var children = $(element).childNodes;
29
- var text = "";
30
- var classtest = new RegExp("^([^ ]+ )*" + ignoreclass+ "( [^ ]+)*$","i");
29
+ var text = '';
30
+ var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i');
31
31
 
32
32
  for (var i = 0; i < children.length; i++) {
33
33
  if(children[i].nodeType==3) {
@@ -41,157 +41,70 @@ Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
41
41
  return text;
42
42
  }
43
43
 
44
+ Element.setStyle = function(element, style) {
45
+ element = $(element);
46
+ for(k in style) element.style[k.camelize()] = style[k];
47
+ }
48
+
44
49
  Element.setContentZoom = function(element, percent) {
45
- element = $(element);
46
- element.style.fontSize = (percent/100) + "em";
50
+ Element.setStyle(element, {fontSize: (percent/100) + 'em'});
47
51
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
48
52
  }
49
53
 
50
54
  Element.getOpacity = function(element){
51
- var opacity;
52
- if (opacity = Element.getStyle(element, "opacity"))
55
+ var opacity;
56
+ if (opacity = Element.getStyle(element, 'opacity'))
53
57
  return parseFloat(opacity);
54
- if (opacity = (Element.getStyle(element, "filter") || '').match(/alpha\(opacity=(.*)\)/))
58
+ if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))
55
59
  if(opacity[1]) return parseFloat(opacity[1]) / 100;
56
60
  return 1.0;
57
61
  }
58
62
 
59
63
  Element.setOpacity = function(element, value){
60
64
  element= $(element);
61
- var els = element.style;
62
- if (value == 1){
63
- els.opacity = '0.999999';
65
+ if (value == 1){
66
+ Element.setStyle(element, { opacity:
67
+ (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
68
+ 0.999999 : null });
64
69
  if(/MSIE/.test(navigator.userAgent))
65
- els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'');
70
+ Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
66
71
  } else {
67
72
  if(value < 0.00001) value = 0;
68
- els.opacity = value;
73
+ Element.setStyle(element, {opacity: value});
69
74
  if(/MSIE/.test(navigator.userAgent))
70
- els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
71
- "alpha(opacity="+value*100+")";
75
+ Element.setStyle(element,
76
+ { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
77
+ 'alpha(opacity='+value*100+')' });
72
78
  }
73
79
  }
74
80
 
75
81
  Element.getInlineOpacity = function(element){
76
- element= $(element);
77
- var op;
78
- op = element.style.opacity;
79
- if (typeof op != "undefined" && op != "") return op;
80
- return "";
82
+ return $(element).style.opacity || '';
81
83
  }
82
-
83
- Element.setInlineOpacity = function(element, value){
84
- element= $(element);
85
- var els = element.style;
86
- els.opacity = value;
87
- }
88
-
89
- /*--------------------------------------------------------------------------*/
90
-
91
- Element.Class = {
92
- // Element.toggleClass(element, className) toggles the class being on/off
93
- // Element.toggleClass(element, className1, className2) toggles between both classes,
94
- // defaulting to className1 if neither exist
95
- toggle: function(element, className) {
96
- if(Element.Class.has(element, className)) {
97
- Element.Class.remove(element, className);
98
- if(arguments.length == 3) Element.Class.add(element, arguments[2]);
99
- } else {
100
- Element.Class.add(element, className);
101
- if(arguments.length == 3) Element.Class.remove(element, arguments[2]);
102
- }
103
- },
104
-
105
- // gets space-delimited classnames of an element as an array
106
- get: function(element) {
107
- return $(element).className.split(' ');
108
- },
109
-
110
- // functions adapted from original functions by Gavin Kistner
111
- remove: function(element) {
112
- element = $(element);
113
- var removeClasses = arguments;
114
- $R(1,arguments.length-1).each( function(index) {
115
- element.className =
116
- element.className.split(' ').reject(
117
- function(klass) { return (klass == removeClasses[index]) } ).join(' ');
118
- });
119
- },
120
-
121
- add: function(element) {
122
- element = $(element);
123
- for(var i = 1; i < arguments.length; i++) {
124
- Element.Class.remove(element, arguments[i]);
125
- element.className += (element.className.length > 0 ? ' ' : '') + arguments[i];
126
- }
127
- },
128
-
129
- // returns true if all given classes exist in said element
130
- has: function(element) {
131
- element = $(element);
132
- if(!element || !element.className) return false;
133
- var regEx;
134
- for(var i = 1; i < arguments.length; i++) {
135
- if((typeof arguments[i] == 'object') &&
136
- (arguments[i].constructor == Array)) {
137
- for(var j = 0; j < arguments[i].length; j++) {
138
- regEx = new RegExp("(^|\\s)" + arguments[i][j] + "(\\s|$)");
139
- if(!regEx.test(element.className)) return false;
140
- }
141
- } else {
142
- regEx = new RegExp("(^|\\s)" + arguments[i] + "(\\s|$)");
143
- if(!regEx.test(element.className)) return false;
144
- }
145
- }
146
- return true;
147
- },
148
-
149
- // expects arrays of strings and/or strings as optional paramters
150
- // Element.Class.has_any(element, ['classA','classB','classC'], 'classD')
151
- has_any: function(element) {
152
- element = $(element);
153
- if(!element || !element.className) return false;
154
- var regEx;
155
- for(var i = 1; i < arguments.length; i++) {
156
- if((typeof arguments[i] == 'object') &&
157
- (arguments[i].constructor == Array)) {
158
- for(var j = 0; j < arguments[i].length; j++) {
159
- regEx = new RegExp("(^|\\s)" + arguments[i][j] + "(\\s|$)");
160
- if(regEx.test(element.className)) return true;
161
- }
162
- } else {
163
- regEx = new RegExp("(^|\\s)" + arguments[i] + "(\\s|$)");
164
- if(regEx.test(element.className)) return true;
165
- }
166
- }
167
- return false;
168
- },
169
-
170
- childrenWith: function(element, className) {
171
- var children = $(element).getElementsByTagName('*');
172
- var elements = new Array();
173
-
174
- for (var i = 0; i < children.length; i++)
175
- if (Element.Class.has(children[i], className))
176
- elements.push(children[i]);
177
-
178
- return elements;
179
- }
180
- }
181
-
84
+
85
+ Element.childrenWithClassName = function(element, className) {
86
+ return $A($(element).getElementsByTagName('*')).select(
87
+ function(c) { return Element.hasClassName(c, className) });
88
+ }
89
+
90
+ Array.prototype.call = function() {
91
+ var args = arguments;
92
+ this.each(function(f){ f.apply(this, args) });
93
+ }
94
+
182
95
  /*--------------------------------------------------------------------------*/
183
96
 
184
97
  var Effect = {
185
98
  tagifyText: function(element) {
186
- var tagifyStyle = "position:relative";
187
- if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ";zoom:1";
99
+ var tagifyStyle = 'position:relative';
100
+ if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
188
101
  element = $(element);
189
102
  $A(element.childNodes).each( function(child) {
190
103
  if(child.nodeType==3) {
191
104
  child.nodeValue.toArray().each( function(character) {
192
105
  element.insertBefore(
193
106
  Builder.node('span',{style: tagifyStyle},
194
- character == " " ? String.fromCharCode(160) : character),
107
+ character == ' ' ? String.fromCharCode(160) : character),
195
108
  child);
196
109
  });
197
110
  Element.remove(child);
@@ -211,11 +124,10 @@ var Effect = {
211
124
  speed: 0.1,
212
125
  delay: 0.0
213
126
  }, arguments[2] || {});
214
- var speed = options.speed;
215
- var delay = options.delay;
127
+ var masterDelay = options.delay;
216
128
 
217
129
  $A(elements).each( function(element, index) {
218
- new effect(element, Object.extend(options, { delay: delay + index * speed }));
130
+ new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
219
131
  });
220
132
  }
221
133
  };
@@ -346,13 +258,15 @@ Effect.Base.prototype = {
346
258
  if(this.setup) this.setup();
347
259
  this.event('afterSetup');
348
260
  }
349
- if(this.options.transition) pos = this.options.transition(pos);
350
- pos *= (this.options.to-this.options.from);
351
- pos += this.options.from;
352
- this.position = pos;
353
- this.event('beforeUpdate');
354
- if(this.update) this.update(pos);
355
- this.event('afterUpdate');
261
+ if(this.state == 'running') {
262
+ if(this.options.transition) pos = this.options.transition(pos);
263
+ pos *= (this.options.to-this.options.from);
264
+ pos += this.options.from;
265
+ this.position = pos;
266
+ this.event('beforeUpdate');
267
+ if(this.update) this.update(pos);
268
+ this.event('afterUpdate');
269
+ }
356
270
  },
357
271
  cancel: function() {
358
272
  if(!this.options.sync) Effect.Queue.remove(this);
@@ -361,6 +275,9 @@ Effect.Base.prototype = {
361
275
  event: function(eventName) {
362
276
  if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
363
277
  if(this.options[eventName]) this.options[eventName](this);
278
+ },
279
+ inspect: function() {
280
+ return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
364
281
  }
365
282
  }
366
283
 
@@ -390,7 +307,7 @@ Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
390
307
  this.element = $(element);
391
308
  // make this work on IE on elements without 'layout'
392
309
  if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
393
- this.element.style.zoom = 1;
310
+ Element.setStyle(this.element, {zoom: 1});
394
311
  var options = Object.extend({
395
312
  from: Element.getOpacity(this.element) || 0.0,
396
313
  to: 1.0
@@ -414,20 +331,16 @@ Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
414
331
  // Bug in Opera: Opera returns the "real" position of a static element or
415
332
  // relative element that does not have top/left explicitly set.
416
333
  // ==> Always set top and left for position relative elements in your stylesheets
417
- // (to 0 if you do not need them)
418
-
334
+ // (to 0 if you do not need them)
419
335
  Element.makePositioned(this.element);
420
336
  this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
421
337
  this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
422
338
  },
423
339
  update: function(position) {
424
- var topd = this.toTop * position + this.originalTop;
425
- var leftd = this.toLeft * position + this.originalLeft;
426
- this.setPosition(topd, leftd);
427
- },
428
- setPosition: function(topd, leftd) {
429
- this.element.style.top = topd + "px";
430
- this.element.style.left = leftd + "px";
340
+ Element.setStyle(this.element, {
341
+ top: this.toTop * position + this.originalTop + 'px',
342
+ left: this.toLeft * position + this.originalLeft + 'px'
343
+ });
431
344
  }
432
345
  });
433
346
 
@@ -447,33 +360,31 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
447
360
  this.start(options);
448
361
  },
449
362
  setup: function() {
450
- var effect = this;
451
-
452
363
  this.restoreAfterFinish = this.options.restoreAfterFinish || false;
453
364
  this.elementPositioning = Element.getStyle(this.element,'position');
454
365
 
455
- effect.originalStyle = {};
366
+ this.originalStyle = {};
456
367
  ['top','left','width','height','fontSize'].each( function(k) {
457
- effect.originalStyle[k] = effect.element.style[k];
458
- });
368
+ this.originalStyle[k] = this.element.style[k];
369
+ }.bind(this));
459
370
 
460
371
  this.originalTop = this.element.offsetTop;
461
372
  this.originalLeft = this.element.offsetLeft;
462
373
 
463
- var fontSize = Element.getStyle(this.element,'font-size') || "100%";
374
+ var fontSize = Element.getStyle(this.element,'font-size') || '100%';
464
375
  ['em','px','%'].each( function(fontSizeType) {
465
376
  if(fontSize.indexOf(fontSizeType)>0) {
466
- effect.fontSize = parseFloat(fontSize);
467
- effect.fontSizeType = fontSizeType;
377
+ this.fontSize = parseFloat(fontSize);
378
+ this.fontSizeType = fontSizeType;
468
379
  }
469
- });
380
+ }.bind(this));
470
381
 
471
382
  this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
472
383
 
473
384
  this.dims = null;
474
385
  if(this.options.scaleMode=='box')
475
- this.dims = [this.element.clientHeight, this.element.clientWidth];
476
- if(this.options.scaleMode=='content')
386
+ this.dims = [this.element.offsetHeight, this.element.offsetWidth];
387
+ if(/^content/.test(this.options.scaleMode))
477
388
  this.dims = [this.element.scrollHeight, this.element.scrollWidth];
478
389
  if(!this.dims)
479
390
  this.dims = [this.options.scaleMode.originalHeight,
@@ -482,32 +393,28 @@ Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
482
393
  update: function(position) {
483
394
  var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
484
395
  if(this.options.scaleContent && this.fontSize)
485
- this.element.style.fontSize = this.fontSize*currentScale + this.fontSizeType;
396
+ Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
486
397
  this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
487
398
  },
488
399
  finish: function(position) {
489
- if (this.restoreAfterFinish) {
490
- var effect = this;
491
- ['top','left','width','height','fontSize'].each( function(k) {
492
- effect.element.style[k] = effect.originalStyle[k];
493
- });
494
- }
400
+ if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
495
401
  },
496
402
  setDimensions: function(height, width) {
497
- var els = this.element.style;
498
- if(this.options.scaleX) els.width = width + 'px';
499
- if(this.options.scaleY) els.height = height + 'px';
403
+ var d = {};
404
+ if(this.options.scaleX) d.width = width + 'px';
405
+ if(this.options.scaleY) d.height = height + 'px';
500
406
  if(this.options.scaleFromCenter) {
501
407
  var topd = (height - this.dims[0])/2;
502
408
  var leftd = (width - this.dims[1])/2;
503
409
  if(this.elementPositioning == 'absolute') {
504
- if(this.options.scaleY) els.top = this.originalTop-topd + "px";
505
- if(this.options.scaleX) els.left = this.originalLeft-leftd + "px";
410
+ if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
411
+ if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
506
412
  } else {
507
- if(this.options.scaleY) els.top = -topd + "px";
508
- if(this.options.scaleX) els.left = -leftd + "px";
413
+ if(this.options.scaleY) d.top = -topd + 'px';
414
+ if(this.options.scaleX) d.left = -leftd + 'px';
509
415
  }
510
416
  }
417
+ Element.setStyle(this.element, d);
511
418
  }
512
419
  });
513
420
 
@@ -515,41 +422,32 @@ Effect.Highlight = Class.create();
515
422
  Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
516
423
  initialize: function(element) {
517
424
  this.element = $(element);
518
- var options = Object.extend({
519
- startcolor: "#ffff99"
520
- }, arguments[1] || {});
425
+ var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
521
426
  this.start(options);
522
427
  },
523
428
  setup: function() {
524
429
  // Prevent executing on elements not in the layout flow
525
- if(this.element.style.display=='none') { this.cancel(); return; }
430
+ if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
526
431
  // Disable background image during the effect
527
- this.oldBgImage = this.element.style.backgroundImage;
528
- this.element.style.backgroundImage = "none";
432
+ this.oldStyle = {
433
+ backgroundImage: Element.getStyle(this.element, 'background-image') };
434
+ Element.setStyle(this.element, {backgroundImage: 'none'});
529
435
  if(!this.options.endcolor)
530
436
  this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
531
- if (typeof this.options.restorecolor == "undefined")
532
- this.options.restorecolor = this.element.style.backgroundColor;
437
+ if(!this.options.restorecolor)
438
+ this.options.restorecolor = Element.getStyle(this.element, 'background-color');
533
439
  // init color calculations
534
- this.colors_base = [
535
- parseInt(this.options.startcolor.slice(1,3),16),
536
- parseInt(this.options.startcolor.slice(3,5),16),
537
- parseInt(this.options.startcolor.slice(5),16) ];
538
- this.colors_delta = [
539
- parseInt(this.options.endcolor.slice(1,3),16)-this.colors_base[0],
540
- parseInt(this.options.endcolor.slice(3,5),16)-this.colors_base[1],
541
- parseInt(this.options.endcolor.slice(5),16)-this.colors_base[2]];
440
+ this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
441
+ 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));
542
442
  },
543
443
  update: function(position) {
544
- var effect = this; var colors = $R(0,2).map( function(i){
545
- return Math.round(effect.colors_base[i]+(effect.colors_delta[i]*position))
546
- });
547
- this.element.style.backgroundColor = "#" +
548
- colors[0].toColorPart() + colors[1].toColorPart() + colors[2].toColorPart();
444
+ Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
445
+ return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
549
446
  },
550
447
  finish: function() {
551
- this.element.style.backgroundColor = this.options.restorecolor;
552
- this.element.style.backgroundImage = this.oldBgImage;
448
+ Element.setStyle(this.element, Object.extend(this.oldStyle, {
449
+ backgroundColor: this.options.restorecolor
450
+ }));
553
451
  }
554
452
  });
555
453
 
@@ -562,6 +460,7 @@ Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
562
460
  setup: function() {
563
461
  Position.prepare();
564
462
  var offsets = Position.cumulativeOffset(this.element);
463
+ if(this.options.offset) offsets[1] += this.options.offset;
565
464
  var max = window.innerHeight ?
566
465
  window.height - window.innerHeight :
567
466
  document.body.scrollHeight -
@@ -584,42 +483,38 @@ Effect.Fade = function(element) {
584
483
  var options = Object.extend({
585
484
  from: Element.getOpacity(element) || 1.0,
586
485
  to: 0.0,
587
- afterFinishInternal: function(effect)
588
- { if (effect.options.to == 0) {
589
- Element.hide(effect.element);
590
- Element.setInlineOpacity(effect.element, oldOpacity);
591
- }
592
- }
486
+ afterFinishInternal: function(effect) { with(Element) {
487
+ if(effect.options.to!=0) return;
488
+ hide(effect.element);
489
+ setStyle(effect.element, {opacity: oldOpacity}); }}
593
490
  }, arguments[1] || {});
594
491
  return new Effect.Opacity(element,options);
595
492
  }
596
493
 
597
494
  Effect.Appear = function(element) {
598
495
  var options = Object.extend({
599
- from: (Element.getStyle(element, "display") == "none" ? 0.0 : Element.getOpacity(element) || 0.0),
496
+ from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
600
497
  to: 1.0,
601
- beforeSetup: function(effect)
602
- { Element.setOpacity(effect.element, effect.options.from);
603
- Element.show(effect.element); }
498
+ beforeSetup: function(effect) { with(Element) {
499
+ setOpacity(effect.element, effect.options.from);
500
+ show(effect.element); }}
604
501
  }, arguments[1] || {});
605
502
  return new Effect.Opacity(element,options);
606
503
  }
607
504
 
608
505
  Effect.Puff = function(element) {
609
506
  element = $(element);
610
- var oldOpacity = Element.getInlineOpacity(element);
611
- var oldPosition = element.style.position;
507
+ var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
612
508
  return new Effect.Parallel(
613
509
  [ new Effect.Scale(element, 200,
614
510
  { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
615
511
  new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
616
512
  Object.extend({ duration: 1.0,
617
- beforeSetupInternal: function(effect)
618
- { effect.effects[0].element.style.position = 'absolute'; },
619
- afterFinishInternal: function(effect)
620
- { Element.hide(effect.effects[0].element);
621
- effect.effects[0].element.style.position = oldPosition;
622
- Element.setInlineOpacity(effect.effects[0].element, oldOpacity); }
513
+ beforeSetupInternal: function(effect) { with(Element) {
514
+ setStyle(effect.effects[0].element, {position: 'absolute'}); }},
515
+ afterFinishInternal: function(effect) { with(Element) {
516
+ hide(effect.effects[0].element);
517
+ setStyle(effect.effects[0].element, oldStyle); }}
623
518
  }, arguments[1] || {})
624
519
  );
625
520
  }
@@ -631,18 +526,15 @@ Effect.BlindUp = function(element) {
631
526
  Object.extend({ scaleContent: false,
632
527
  scaleX: false,
633
528
  restoreAfterFinish: true,
634
- afterFinishInternal: function(effect)
635
- {
636
- Element.hide(effect.element);
637
- Element.undoClipping(effect.element);
638
- }
529
+ afterFinishInternal: function(effect) { with(Element) {
530
+ [hide, undoClipping].call(effect.element); }}
639
531
  }, arguments[1] || {})
640
532
  );
641
533
  }
642
534
 
643
535
  Effect.BlindDown = function(element) {
644
536
  element = $(element);
645
- var oldHeight = element.style.height;
537
+ var oldHeight = Element.getStyle(element, 'height');
646
538
  var elementDimensions = Element.getDimensions(element);
647
539
  return new Effect.Scale(element, 100,
648
540
  Object.extend({ scaleContent: false,
@@ -650,15 +542,15 @@ Effect.BlindDown = function(element) {
650
542
  scaleFrom: 0,
651
543
  scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
652
544
  restoreAfterFinish: true,
653
- afterSetup: function(effect) {
654
- Element.makeClipping(effect.element);
655
- effect.element.style.height = "0px";
656
- Element.show(effect.element);
657
- },
658
- afterFinishInternal: function(effect) {
659
- Element.undoClipping(effect.element);
660
- effect.element.style.height = oldHeight;
661
- }
545
+ afterSetup: function(effect) { with(Element) {
546
+ makeClipping(effect.element);
547
+ setStyle(effect.element, {height: '0px'});
548
+ show(effect.element);
549
+ }},
550
+ afterFinishInternal: function(effect) { with(Element) {
551
+ undoClipping(effect.element);
552
+ setStyle(effect.element, {height: oldHeight});
553
+ }}
662
554
  }, arguments[1] || {})
663
555
  );
664
556
  }
@@ -674,16 +566,13 @@ Effect.SwitchOff = function(element) {
674
566
  new Effect.Scale(effect.element, 1, {
675
567
  duration: 0.3, scaleFromCenter: true,
676
568
  scaleX: false, scaleContent: false, restoreAfterFinish: true,
677
- beforeSetup: function(effect) {
678
- Element.makePositioned(effect.element);
679
- Element.makeClipping(effect.element);
680
- },
681
- afterFinishInternal: function(effect) {
682
- Element.hide(effect.element);
683
- Element.undoClipping(effect.element);
684
- Element.undoPositioned(effect.element);
685
- Element.setInlineOpacity(effect.element, oldOpacity);
686
- }
569
+ beforeSetup: function(effect) { with(Element) {
570
+ [makePositioned,makeClipping].call(effect.element);
571
+ }},
572
+ afterFinishInternal: function(effect) { with(Element) {
573
+ [hide,undoClipping,undoPositioned].call(effect.element);
574
+ setStyle(effect.element, {opacity: oldOpacity});
575
+ }}
687
576
  })
688
577
  }
689
578
  });
@@ -691,29 +580,28 @@ Effect.SwitchOff = function(element) {
691
580
 
692
581
  Effect.DropOut = function(element) {
693
582
  element = $(element);
694
- var oldTop = element.style.top;
695
- var oldLeft = element.style.left;
696
- var oldOpacity = Element.getInlineOpacity(element);
583
+ var oldStyle = {
584
+ top: Element.getStyle(element, 'top'),
585
+ left: Element.getStyle(element, 'left'),
586
+ opacity: Element.getInlineOpacity(element) };
697
587
  return new Effect.Parallel(
698
588
  [ new Effect.MoveBy(element, 100, 0, { sync: true }),
699
589
  new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
700
590
  Object.extend(
701
591
  { duration: 0.5,
702
- beforeSetup: function(effect) {
703
- Element.makePositioned(effect.effects[0].element); },
704
- afterFinishInternal: function(effect) {
705
- Element.hide(effect.effects[0].element);
706
- Element.undoPositioned(effect.effects[0].element);
707
- effect.effects[0].element.style.left = oldLeft;
708
- effect.effects[0].element.style.top = oldTop;
709
- Element.setInlineOpacity(effect.effects[0].element, oldOpacity); }
592
+ beforeSetup: function(effect) { with(Element) {
593
+ makePositioned(effect.effects[0].element); }},
594
+ afterFinishInternal: function(effect) { with(Element) {
595
+ [hide, undoPositioned].call(effect.effects[0].element);
596
+ setStyle(effect.effects[0].element, oldStyle); }}
710
597
  }, arguments[1] || {}));
711
598
  }
712
599
 
713
600
  Effect.Shake = function(element) {
714
601
  element = $(element);
715
- var oldTop = element.style.top;
716
- var oldLeft = element.style.left;
602
+ var oldStyle = {
603
+ top: Element.getStyle(element, 'top'),
604
+ left: Element.getStyle(element, 'left') };
717
605
  return new Effect.MoveBy(element, 0, 20,
718
606
  { duration: 0.05, afterFinishInternal: function(effect) {
719
607
  new Effect.MoveBy(effect.element, 0, -40,
@@ -725,39 +613,39 @@ Effect.Shake = function(element) {
725
613
  new Effect.MoveBy(effect.element, 0, 40,
726
614
  { duration: 0.1, afterFinishInternal: function(effect) {
727
615
  new Effect.MoveBy(effect.element, 0, -20,
728
- { duration: 0.05, afterFinishInternal: function(effect) {
729
- Element.undoPositioned(effect.element);
730
- effect.element.style.left = oldLeft;
731
- effect.element.style.top = oldTop;
732
- }}) }}) }}) }}) }}) }});
616
+ { duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
617
+ undoPositioned(effect.element);
618
+ setStyle(effect.element, oldStyle);
619
+ }}}) }}) }}) }}) }}) }});
733
620
  }
734
621
 
735
622
  Effect.SlideDown = function(element) {
736
623
  element = $(element);
737
624
  Element.cleanWhitespace(element);
738
625
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
739
- var oldInnerBottom = element.firstChild.style.bottom;
626
+ var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
740
627
  var elementDimensions = Element.getDimensions(element);
741
- return new Effect.Scale(element, 100,
742
- Object.extend({ scaleContent: false,
628
+ return new Effect.Scale(element, 100, Object.extend({
629
+ scaleContent: false,
743
630
  scaleX: false,
744
631
  scaleFrom: 0,
745
- scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
632
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
746
633
  restoreAfterFinish: true,
747
- afterSetup: function(effect) {
748
- Element.makePositioned(effect.element.firstChild);
749
- if (window.opera) effect.element.firstChild.style.top = "";
750
- Element.makeClipping(effect.element);
751
- element.style.height = '0';
752
- Element.show(element);
753
- },
754
- afterUpdateInternal: function(effect) {
755
- effect.element.firstChild.style.bottom =
756
- (effect.dims[0] - effect.element.clientHeight) + 'px'; },
757
- afterFinishInternal: function(effect) {
758
- Element.undoClipping(effect.element);
759
- Element.undoPositioned(effect.element.firstChild);
760
- effect.element.firstChild.style.bottom = oldInnerBottom; }
634
+ afterSetup: function(effect) { with(Element) {
635
+ makePositioned(effect.element);
636
+ makePositioned(effect.element.firstChild);
637
+ if(window.opera) setStyle(effect.element, {top: ''});
638
+ makeClipping(effect.element);
639
+ setStyle(effect.element, {height: '0px'});
640
+ show(element); }},
641
+ afterUpdateInternal: function(effect) { with(Element) {
642
+ setStyle(effect.element.firstChild, {bottom:
643
+ (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
644
+ afterFinishInternal: function(effect) { with(Element) {
645
+ undoClipping(effect.element);
646
+ undoPositioned(effect.element.firstChild);
647
+ undoPositioned(effect.element);
648
+ setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
761
649
  }, arguments[1] || {})
762
650
  );
763
651
  }
@@ -765,122 +653,111 @@ Effect.SlideDown = function(element) {
765
653
  Effect.SlideUp = function(element) {
766
654
  element = $(element);
767
655
  Element.cleanWhitespace(element);
768
- var oldInnerBottom = element.firstChild.style.bottom;
656
+ var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
769
657
  return new Effect.Scale(element, 0,
770
658
  Object.extend({ scaleContent: false,
771
659
  scaleX: false,
772
660
  scaleMode: 'box',
773
661
  scaleFrom: 100,
774
662
  restoreAfterFinish: true,
775
- beforeStartInternal: function(effect) {
776
- Element.makePositioned(effect.element.firstChild);
777
- if (window.opera) effect.element.firstChild.style.top = "";
778
- Element.makeClipping(effect.element);
779
- Element.show(element);
780
- },
781
- afterUpdateInternal: function(effect) {
782
- effect.element.firstChild.style.bottom =
783
- (effect.dims[0] - effect.element.clientHeight) + 'px'; },
784
- afterFinishInternal: function(effect) {
785
- Element.hide(effect.element);
786
- Element.undoClipping(effect.element);
787
- Element.undoPositioned(effect.element.firstChild);
788
- effect.element.firstChild.style.bottom = oldInnerBottom; }
663
+ beforeStartInternal: function(effect) { with(Element) {
664
+ makePositioned(effect.element);
665
+ makePositioned(effect.element.firstChild);
666
+ if(window.opera) setStyle(effect.element, {top: ''});
667
+ makeClipping(effect.element);
668
+ show(element); }},
669
+ afterUpdateInternal: function(effect) { with(Element) {
670
+ setStyle(effect.element.firstChild, {bottom:
671
+ (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
672
+ afterFinishInternal: function(effect) { with(Element) {
673
+ [hide, undoClipping].call(effect.element);
674
+ undoPositioned(effect.element.firstChild);
675
+ undoPositioned(effect.element);
676
+ setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
789
677
  }, arguments[1] || {})
790
678
  );
791
679
  }
792
680
 
681
+ // Bug in opera makes the TD containing this element expand for a instance after finish
793
682
  Effect.Squish = function(element) {
794
- // Bug in opera makes the TD containing this element expand for a instance after finish
795
683
  return new Effect.Scale(element, window.opera ? 1 : 0,
796
684
  { restoreAfterFinish: true,
797
- beforeSetup: function(effect) {
798
- Element.makeClipping(effect.element); },
799
- afterFinishInternal: function(effect) {
800
- Element.hide(effect.element);
801
- Element.undoClipping(effect.element); }
685
+ beforeSetup: function(effect) { with(Element) {
686
+ makeClipping(effect.element); }},
687
+ afterFinishInternal: function(effect) { with(Element) {
688
+ hide(effect.element);
689
+ undoClipping(effect.element); }}
802
690
  });
803
691
  }
804
692
 
805
693
  Effect.Grow = function(element) {
806
694
  element = $(element);
807
- var options = arguments[1] || {};
808
-
809
- var elementDimensions = Element.getDimensions(element);
810
- var originalWidth = elementDimensions.width;
811
- var originalHeight = elementDimensions.height;
812
- var oldTop = element.style.top;
813
- var oldLeft = element.style.left;
814
- var oldHeight = element.style.height;
815
- var oldWidth = element.style.width;
816
- var oldOpacity = Element.getInlineOpacity(element);
817
-
818
- var direction = options.direction || 'center';
819
- var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
820
- var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
821
- var opacityTransition = options.opacityTransition || Effect.Transitions.full;
822
-
695
+ var options = Object.extend({
696
+ direction: 'center',
697
+ moveTransistion: Effect.Transitions.sinoidal,
698
+ scaleTransition: Effect.Transitions.sinoidal,
699
+ opacityTransition: Effect.Transitions.full
700
+ }, arguments[1] || {});
701
+ var oldStyle = {
702
+ top: element.style.top,
703
+ left: element.style.left,
704
+ height: element.style.height,
705
+ width: element.style.width,
706
+ opacity: Element.getInlineOpacity(element) };
707
+
708
+ var dims = Element.getDimensions(element);
823
709
  var initialMoveX, initialMoveY;
824
710
  var moveX, moveY;
825
711
 
826
- switch (direction) {
712
+ switch (options.direction) {
827
713
  case 'top-left':
828
714
  initialMoveX = initialMoveY = moveX = moveY = 0;
829
715
  break;
830
716
  case 'top-right':
831
- initialMoveX = originalWidth;
717
+ initialMoveX = dims.width;
832
718
  initialMoveY = moveY = 0;
833
- moveX = -originalWidth;
719
+ moveX = -dims.width;
834
720
  break;
835
721
  case 'bottom-left':
836
722
  initialMoveX = moveX = 0;
837
- initialMoveY = originalHeight;
838
- moveY = -originalHeight;
723
+ initialMoveY = dims.height;
724
+ moveY = -dims.height;
839
725
  break;
840
726
  case 'bottom-right':
841
- initialMoveX = originalWidth;
842
- initialMoveY = originalHeight;
843
- moveX = -originalWidth;
844
- moveY = -originalHeight;
727
+ initialMoveX = dims.width;
728
+ initialMoveY = dims.height;
729
+ moveX = -dims.width;
730
+ moveY = -dims.height;
845
731
  break;
846
732
  case 'center':
847
- initialMoveX = originalWidth / 2;
848
- initialMoveY = originalHeight / 2;
849
- moveX = -originalWidth / 2;
850
- moveY = -originalHeight / 2;
733
+ initialMoveX = dims.width / 2;
734
+ initialMoveY = dims.height / 2;
735
+ moveX = -dims.width / 2;
736
+ moveY = -dims.height / 2;
851
737
  break;
852
738
  }
853
739
 
854
740
  return new Effect.MoveBy(element, initialMoveY, initialMoveX, {
855
741
  duration: 0.01,
856
- beforeSetup: function(effect) {
857
- Element.hide(effect.element);
858
- Element.makeClipping(effect.element);
859
- Element.makePositioned(effect.element);
860
- },
742
+ beforeSetup: function(effect) { with(Element) {
743
+ hide(effect.element);
744
+ makeClipping(effect.element);
745
+ makePositioned(effect.element);
746
+ }},
861
747
  afterFinishInternal: function(effect) {
862
748
  new Effect.Parallel(
863
- [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }),
864
- new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: moveTransition }),
749
+ [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
750
+ new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }),
865
751
  new Effect.Scale(effect.element, 100, {
866
- scaleMode: { originalHeight: originalHeight, originalWidth: originalWidth },
867
- sync: true, scaleFrom: window.opera ? 1 : 0, transition: scaleTransition, restoreAfterFinish: true})
752
+ scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
753
+ sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
868
754
  ], Object.extend({
869
- beforeSetup: function(effect) {
870
- effect.effects[0].element.style.height = 0;
871
- Element.show(effect.effects[0].element);
872
- },
873
- afterFinishInternal: function(effect) {
874
- var el = effect.effects[0].element;
875
- var els = el.style;
876
- Element.undoClipping(el);
877
- Element.undoPositioned(el);
878
- els.top = oldTop;
879
- els.left = oldLeft;
880
- els.height = oldHeight;
881
- els.width = originalWidth + 'px';
882
- Element.setInlineOpacity(el, oldOpacity);
883
- }
755
+ beforeSetup: function(effect) { with(Element) {
756
+ setStyle(effect.effects[0].element, {height: '0px'});
757
+ show(effect.effects[0].element); }},
758
+ afterFinishInternal: function(effect) { with(Element) {
759
+ [undoClipping, undoPositioned].call(effect.effects[0].element);
760
+ setStyle(effect.effects[0].element, oldStyle); }}
884
761
  }, options)
885
762
  )
886
763
  }
@@ -889,66 +766,54 @@ Effect.Grow = function(element) {
889
766
 
890
767
  Effect.Shrink = function(element) {
891
768
  element = $(element);
892
- var options = arguments[1] || {};
893
-
894
- var originalWidth = element.clientWidth;
895
- var originalHeight = element.clientHeight;
896
- var oldTop = element.style.top;
897
- var oldLeft = element.style.left;
898
- var oldHeight = element.style.height;
899
- var oldWidth = element.style.width;
900
- var oldOpacity = Element.getInlineOpacity(element);
901
-
902
- var direction = options.direction || 'center';
903
- var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
904
- var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
905
- var opacityTransition = options.opacityTransition || Effect.Transitions.none;
906
-
769
+ var options = Object.extend({
770
+ direction: 'center',
771
+ moveTransistion: Effect.Transitions.sinoidal,
772
+ scaleTransition: Effect.Transitions.sinoidal,
773
+ opacityTransition: Effect.Transitions.none
774
+ }, arguments[1] || {});
775
+ var oldStyle = {
776
+ top: element.style.top,
777
+ left: element.style.left,
778
+ height: element.style.height,
779
+ width: element.style.width,
780
+ opacity: Element.getInlineOpacity(element) };
781
+
782
+ var dims = Element.getDimensions(element);
907
783
  var moveX, moveY;
908
784
 
909
- switch (direction) {
785
+ switch (options.direction) {
910
786
  case 'top-left':
911
787
  moveX = moveY = 0;
912
788
  break;
913
789
  case 'top-right':
914
- moveX = originalWidth;
790
+ moveX = dims.width;
915
791
  moveY = 0;
916
792
  break;
917
793
  case 'bottom-left':
918
794
  moveX = 0;
919
- moveY = originalHeight;
795
+ moveY = dims.height;
920
796
  break;
921
797
  case 'bottom-right':
922
- moveX = originalWidth;
923
- moveY = originalHeight;
798
+ moveX = dims.width;
799
+ moveY = dims.height;
924
800
  break;
925
801
  case 'center':
926
- moveX = originalWidth / 2;
927
- moveY = originalHeight / 2;
802
+ moveX = dims.width / 2;
803
+ moveY = dims.height / 2;
928
804
  break;
929
805
  }
930
806
 
931
807
  return new Effect.Parallel(
932
- [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: opacityTransition }),
933
- new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: scaleTransition, restoreAfterFinish: true}),
934
- new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition })
808
+ [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
809
+ new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
810
+ new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition })
935
811
  ], Object.extend({
936
- beforeStartInternal: function(effect) {
937
- Element.makePositioned(effect.effects[0].element);
938
- Element.makeClipping(effect.effects[0].element);
939
- },
940
- afterFinishInternal: function(effect) {
941
- var el = effect.effects[0].element;
942
- var els = el.style;
943
- Element.hide(el);
944
- Element.undoClipping(el);
945
- Element.undoPositioned(el);
946
- els.top = oldTop;
947
- els.left = oldLeft;
948
- els.height = oldHeight;
949
- els.width = oldWidth;
950
- Element.setInlineOpacity(el, oldOpacity);
951
- }
812
+ beforeStartInternal: function(effect) { with(Element) {
813
+ [makePositioned, makeClipping].call(effect.effects[0].element) }},
814
+ afterFinishInternal: function(effect) { with(Element) {
815
+ [hide, undoClipping, undoPositioned].call(effect.effects[0].element);
816
+ setStyle(effect.effects[0].element, oldStyle); }}
952
817
  }, options)
953
818
  );
954
819
  }
@@ -962,16 +827,17 @@ Effect.Pulsate = function(element) {
962
827
  reverser.bind(transition);
963
828
  return new Effect.Opacity(element,
964
829
  Object.extend(Object.extend({ duration: 3.0, from: 0,
965
- afterFinishInternal: function(effect) { Element.setInlineOpacity(effect.element, oldOpacity); }
830
+ afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
966
831
  }, options), {transition: reverser}));
967
832
  }
968
833
 
969
834
  Effect.Fold = function(element) {
970
835
  element = $(element);
971
- var originalTop = element.style.top;
972
- var originalLeft = element.style.left;
973
- var originalWidth = element.style.width;
974
- var originalHeight = element.style.height;
836
+ var oldStyle = {
837
+ top: element.style.top,
838
+ left: element.style.left,
839
+ width: element.style.width,
840
+ height: element.style.height };
975
841
  Element.makeClipping(element);
976
842
  return new Effect.Scale(element, 5, Object.extend({
977
843
  scaleContent: false,
@@ -980,13 +846,9 @@ Effect.Fold = function(element) {
980
846
  new Effect.Scale(element, 1, {
981
847
  scaleContent: false,
982
848
  scaleY: false,
983
- afterFinishInternal: function(effect) {
984
- Element.hide(effect.element);
985
- Element.undoClipping(effect.element);
986
- effect.element.style.top = originalTop;
987
- effect.element.style.left = originalLeft;
988
- effect.element.style.width = originalWidth;
989
- effect.element.style.height = originalHeight;
990
- } });
849
+ afterFinishInternal: function(effect) { with(Element) {
850
+ [hide, undoClipping].call(effect.element);
851
+ setStyle(effect.element, oldStyle);
852
+ }} });
991
853
  }}, arguments[1] || {}));
992
854
  }