-
+ 8D811C88CEEEA3F18F44C44F87AAAE52F5E5D5C242EDCAEE6E7ADFD440ADE0BC037117FC3F2CED34DF3B3646D8002F0CD11EBE2C0F6E18487FD1526882FBAE5Emp-wp/wp-includes/js/scriptaculous/effects.js(0 . 0)(1 . 1122)
109759 // script.aculo.us effects.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
109760
109761 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
109762 // Contributors:
109763 // Justin Palmer (http://encytemedia.com/)
109764 // Mark Pilgrim (http://diveintomark.org/)
109765 // Martin Bialasinki
109766 //
109767 // script.aculo.us is freely distributable under the terms of an MIT-style license.
109768 // For details, see the script.aculo.us web site: http://script.aculo.us/
109769
109770 // converts rgb() and #xxx to #xxxxxx format,
109771 // returns self (or first argument) if not convertable
109772 String.prototype.parseColor = function() {
109773 var color = '#';
109774 if (this.slice(0,4) == 'rgb(') {
109775 var cols = this.slice(4,this.length-1).split(',');
109776 var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
109777 } else {
109778 if (this.slice(0,1) == '#') {
109779 if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
109780 if (this.length==7) color = this.toLowerCase();
109781 }
109782 }
109783 return (color.length==7 ? color : (arguments[0] || this));
109784 };
109785
109786 /*--------------------------------------------------------------------------*/
109787
109788 Element.collectTextNodes = function(element) {
109789 return $A($(element).childNodes).collect( function(node) {
109790 return (node.nodeType==3 ? node.nodeValue :
109791 (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
109792 }).flatten().join('');
109793 };
109794
109795 Element.collectTextNodesIgnoreClass = function(element, className) {
109796 return $A($(element).childNodes).collect( function(node) {
109797 return (node.nodeType==3 ? node.nodeValue :
109798 ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
109799 Element.collectTextNodesIgnoreClass(node, className) : ''));
109800 }).flatten().join('');
109801 };
109802
109803 Element.setContentZoom = function(element, percent) {
109804 element = $(element);
109805 element.setStyle({fontSize: (percent/100) + 'em'});
109806 if (Prototype.Browser.WebKit) window.scrollBy(0,0);
109807 return element;
109808 };
109809
109810 Element.getInlineOpacity = function(element){
109811 return $(element).style.opacity || '';
109812 };
109813
109814 Element.forceRerendering = function(element) {
109815 try {
109816 element = $(element);
109817 var n = document.createTextNode(' ');
109818 element.appendChild(n);
109819 element.removeChild(n);
109820 } catch(e) { }
109821 };
109822
109823 /*--------------------------------------------------------------------------*/
109824
109825 var Effect = {
109826 _elementDoesNotExistError: {
109827 name: 'ElementDoesNotExistError',
109828 message: 'The specified DOM element does not exist, but is required for this effect to operate'
109829 },
109830 Transitions: {
109831 linear: Prototype.K,
109832 sinoidal: function(pos) {
109833 return (-Math.cos(pos*Math.PI)/2) + 0.5;
109834 },
109835 reverse: function(pos) {
109836 return 1-pos;
109837 },
109838 flicker: function(pos) {
109839 var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
109840 return pos > 1 ? 1 : pos;
109841 },
109842 wobble: function(pos) {
109843 return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
109844 },
109845 pulse: function(pos, pulses) {
109846 pulses = pulses || 5;
109847 return (
109848 ((pos % (1/pulses)) * pulses).round() == 0 ?
109849 ((pos * pulses * 2) - (pos * pulses * 2).floor()) :
109850 1 - ((pos * pulses * 2) - (pos * pulses * 2).floor())
109851 );
109852 },
109853 spring: function(pos) {
109854 return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
109855 },
109856 none: function(pos) {
109857 return 0;
109858 },
109859 full: function(pos) {
109860 return 1;
109861 }
109862 },
109863 DefaultOptions: {
109864 duration: 1.0, // seconds
109865 fps: 100, // 100= assume 66fps max.
109866 sync: false, // true for combining
109867 from: 0.0,
109868 to: 1.0,
109869 delay: 0.0,
109870 queue: 'parallel'
109871 },
109872 tagifyText: function(element) {
109873 var tagifyStyle = 'position:relative';
109874 if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';
109875
109876 element = $(element);
109877 $A(element.childNodes).each( function(child) {
109878 if (child.nodeType==3) {
109879 child.nodeValue.toArray().each( function(character) {
109880 element.insertBefore(
109881 new Element('span', {style: tagifyStyle}).update(
109882 character == ' ' ? String.fromCharCode(160) : character),
109883 child);
109884 });
109885 Element.remove(child);
109886 }
109887 });
109888 },
109889 multiple: function(element, effect) {
109890 var elements;
109891 if (((typeof element == 'object') ||
109892 Object.isFunction(element)) &&
109893 (element.length))
109894 elements = element;
109895 else
109896 elements = $(element).childNodes;
109897
109898 var options = Object.extend({
109899 speed: 0.1,
109900 delay: 0.0
109901 }, arguments[2] || { });
109902 var masterDelay = options.delay;
109903
109904 $A(elements).each( function(element, index) {
109905 new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
109906 });
109907 },
109908 PAIRS: {
109909 'slide': ['SlideDown','SlideUp'],
109910 'blind': ['BlindDown','BlindUp'],
109911 'appear': ['Appear','Fade']
109912 },
109913 toggle: function(element, effect) {
109914 element = $(element);
109915 effect = (effect || 'appear').toLowerCase();
109916 var options = Object.extend({
109917 queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
109918 }, arguments[2] || { });
109919 Effect[element.visible() ?
109920 Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
109921 }
109922 };
109923
109924 Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
109925
109926 /* ------------- core effects ------------- */
109927
109928 Effect.ScopedQueue = Class.create(Enumerable, {
109929 initialize: function() {
109930 this.effects = [];
109931 this.interval = null;
109932 },
109933 _each: function(iterator) {
109934 this.effects._each(iterator);
109935 },
109936 add: function(effect) {
109937 var timestamp = new Date().getTime();
109938
109939 var position = Object.isString(effect.options.queue) ?
109940 effect.options.queue : effect.options.queue.position;
109941
109942 switch(position) {
109943 case 'front':
109944 // move unstarted effects after this effect
109945 this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
109946 e.startOn += effect.finishOn;
109947 e.finishOn += effect.finishOn;
109948 });
109949 break;
109950 case 'with-last':
109951 timestamp = this.effects.pluck('startOn').max() || timestamp;
109952 break;
109953 case 'end':
109954 // start effect after last queued effect has finished
109955 timestamp = this.effects.pluck('finishOn').max() || timestamp;
109956 break;
109957 }
109958
109959 effect.startOn += timestamp;
109960 effect.finishOn += timestamp;
109961
109962 if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
109963 this.effects.push(effect);
109964
109965 if (!this.interval)
109966 this.interval = setInterval(this.loop.bind(this), 15);
109967 },
109968 remove: function(effect) {
109969 this.effects = this.effects.reject(function(e) { return e==effect });
109970 if (this.effects.length == 0) {
109971 clearInterval(this.interval);
109972 this.interval = null;
109973 }
109974 },
109975 loop: function() {
109976 var timePos = new Date().getTime();
109977 for(var i=0, len=this.effects.length;i<len;i++)
109978 this.effects[i] && this.effects[i].loop(timePos);
109979 }
109980 });
109981
109982 Effect.Queues = {
109983 instances: $H(),
109984 get: function(queueName) {
109985 if (!Object.isString(queueName)) return queueName;
109986
109987 return this.instances.get(queueName) ||
109988 this.instances.set(queueName, new Effect.ScopedQueue());
109989 }
109990 };
109991 Effect.Queue = Effect.Queues.get('global');
109992
109993 Effect.Base = Class.create({
109994 position: null,
109995 start: function(options) {
109996 function codeForEvent(options,eventName){
109997 return (
109998 (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
109999 (options[eventName] ? 'this.options.'+eventName+'(this);' : '')
110000 );
110001 }
110002 if (options && options.transition === false) options.transition = Effect.Transitions.linear;
110003 this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
110004 this.currentFrame = 0;
110005 this.state = 'idle';
110006 this.startOn = this.options.delay*1000;
110007 this.finishOn = this.startOn+(this.options.duration*1000);
110008 this.fromToDelta = this.options.to-this.options.from;
110009 this.totalTime = this.finishOn-this.startOn;
110010 this.totalFrames = this.options.fps*this.options.duration;
110011
110012 eval('this.render = function(pos){ '+
110013 'if (this.state=="idle"){this.state="running";'+
110014 codeForEvent(this.options,'beforeSetup')+
110015 (this.setup ? 'this.setup();':'')+
110016 codeForEvent(this.options,'afterSetup')+
110017 '};if (this.state=="running"){'+
110018 'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
110019 'this.position=pos;'+
110020 codeForEvent(this.options,'beforeUpdate')+
110021 (this.update ? 'this.update(pos);':'')+
110022 codeForEvent(this.options,'afterUpdate')+
110023 '}}');
110024
110025 this.event('beforeStart');
110026 if (!this.options.sync)
110027 Effect.Queues.get(Object.isString(this.options.queue) ?
110028 'global' : this.options.queue.scope).add(this);
110029 },
110030 loop: function(timePos) {
110031 if (timePos >= this.startOn) {
110032 if (timePos >= this.finishOn) {
110033 this.render(1.0);
110034 this.cancel();
110035 this.event('beforeFinish');
110036 if (this.finish) this.finish();
110037 this.event('afterFinish');
110038 return;
110039 }
110040 var pos = (timePos - this.startOn) / this.totalTime,
110041 frame = (pos * this.totalFrames).round();
110042 if (frame > this.currentFrame) {
110043 this.render(pos);
110044 this.currentFrame = frame;
110045 }
110046 }
110047 },
110048 cancel: function() {
110049 if (!this.options.sync)
110050 Effect.Queues.get(Object.isString(this.options.queue) ?
110051 'global' : this.options.queue.scope).remove(this);
110052 this.state = 'finished';
110053 },
110054 event: function(eventName) {
110055 if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
110056 if (this.options[eventName]) this.options[eventName](this);
110057 },
110058 inspect: function() {
110059 var data = $H();
110060 for(property in this)
110061 if (!Object.isFunction(this[property])) data.set(property, this[property]);
110062 return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
110063 }
110064 });
110065
110066 Effect.Parallel = Class.create(Effect.Base, {
110067 initialize: function(effects) {
110068 this.effects = effects || [];
110069 this.start(arguments[1]);
110070 },
110071 update: function(position) {
110072 this.effects.invoke('render', position);
110073 },
110074 finish: function(position) {
110075 this.effects.each( function(effect) {
110076 effect.render(1.0);
110077 effect.cancel();
110078 effect.event('beforeFinish');
110079 if (effect.finish) effect.finish(position);
110080 effect.event('afterFinish');
110081 });
110082 }
110083 });
110084
110085 Effect.Tween = Class.create(Effect.Base, {
110086 initialize: function(object, from, to) {
110087 object = Object.isString(object) ? $(object) : object;
110088 var args = $A(arguments), method = args.last(),
110089 options = args.length == 5 ? args[3] : null;
110090 this.method = Object.isFunction(method) ? method.bind(object) :
110091 Object.isFunction(object[method]) ? object[method].bind(object) :
110092 function(value) { object[method] = value };
110093 this.start(Object.extend({ from: from, to: to }, options || { }));
110094 },
110095 update: function(position) {
110096 this.method(position);
110097 }
110098 });
110099
110100 Effect.Event = Class.create(Effect.Base, {
110101 initialize: function() {
110102 this.start(Object.extend({ duration: 0 }, arguments[0] || { }));
110103 },
110104 update: Prototype.emptyFunction
110105 });
110106
110107 Effect.Opacity = Class.create(Effect.Base, {
110108 initialize: function(element) {
110109 this.element = $(element);
110110 if (!this.element) throw(Effect._elementDoesNotExistError);
110111 // make this work on IE on elements without 'layout'
110112 if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
110113 this.element.setStyle({zoom: 1});
110114 var options = Object.extend({
110115 from: this.element.getOpacity() || 0.0,
110116 to: 1.0
110117 }, arguments[1] || { });
110118 this.start(options);
110119 },
110120 update: function(position) {
110121 this.element.setOpacity(position);
110122 }
110123 });
110124
110125 Effect.Move = Class.create(Effect.Base, {
110126 initialize: function(element) {
110127 this.element = $(element);
110128 if (!this.element) throw(Effect._elementDoesNotExistError);
110129 var options = Object.extend({
110130 x: 0,
110131 y: 0,
110132 mode: 'relative'
110133 }, arguments[1] || { });
110134 this.start(options);
110135 },
110136 setup: function() {
110137 this.element.makePositioned();
110138 this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
110139 this.originalTop = parseFloat(this.element.getStyle('top') || '0');
110140 if (this.options.mode == 'absolute') {
110141 this.options.x = this.options.x - this.originalLeft;
110142 this.options.y = this.options.y - this.originalTop;
110143 }
110144 },
110145 update: function(position) {
110146 this.element.setStyle({
110147 left: (this.options.x * position + this.originalLeft).round() + 'px',
110148 top: (this.options.y * position + this.originalTop).round() + 'px'
110149 });
110150 }
110151 });
110152
110153 // for backwards compatibility
110154 Effect.MoveBy = function(element, toTop, toLeft) {
110155 return new Effect.Move(element,
110156 Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
110157 };
110158
110159 Effect.Scale = Class.create(Effect.Base, {
110160 initialize: function(element, percent) {
110161 this.element = $(element);
110162 if (!this.element) throw(Effect._elementDoesNotExistError);
110163 var options = Object.extend({
110164 scaleX: true,
110165 scaleY: true,
110166 scaleContent: true,
110167 scaleFromCenter: false,
110168 scaleMode: 'box', // 'box' or 'contents' or { } with provided values
110169 scaleFrom: 100.0,
110170 scaleTo: percent
110171 }, arguments[2] || { });
110172 this.start(options);
110173 },
110174 setup: function() {
110175 this.restoreAfterFinish = this.options.restoreAfterFinish || false;
110176 this.elementPositioning = this.element.getStyle('position');
110177
110178 this.originalStyle = { };
110179 ['top','left','width','height','fontSize'].each( function(k) {
110180 this.originalStyle[k] = this.element.style[k];
110181 }.bind(this));
110182
110183 this.originalTop = this.element.offsetTop;
110184 this.originalLeft = this.element.offsetLeft;
110185
110186 var fontSize = this.element.getStyle('font-size') || '100%';
110187 ['em','px','%','pt'].each( function(fontSizeType) {
110188 if (fontSize.indexOf(fontSizeType)>0) {
110189 this.fontSize = parseFloat(fontSize);
110190 this.fontSizeType = fontSizeType;
110191 }
110192 }.bind(this));
110193
110194 this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
110195
110196 this.dims = null;
110197 if (this.options.scaleMode=='box')
110198 this.dims = [this.element.offsetHeight, this.element.offsetWidth];
110199 if (/^content/.test(this.options.scaleMode))
110200 this.dims = [this.element.scrollHeight, this.element.scrollWidth];
110201 if (!this.dims)
110202 this.dims = [this.options.scaleMode.originalHeight,
110203 this.options.scaleMode.originalWidth];
110204 },
110205 update: function(position) {
110206 var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
110207 if (this.options.scaleContent && this.fontSize)
110208 this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
110209 this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
110210 },
110211 finish: function(position) {
110212 if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
110213 },
110214 setDimensions: function(height, width) {
110215 var d = { };
110216 if (this.options.scaleX) d.width = width.round() + 'px';
110217 if (this.options.scaleY) d.height = height.round() + 'px';
110218 if (this.options.scaleFromCenter) {
110219 var topd = (height - this.dims[0])/2;
110220 var leftd = (width - this.dims[1])/2;
110221 if (this.elementPositioning == 'absolute') {
110222 if (this.options.scaleY) d.top = this.originalTop-topd + 'px';
110223 if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
110224 } else {
110225 if (this.options.scaleY) d.top = -topd + 'px';
110226 if (this.options.scaleX) d.left = -leftd + 'px';
110227 }
110228 }
110229 this.element.setStyle(d);
110230 }
110231 });
110232
110233 Effect.Highlight = Class.create(Effect.Base, {
110234 initialize: function(element) {
110235 this.element = $(element);
110236 if (!this.element) throw(Effect._elementDoesNotExistError);
110237 var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });
110238 this.start(options);
110239 },
110240 setup: function() {
110241 // Prevent executing on elements not in the layout flow
110242 if (this.element.getStyle('display')=='none') { this.cancel(); return; }
110243 // Disable background image during the effect
110244 this.oldStyle = { };
110245 if (!this.options.keepBackgroundImage) {
110246 this.oldStyle.backgroundImage = this.element.getStyle('background-image');
110247 this.element.setStyle({backgroundImage: 'none'});
110248 }
110249 if (!this.options.endcolor)
110250 this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
110251 if (!this.options.restorecolor)
110252 this.options.restorecolor = this.element.getStyle('background-color');
110253 // init color calculations
110254 this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
110255 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));
110256 },
110257 update: function(position) {
110258 this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
110259 return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });
110260 },
110261 finish: function() {
110262 this.element.setStyle(Object.extend(this.oldStyle, {
110263 backgroundColor: this.options.restorecolor
110264 }));
110265 }
110266 });
110267
110268 Effect.ScrollTo = function(element) {
110269 var options = arguments[1] || { },
110270 scrollOffsets = document.viewport.getScrollOffsets(),
110271 elementOffsets = $(element).cumulativeOffset(),
110272 max = (window.height || document.body.scrollHeight) - document.viewport.getHeight();
110273
110274 if (options.offset) elementOffsets[1] += options.offset;
110275
110276 return new Effect.Tween(null,
110277 scrollOffsets.top,
110278 elementOffsets[1] > max ? max : elementOffsets[1],
110279 options,
110280 function(p){ scrollTo(scrollOffsets.left, p.round()) }
110281 );
110282 };
110283
110284 /* ------------- combination effects ------------- */
110285
110286 Effect.Fade = function(element) {
110287 element = $(element);
110288 var oldOpacity = element.getInlineOpacity();
110289 var options = Object.extend({
110290 from: element.getOpacity() || 1.0,
110291 to: 0.0,
110292 afterFinishInternal: function(effect) {
110293 if (effect.options.to!=0) return;
110294 effect.element.hide().setStyle({opacity: oldOpacity});
110295 }
110296 }, arguments[1] || { });
110297 return new Effect.Opacity(element,options);
110298 };
110299
110300 Effect.Appear = function(element) {
110301 element = $(element);
110302 var options = Object.extend({
110303 from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
110304 to: 1.0,
110305 // force Safari to render floated elements properly
110306 afterFinishInternal: function(effect) {
110307 effect.element.forceRerendering();
110308 },
110309 beforeSetup: function(effect) {
110310 effect.element.setOpacity(effect.options.from).show();
110311 }}, arguments[1] || { });
110312 return new Effect.Opacity(element,options);
110313 };
110314
110315 Effect.Puff = function(element) {
110316 element = $(element);
110317 var oldStyle = {
110318 opacity: element.getInlineOpacity(),
110319 position: element.getStyle('position'),
110320 top: element.style.top,
110321 left: element.style.left,
110322 width: element.style.width,
110323 height: element.style.height
110324 };
110325 return new Effect.Parallel(
110326 [ new Effect.Scale(element, 200,
110327 { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
110328 new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
110329 Object.extend({ duration: 1.0,
110330 beforeSetupInternal: function(effect) {
110331 Position.absolutize(effect.effects[0].element)
110332 },
110333 afterFinishInternal: function(effect) {
110334 effect.effects[0].element.hide().setStyle(oldStyle); }
110335 }, arguments[1] || { })
110336 );
110337 };
110338
110339 Effect.BlindUp = function(element) {
110340 element = $(element);
110341 element.makeClipping();
110342 return new Effect.Scale(element, 0,
110343 Object.extend({ scaleContent: false,
110344 scaleX: false,
110345 restoreAfterFinish: true,
110346 afterFinishInternal: function(effect) {
110347 effect.element.hide().undoClipping();
110348 }
110349 }, arguments[1] || { })
110350 );
110351 };
110352
110353 Effect.BlindDown = function(element) {
110354 element = $(element);
110355 var elementDimensions = element.getDimensions();
110356 return new Effect.Scale(element, 100, Object.extend({
110357 scaleContent: false,
110358 scaleX: false,
110359 scaleFrom: 0,
110360 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
110361 restoreAfterFinish: true,
110362 afterSetup: function(effect) {
110363 effect.element.makeClipping().setStyle({height: '0px'}).show();
110364 },
110365 afterFinishInternal: function(effect) {
110366 effect.element.undoClipping();
110367 }
110368 }, arguments[1] || { }));
110369 };
110370
110371 Effect.SwitchOff = function(element) {
110372 element = $(element);
110373 var oldOpacity = element.getInlineOpacity();
110374 return new Effect.Appear(element, Object.extend({
110375 duration: 0.4,
110376 from: 0,
110377 transition: Effect.Transitions.flicker,
110378 afterFinishInternal: function(effect) {
110379 new Effect.Scale(effect.element, 1, {
110380 duration: 0.3, scaleFromCenter: true,
110381 scaleX: false, scaleContent: false, restoreAfterFinish: true,
110382 beforeSetup: function(effect) {
110383 effect.element.makePositioned().makeClipping();
110384 },
110385 afterFinishInternal: function(effect) {
110386 effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
110387 }
110388 })
110389 }
110390 }, arguments[1] || { }));
110391 };
110392
110393 Effect.DropOut = function(element) {
110394 element = $(element);
110395 var oldStyle = {
110396 top: element.getStyle('top'),
110397 left: element.getStyle('left'),
110398 opacity: element.getInlineOpacity() };
110399 return new Effect.Parallel(
110400 [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
110401 new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
110402 Object.extend(
110403 { duration: 0.5,
110404 beforeSetup: function(effect) {
110405 effect.effects[0].element.makePositioned();
110406 },
110407 afterFinishInternal: function(effect) {
110408 effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
110409 }
110410 }, arguments[1] || { }));
110411 };
110412
110413 Effect.Shake = function(element) {
110414 element = $(element);
110415 var options = Object.extend({
110416 distance: 20,
110417 duration: 0.5
110418 }, arguments[1] || {});
110419 var distance = parseFloat(options.distance);
110420 var split = parseFloat(options.duration) / 10.0;
110421 var oldStyle = {
110422 top: element.getStyle('top'),
110423 left: element.getStyle('left') };
110424 return new Effect.Move(element,
110425 { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) {
110426 new Effect.Move(effect.element,
110427 { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
110428 new Effect.Move(effect.element,
110429 { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
110430 new Effect.Move(effect.element,
110431 { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
110432 new Effect.Move(effect.element,
110433 { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) {
110434 new Effect.Move(effect.element,
110435 { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
110436 effect.element.undoPositioned().setStyle(oldStyle);
110437 }}) }}) }}) }}) }}) }});
110438 };
110439
110440 Effect.SlideDown = function(element) {
110441 element = $(element).cleanWhitespace();
110442 // SlideDown need to have the content of the element wrapped in a container element with fixed height!
110443 var oldInnerBottom = element.down().getStyle('bottom');
110444 var elementDimensions = element.getDimensions();
110445 return new Effect.Scale(element, 100, Object.extend({
110446 scaleContent: false,
110447 scaleX: false,
110448 scaleFrom: window.opera ? 0 : 1,
110449 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
110450 restoreAfterFinish: true,
110451 afterSetup: function(effect) {
110452 effect.element.makePositioned();
110453 effect.element.down().makePositioned();
110454 if (window.opera) effect.element.setStyle({top: ''});
110455 effect.element.makeClipping().setStyle({height: '0px'}).show();
110456 },
110457 afterUpdateInternal: function(effect) {
110458 effect.element.down().setStyle({bottom:
110459 (effect.dims[0] - effect.element.clientHeight) + 'px' });
110460 },
110461 afterFinishInternal: function(effect) {
110462 effect.element.undoClipping().undoPositioned();
110463 effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
110464 }, arguments[1] || { })
110465 );
110466 };
110467
110468 Effect.SlideUp = function(element) {
110469 element = $(element).cleanWhitespace();
110470 var oldInnerBottom = element.down().getStyle('bottom');
110471 var elementDimensions = element.getDimensions();
110472 return new Effect.Scale(element, window.opera ? 0 : 1,
110473 Object.extend({ scaleContent: false,
110474 scaleX: false,
110475 scaleMode: 'box',
110476 scaleFrom: 100,
110477 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
110478 restoreAfterFinish: true,
110479 afterSetup: function(effect) {
110480 effect.element.makePositioned();
110481 effect.element.down().makePositioned();
110482 if (window.opera) effect.element.setStyle({top: ''});
110483 effect.element.makeClipping().show();
110484 },
110485 afterUpdateInternal: function(effect) {
110486 effect.element.down().setStyle({bottom:
110487 (effect.dims[0] - effect.element.clientHeight) + 'px' });
110488 },
110489 afterFinishInternal: function(effect) {
110490 effect.element.hide().undoClipping().undoPositioned();
110491 effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});
110492 }
110493 }, arguments[1] || { })
110494 );
110495 };
110496
110497 // Bug in opera makes the TD containing this element expand for a instance after finish
110498 Effect.Squish = function(element) {
110499 return new Effect.Scale(element, window.opera ? 1 : 0, {
110500 restoreAfterFinish: true,
110501 beforeSetup: function(effect) {
110502 effect.element.makeClipping();
110503 },
110504 afterFinishInternal: function(effect) {
110505 effect.element.hide().undoClipping();
110506 }
110507 });
110508 };
110509
110510 Effect.Grow = function(element) {
110511 element = $(element);
110512 var options = Object.extend({
110513 direction: 'center',
110514 moveTransition: Effect.Transitions.sinoidal,
110515 scaleTransition: Effect.Transitions.sinoidal,
110516 opacityTransition: Effect.Transitions.full
110517 }, arguments[1] || { });
110518 var oldStyle = {
110519 top: element.style.top,
110520 left: element.style.left,
110521 height: element.style.height,
110522 width: element.style.width,
110523 opacity: element.getInlineOpacity() };
110524
110525 var dims = element.getDimensions();
110526 var initialMoveX, initialMoveY;
110527 var moveX, moveY;
110528
110529 switch (options.direction) {
110530 case 'top-left':
110531 initialMoveX = initialMoveY = moveX = moveY = 0;
110532 break;
110533 case 'top-right':
110534 initialMoveX = dims.width;
110535 initialMoveY = moveY = 0;
110536 moveX = -dims.width;
110537 break;
110538 case 'bottom-left':
110539 initialMoveX = moveX = 0;
110540 initialMoveY = dims.height;
110541 moveY = -dims.height;
110542 break;
110543 case 'bottom-right':
110544 initialMoveX = dims.width;
110545 initialMoveY = dims.height;
110546 moveX = -dims.width;
110547 moveY = -dims.height;
110548 break;
110549 case 'center':
110550 initialMoveX = dims.width / 2;
110551 initialMoveY = dims.height / 2;
110552 moveX = -dims.width / 2;
110553 moveY = -dims.height / 2;
110554 break;
110555 }
110556
110557 return new Effect.Move(element, {
110558 x: initialMoveX,
110559 y: initialMoveY,
110560 duration: 0.01,
110561 beforeSetup: function(effect) {
110562 effect.element.hide().makeClipping().makePositioned();
110563 },
110564 afterFinishInternal: function(effect) {
110565 new Effect.Parallel(
110566 [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
110567 new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
110568 new Effect.Scale(effect.element, 100, {
110569 scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
110570 sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
110571 ], Object.extend({
110572 beforeSetup: function(effect) {
110573 effect.effects[0].element.setStyle({height: '0px'}).show();
110574 },
110575 afterFinishInternal: function(effect) {
110576 effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
110577 }
110578 }, options)
110579 )
110580 }
110581 });
110582 };
110583
110584 Effect.Shrink = function(element) {
110585 element = $(element);
110586 var options = Object.extend({
110587 direction: 'center',
110588 moveTransition: Effect.Transitions.sinoidal,
110589 scaleTransition: Effect.Transitions.sinoidal,
110590 opacityTransition: Effect.Transitions.none
110591 }, arguments[1] || { });
110592 var oldStyle = {
110593 top: element.style.top,
110594 left: element.style.left,
110595 height: element.style.height,
110596 width: element.style.width,
110597 opacity: element.getInlineOpacity() };
110598
110599 var dims = element.getDimensions();
110600 var moveX, moveY;
110601
110602 switch (options.direction) {
110603 case 'top-left':
110604 moveX = moveY = 0;
110605 break;
110606 case 'top-right':
110607 moveX = dims.width;
110608 moveY = 0;
110609 break;
110610 case 'bottom-left':
110611 moveX = 0;
110612 moveY = dims.height;
110613 break;
110614 case 'bottom-right':
110615 moveX = dims.width;
110616 moveY = dims.height;
110617 break;
110618 case 'center':
110619 moveX = dims.width / 2;
110620 moveY = dims.height / 2;
110621 break;
110622 }
110623
110624 return new Effect.Parallel(
110625 [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
110626 new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
110627 new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
110628 ], Object.extend({
110629 beforeStartInternal: function(effect) {
110630 effect.effects[0].element.makePositioned().makeClipping();
110631 },
110632 afterFinishInternal: function(effect) {
110633 effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
110634 }, options)
110635 );
110636 };
110637
110638 Effect.Pulsate = function(element) {
110639 element = $(element);
110640 var options = arguments[1] || { };
110641 var oldOpacity = element.getInlineOpacity();
110642 var transition = options.transition || Effect.Transitions.sinoidal;
110643 var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
110644 reverser.bind(transition);
110645 return new Effect.Opacity(element,
110646 Object.extend(Object.extend({ duration: 2.0, from: 0,
110647 afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
110648 }, options), {transition: reverser}));
110649 };
110650
110651 Effect.Fold = function(element) {
110652 element = $(element);
110653 var oldStyle = {
110654 top: element.style.top,
110655 left: element.style.left,
110656 width: element.style.width,
110657 height: element.style.height };
110658 element.makeClipping();
110659 return new Effect.Scale(element, 5, Object.extend({
110660 scaleContent: false,
110661 scaleX: false,
110662 afterFinishInternal: function(effect) {
110663 new Effect.Scale(element, 1, {
110664 scaleContent: false,
110665 scaleY: false,
110666 afterFinishInternal: function(effect) {
110667 effect.element.hide().undoClipping().setStyle(oldStyle);
110668 } });
110669 }}, arguments[1] || { }));
110670 };
110671
110672 Effect.Morph = Class.create(Effect.Base, {
110673 initialize: function(element) {
110674 this.element = $(element);
110675 if (!this.element) throw(Effect._elementDoesNotExistError);
110676 var options = Object.extend({
110677 style: { }
110678 }, arguments[1] || { });
110679
110680 if (!Object.isString(options.style)) this.style = $H(options.style);
110681 else {
110682 if (options.style.include(':'))
110683 this.style = options.style.parseStyle();
110684 else {
110685 this.element.addClassName(options.style);
110686 this.style = $H(this.element.getStyles());
110687 this.element.removeClassName(options.style);
110688 var css = this.element.getStyles();
110689 this.style = this.style.reject(function(style) {
110690 return style.value == css[style.key];
110691 });
110692 options.afterFinishInternal = function(effect) {
110693 effect.element.addClassName(effect.options.style);
110694 effect.transforms.each(function(transform) {
110695 effect.element.style[transform.style] = '';
110696 });
110697 }
110698 }
110699 }
110700 this.start(options);
110701 },
110702
110703 setup: function(){
110704 function parseColor(color){
110705 if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
110706 color = color.parseColor();
110707 return $R(0,2).map(function(i){
110708 return parseInt( color.slice(i*2+1,i*2+3), 16 )
110709 });
110710 }
110711 this.transforms = this.style.map(function(pair){
110712 var property = pair[0], value = pair[1], unit = null;
110713
110714 if (value.parseColor('#zzzzzz') != '#zzzzzz') {
110715 value = value.parseColor();
110716 unit = 'color';
110717 } else if (property == 'opacity') {
110718 value = parseFloat(value);
110719 if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
110720 this.element.setStyle({zoom: 1});
110721 } else if (Element.CSS_LENGTH.test(value)) {
110722 var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
110723 value = parseFloat(components[1]);
110724 unit = (components.length == 3) ? components[2] : null;
110725 }
110726
110727 var originalValue = this.element.getStyle(property);
110728 return {
110729 style: property.camelize(),
110730 originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),
110731 targetValue: unit=='color' ? parseColor(value) : value,
110732 unit: unit
110733 };
110734 }.bind(this)).reject(function(transform){
110735 return (
110736 (transform.originalValue == transform.targetValue) ||
110737 (
110738 transform.unit != 'color' &&
110739 (isNaN(transform.originalValue) || isNaN(transform.targetValue))
110740 )
110741 )
110742 });
110743 },
110744 update: function(position) {
110745 var style = { }, transform, i = this.transforms.length;
110746 while(i--)
110747 style[(transform = this.transforms[i]).style] =
110748 transform.unit=='color' ? '#'+
110749 (Math.round(transform.originalValue[0]+
110750 (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
110751 (Math.round(transform.originalValue[1]+
110752 (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
110753 (Math.round(transform.originalValue[2]+
110754 (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
110755 (transform.originalValue +
110756 (transform.targetValue - transform.originalValue) * position).toFixed(3) +
110757 (transform.unit === null ? '' : transform.unit);
110758 this.element.setStyle(style, true);
110759 }
110760 });
110761
110762 Effect.Transform = Class.create({
110763 initialize: function(tracks){
110764 this.tracks = [];
110765 this.options = arguments[1] || { };
110766 this.addTracks(tracks);
110767 },
110768 addTracks: function(tracks){
110769 tracks.each(function(track){
110770 track = $H(track);
110771 var data = track.values().first();
110772 this.tracks.push($H({
110773 ids: track.keys().first(),
110774 effect: Effect.Morph,
110775 options: { style: data }
110776 }));
110777 }.bind(this));
110778 return this;
110779 },
110780 play: function(){
110781 return new Effect.Parallel(
110782 this.tracks.map(function(track){
110783 var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');
110784 var elements = [$(ids) || $$(ids)].flatten();
110785 return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });
110786 }).flatten(),
110787 this.options
110788 );
110789 }
110790 });
110791
110792 Element.CSS_PROPERTIES = $w(
110793 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +
110794 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
110795 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
110796 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
110797 'fontSize fontWeight height left letterSpacing lineHeight ' +
110798 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
110799 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
110800 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
110801 'right textIndent top width wordSpacing zIndex');
110802
110803 Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
110804
110805 String.__parseStyleElement = document.createElement('div');
110806 String.prototype.parseStyle = function(){
110807 var style, styleRules = $H();
110808 if (Prototype.Browser.WebKit)
110809 style = new Element('div',{style:this}).style;
110810 else {
110811 String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
110812 style = String.__parseStyleElement.childNodes[0].style;
110813 }
110814
110815 Element.CSS_PROPERTIES.each(function(property){
110816 if (style[property]) styleRules.set(property, style[property]);
110817 });
110818
110819 if (Prototype.Browser.IE && this.include('opacity'))
110820 styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
110821
110822 return styleRules;
110823 };
110824
110825 if (document.defaultView && document.defaultView.getComputedStyle) {
110826 Element.getStyles = function(element) {
110827 var css = document.defaultView.getComputedStyle($(element), null);
110828 return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {
110829 styles[property] = css[property];
110830 return styles;
110831 });
110832 };
110833 } else {
110834 Element.getStyles = function(element) {
110835 element = $(element);
110836 var css = element.currentStyle, styles;
110837 styles = Element.CSS_PROPERTIES.inject({ }, function(hash, property) {
110838 hash.set(property, css[property]);
110839 return hash;
110840 });
110841 if (!styles.opacity) styles.set('opacity', element.getOpacity());
110842 return styles;
110843 };
110844 };
110845
110846 Effect.Methods = {
110847 morph: function(element, style) {
110848 element = $(element);
110849 new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
110850 return element;
110851 },
110852 visualEffect: function(element, effect, options) {
110853 element = $(element)
110854 var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
110855 new Effect[klass](element, options);
110856 return element;
110857 },
110858 highlight: function(element, options) {
110859 element = $(element);
110860 new Effect.Highlight(element, options);
110861 return element;
110862 }
110863 };
110864
110865 $w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
110866 'pulsate shake puff squish switchOff dropOut').each(
110867 function(effect) {
110868 Effect.Methods[effect] = function(element, options){
110869 element = $(element);
110870 Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
110871 return element;
110872 }
110873 }
110874 );
110875
110876 $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(
110877 function(f) { Effect.Methods[f] = Element[f]; }
110878 );
110879
110880 Element.addMethods(Effect.Methods);