From: <sm...@us...> - 2008-07-24 08:04:47
|
Revision: 8574 http://plplot.svn.sourceforge.net/plplot/?rev=8574&view=rev Author: smekal Date: 2008-07-24 08:04:55 +0000 (Thu, 24 Jul 2008) Log Message: ----------- New Homepage implementation, valid XHTML 1.0 Transitional, fully CSS driven. Added Paths: ----------- trunk/www/js/ trunk/www/js/slimbox.js Added: trunk/www/js/slimbox.js =================================================================== --- trunk/www/js/slimbox.js (rev 0) +++ trunk/www/js/slimbox.js 2008-07-24 08:04:55 UTC (rev 8574) @@ -0,0 +1,7 @@ +//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License. +/* + Slimbox v1.41 - The ultimate lightweight Lightbox clone + by Christophe Beyls (http://www.digitalia.be) - MIT-style license. + Inspired by the original Lightbox v2 by Lokesh Dhakar. +*/ +var MooTools={version:'1.11'};function $defined(a){return(a!=undefined)};function $type(a){if(!$defined(a))return false;if(a.htmlElement)return'element';var b=typeof a;if(b=='object'&&a.nodeName){switch(a.nodeType){case 1:return'element';case 3:return(/\S/).test(a.nodeValue)?'textnode':'whitespace'}}if(b=='object'||b=='function'){switch(a.constructor){case Array:return'array';case RegExp:return'regexp';case Class:return'class'}if(typeof a.length=='number'){if(a.item)return'collection';if(a.callee)return'arguments'}}return b};function $merge(){var a={};for(var i=0;i<arguments.length;i++){for(var b in arguments[i]){var c=arguments[i][b];var d=a[b];if(d&&$type(c)=='object'&&$type(d)=='object')a[b]=$merge(d,c);else a[b]=c}}return a};var $extend=function(){var a=arguments;if(!a[1])a=[this,a[0]];for(var b in a[1])a[0][b]=a[1][b];return a[0]};var $native=function(){for(var i=0,l=arguments.length;i<l;i++){arguments[i].extend=function(a){for(var b in a){if(!this.prototype[b])this.prototype[b]=a[b];if(!this[b])this[b]=$native.generic(b)}}}};$native.generic=function(b){return function(a){return this.prototype[b].apply(a,Array.prototype.slice.call(arguments,1))}};$native(Function,Array,String,Number);function $chk(a){return!!(a||a===0)};function $pick(a,b){return $defined(a)?a:b};function $random(a,b){return Math.floor(Math.random()*(b-a+1)+a)};function $time(){return new Date().getTime()};function $clear(a){clearTimeout(a);clearInterval(a);return null};var Abstract=function(a){a=a||{};a.extend=$extend;return a};var Window=new Abstract(window);var Document=new Abstract(document);document.head=document.getElementsByTagName('head')[0];window.xpath=!!(document.evaluate);if(window.ActiveXObject)window.ie=window[window.XMLHttpRequest?'ie7':'ie6']=true;else if(document.childNodes&&!document.all&&!navigator.taintEnabled)window.webkit=window[window.xpath?'webkit420':'webkit419']=true;else if(document.getBoxObjectFor!=null)window.gecko=true;window.khtml=window.webkit;Object.extend=$extend;if(typeof HTMLElement=='undefined'){var HTMLElement=function(){};if(window.webkit)document.createElement("iframe");HTMLElement.prototype=(window.webkit)?window["[[DOMElement.prototype]]"]:{}}HTMLElement.prototype.htmlElement=function(){};if(window.ie6)try{document.execCommand("BackgroundImageCache",false,true)}catch(e){};var Class=function(a){var b=function(){return(arguments[0]!==null&&this.initialize&&$type(this.initialize)=='function')?this.initialize.apply(this,arguments):this};$extend(b,this);b.prototype=a;b.constructor=Class;return b};Class.empty=function(){};Class.prototype={extend:function(a){var b=new this(null);for(var c in a){var d=b[c];b[c]=Class.Merge(d,a[c])}return new Class(b)},implement:function(){for(var i=0,l=arguments.length;i<l;i++)$extend(this.prototype,arguments[i])}};Class.Merge=function(a,b){if(a&&a!=b){var c=$type(b);if(c!=$type(a))return b;switch(c){case'function':var d=function(){this.parent=arguments.callee.parent;return b.apply(this,arguments)};d.parent=a;return d;case'object':return $merge(a,b)}}return b};var Chain=new Class({chain:function(a){this.chains=this.chains||[];this.chains.push(a);return this},callChain:function(){if(this.chains&&this.chains.length)this.chains.shift().delay(10,this)},clearChain:function(){this.chains=[]}});var Events=new Class({addEvent:function(a,b){if(b!=Class.empty){this.$events=this.$events||{};this.$events[a]=this.$events[a]||[];this.$events[a].include(b)}return this},fireEvent:function(b,c,d){if(this.$events&&this.$events[b]){this.$events[b].each(function(a){a.create({'bind':this,'delay':d,'arguments':c})()},this)}return this},removeEvent:function(a,b){if(this.$events&&this.$events[a])this.$events[a].remove(b);return this}});var Options=new Class({setOptions:function(){this.options=$merge.apply(null,[this.options].extend(arguments));if(this.addEvent){for(var a in this.options){if($type(this.options[a]=='function')&&(/^on[A-Z]/).test(a))this.addEvent(a,this.options[a])}}return this}});Array.extend({forEach:function(a,b){for(var i=0,j=this.length;i<j;i++)a.call(b,this[i],i,this)},filter:function(a,b){var c=[];for(var i=0,j=this.length;i<j;i++){if(a.call(b,this[i],i,this))c.push(this[i])}return c},map:function(a,b){var c=[];for(var i=0,j=this.length;i<j;i++)c[i]=a.call(b,this[i],i,this);return c},every:function(a,b){for(var i=0,j=this.length;i<j;i++){if(!a.call(b,this[i],i,this))return false}return true},some:function(a,b){for(var i=0,j=this.length;i<j;i++){if(a.call(b,this[i],i,this))return true}return false},indexOf:function(a,b){var c=this.length;for(var i=(b<0)?Math.max(0,c+b):b||0;i<c;i++){if(this[i]===a)return i}return-1},copy:function(a,b){a=a||0;if(a<0)a=this.length+a;b=b||(this.length-a);var c=[];for(var i=0;i<b;i++)c[i]=this[a++];return c},remove:function(a){var i=0;var b=this.length;while(i<b){if(this[i]===a){this.splice(i,1);b--}else{i++}}return this},contains:function(a,b){return this.indexOf(a,b)!=-1},associate:function(a){var b={},length=Math.min(this.length,a.length);for(var i=0;i<length;i++)b[a[i]]=this[i];return b},extend:function(a){for(var i=0,j=a.length;i<j;i++)this.push(a[i]);return this},merge:function(a){for(var i=0,l=a.length;i<l;i++)this.include(a[i]);return this},include:function(a){if(!this.contains(a))this.push(a);return this},getRandom:function(){return this[$random(0,this.length-1)]||null},getLast:function(){return this[this.length-1]||null}});Array.prototype.each=Array.prototype.forEach;Array.each=Array.forEach;function $A(a){return Array.copy(a)};function $each(a,b,c){if(a&&typeof a.length=='number'&&$type(a)!='object'){Array.forEach(a,b,c)}else{for(var d in a)b.call(c||a,a[d],d)}};Array.prototype.test=Array.prototype.contains;String.extend({test:function(a,b){return(($type(a)=='string')?new RegExp(a,b):a).test(this)},toInt:function(){return parseInt(this,10)},toFloat:function(){return parseFloat(this)},camelCase:function(){return this.replace(/-\D/g,function(a){return a.charAt(1).toUpperCase()})},hyphenate:function(){return this.replace(/\w[A-Z]/g,function(a){return(a.charAt(0)+'-'+a.charAt(1).toLowerCase())})},capitalize:function(){return this.replace(/\b[a-z]/g,function(a){return a.toUpperCase()})},trim:function(){return this.replace(/^\s+|\s+$/g,'')},clean:function(){return this.replace(/\s{2,}/g,' ').trim()},rgbToHex:function(a){var b=this.match(/\d{1,3}/g);return(b)?b.rgbToHex(a):false},hexToRgb:function(a){var b=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(b)?b.slice(1).hexToRgb(a):false},contains:function(a,s){return(s)?(s+this+s).indexOf(s+a+s)>-1:this.indexOf(a)>-1},escapeRegExp:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,'\\$1')}});Array.extend({rgbToHex:function(a){if(this.length<3)return false;if(this.length==4&&this[3]==0&&!a)return'transparent';var b=[];for(var i=0;i<3;i++){var c=(this[i]-0).toString(16);b.push((c.length==1)?'0'+c:c)}return a?b:'#'+b.join('')},hexToRgb:function(a){if(this.length!=3)return false;var b=[];for(var i=0;i<3;i++){b.push(parseInt((this[i].length==1)?this[i]+this[i]:this[i],16))}return a?b:'rgb('+b.join(',')+')'}});Function.extend({create:function(d){var e=this;d=$merge({'bind':e,'event':false,'arguments':null,'delay':false,'periodical':false,'attempt':false},d);if($chk(d.arguments)&&$type(d.arguments)!='array')d.arguments=[d.arguments];return function(a){var b;if(d.event){a=a||window.event;b=[(d.event===true)?a:new d.event(a)];if(d.arguments)b.extend(d.arguments)}else b=d.arguments||arguments;var c=function(){return e.apply($pick(d.bind,e),b)};if(d.delay)return setTimeout(c,d.delay);if(d.periodical)return setInterval(c,d.periodical);if(d.attempt)try{return c()}catch(err){return false};return c()}},pass:function(a,b){return this.create({'arguments':a,'bind':b})},attempt:function(a,b){return this.create({'arguments':a,'bind':b,'attempt':true})()},bind:function(a,b){return this.create({'bind':a,'arguments':b})},bindAsEventListener:function(a,b){return this.create({'bind':a,'event':true,'arguments':b})},delay:function(a,b,c){return this.create({'delay':a,'bind':b,'arguments':c})()},periodical:function(a,b,c){return this.create({'periodical':a,'bind':b,'arguments':c})()}});Number.extend({toInt:function(){return parseInt(this)},toFloat:function(){return parseFloat(this)},limit:function(a,b){return Math.min(b,Math.max(a,this))},round:function(a){a=Math.pow(10,a||0);return Math.round(this*a)/a},times:function(a){for(var i=0;i<this;i++)a(i)}});var Element=new Class({initialize:function(a,b){if($type(a)=='string'){if(window.ie&&b&&(b.name||b.type)){var c=(b.name)?' name="'+b.name+'"':'';var d=(b.type)?' type="'+b.type+'"':'';delete b.name;delete b.type;a='<'+a+c+d+'>'}a=document.createElement(a)}a=$(a);return(!b||!a)?a:a.set(b)}});var Elements=new Class({initialize:function(a){return(a)?$extend(a,this):this}});Elements.extend=function(a){for(var b in a){this.prototype[b]=a[b];this[b]=$native.generic(b)}};function $(a){if(!a)return null;if(a.htmlElement)return Garbage.collect(a);if([window,document].contains(a))return a;var b=$type(a);if(b=='string'){a=document.getElementById(a);b=(a)?'element':false}if(b!='element')return null;if(a.htmlElement)return Garbage.collect(a);if(['object','embed'].contains(a.tagName.toLowerCase()))return a;$extend(a,Element.prototype);a.htmlElement=function(){};return Garbage.collect(a)};document.getElementsBySelector=document.getElementsByTagName;function $$(){var a=[];for(var i=0,j=arguments.length;i<j;i++){var b=arguments[i];switch($type(b)){case'element':a.push(b);case'boolean':break;case false:break;case'string':b=document.getElementsBySelector(b,true);default:a.extend(b)}}return $$.unique(a)};$$.unique=function(a){var b=[];for(var i=0,l=a.length;i<l;i++){if(a[i].$included)continue;var c=$(a[i]);if(c&&!c.$included){c.$included=true;b.push(c)}}for(var n=0,d=b.length;n<d;n++)b[n].$included=null;return new Elements(b)};Elements.Multi=function(d){return function(){var a=arguments;var b=[];var c=true;for(var i=0,j=this.length,returns;i<j;i++){returns=this[i][d].apply(this[i],a);if($type(returns)!='element')c=false;b.push(returns)};return(c)?$$.unique(b):b}};Element.extend=function(a){for(var b in a){HTMLElement.prototype[b]=a[b];Element.prototype[b]=a[b];Element[b]=$native.generic(b);var c=(Array.prototype[b])?b+'Elements':b;Elements.prototype[c]=Elements.Multi(b)}};Element.extend({set:function(a){for(var b in a){var c=a[b];switch(b){case'styles':this.setStyles(c);break;case'events':if(this.addEvents)this.addEvents(c);break;case'properties':this.setProperties(c);break;default:this.setProperty(b,c)}}return this},inject:function(a,b){a=$(a);switch(b){case'before':a.parentNode.insertBefore(this,a);break;case'after':var c=a.getNext();if(!c)a.parentNode.appendChild(this);else a.parentNode.insertBefore(this,c);break;case'top':var d=a.firstChild;if(d){a.insertBefore(this,d);break}default:a.appendChild(this)}return this},injectBefore:function(a){return this.inject(a,'before')},injectAfter:function(a){return this.inject(a,'after')},injectInside:function(a){return this.inject(a,'bottom')},injectTop:function(a){return this.inject(a,'top')},adopt:function(){var b=[];$each(arguments,function(a){b=b.concat(a)});$$(b).inject(this);return this},remove:function(){return this.parentNode.removeChild(this)},clone:function(a){var b=$(this.cloneNode(a!==false));if(!b.$events)return b;b.$events={};for(var c in this.$events)b.$events[c]={'keys':$A(this.$events[c].keys),'values':$A(this.$events[c].values)};return b.removeEvents()},replaceWith:function(a){a=$(a);this.parentNode.replaceChild(a,this);return a},appendText:function(a){this.appendChild(document.createTextNode(a));return this},hasClass:function(a){return this.className.contains(a,' ')},addClass:function(a){if(!this.hasClass(a))this.className=(this.className+' '+a).clean();return this},removeClass:function(a){this.className=this.className.replace(new RegExp('(^|\\s)'+a+'(?:\\s|$)'),'$1').clean();return this},toggleClass:function(a){return this.hasClass(a)?this.removeClass(a):this.addClass(a)},setStyle:function(a,b){switch(a){case'opacity':return this.setOpacity(parseFloat(b));case'float':a=(window.ie)?'styleFloat':'cssFloat'}a=a.camelCase();switch($type(b)){case'number':if(!['zIndex','zoom'].contains(a))b+='px';break;case'array':b='rgb('+b.join(',')+')'}this.style[a]=b;return this},setStyles:function(a){switch($type(a)){case'object':Element.setMany(this,'setStyle',a);break;case'string':this.style.cssText=a}return this},setOpacity:function(a){if(a==0){if(this.style.visibility!="hidden")this.style.visibility="hidden"}else{if(this.style.visibility!="visible")this.style.visibility="visible"}if(!this.currentStyle||!this.currentStyle.hasLayout)this.style.zoom=1;if(window.ie)this.style.filter=(a==1)?'':"alpha(opacity="+a*100+")";this.style.opacity=this.$tmp.opacity=a;return this},getStyle:function(b){b=b.camelCase();var c=this.style[b];if(!$chk(c)){if(b=='opacity')return this.$tmp.opacity;c=[];for(var d in Element.Styles){if(b==d){Element.Styles[d].each(function(s){var a=this.getStyle(s);c.push(parseInt(a)?a:'0px')},this);if(b=='border'){var e=c.every(function(a){return(a==c[0])});return(e)?c[0]:false}return c.join(' ')}}if(b.contains('border')){if(Element.Styles.border.contains(b)){return['Width','Style','Color'].map(function(p){return this.getStyle(b+p)},this).join(' ')}else if(Element.borderShort.contains(b)){return['Top','Right','Bottom','Left'].map(function(p){return this.getStyle('border'+p+b.replace('border',''))},this).join(' ')}}if(document.defaultView)c=document.defaultView.getComputedStyle(this,null).getPropertyValue(b.hyphenate());else if(this.currentStyle)c=this.currentStyle[b]}if(window.ie)c=Element.fixStyle(b,c,this);if(c&&b.test(/color/i)&&c.contains('rgb')){return c.split('rgb').splice(1,4).map(function(a){return a.rgbToHex()}).join(' ')}return c},getStyles:function(){return Element.getMany(this,'getStyle',arguments)},walk:function(a,b){a+='Sibling';var c=(b)?this[b]:this[a];while(c&&$type(c)!='element')c=c[a];return $(c)},getPrevious:function(){return this.walk('previous')},getNext:function(){return this.walk('next')},getFirst:function(){return this.walk('next','firstChild')},getLast:function(){return this.walk('previous','lastChild')},getParent:function(){return $(this.parentNode)},getChildren:function(){return $$(this.childNodes)},hasChild:function(a){return!!$A(this.getElementsByTagName('*')).contains(a)},getProperty:function(a){var b=Element.Properties[a];if(b)return this[b];var c=Element.PropertiesIFlag[a]||0;if(!window.ie||c)return this.getAttribute(a,c);var d=this.attributes[a];return(d)?d.nodeValue:null},removeProperty:function(a){var b=Element.Properties[a];if(b)this[b]='';else this.removeAttribute(a);return this},getProperties:function(){return Element.getMany(this,'getProperty',arguments)},setProperty:function(a,b){var c=Element.Properties[a];if(c)this[c]=b;else this.setAttribute(a,b);return this},setProperties:function(a){return Element.setMany(this,'setProperty',a)},setHTML:function(){this.innerHTML=$A(arguments).join('');return this},setText:function(a){var b=this.getTag();if(['style','script'].contains(b)){if(window.ie){if(b=='style')this.styleSheet.cssText=a;else if(b=='script')this.setProperty('text',a);return this}else{this.removeChild(this.firstChild);return this.appendText(a)}}this[$defined(this.innerText)?'innerText':'textContent']=a;return this},getText:function(){var a=this.getTag();if(['style','script'].contains(a)){if(window.ie){if(a=='style')return this.styleSheet.cssText;else if(a=='script')return this.getProperty('text')}else{return this.innerHTML}}return($pick(this.innerText,this.textContent))},getTag:function(){return this.tagName.toLowerCase()},empty:function(){Garbage.trash(this.getElementsByTagName('*'));return this.setHTML('')}});Element.fixStyle=function(b,c,d){if($chk(parseInt(c)))return c;if(['height','width'].contains(b)){var e=(b=='width')?['left','right']:['top','bottom'];var f=0;e.each(function(a){f+=d.getStyle('border-'+a+'-width').toInt()+d.getStyle('padding-'+a).toInt()});return d['offset'+b.capitalize()]-f+'px'}else if(b.test(/border(.+)Width|margin|padding/)){return'0px'}return c};Element.Styles={'border':[],'padding':[],'margin':[]};['Top','Right','Bottom','Left'].each(function(a){for(var b in Element.Styles)Element.Styles[b].push(b+a)});Element.borderShort=['borderWidth','borderStyle','borderColor'];Element.getMany=function(b,c,d){var e={};$each(d,function(a){e[a]=b[c](a)});return e};Element.setMany=function(a,b,c){for(var d in c)a[b](d,c[d]);return a};Element.Properties=new Abstract({'class':'className','for':'htmlFor','colspan':'colSpan','rowspan':'rowSpan','accesskey':'accessKey','tabindex':'tabIndex','maxlength':'maxLength','readonly':'readOnly','frameborder':'frameBorder','value':'value','disabled':'disabled','checked':'checked','multiple':'multiple','selected':'selected'});Element.PropertiesIFlag={'href':2,'src':2};Element.Methods={Listeners:{addListener:function(a,b){if(this.addEventListener)this.addEventListener(a,b,false);else this.attachEvent('on'+a,b);return this},removeListener:function(a,b){if(this.removeEventListener)this.removeEventListener(a,b,false);else this.detachEvent('on'+a,b);return this}}};window.extend(Element.Methods.Listeners);document.extend(Element.Methods.Listeners);Element.extend(Element.Methods.Listeners);var Garbage={elements:[],collect:function(a){if(!a.$tmp){Garbage.elements.push(a);a.$tmp={'opacity':1}}return a},trash:function(a){for(var i=0,j=a.length,el;i<j;i++){if(!(el=a[i])||!el.$tmp)continue;if(el.$events)el.fireEvent('trash').removeEvents();for(var p in el.$tmp)el.$tmp[p]=null;for(var d in Element.prototype)el[d]=null;Garbage.elements[Garbage.elements.indexOf(el)]=null;el.htmlElement=el.$tmp=el=null}Garbage.elements.remove(null)},empty:function(){Garbage.collect(window);Garbage.collect(document);Garbage.trash(Garbage.elements)}};window.addListener('beforeunload',function(){window.addListener('unload',Garbage.empty);if(window.ie)window.addListener('unload',CollectGarbage)});var Event=new Class({initialize:function(a){if(a&&a.$extended)return a;this.$extended=true;a=a||window.event;this.event=a;this.type=a.type;this.target=a.target||a.srcElement;if(this.target.nodeType==3)this.target=this.target.parentNode;this.shift=a.shiftKey;this.control=a.ctrlKey;this.alt=a.altKey;this.meta=a.metaKey;if(['DOMMouseScroll','mousewheel'].contains(this.type)){this.wheel=(a.wheelDelta)?a.wheelDelta/120:-(a.detail||0)/3}else if(this.type.contains('key')){this.code=a.which||a.keyCode;for(var b in Event.keys){if(Event.keys[b]==this.code){this.key=b;break}}if(this.type=='keydown'){var c=this.code-111;if(c>0&&c<13)this.key='f'+c}this.key=this.key||String.fromCharCode(this.code).toLowerCase()}else if(this.type.test(/(click|mouse|menu)/)){this.page={'x':a.pageX||a.clientX+document.documentElement.scrollLeft,'y':a.pageY||a.clientY+document.documentElement.scrollTop};this.client={'x':a.pageX?a.pageX-window.pageXOffset:a.clientX,'y':a.pageY?a.pageY-window.pageYOffset:a.clientY};this.rightClick=(a.which==3)||(a.button==2);switch(this.type){case'mouseover':this.relatedTarget=a.relatedTarget||a.fromElement;break;case'mouseout':this.relatedTarget=a.relatedTarget||a.toElement}this.fixRelatedTarget()}return this},stop:function(){return this.stopPropagation().preventDefault()},stopPropagation:function(){if(this.event.stopPropagation)this.event.stopPropagation();else this.event.cancelBubble=true;return this},preventDefault:function(){if(this.event.preventDefault)this.event.preventDefault();else this.event.returnValue=false;return this}});Event.fix={relatedTarget:function(){if(this.relatedTarget&&this.relatedTarget.nodeType==3)this.relatedTarget=this.relatedTarget.parentNode},relatedTargetGecko:function(){try{Event.fix.relatedTarget.call(this)}catch(e){this.relatedTarget=this.target}}};Event.prototype.fixRelatedTarget=(window.gecko)?Event.fix.relatedTargetGecko:Event.fix.relatedTarget;Event.keys=new Abstract({'enter':13,'up':38,'down':40,'left':37,'right':39,'esc':27,'space':32,'backspace':8,'tab':9,'delete':46});Element.Methods.Events={addEvent:function(a,b){this.$events=this.$events||{};this.$events[a]=this.$events[a]||{'keys':[],'values':[]};if(this.$events[a].keys.contains(b))return this;this.$events[a].keys.push(b);var c=a;var d=Element.Events[a];if(d){if(d.add)d.add.call(this,b);if(d.map)b=d.map;if(d.type)c=d.type}if(!this.addEventListener)b=b.create({'bind':this,'event':true});this.$events[a].values.push(b);return(Element.NativeEvents.contains(c))?this.addListener(c,b):this},removeEvent:function(a,b){if(!this.$events||!this.$events[a])return this;var c=this.$events[a].keys.indexOf(b);if(c==-1)return this;var d=this.$events[a].keys.splice(c,1)[0];var e=this.$events[a].values.splice(c,1)[0];var f=Element.Events[a];if(f){if(f.remove)f.remove.call(this,b);if(f.type)a=f.type}return(Element.NativeEvents.contains(a))?this.removeListener(a,e):this},addEvents:function(a){return Element.setMany(this,'addEvent',a)},removeEvents:function(b){if(!this.$events)return this;if(!b){for(var c in this.$events)this.removeEvents(c);this.$events=null}else if(this.$events[b]){this.$events[b].keys.each(function(a){this.removeEvent(b,a)},this);this.$events[b]=null}return this},fireEvent:function(b,c,d){if(this.$events&&this.$events[b]){this.$events[b].keys.each(function(a){a.create({'bind':this,'delay':d,'arguments':c})()},this)}return this},cloneEvents:function(b,c){if(!b.$events)return this;if(!c){for(var d in b.$events)this.cloneEvents(b,d)}else if(b.$events[c]){b.$events[c].keys.each(function(a){this.addEvent(c,a)},this)}return this}};window.extend(Element.Methods.Events);document.extend(Element.Methods.Events);Element.extend(Element.Methods.Events);Element.Events=new Abstract({'mouseenter':{type:'mouseover',map:function(a){a=new Event(a);if(a.relatedTarget!=this&&!this.hasChild(a.relatedTarget))this.fireEvent('mouseenter',a)}},'mouseleave':{type:'mouseout',map:function(a){a=new Event(a);if(a.relatedTarget!=this&&!this.hasChild(a.relatedTarget))this.fireEvent('mouseleave',a)}},'mousewheel':{type:(window.gecko)?'DOMMouseScroll':'mousewheel'}});Element.NativeEvents=['click','dblclick','mouseup','mousedown','mousewheel','DOMMouseScroll','mouseover','mouseout','mousemove','keydown','keypress','keyup','load','unload','beforeunload','resize','move','focus','blur','change','submit','reset','select','error','abort','contextmenu','scroll'];Function.extend({bindWithEvent:function(a,b){return this.create({'bind':a,'arguments':b,'event':Event})}});Element.Events.domready={add:function(a){if(window.loaded){a.call(this);return}var b=function(){if(window.loaded)return;window.loaded=true;window.timer=$clear(window.timer);this.fireEvent('domready')}.bind(this);if(document.readyState&&window.webkit){window.timer=function(){if(['loaded','complete'].contains(document.readyState))b()}.periodical(50)}else if(document.readyState&&window.ie){if(!$('ie_ready')){var c=(window.location.protocol=='https:')?'://0':'javascript:void(0)';document.write('<script id="ie_ready" defer src="'+c+'"><\/script>');$('ie_ready').onreadystatechange=function(){if(this.readyState=='complete')b()}}}else{window.addListener("load",b);document.addListener("DOMContentLoaded",b)}}};window.onDomReady=function(a){return this.addEvent('domready',a)};window.extend({getWidth:function(){if(this.webkit419)return this.innerWidth;if(this.opera)return document.body.clientWidth;return document.documentElement.clientWidth},getHeight:function(){if(this.webkit419)return this.innerHeight;if(this.opera)return document.body.clientHeight;return document.documentElement.clientHeight},getScrollWidth:function(){if(this.ie)return Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth);if(this.webkit)return document.body.scrollWidth;return document.documentElement.scrollWidth},getScrollHeight:function(){if(this.ie)return Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight);if(this.webkit)return document.body.scrollHeight;return document.documentElement.scrollHeight},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop},getSize:function(){return{'size':{'x':this.getWidth(),'y':this.getHeight()},'scrollSize':{'x':this.getScrollWidth(),'y':this.getScrollHeight()},'scroll':{'x':this.getScrollLeft(),'y':this.getScrollTop()}}},getPosition:function(){return{'x':0,'y':0}}});var Fx={};Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(p){return-(Math.cos(Math.PI*p)-1)/2},duration:500,unit:'px',wait:true,fps:50},initialize:function(a){this.element=this.element||null;this.setOptions(a);if(this.options.initialize)this.options.initialize.call(this)},step:function(){var a=$time();if(a<this.time+this.options.duration){this.delta=this.options.transition((a-this.time)/this.options.duration);this.setNow();this.increase()}else{this.stop(true);this.set(this.to);this.fireEvent('onComplete',this.element,10);this.callChain()}},set:function(a){this.now=a;this.increase();return this},setNow:function(){this.now=this.compute(this.from,this.to)},compute:function(a,b){return(b-a)*this.delta+a},start:function(a,b){if(!this.options.wait)this.stop();else if(this.timer)return this;this.from=a;this.to=b;this.change=this.to-this.from;this.time=$time();this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);this.fireEvent('onStart',this.element);return this},stop:function(a){if(!this.timer)return this;this.timer=$clear(this.timer);if(!a)this.fireEvent('onCancel',this.element);return this},custom:function(a,b){return this.start(a,b)},clearTimer:function(a){return this.stop(a)}});Fx.Base.implement(new Chain,new Events,new Options);Fx.CSS={select:function(a,b){if(a.test(/color/i))return this.Color;var c=$type(b);if((c=='array')||(c=='string'&&b.contains(' ')))return this.Multi;return this.Single},parse:function(a,b,c){if(!c.push)c=[c];var d=c[0],to=c[1];if(!$chk(to)){to=d;d=a.getStyle(b)}var e=this.select(b,to);return{'from':e.parse(d),'to':e.parse(to),'css':e}}};Fx.CSS.Single={parse:function(a){return parseFloat(a)},getNow:function(a,b,c){return c.compute(a,b)},getValue:function(a,b,c){if(b=='px'&&c!='opacity')a=Math.round(a);return a+b}};Fx.CSS.Multi={parse:function(a){return a.push?a:a.split(' ').map(function(v){return parseFloat(v)})},getNow:function(a,b,c){var d=[];for(var i=0;i<a.length;i++)d[i]=c.compute(a[i],b[i]);return d},getValue:function(a,b,c){if(b=='px'&&c!='opacity')a=a.map(Math.round);return a.join(b+' ')+b}};Fx.CSS.Color={parse:function(a){return a.push?a:a.hexToRgb(true)},getNow:function(a,b,c){var d=[];for(var i=0;i<a.length;i++)d[i]=Math.round(c.compute(a[i],b[i]));return d},getValue:function(a){return'rgb('+a.join(',')+')'}};Fx.Style=Fx.Base.extend({initialize:function(a,b,c){this.element=$(a);this.property=b;this.parent(c)},hide:function(){return this.set(0)},setNow:function(){this.now=this.css.getNow(this.from,this.to,this)},set:function(a){this.css=Fx.CSS.select(this.property,a);return this.parent(this.css.parse(a))},start:function(a,b){if(this.timer&&this.options.wait)return this;var c=Fx.CSS.parse(this.element,this.property,[a,b]);this.css=c.css;return this.parent(c.from,c.to)},increase:function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property))}});Element.extend({effect:function(a,b){return new Fx.Style(this,a,b)}});Fx.Styles=Fx.Base.extend({initialize:function(a,b){this.element=$(a);this.parent(b)},setNow:function(){for(var p in this.from)this.now[p]=this.css[p].getNow(this.from[p],this.to[p],this)},set:function(a){var b={};this.css={};for(var p in a){this.css[p]=Fx.CSS.select(p,a[p]);b[p]=this.css[p].parse(a[p])}return this.parent(b)},start:function(a){if(this.timer&&this.options.wait)return this;this.now={};this.css={};var b={},to={};for(var p in a){var c=Fx.CSS.parse(this.element,p,a[p]);b[p]=c.from;to[p]=c.to;this.css[p]=c.css}return this.parent(b,to)},increase:function(){for(var p in this.now)this.element.setStyle(p,this.css[p].getValue(this.now[p],this.options.unit,p))}});Element.extend({effects:function(a){return new Fx.Styles(this,a)}});var Lightbox={init:function(b){this.options=$extend({resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true},b||{});this.anchors=[];$each(document.links,function(a){if(a.rel&&a.rel.test(/^lightbox/i)){a.onclick=this.click.pass(a,this);this.anchors.push(a)}},this);this.eventKeyDown=this.keyboardListener.bindAsEventListener(this);this.eventPosition=this.position.bind(this);this.overlay=new Element('div',{'id':'lbOverlay'}).injectInside(document.body);this.center=new Element('div',{'id':'lbCenter','styles':{'width':this.options.initialWidth,'height':this.options.initialHeight,'marginLeft':-(this.options.initialWidth/2),'display':'none'}}).injectInside(document.body);this.image=new Element('div',{'id':'lbImage'}).injectInside(this.center);this.prevLink=new Element('a',{'id':'lbPrevLink','href':'#','styles':{'display':'none'}}).injectInside(this.image);this.nextLink=this.prevLink.clone().setProperty('id','lbNextLink').injectInside(this.image);this.prevLink.onclick=this.previous.bind(this);this.nextLink.onclick=this.next.bind(this);this.bottomContainer=new Element('div',{'id':'lbBottomContainer','styles':{'display':'none'}}).injectInside(document.body);this.bottom=new Element('div',{'id':'lbBottom'}).injectInside(this.bottomContainer);new Element('a',{'id':'lbCloseLink','href':'#'}).injectInside(this.bottom).onclick=this.overlay.onclick=this.close.bind(this);this.caption=new Element('div',{'id':'lbCaption'}).injectInside(this.bottom);this.number=new Element('div',{'id':'lbNumber'}).injectInside(this.bottom);new Element('div',{'styles':{'clear':'both'}}).injectInside(this.bottom);var c=this.nextEffect.bind(this);this.fx={overlay:this.overlay.effect('opacity',{duration:500}).hide(),resize:this.center.effects($extend({duration:this.options.resizeDuration,onComplete:c},this.options.resizeTransition?{transition:this.options.resizeTransition}:{})),image:this.image.effect('opacity',{duration:500,onComplete:c}),bottom:this.bottom.effect('margin-top',{duration:400,onComplete:c})};this.preloadPrev=new Image();this.preloadNext=new Image()},click:function(b){if(b.rel.length==8)return this.show(b.href,b.title);var j,imageNum,images=[];this.anchors.each(function(a){if(a.rel==b.rel){for(j=0;j<images.length;j++)if(images[j][0]==a.href)break;if(j==images.length){images.push([a.href,a.title]);if(a.href==b.href)imageNum=j}}},this);return this.open(images,imageNum)},show:function(a,b){return this.open([[a,b]],0)},open:function(a,b){this.images=a;this.position();this.setup(true);this.top=window.getScrollTop()+(window.getHeight()/15);this.center.setStyles({top:this.top,display:''});this.fx.overlay.start(0.8);return this.changeImage(b)},position:function(){this.overlay.setStyles({'top':window.getScrollTop(),'height':window.getHeight()})},setup:function(b){var c=$A(document.getElementsByTagName('object'));c.extend(document.getElementsByTagName(window.ie?'select':'embed'));c.each(function(a){if(b)a.lbBackupStyle=a.style.visibility;a.style.visibility=b?'hidden':a.lbBackupStyle});var d=b?'addEvent':'removeEvent';window[d]('scroll',this.eventPosition)[d]('resize',this.eventPosition);document[d]('keydown',this.eventKeyDown);this.step=0},keyboardListener:function(a){switch(a.keyCode){case 27:case 88:case 67:this.close();break;case 37:case 80:this.previous();break;case 39:case 78:this.next()}},previous:function(){return this.changeImage(this.activeImage-1)},next:function(){return this.changeImage(this.activeImage+1)},changeImage:function(a){if(this.step||(a<0)||(a>=this.images.length))return false;this.step=1;this.activeImage=a;this.bottomContainer.style.display=this.prevLink.style.display=this.nextLink.style.display='none';this.fx.image.hide();this.center.className='lbLoading';this.preload=new Image();this.preload.onload=this.nextEffect.bind(this);this.preload.src=this.images[a][0];return false},nextEffect:function(){switch(this.step++){case 1:this.center.className='';this.image.style.backgroundImage='url('+this.images[this.activeImage][0]+')';this.image.style.width=this.bottom.style.width=this.preload.width+'px';this.image.style.height=this.prevLink.style.height=this.nextLink.style.height=this.preload.height+'px';this.caption.setHTML(this.images[this.activeImage][1]||'');this.number.setHTML((!this.options.showCounter||(this.images.length==1))?'':'Image '+(this.activeImage+1)+' of '+this.images.length);if(this.activeImage)this.preloadPrev.src=this.images[this.activeImage-1][0];if(this.activeImage!=(this.images.length-1))this.preloadNext.src=this.images[this.activeImage+1][0];if(this.center.clientHeight!=this.image.offsetHeight){this.fx.resize.start({height:this.image.offsetHeight});break}this.step++;case 2:if(this.center.clientWidth!=this.image.offsetWidth){this.fx.resize.start({width:this.image.offsetWidth,marginLeft:-this.image.offsetWidth/2});break}this.step++;case 3:this.bottomContainer.setStyles({top:this.top+this.center.clientHeight,height:0,marginLeft:this.center.style.marginLeft,display:''});this.fx.image.start(1);break;case 4:if(this.options.animateCaption){this.fx.bottom.set(-this.bottom.offsetHeight);this.bottomContainer.style.height='';this.fx.bottom.start(0);break}this.bottomContainer.style.height='';case 5:if(this.activeImage)this.prevLink.style.display='';if(this.activeImage!=(this.images.length-1))this.nextLink.style.display='';this.step=0}},close:function(){if(this.step<0)return;this.step=-1;if(this.preload){this.preload.onload=Class.empty;this.preload=null}for(var f in this.fx)this.fx[f].stop();this.center.style.display=this.bottomContainer.style.display='none';this.fx.overlay.chain(this.setup.pass(false,this)).start(0);return false}};window.addEvent('domready',Lightbox.init.bind(Lightbox)); \ No newline at end of file Property changes on: trunk/www/js/slimbox.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |