You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2005/12/23 12:58:46 UTC

svn commit: r358796 [2/3] - in /incubator/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ tobago-core/src/main/resources/META-INF/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit...

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/effects.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/effects.js?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/effects.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/effects.js Fri Dec 23 03:58:10 2005
@@ -1,30 +1,138 @@
 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-//
-// Parts (c) 2005 Justin Palmer (http://encytemedia.com/)
-// Parts (c) 2005 Mark Pilgrim (http://diveintomark.org/)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// Contributors:
+//  Justin Palmer (http://encytemedia.com/)
+//  Mark Pilgrim (http://diveintomark.org/)
+//  Martin Bialasinki
+// 
+// See scriptaculous.js for full license.  
+
+/* ------------- element ext -------------- */  
+ 
+// converts rgb() and #xxx to #xxxxxx format,  
+// returns self (or first argument) if not convertable  
+String.prototype.parseColor = function() {  
+  var color = '#';  
+  if(this.slice(0,4) == 'rgb(') {  
+    var cols = this.slice(4,this.length-1).split(',');  
+    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
+  } else {  
+    if(this.slice(0,1) == '#') {  
+      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
+      if(this.length==7) color = this.toLowerCase();  
+    }  
+  }  
+  return(color.length==7 ? color : (arguments[0] || this));  
+}  
+
+Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {  
+  var children = $(element).childNodes;  
+  var text     = '';  
+  var classtest = new RegExp('^([^ ]+ )*' + ignoreclass+ '( [^ ]+)*$','i');  
+ 
+  for (var i = 0; i < children.length; i++) {  
+    if(children[i].nodeType==3) {  
+      text+=children[i].nodeValue;  
+    } else {  
+      if((!children[i].className.match(classtest)) && children[i].hasChildNodes())  
+        text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass);  
+    }  
+  }  
+ 
+  return text;
+}
 
+Element.setStyle = function(element, style) {
+  element = $(element);
+  for(k in style) element.style[k.camelize()] = style[k];
+}
 
-Effect = {}
-Effect2 = Effect; // deprecated
+Element.setContentZoom = function(element, percent) {  
+  Element.setStyle(element, {fontSize: (percent/100) + 'em'});   
+  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);  
+}
+
+Element.getOpacity = function(element){  
+  var opacity;
+  if (opacity = Element.getStyle(element, 'opacity'))  
+    return parseFloat(opacity);  
+  if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))  
+    if(opacity[1]) return parseFloat(opacity[1]) / 100;  
+  return 1.0;  
+}
+
+Element.setOpacity = function(element, value){  
+  element= $(element);  
+  if (value == 1){
+    Element.setStyle(element, { opacity: 
+      (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 
+      0.999999 : null });
+    if(/MSIE/.test(navigator.userAgent))  
+      Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});  
+  } else {  
+    if(value < 0.00001) value = 0;  
+    Element.setStyle(element, {opacity: value});
+    if(/MSIE/.test(navigator.userAgent))  
+     Element.setStyle(element, 
+       { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
+                 'alpha(opacity='+value*100+')' });  
+  }   
+}  
+ 
+Element.getInlineOpacity = function(element){  
+  return $(element).style.opacity || '';
+}  
+
+Element.childrenWithClassName = function(element, className) {  
+  return $A($(element).getElementsByTagName('*')).select(
+    function(c) { return Element.hasClassName(c, className) });
+}
+
+Array.prototype.call = function() {
+  var args = arguments;
+  this.each(function(f){ f.apply(this, args) });
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Effect = {
+  tagifyText: function(element) {
+    var tagifyStyle = 'position:relative';
+    if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1';
+    element = $(element);
+    $A(element.childNodes).each( function(child) {
+      if(child.nodeType==3) {
+        child.nodeValue.toArray().each( function(character) {
+          element.insertBefore(
+            Builder.node('span',{style: tagifyStyle},
+              character == ' ' ? String.fromCharCode(160) : character), 
+              child);
+        });
+        Element.remove(child);
+      }
+    });
+  },
+  multiple: function(element, effect) {
+    var elements;
+    if(((typeof element == 'object') || 
+        (typeof element == 'function')) && 
+       (element.length))
+      elements = element;
+    else
+      elements = $(element).childNodes;
+      
+    var options = Object.extend({
+      speed: 0.1,
+      delay: 0.0
+    }, arguments[2] || {});
+    var masterDelay = options.delay;
+
+    $A(elements).each( function(element, index) {
+      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
+    });
+  }
+};
+
+var Effect2 = Effect; // deprecated
 
 /* ------------- transitions ------------- */
 
@@ -40,13 +148,13 @@
   return 1-pos;
 }
 Effect.Transitions.flicker = function(pos) {
-  return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random(0.25);
+  return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
 }
 Effect.Transitions.wobble = function(pos) {
   return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
 }
 Effect.Transitions.pulse = function(pos) {
-  return (Math.floor(pos*10) % 2 == 0 ?
+  return (Math.floor(pos*10) % 2 == 0 ? 
     (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10)));
 }
 Effect.Transitions.none = function(pos) {
@@ -56,73 +164,120 @@
   return 1;
 }
 
-/* ------------- element ext -------------- */
-
-Element.makePositioned = function(element) {
-  element = $(element);
-  if(element.style.position == "")
-    element.style.position = "relative";
-}
-
-Element.makeClipping = function(element) {
-  element = $(element);
-  element._overflow = element.style.overflow || 'visible';
-  if(element._overflow!='hidden') element.style.overflow = 'hidden';
-}
+/* ------------- core effects ------------- */
 
-Element.undoClipping = function(element) {
-  element = $(element);
-  if(element._overflow!='hidden') element.style.overflow = element._overflow;
+Effect.Queue = {
+  effects:  [],
+  _each: function(iterator) {
+    this.effects._each(iterator);
+  },
+  interval: null,
+  add: function(effect) {
+    var timestamp = new Date().getTime();
+    
+    switch(effect.options.queue) {
+      case 'front':
+        // move unstarted effects after this effect  
+        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
+            e.startOn  += effect.finishOn;
+            e.finishOn += effect.finishOn;
+          });
+        break;
+      case 'end':
+        // start effect after last queued effect has finished
+        timestamp = this.effects.pluck('finishOn').max() || timestamp;
+        break;
+    }
+    
+    effect.startOn  += timestamp;
+    effect.finishOn += timestamp;
+    this.effects.push(effect);
+    if(!this.interval) 
+      this.interval = setInterval(this.loop.bind(this), 40);
+  },
+  remove: function(effect) {
+    this.effects = this.effects.reject(function(e) { return e==effect });
+    if(this.effects.length == 0) {
+      clearInterval(this.interval);
+      this.interval = null;
+    }
+  },
+  loop: function() {
+    var timePos = new Date().getTime();
+    this.effects.invoke('loop', timePos);
+  }
 }
-
-/* ------------- core effects ------------- */
+Object.extend(Effect.Queue, Enumerable);
 
 Effect.Base = function() {};
 Effect.Base.prototype = {
+  position: null,
   setOptions: function(options) {
     this.options = Object.extend({
       transition: Effect.Transitions.sinoidal,
       duration:   1.0,   // seconds
-      fps:        25.0,  // max. 100fps
+      fps:        25.0,  // max. 25fps due to Effect.Queue implementation
       sync:       false, // true for combining
       from:       0.0,
-      to:         1.0
+      to:         1.0,
+      delay:      0.0,
+      queue:      'parallel'
     }, options || {});
   },
   start: function(options) {
     this.setOptions(options || {});
     this.currentFrame = 0;
-    this.startOn      = new Date().getTime();
+    this.state        = 'idle';
+    this.startOn      = this.options.delay*1000;
     this.finishOn     = this.startOn + (this.options.duration*1000);
-    if(this.options.beforeStart) this.options.beforeStart(this);
-    if(!this.options.sync) this.loop();
+    this.event('beforeStart');
+    if(!this.options.sync) Effect.Queue.add(this);
   },
-  loop: function() {
-    var timePos = new Date().getTime();
-    if(timePos >= this.finishOn) {
-      this.render(this.options.to);
-      if(this.finish) this.finish();
-      if(this.options.afterFinish) this.options.afterFinish(this);
-      return;
-    }
-    var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
-    var frame = Math.round(pos * this.options.fps * this.options.duration);
-    if(frame > this.currentFrame) {
-      this.render(pos);
-      this.currentFrame = frame;
+  loop: function(timePos) {
+    if(timePos >= this.startOn) {
+      if(timePos >= this.finishOn) {
+        this.render(1.0);
+        this.cancel();
+        this.event('beforeFinish');
+        if(this.finish) this.finish(); 
+        this.event('afterFinish');
+        return;  
+      }
+      var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
+      var frame = Math.round(pos * this.options.fps * this.options.duration);
+      if(frame > this.currentFrame) {
+        this.render(pos);
+        this.currentFrame = frame;
+      }
     }
-    this.timeout = setTimeout(this.loop.bind(this), 10);
   },
   render: function(pos) {
-    if(this.options.transition) pos = this.options.transition(pos);
-    pos *= (this.options.to-this.options.from);
-    pos += this.options.from;
-    if(this.options.beforeUpdate) this.options.beforeUpdate(this);
-    if(this.update) this.update(pos);
-    if(this.options.afterUpdate) this.options.afterUpdate(this);
+    if(this.state == 'idle') {
+      this.state = 'running';
+      this.event('beforeSetup');
+      if(this.setup) this.setup();
+      this.event('afterSetup');
+    }
+    if(this.state == 'running') {
+      if(this.options.transition) pos = this.options.transition(pos);
+      pos *= (this.options.to-this.options.from);
+      pos += this.options.from;
+      this.position = pos;
+      this.event('beforeUpdate');
+      if(this.update) this.update(pos);
+      this.event('afterUpdate');
+    }
   },
   cancel: function() {
-    if(this.timeout) clearTimeout(this.timeout);
+    if(!this.options.sync) Effect.Queue.remove(this);
+    this.state = 'finished';
+  },
+  event: function(eventName) {
+    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
+    if(this.options[eventName]) this.options[eventName](this);
+  },
+  inspect: function() {
+    return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
   }
 }
 
@@ -133,35 +288,34 @@
     this.start(arguments[1]);
   },
   update: function(position) {
-    for (var i = 0; i < this.effects.length; i++)
-      this.effects[i].render(position);
+    this.effects.invoke('render', position);
   },
   finish: function(position) {
-    for (var i = 0; i < this.effects.length; i++)
-      if(this.effects[i].finish) this.effects[i].finish(position);
+    this.effects.each( function(effect) {
+      effect.render(1.0);
+      effect.cancel();
+      effect.event('beforeFinish');
+      if(effect.finish) effect.finish(position);
+      effect.event('afterFinish');
+    });
   }
 });
 
-// Internet Explorer caveat: works only on elements the have
-// a 'layout', meaning having a given width or height.
-// There is no way to safely set this automatically.
 Effect.Opacity = Class.create();
 Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
   initialize: function(element) {
     this.element = $(element);
-    options = Object.extend({
-      from: 0.0,
+    // make this work on IE on elements without 'layout'
+    if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
+      Element.setStyle(this.element, {zoom: 1});
+    var options = Object.extend({
+      from: Element.getOpacity(this.element) || 0.0,
       to:   1.0
     }, arguments[1] || {});
     this.start(options);
   },
   update: function(position) {
-    this.setOpacity(position);
-  },
-  setOpacity: function(opacity) {
-    opacity = (opacity == 1) ? 0.99999 : opacity;
-    this.element.style.opacity = opacity;
-    this.element.style.filter = "alpha(opacity:"+opacity*100+")";
+    Element.setOpacity(this.element, position);
   }
 });
 
@@ -169,21 +323,24 @@
 Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
   initialize: function(element, toTop, toLeft) {
     this.element      = $(element);
-    this.originalTop  = parseFloat(this.element.style.top || '0');
-    this.originalLeft = parseFloat(this.element.style.left || '0');
     this.toTop        = toTop;
     this.toLeft       = toLeft;
-    Element.makePositioned(this.element);
     this.start(arguments[3]);
   },
+  setup: function() {
+    // Bug in Opera: Opera returns the "real" position of a static element or
+    // relative element that does not have top/left explicitly set.
+    // ==> Always set top and left for position relative elements in your stylesheets 
+    // (to 0 if you do not need them) 
+    Element.makePositioned(this.element);
+    this.originalTop  = parseFloat(Element.getStyle(this.element,'top')  || '0');
+    this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
+  },
   update: function(position) {
-    topd  = this.toTop  * position + this.originalTop;
-    leftd = this.toLeft * position + this.originalLeft;
-    this.setPosition(topd, leftd);
-  },
-  setPosition: function(topd, leftd) {
-    this.element.style.top  = topd  + "px";
-    this.element.style.left = leftd + "px";
+    Element.setStyle(this.element, {
+      top:  this.toTop  * position + this.originalTop + 'px',
+      left: this.toLeft * position + this.originalLeft + 'px'
+    });
   }
 });
 
@@ -191,57 +348,73 @@
 Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
   initialize: function(element, percent) {
     this.element = $(element)
-    options = Object.extend({
+    var options = Object.extend({
       scaleX: true,
       scaleY: true,
       scaleContent: true,
       scaleFromCenter: false,
       scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
-      scaleFrom: 100.0
+      scaleFrom: 100.0,
+      scaleTo:   percent
     }, arguments[2] || {});
-    this.originalTop    = this.element.offsetTop;
-    this.originalLeft   = this.element.offsetLeft;
-    if(this.element.style.fontSize=="") this.sizeEm = 1.0;
-    if(this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
-      this.sizeEm      = parseFloat(this.element.style.fontSize);
-    this.factor = (percent/100.0) - (options.scaleFrom/100.0);
-    if(options.scaleMode=='box') {
-      this.originalHeight = this.element.clientHeight;
-      this.originalWidth  = this.element.clientWidth;
-    } else
-    if(options.scaleMode=='contents') {
-      this.originalHeight = this.element.scrollHeight;
-      this.originalWidth  = this.element.scrollWidth;
-    } else {
-      this.originalHeight = options.scaleMode.originalHeight;
-      this.originalWidth  = options.scaleMode.originalWidth;
-    }
     this.start(options);
   },
-
+  setup: function() {
+    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
+    this.elementPositioning = Element.getStyle(this.element,'position');
+    
+    this.originalStyle = {};
+    ['top','left','width','height','fontSize'].each( function(k) {
+      this.originalStyle[k] = this.element.style[k];
+    }.bind(this));
+      
+    this.originalTop  = this.element.offsetTop;
+    this.originalLeft = this.element.offsetLeft;
+    
+    var fontSize = Element.getStyle(this.element,'font-size') || '100%';
+    ['em','px','%'].each( function(fontSizeType) {
+      if(fontSize.indexOf(fontSizeType)>0) {
+        this.fontSize     = parseFloat(fontSize);
+        this.fontSizeType = fontSizeType;
+      }
+    }.bind(this));
+    
+    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
+    
+    this.dims = null;
+    if(this.options.scaleMode=='box')
+      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
+    if(/^content/.test(this.options.scaleMode))
+      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
+    if(!this.dims)
+      this.dims = [this.options.scaleMode.originalHeight,
+                   this.options.scaleMode.originalWidth];
+  },
   update: function(position) {
-    currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
-    if(this.options.scaleContent && this.sizeEm)
-      this.element.style.fontSize = this.sizeEm*currentScale + "em";
-    this.setDimensions(
-      this.originalWidth * currentScale,
-      this.originalHeight * currentScale);
+    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
+    if(this.options.scaleContent && this.fontSize)
+      Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType });
+    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
   },
-
-  setDimensions: function(width, height) {
-    if(this.options.scaleX) this.element.style.width = width + 'px';
-    if(this.options.scaleY) this.element.style.height = height + 'px';
+  finish: function(position) {
+    if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle);
+  },
+  setDimensions: function(height, width) {
+    var d = {};
+    if(this.options.scaleX) d.width = width + 'px';
+    if(this.options.scaleY) d.height = height + 'px';
     if(this.options.scaleFromCenter) {
-      topd  = (height - this.originalHeight)/2;
-      leftd = (width  - this.originalWidth)/2;
-      if(this.element.style.position=='absolute') {
-        if(this.options.scaleY) this.element.style.top = this.originalTop-topd + "px";
-        if(this.options.scaleX) this.element.style.left = this.originalLeft-leftd + "px";
+      var topd  = (height - this.dims[0])/2;
+      var leftd = (width  - this.dims[1])/2;
+      if(this.elementPositioning == 'absolute') {
+        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
+        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
       } else {
-        if(this.options.scaleY) this.element.style.top = -topd + "px";
-        if(this.options.scaleX) this.element.style.left = -leftd + "px";
+        if(this.options.scaleY) d.top = -topd + 'px';
+        if(this.options.scaleX) d.left = -leftd + 'px';
       }
     }
+    Element.setStyle(this.element, d);
   }
 });
 
@@ -249,44 +422,32 @@
 Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
   initialize: function(element) {
     this.element = $(element);
-
-    // try to parse current background color as default for endcolor
-    // browser stores this as: "rgb(255, 255, 255)", convert to "#ffffff" format
-    var endcolor = "#ffffff";
-    var current = this.element.style.backgroundColor;
-    if(current && current.slice(0,4) == "rgb(") {
-      endcolor = "#";
-      var cols = current.slice(4,current.length-1).split(',');
-      var i=0; do { endcolor += parseInt(cols[i]).toColorPart() } while (++i<3); }
-
-    var options = Object.extend({
-      startcolor:   "#ffff99",
-      endcolor:     endcolor,
-      restorecolor: current
-    }, arguments[1] || {});
-
-    // init color calculations
-    this.colors_base = [
-      parseInt(options.startcolor.slice(1,3),16),
-      parseInt(options.startcolor.slice(3,5),16),
-      parseInt(options.startcolor.slice(5),16) ];
-    this.colors_delta = [
-      parseInt(options.endcolor.slice(1,3),16)-this.colors_base[0],
-      parseInt(options.endcolor.slice(3,5),16)-this.colors_base[1],
-      parseInt(options.endcolor.slice(5),16)-this.colors_base[2] ];
-
+    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
     this.start(options);
   },
+  setup: function() {
+    // Prevent executing on elements not in the layout flow
+    if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; }
+    // Disable background image during the effect
+    this.oldStyle = {
+      backgroundImage: Element.getStyle(this.element, 'background-image') };
+    Element.setStyle(this.element, {backgroundImage: 'none'});
+    if(!this.options.endcolor)
+      this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
+    if(!this.options.restorecolor)
+      this.options.restorecolor = Element.getStyle(this.element, 'background-color');
+    // init color calculations
+    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
+    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));
+  },
   update: function(position) {
-    var colors = [
-      Math.round(this.colors_base[0]+(this.colors_delta[0]*position)),
-      Math.round(this.colors_base[1]+(this.colors_delta[1]*position)),
-      Math.round(this.colors_base[2]+(this.colors_delta[2]*position)) ];
-    this.element.style.backgroundColor = "#" +
-      colors[0].toColorPart() + colors[1].toColorPart() + colors[2].toColorPart();
+    Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){
+      return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
   },
   finish: function() {
-    this.element.style.backgroundColor = this.options.restorecolor;
+    Element.setStyle(this.element, Object.extend(this.oldStyle, {
+      backgroundColor: this.options.restorecolor
+    }));
   }
 });
 
@@ -294,322 +455,400 @@
 Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
   initialize: function(element) {
     this.element = $(element);
+    this.start(arguments[1] || {});
+  },
+  setup: function() {
     Position.prepare();
     var offsets = Position.cumulativeOffset(this.element);
-    var max = window.innerHeight ?
+    if(this.options.offset) offsets[1] += this.options.offset;
+    var max = window.innerHeight ? 
       window.height - window.innerHeight :
-      document.body.scrollHeight -
-        (document.documentElement.clientHeight ?
+      document.body.scrollHeight - 
+        (document.documentElement.clientHeight ? 
           document.documentElement.clientHeight : document.body.clientHeight);
     this.scrollStart = Position.deltaY;
-    this.delta  = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
-    this.start(arguments[1] || {});
+    this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
   },
   update: function(position) {
     Position.prepare();
-    window.scrollTo(Position.deltaX,
+    window.scrollTo(Position.deltaX, 
       this.scrollStart + (position*this.delta));
   }
 });
 
-/* ------------- prepackaged effects ------------- */
+/* ------------- combination effects ------------- */
 
 Effect.Fade = function(element) {
-  options = Object.extend({
-  from: 1.0,
+  var oldOpacity = Element.getInlineOpacity(element);
+  var options = Object.extend({
+  from: Element.getOpacity(element) || 1.0,
   to:   0.0,
-  afterFinish: function(effect)
-    { Element.hide(effect.element);
-      effect.setOpacity(1); }
+  afterFinishInternal: function(effect) { with(Element) { 
+    if(effect.options.to!=0) return;
+    hide(effect.element);
+    setStyle(effect.element, {opacity: oldOpacity}); }}
   }, arguments[1] || {});
-  new Effect.Opacity(element,options);
+  return new Effect.Opacity(element,options);
 }
 
 Effect.Appear = function(element) {
-  options = Object.extend({
-  from: 0.0,
+  var options = Object.extend({
+  from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0),
   to:   1.0,
-  beforeStart: function(effect)
-    { effect.setOpacity(0);
-      Element.show(effect.element); },
-  afterUpdate: function(effect)
-    { Element.show(effect.element); }
+  beforeSetup: function(effect) { with(Element) {
+    setOpacity(effect.element, effect.options.from);
+    show(effect.element); }}
   }, arguments[1] || {});
-  new Effect.Opacity(element,options);
+  return new Effect.Opacity(element,options);
 }
 
 Effect.Puff = function(element) {
-  new Effect.Parallel(
-   [ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true }),
-     new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
-     { duration: 1.0,
-      afterUpdate: function(effect)
-       { effect.effects[0].element.style.position = 'absolute'; },
-      afterFinish: function(effect)
-       { Element.hide(effect.effects[0].element); }
-     }
+  element = $(element);
+  var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') };
+  return new Effect.Parallel(
+   [ new Effect.Scale(element, 200, 
+      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), 
+     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], 
+     Object.extend({ duration: 1.0, 
+      beforeSetupInternal: function(effect) { with(Element) {
+        setStyle(effect.effects[0].element, {position: 'absolute'}); }},
+      afterFinishInternal: function(effect) { with(Element) {
+         hide(effect.effects[0].element);
+         setStyle(effect.effects[0].element, oldStyle); }}
+     }, arguments[1] || {})
    );
 }
 
 Effect.BlindUp = function(element) {
+  element = $(element);
   Element.makeClipping(element);
-  new Effect.Scale(element, 0,
-    Object.extend({ scaleContent: false,
-      scaleX: false,
-      afterFinish: function(effect)
-        {
-          Element.hide(effect.element);
-          Element.undoClipping(effect.element);
-        }
+  return new Effect.Scale(element, 0, 
+    Object.extend({ scaleContent: false, 
+      scaleX: false, 
+      restoreAfterFinish: true,
+      afterFinishInternal: function(effect) { with(Element) {
+        [hide, undoClipping].call(effect.element); }} 
     }, arguments[1] || {})
   );
 }
 
 Effect.BlindDown = function(element) {
-  $(element).style.height   = '0px';
-  Element.makeClipping(element);
-  Element.show(element);
-  new Effect.Scale(element, 100,
-    Object.extend({ scaleContent: false,
+  element = $(element);
+  var oldHeight = Element.getStyle(element, 'height');
+  var elementDimensions = Element.getDimensions(element);
+  return new Effect.Scale(element, 100, 
+    Object.extend({ scaleContent: false, 
       scaleX: false,
-      scaleMode: 'contents',
       scaleFrom: 0,
-      afterFinish: function(effect) {
-        Element.undoClipping(effect.element);
-      }
+      scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+      restoreAfterFinish: true,
+      afterSetup: function(effect) { with(Element) {
+        makeClipping(effect.element);
+        setStyle(effect.element, {height: '0px'});
+        show(effect.element); 
+      }},  
+      afterFinishInternal: function(effect) { with(Element) {
+        undoClipping(effect.element);
+        setStyle(effect.element, {height: oldHeight});
+      }}
     }, arguments[1] || {})
   );
 }
 
 Effect.SwitchOff = function(element) {
-  new Effect.Appear(element,
-    { duration: 0.4,
-     transition: Effect.Transitions.flicker,
-     afterFinish: function(effect)
-      { effect.element.style.overflow = 'hidden';
-        new Effect.Scale(effect.element, 1,
-         { duration: 0.3, scaleFromCenter: true,
-          scaleX: false, scaleContent: false,
-          afterUpdate: function(effect) {
-           if(effect.element.style.position=="")
-             effect.element.style.position = 'relative'; },
-          afterFinish: function(effect) { Element.hide(effect.element); }
-         } )
-      }
-    } );
+  element = $(element);
+  var oldOpacity = Element.getInlineOpacity(element);
+  return new Effect.Appear(element, { 
+    duration: 0.4,
+    from: 0,
+    transition: Effect.Transitions.flicker,
+    afterFinishInternal: function(effect) {
+      new Effect.Scale(effect.element, 1, { 
+        duration: 0.3, scaleFromCenter: true,
+        scaleX: false, scaleContent: false, restoreAfterFinish: true,
+        beforeSetup: function(effect) { with(Element) {
+          [makePositioned,makeClipping].call(effect.element);
+        }},
+        afterFinishInternal: function(effect) { with(Element) {
+          [hide,undoClipping,undoPositioned].call(effect.element);
+          setStyle(effect.element, {opacity: oldOpacity});
+        }}
+      })
+    }
+  });
 }
 
 Effect.DropOut = function(element) {
-  new Effect.Parallel(
-    [ new Effect.MoveBy(element, 100, 0, { sync: true }),
-      new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
-    { duration: 0.5,
-     afterFinish: function(effect)
-       { Element.hide(effect.effects[0].element); }
-    });
+  element = $(element);
+  var oldStyle = {
+    top: Element.getStyle(element, 'top'),
+    left: Element.getStyle(element, 'left'),
+    opacity: Element.getInlineOpacity(element) };
+  return new Effect.Parallel(
+    [ new Effect.MoveBy(element, 100, 0, { sync: true }), 
+      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
+    Object.extend(
+      { duration: 0.5,
+        beforeSetup: function(effect) { with(Element) {
+          makePositioned(effect.effects[0].element); }},
+        afterFinishInternal: function(effect) { with(Element) {
+          [hide, undoPositioned].call(effect.effects[0].element);
+          setStyle(effect.effects[0].element, oldStyle); }} 
+      }, arguments[1] || {}));
 }
 
 Effect.Shake = function(element) {
-  new Effect.MoveBy(element, 0, 20,
-    { duration: 0.05, afterFinish: function(effect) {
-  new Effect.MoveBy(effect.element, 0, -40,
-    { duration: 0.1, afterFinish: function(effect) {
-  new Effect.MoveBy(effect.element, 0, 40,
-    { duration: 0.1, afterFinish: function(effect) {
-  new Effect.MoveBy(effect.element, 0, -40,
-    { duration: 0.1, afterFinish: function(effect) {
-  new Effect.MoveBy(effect.element, 0, 40,
-    { duration: 0.1, afterFinish: function(effect) {
-  new Effect.MoveBy(effect.element, 0, -20,
-    { duration: 0.05, afterFinish: function(effect) {
-  }}) }}) }}) }}) }}) }});
+  element = $(element);
+  var oldStyle = {
+    top: Element.getStyle(element, 'top'),
+    left: Element.getStyle(element, 'left') };
+  return new Effect.MoveBy(element, 0, 20, 
+    { duration: 0.05, afterFinishInternal: function(effect) {
+  new Effect.MoveBy(effect.element, 0, -40, 
+    { duration: 0.1, afterFinishInternal: function(effect) {
+  new Effect.MoveBy(effect.element, 0, 40, 
+    { duration: 0.1, afterFinishInternal: function(effect) {
+  new Effect.MoveBy(effect.element, 0, -40, 
+    { duration: 0.1, afterFinishInternal: function(effect) {
+  new Effect.MoveBy(effect.element, 0, 40, 
+    { duration: 0.1, afterFinishInternal: function(effect) {
+  new Effect.MoveBy(effect.element, 0, -20, 
+    { duration: 0.05, afterFinishInternal: function(effect) { with(Element) {
+        undoPositioned(effect.element);
+        setStyle(effect.element, oldStyle);
+  }}}) }}) }}) }}) }}) }});
 }
 
 Effect.SlideDown = function(element) {
   element = $(element);
-  element.style.height   = '0px';
-  Element.makeClipping(element);
   Element.cleanWhitespace(element);
-  Element.makePositioned(element.firstChild);
-  Element.show(element);
-  new Effect.Scale(element, 100,
-   Object.extend({ scaleContent: false,
-    scaleX: false,
-    scaleMode: 'contents',
+  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
+  var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
+  var elementDimensions = Element.getDimensions(element);
+  return new Effect.Scale(element, 100, Object.extend({ 
+    scaleContent: false, 
+    scaleX: false, 
     scaleFrom: 0,
-    afterUpdate: function(effect)
-      { effect.element.firstChild.style.bottom =
-          (effect.originalHeight - effect.element.clientHeight) + 'px'; },
-    afterFinish: function(effect)
-      {  Element.undoClipping(effect.element); }
+    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+    restoreAfterFinish: true,
+    afterSetup: function(effect) { with(Element) {
+      makePositioned(effect.element);
+      makePositioned(effect.element.firstChild);
+      if(window.opera) setStyle(effect.element, {top: ''});
+      makeClipping(effect.element);
+      setStyle(effect.element, {height: '0px'});
+      show(element); }},
+    afterUpdateInternal: function(effect) { with(Element) {
+      setStyle(effect.element.firstChild, {bottom:
+        (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
+    afterFinishInternal: function(effect) { with(Element) {
+      undoClipping(effect.element); 
+      undoPositioned(effect.element.firstChild);
+      undoPositioned(effect.element);
+      setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
     }, arguments[1] || {})
   );
 }
-
+  
 Effect.SlideUp = function(element) {
   element = $(element);
-  Element.makeClipping(element);
   Element.cleanWhitespace(element);
-  Element.makePositioned(element.firstChild);
-  Element.show(element);
-  new Effect.Scale(element, 0,
-   Object.extend({ scaleContent: false,
-    scaleX: false,
-    afterUpdate: function(effect)
-      { effect.element.firstChild.style.bottom =
-          (effect.originalHeight - effect.element.clientHeight) + 'px'; },
-    afterFinish: function(effect)
-      {
-        Element.hide(effect.element);
-        Element.undoClipping(effect.element);
-      }
+  var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom');
+  return new Effect.Scale(element, 0, 
+   Object.extend({ scaleContent: false, 
+    scaleX: false, 
+    scaleMode: 'box',
+    scaleFrom: 100,
+    restoreAfterFinish: true,
+    beforeStartInternal: function(effect) { with(Element) {
+      makePositioned(effect.element);
+      makePositioned(effect.element.firstChild);
+      if(window.opera) setStyle(effect.element, {top: ''});
+      makeClipping(effect.element);
+      show(element); }},  
+    afterUpdateInternal: function(effect) { with(Element) {
+      setStyle(effect.element.firstChild, {bottom:
+        (effect.dims[0] - effect.element.clientHeight) + 'px' }); }},
+    afterFinishInternal: function(effect) { with(Element) {
+        [hide, undoClipping].call(effect.element); 
+        undoPositioned(effect.element.firstChild);
+        undoPositioned(effect.element);
+        setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }}
    }, arguments[1] || {})
   );
 }
 
+// Bug in opera makes the TD containing this element expand for a instance after finish 
 Effect.Squish = function(element) {
- new Effect.Scale(element, 0,
-   { afterFinish: function(effect) { Element.hide(effect.element); } });
+  return new Effect.Scale(element, window.opera ? 1 : 0, 
+    { restoreAfterFinish: true,
+      beforeSetup: function(effect) { with(Element) {
+        makeClipping(effect.element); }},  
+      afterFinishInternal: function(effect) { with(Element) {
+        hide(effect.element); 
+        undoClipping(effect.element); }}
+  });
 }
 
 Effect.Grow = function(element) {
   element = $(element);
-  var options = arguments[1] || {};
-
-  var originalWidth = element.clientWidth;
-  var originalHeight = element.clientHeight;
-  element.style.overflow = 'hidden';
-  Element.show(element);
-
-  var direction = options.direction || 'center';
-  var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
-  var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
-  var opacityTransition = options.opacityTransition || Effect.Transitions.full;
+  var options = Object.extend({
+    direction: 'center',
+    moveTransistion: Effect.Transitions.sinoidal,
+    scaleTransition: Effect.Transitions.sinoidal,
+    opacityTransition: Effect.Transitions.full
+  }, arguments[1] || {});
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    height: element.style.height,
+    width: element.style.width,
+    opacity: Element.getInlineOpacity(element) };
 
+  var dims = Element.getDimensions(element);    
   var initialMoveX, initialMoveY;
   var moveX, moveY;
-
-  switch (direction) {
+  
+  switch (options.direction) {
     case 'top-left':
-      initialMoveX = initialMoveY = moveX = moveY = 0;
+      initialMoveX = initialMoveY = moveX = moveY = 0; 
       break;
     case 'top-right':
-      initialMoveX = originalWidth;
+      initialMoveX = dims.width;
       initialMoveY = moveY = 0;
-      moveX = -originalWidth;
+      moveX = -dims.width;
       break;
     case 'bottom-left':
       initialMoveX = moveX = 0;
-      initialMoveY = originalHeight;
-      moveY = -originalHeight;
+      initialMoveY = dims.height;
+      moveY = -dims.height;
       break;
     case 'bottom-right':
-      initialMoveX = originalWidth;
-      initialMoveY = originalHeight;
-      moveX = -originalWidth;
-      moveY = -originalHeight;
+      initialMoveX = dims.width;
+      initialMoveY = dims.height;
+      moveX = -dims.width;
+      moveY = -dims.height;
       break;
     case 'center':
-      initialMoveX = originalWidth / 2;
-      initialMoveY = originalHeight / 2;
-      moveX = -originalWidth / 2;
-      moveY = -originalHeight / 2;
+      initialMoveX = dims.width / 2;
+      initialMoveY = dims.height / 2;
+      moveX = -dims.width / 2;
+      moveY = -dims.height / 2;
       break;
   }
-
-  new Effect.MoveBy(element, initialMoveY, initialMoveX, {
-    duration: 0.01,
-    beforeUpdate: function(effect) { $(element).style.height = '0px'; },
-    afterFinish: function(effect) {
+  
+  return new Effect.MoveBy(element, initialMoveY, initialMoveX, { 
+    duration: 0.01, 
+    beforeSetup: function(effect) { with(Element) {
+      hide(effect.element);
+      makeClipping(effect.element);
+      makePositioned(effect.element);
+    }},
+    afterFinishInternal: function(effect) {
       new Effect.Parallel(
-        [ new Effect.Opacity(element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }),
-          new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition }),
-          new Effect.Scale(element, 100, {
-            scaleMode: { originalHeight: originalHeight, originalWidth: originalWidth },
-            sync: true, scaleFrom: 0, scaleTo: 100, transition: scaleTransition })],
-        options); }
-    });
+        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
+          new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: options.moveTransition }),
+          new Effect.Scale(effect.element, 100, {
+            scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, 
+            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
+        ], Object.extend({
+             beforeSetup: function(effect) { with(Element) {
+               setStyle(effect.effects[0].element, {height: '0px'});
+               show(effect.effects[0].element); }},
+             afterFinishInternal: function(effect) { with(Element) {
+               [undoClipping, undoPositioned].call(effect.effects[0].element); 
+               setStyle(effect.effects[0].element, oldStyle); }}
+           }, options)
+      )
+    }
+  });
 }
 
 Effect.Shrink = function(element) {
   element = $(element);
-  var options = arguments[1] || {};
-
-  var originalWidth = element.clientWidth;
-  var originalHeight = element.clientHeight;
-  element.style.overflow = 'hidden';
-  Element.show(element);
-
-  var direction = options.direction || 'center';
-  var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
-  var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal;
-  var opacityTransition = options.opacityTransition || Effect.Transitions.none;
+  var options = Object.extend({
+    direction: 'center',
+    moveTransistion: Effect.Transitions.sinoidal,
+    scaleTransition: Effect.Transitions.sinoidal,
+    opacityTransition: Effect.Transitions.none
+  }, arguments[1] || {});
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    height: element.style.height,
+    width: element.style.width,
+    opacity: Element.getInlineOpacity(element) };
 
+  var dims = Element.getDimensions(element);
   var moveX, moveY;
-
-  switch (direction) {
+  
+  switch (options.direction) {
     case 'top-left':
       moveX = moveY = 0;
       break;
     case 'top-right':
-      moveX = originalWidth;
+      moveX = dims.width;
       moveY = 0;
       break;
     case 'bottom-left':
       moveX = 0;
-      moveY = originalHeight;
+      moveY = dims.height;
       break;
     case 'bottom-right':
-      moveX = originalWidth;
-      moveY = originalHeight;
+      moveX = dims.width;
+      moveY = dims.height;
       break;
-    case 'center':
-      moveX = originalWidth / 2;
-      moveY = originalHeight / 2;
+    case 'center':  
+      moveX = dims.width / 2;
+      moveY = dims.height / 2;
       break;
   }
-
-  new Effect.Parallel(
-    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: opacityTransition }),
-      new Effect.Scale(element, 0, { sync: true, transition: moveTransition }),
-      new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: scaleTransition }) ],
-    options);
+  
+  return new Effect.Parallel(
+    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
+      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
+      new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: options.moveTransition })
+    ], Object.extend({            
+         beforeStartInternal: function(effect) { with(Element) {
+           [makePositioned, makeClipping].call(effect.effects[0].element) }},
+         afterFinishInternal: function(effect) { with(Element) {
+           [hide, undoClipping, undoPositioned].call(effect.effects[0].element);
+           setStyle(effect.effects[0].element, oldStyle); }}
+       }, options)
+  );
 }
 
 Effect.Pulsate = function(element) {
+  element = $(element);
   var options    = arguments[1] || {};
+  var oldOpacity = Element.getInlineOpacity(element);
   var transition = options.transition || Effect.Transitions.sinoidal;
   var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
   reverser.bind(transition);
-  new Effect.Opacity(element,
-    Object.extend(Object.extend({  duration: 3.0,
-       afterFinish: function(effect) { Element.show(effect.element); }
+  return new Effect.Opacity(element, 
+    Object.extend(Object.extend({  duration: 3.0, from: 0,
+      afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); }
     }, options), {transition: reverser}));
 }
 
 Effect.Fold = function(element) {
- $(element).style.overflow = 'hidden';
- new Effect.Scale(element, 5, Object.extend({
-   scaleContent: false,
-   scaleTo: 100,
-   scaleX: false,
-   afterFinish: function(effect) {
-   new Effect.Scale(element, 1, {
-     scaleContent: false,
-     scaleTo: 0,
-     scaleY: false,
-     afterFinish: function(effect) { Element.hide(effect.element) } });
- }}, arguments[1] || {}));
-}
-
-// old: new Effect.ContentZoom(element, percent)
-// new: Element.setContentZoom(element, percent)
-
-Element.setContentZoom = function(element, percent) {
-  var element = $(element);
-  element.style.fontSize = (percent/100) + "em";
-  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+  element = $(element);
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    width: element.style.width,
+    height: element.style.height };
+  Element.makeClipping(element);
+  return new Effect.Scale(element, 5, Object.extend({   
+    scaleContent: false,
+    scaleX: false,
+    afterFinishInternal: function(effect) {
+    new Effect.Scale(element, 1, { 
+      scaleContent: false, 
+      scaleY: false,
+      afterFinishInternal: function(effect) { with(Element) {
+        [hide, undoClipping].call(effect.element); 
+        setStyle(effect.element, oldStyle);
+      }} });
+  }}, arguments[1] || {}));
 }
-
-// This MUST be the last line !
-Tobago.registerScript("/html/standard/standard/script/effects.js");

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/inputSuggest.js Fri Dec 23 03:58:10 2005
@@ -19,17 +19,37 @@
 Ajax.MyFacesAutocompleter.prototype = Object.extend(new Autocompleter.Base(),
 Object.extend(new Ajax.Base(), {
   initialize: function(element, update, url, options) {
-	  this.base_initialize(element, update, options);
+	  this.baseInitialize(element, update, options);
     this.options.asynchronous = true;
     this.options.onComplete   = this.onComplete.bind(this)
     this.options.method       = 'post';
     this.url                  = url;
+    this.options.onShow       =
+        function(element, update){
+          element.autoCompleter.setup();
+          if(!update.style.position || update.style.position=='absolute') {
+            update.style.position = 'absolute';
+            var offsets = Position.cumulativeOffset(element);
+            update.style.top    = (offsets[1] + element.offsetHeight) + 'px';
+            update.style.left   = offsets[0] + 'px';
+          }
+          Effect.Appear(update,{duration:0.15});
+        };
+    this.element.autoCompleter = this;
     LOG.debug("new Autocompleter for " + this.element.id);
   },
 
+  setup: function() {
+    if (this.update.parentNode.tagName.toUpperCase() != "BODY"){
+//      LOG.debug("Move Autocompleter DIV to BODY");
+      this.update.parentNode.removeChild(this.update);
+      Tobago.findAnchestorWithTagName(this.element, "BODY").appendChild(this.update);
+    }
+  },
+
   getUpdatedChoices: function() {
     entry = encodeURIComponent(this.element.name) + '=' 
-        + encodeURIComponent(this.getEntry());
+        + encodeURIComponent(this.getToken());
 
     this.options.parameters = this.options.callback
         ? this.options.callback(this.element, entry) : entry;
@@ -40,9 +60,16 @@
   onComplete: function(request) {
     LOG.debug("get response = " + request.responseText);
     this.updateChoices(request.responseText);
+    this.resetWidth();
+  },
+
+  resetWidth: function() {
+    this.update.style.width = this.element.offsetWidth + 'px';
+    // TODO: make offset configurable
+    var offset = this.iefix ? 2 : -8;
+    if ((this.update.scrollWidth + offset) > this.element.offsetWidth) {
+      this.update.style.width = (this.update.scrollWidth + offset) + 'px';
+    }
   }
 
 }));
-
-// This MUST be the last line !
-Tobago.registerScript("/html/standard/standard/script/inputSuggest.js");

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js Fri Dec 23 03:58:10 2005
@@ -15,8 +15,71 @@
  */
 
 
+var LOG = new Object();
+Object.extend(LOG, {
+    IdBase: "TbgLog",
+    messages: new Array(),
+    appenders: new Array(),
+    DEBUG: 1,
+    INFO:  2,
+    WARN:  3,
+    ERROR: 4,
+
+    show: function() {
+      for (var i = 0 ; i < this.appenders.length; i++) {
+        var appender = this.appenders[i];
+        if (appender.show) {
+          appender.show();
+        }
+      }
+    },
+
+    addAppender: function(appender) {
+      this.appenders.push(appender);
+    },
+
+    addMessage: function(msg) {
+      this.messages.push(msg);
+      for (var i = 0 ; i < this.appenders.length; i++) {
+        var appender = this.appenders[i];
+        if (appender.append
+            && typeof(msg.type) == "number"
+            && appender.logFor(msg.type)) {
+          appender.append(msg);
+        }
+      }
+    },
+
+    debug: function(text) {
+      this.addMessage(new LOG.LogMessage(LOG.DEBUG, text));
+    },
+
+    info  : function(text) {
+      this.addMessage(new LOG.LogMessage(LOG.INFO, text));
+    },
+
+    warn: function(text) {
+      this.addMessage(new LOG.LogMessage(LOG.WARN, text));
+    },
+
+    error: function(text) {
+      this.addMessage(new LOG.LogMessage(LOG.ERROR, text));
+    },
+
+    bindOnWindow: function() {
+      window.onerror = this.windowError.bind(this);
+    },
+
+    windowError: function(msg, url, line){
+		  var message = "Error in (" + (url || window.location) + ") on line "+ line +" with message (" + msg + ")";
+		  this.error(message);	
+    }
+});
+LOG.bindOnWindow();
+
+
 LOG.LogArea = Class.create();
-LOG.LogArea.prototype = Object.extend(Draggable.prototype).extend({
+LOG.LogArea.prototype = Object.extend(Draggable.prototype, {
   initialize: function() {
     var options = Object.extend({
       handle: false,
@@ -25,9 +88,15 @@
       endeffect: Prototype.emptyFunction,
       zindex: 1000,
       revert: false,
-      hide: false
+      snap: false,   // false, or xy or [x,y] or function(x,y){ return [x,y] }
+
+      // logging
+      hide: false,
+      severity: LOG.DEBUG
     }, arguments[0] || {});
 
+    this.options = options;
+
     if ($(LOG.IdBase)) {
       return;
     }
@@ -36,6 +105,7 @@
 //    this.element.id = LOG.IdBase + "Element"
     this.setUpLogDiv(this.element, "30px", "2px", "400px", "500px", "1px solid red", "#aaaaaa");
     this.element.style.paddingTop = "25px";
+    this.element.style.overflow = "hidden";
     this.element.style.zIndex = "9010";
 
     this.dragHandleTop = document.createElement("DIV");
@@ -53,6 +123,13 @@
     this.clearButton.innerHTML = "Clear";
     this.dragHandleTop.appendChild(this.clearButton);
 
+    this.oldButton = document.createElement("BUTTON");
+    this.oldButton.style.marginLeft = "20px";
+    this.oldButton.style.height = "20px";
+//    this.hideButton.style.float = "right";
+    this.oldButton.innerHTML = "Get old";
+    this.dragHandleTop.appendChild(this.oldButton);
+
     this.hideButton = document.createElement("BUTTON");
     this.hideButton.style.marginLeft = "20px";
     this.hideButton.style.height = "20px";
@@ -88,41 +165,31 @@
 //    this.setUpHandleDiv(this.resizeHandleSW, null, "0px", "0px", null, "5px", "5px", null, "#000000", "sw-resize");
 //    this.element.appendChild(this.resizeHandleSW);
 
-    tmpElement = document.createElement("DIV");
-    tmpElement.style.overflow = "auto";
-    tmpElement.style.widht = "100%";
-    tmpElement.style.height = "100%";
-    tmpElement.style.background = "#ffffff";
-    this.element.appendChild(tmpElement);
+    this.scrollElement = document.createElement("DIV");
+    this.scrollElement.style.overflow = "auto";
+    this.scrollElement.style.widht = "100%";
+    this.scrollElement.style.height = "100%";
+    this.scrollElement.style.background = "#ffffff";
+    this.element.appendChild(this.scrollElement);
 
     this.logList = document.createElement("OL");
     this.logList.style.fontFamily = "Arial, sans-serif";
     this.logList.style.fontSize = "10pt";
     this.logList.id = "Log";
-    tmpElement.appendChild(this.logList);
+    this.scrollElement.appendChild(this.logList);
 
     this.handle       = options.handle ? $(options.handle) : this.element;
 
     Element.makePositioned(this.element); // fix IE
 
-    this.offsetX      = 0;
-    this.offsetY      = 0;
-    this.originalLeft = this.currentLeft();
-    this.originalTop  = this.currentTop();
-    this.originalX    = this.element.offsetLeft;
-    this.originalY    = this.element.offsetTop;
-    this.originalZ    = parseInt(this.element.style.zIndex || "0");
+    this.delta    = this.currentDelta();
 
-    this.options      = options;
-
-    this.active       = false;
     this.dragging     = false;
 
-    this.eventMouseDown = this.startDrag.bindAsEventListener(this);
-    this.eventMouseUp   = this.endDrag.bindAsEventListener(this);
-    this.eventMouseMove = this.update.bindAsEventListener(this);
-    this.eventKeypress  = this.keyPress.bindAsEventListener(this);
+    this.eventMouseDown = this.initDrag.bindAsEventListener(this);
+
     this.eventClear     = this.clearList.bindAsEventListener(this);
+    this.eventOld      = this.getOld.bindAsEventListener(this);
     this.eventHide      = this.hide.bindAsEventListener(this);
     this.eventStopEvent  = this.stopEvent.bindAsEventListener(this);
 
@@ -131,28 +198,32 @@
     Event.observe(this.dragHandleRight, "mousedown", this.eventMouseDown);
     Event.observe(this.dragHandleBottom, "mousedown", this.eventMouseDown);
     Event.observe(this.dragHandleLeft, "mousedown", this.eventMouseDown);
+
     Event.observe(this.clearButton, "click", this.eventClear);
     Event.observe(this.clearButton, "mousedown", this.eventStopEvent);
+    Event.observe(this.oldButton, "click", this.eventOld);
+    Event.observe(this.oldButton, "mousedown", this.eventStopEvent);
     Event.observe(this.hideButton, "click", this.eventHide);
     Event.observe(this.hideButton, "mousedown", this.eventStopEvent);
-    Event.observe(document, "mouseup", this.eventMouseUp);
-    Event.observe(document, "mousemove", this.eventMouseMove);
-    Event.observe(document, "keypress", this.eventKeypress);
+
+    Draggables.register(this);
 
     this.body = document.getElementsByTagName("body")[0];
     this.body.tbgLogArea = this;
 
-    if (!this.options.hide) {
-      this.show();
+    if (this.options.hide) {
+      this.element.style.display = 'none';
     }
+    this.body.appendChild(this.element);
+    LOG.addAppender(this);
   },
 
   show: function() {
-    this.body.appendChild(this.element);
+    this.element.style.display = '';
   },
 
   hide: function() {
-    this.body.removeChild(this.element);
+    this.element.style.display = 'none';
   },
 
   setUpLogDiv: function(element, top, right, width, height, border, background) {
@@ -177,11 +248,54 @@
     this.logList.innerHTML = "";
   },
 
+  getOld: function() {
+    for (var i = 0 ; i < LOG.messages.length; i++) {
+      this.append(LOG.messages[i]);
+    }
+  },
+
   stopEvent: function(event) {
     Event.stop(event);
+  },
+
+  scrollToBottom: function() {
+    this.scrollElement.scrollTop = this.scrollElement.scrollHeight;
+  },
+
+  append: function(message) {
+    if (typeof(message.type) == "number" && !this.logFor(message.type)) {
+      return;
+    }
+
+    var listElement = document.createElement("li");
+
+    var logMessage;
+    if (typeof(message) == "string") {
+      logMessage = document.createTextNode(message);
+    } else if (typeof(message.type) == "number") {
+      // TODO severity marker
+      logMessage = document.createTextNode(message.message);
+    }
+    listElement.appendChild(logMessage);
+    this.logList.appendChild(listElement);
+
+    this.scrollToBottom();
+  },
+
+  logFor: function(severity) {
+    return (severity >= this.options.severity);
   }
 });
 
+LOG.LogMessage = Class.create();
+LOG.LogMessage.prototype = {
+    initialize: function(type, message) {
+      this.type = type;
+      this.message = message;
+      this.time = new Date();
+    },
 
-// This MUST be the last line !
-Tobago.registerScript("/html/standard/standard/script/logging.js");
+    displayOn: function(type) {
+      return this.type <= type;
+    }
+}

Modified: incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/popup.js
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/popup.js?rev=358796&r1=358795&r2=358796&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/popup.js (original)
+++ incubator/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/popup.js Fri Dec 23 03:58:10 2005
@@ -72,6 +72,3 @@
   return width + height + parent + dirbar + locationbar
       + menubar + resizable + scrollbars + statusbar + toolbar;
 }
-
-// This MUST be the last line !
-if (typeof(Tobago) != "undefined") { Tobago.registerScript("/html/standard/standard/script/popup.js"); }