impress/public/assets/effects.js

12 lines
24 KiB
JavaScript
Raw Normal View History

// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
// Martin Bialasinki
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
// converts rgb() and #xxx to #xxxxxx format,
// returns self (or first argument) if not convertable
String.prototype.parseColor=function(){var e="#";if(this.slice(0,4)=="rgb("){var t=this.slice(4,this.length-1).split(","),n=0;do e+=parseInt(t[n]).toColorPart();while(++n<3)}else if(this.slice(0,1)=="#"){if(this.length==4)for(var n=1;n<4;n++)e+=(this.charAt(n)+this.charAt(n)).toLowerCase();this.length==7&&(e=this.toLowerCase())}return e.length==7?e:arguments[0]||this},Element.collectTextNodes=function(e){return $A($(e).childNodes).collect(function(e){return e.nodeType==3?e.nodeValue:e.hasChildNodes()?Element.collectTextNodes(e):""}).flatten().join("")},Element.collectTextNodesIgnoreClass=function(e,t){return $A($(e).childNodes).collect(function(e){return e.nodeType==3?e.nodeValue:e.hasChildNodes()&&!Element.hasClassName(e,t)?Element.collectTextNodesIgnoreClass(e,t):""}).flatten().join("")},Element.setContentZoom=function(e,t){return e=$(e),e.setStyle({fontSize:t/100+"em"}),Prototype.Browser.WebKit&&window.scrollBy(0,0),e},Element.getInlineOpacity=function(e){return $(e).style.opacity||""},Element.forceRerendering=function(e){try{e=$(e);var t=document.createTextNode(" ");e.appendChild(t),e.removeChild(t)}catch(n){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(e){return-Math.cos(e*Math.PI)/2+.5},reverse:function(e){return 1-e},flicker:function(e){var e=-Math.cos(e*Math.PI)/4+.75+Math.random()/4;return e>1?1:e},wobble:function(e){return-Math.cos(e*Math.PI*9*e)/2+.5},pulse:function(e,t){return-Math.cos(e*((t||5)-.5)*2*Math.PI)/2+.5},spring:function(e){return 1-Math.cos(e*4.5*Math.PI)*Math.exp(-e*6)},none:function(e){return 0},full:function(e){return 1}},DefaultOptions:{duration:1,fps:100,sync:!1,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(e){var t="position:relative";Prototype.Browser.IE&&(t+=";zoom:1"),e=$(e),$A(e.childNodes).each(function(n){n.nodeType==3&&(n.nodeValue.toArray().each(function(r){e.insertBefore((new Element("span",{style:t})).update(r==" "?String.fromCharCode(160):r),n)}),Element.remove(n))})},multiple:function(e,t){var n;(typeof e=="object"||Object.isFunction(e))&&e.length?n=e:n=$(e).childNodes;var r=Object.extend({speed:.1,delay:0},arguments[2]||{}),i=r.delay;$A(n).each(function(e,n){new t(e,Object.extend(r,{delay:n*r.speed+i}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(e,t,n){return e=$(e),t=(t||"appear").toLowerCase(),Effect[Effect.PAIRS[t][e.visible()?1:0]](e,Object.extend({queue:{position:"end",scope:e.id||"global",limit:1}},n||{}))}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal,Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[],this.interval=null},_each:function(e){this.effects._each(e)},add:function(e){var t=(new Date).getTime(),n=Object.isString(e.options.queue)?e.options.queue:e.options.queue.position;switch(n){case"front":this.effects.findAll(function(e){return e.state=="idle"}).each(function(t){t.startOn+=e.finishOn,t.finishOn+=e.finishOn});break;case"with-last":t=this.effects.pluck("startOn").max()||t;break;case"end":t=this.effects.pluck("finishOn").max()||t}e.startOn+=t,e.finishOn+=t,(!e.options.queue.limit||this.effects.length<e.options.queue.limit)&&this.effects.push(e),this.interval||(this.interval=setInterval(this.loop.bind(this),15))},remove:function(e){this.effects=this.effects.reject(function(t){return t==e}),this.effects.length==0&&(clearInterval(this.interval),this.interval=null)},loop:function(){var e=(new Date).getTime();for(var t=0,n=this.effects.length;t<n;t++)this.effects[t]&&this.effects[t].loop(e)}}),Effect.Queues={instances:$H(),get:function(e){return Object.isString(e)?this.instances.get(e)||this.instances.set(e,new Effect.ScopedQueue):e}},Effect.Queue=Effect.Queues.get("global"),Effect.Base=Class.create({position:null,start:function(e){e&&e.transition===!1&&(e.transition=Effect.Transitions.linear),this.options=Object.extend(Object.extend({},Effect.DefaultOptions),e||{}),this.