1 2// MooTools: the javascript framework. 3// Load this file's selection again by visiting: http://mootools.net/more/777f20ee39b438de94ffb908da026aef 4// Or build this file again with packager using: packager build More/Fx.Scroll More/Scroller 5/* 6--- 7copyrights: 8 - [MooTools](http://mootools.net) 9 10licenses: 11 - [MIT License](http://mootools.net/license.txt) 12... 13*/ 14MooTools.More={version:"1.3.2.1",build:"e586bcd2496e9b22acfde32e12f84d49ce09e59d"};(function(){Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(c,b){this.element=this.subject=document.id(c); 15this.parent(b);if(typeOf(this.element)!="element"){this.element=document.id(this.element.getDocument().body);}if(this.options.wheelStops){var d=this.element,e=this.cancel.pass(false,this); 16this.addEvent("start",function(){d.addEvent("mousewheel",e);},true);this.addEvent("complete",function(){d.removeEvent("mousewheel",e);},true);}},set:function(){var b=Array.flatten(arguments); 17if(Browser.firefox){b=[Math.round(b[0]),Math.round(b[1])];}this.element.scrollTo(b[0],b[1]);return this;},compute:function(d,c,b){return[0,1].map(function(e){return Fx.compute(d[e],c[e],b); 18});},start:function(c,d){if(!this.check(c,d)){return this;}var b=this.element.getScroll();return this.parent([b.x,b.y],[c,d]);},calculateScroll:function(g,f){var d=this.element,b=d.getScrollSize(),h=d.getScroll(),j=d.getSize(),c=this.options.offset,i={x:g,y:f}; 19for(var e in i){if(!i[e]&&i[e]!==0){i[e]=h[e];}if(typeOf(i[e])!="number"){i[e]=b[e]-j[e];}i[e]+=c[e];}return[i.x,i.y];},toTop:function(){return this.start.apply(this,this.calculateScroll(false,0)); 20},toLeft:function(){return this.start.apply(this,this.calculateScroll(0,false));},toRight:function(){return this.start.apply(this,this.calculateScroll("right",false)); 21},toBottom:function(){return this.start.apply(this,this.calculateScroll(false,"bottom"));},toElement:function(d,e){e=e?Array.from(e):["x","y"];var c=a(this.element)?{x:0,y:0}:this.element.getScroll(); 22var b=Object.map(document.id(d).getPosition(this.element),function(g,f){return e.contains(f)?g+c[f]:false;});return this.start.apply(this,this.calculateScroll(b.x,b.y)); 23},toElementEdge:function(d,g,e){g=g?Array.from(g):["x","y"];d=document.id(d);var i={},f=d.getPosition(this.element),j=d.getSize(),h=this.element.getScroll(),b=this.element.getSize(),c={x:f.x+j.x,y:f.y+j.y}; 24["x","y"].each(function(k){if(g.contains(k)){if(c[k]>h[k]+b[k]){i[k]=c[k]-b[k];}if(f[k]<h[k]){i[k]=f[k];}}if(i[k]==null){i[k]=h[k];}if(e&&e[k]){i[k]=i[k]+e[k]; 25}},this);if(i.x!=h.x||i.y!=h.y){this.start(i.x,i.y);}return this;},toElementCenter:function(e,f,h){f=f?Array.from(f):["x","y"];e=document.id(e);var i={},c=e.getPosition(this.element),d=e.getSize(),b=this.element.getScroll(),g=this.element.getSize(); 26["x","y"].each(function(j){if(f.contains(j)){i[j]=c[j]-(g[j]-d[j])/2;}if(i[j]==null){i[j]=b[j];}if(h&&h[j]){i[j]=i[j]+h[j];}},this);if(i.x!=b.x||i.y!=b.y){this.start(i.x,i.y); 27}return this;}});function a(b){return(/^(?:body|html)$/i).test(b.tagName);}})();var Scroller=new Class({Implements:[Events,Options],options:{area:20,velocity:1,onChange:function(a,b){this.element.scrollTo(a,b); 28},fps:50},initialize:function(b,a){this.setOptions(a);this.element=document.id(b);this.docBody=document.id(this.element.getDocument().body);this.listener=(typeOf(this.element)!="element")?this.docBody:this.element; 29this.timer=null;this.bound={attach:this.attach.bind(this),detach:this.detach.bind(this),getCoords:this.getCoords.bind(this)};},start:function(){this.listener.addEvents({mouseover:this.bound.attach,mouseleave:this.bound.detach}); 30return this;},stop:function(){this.listener.removeEvents({mouseover:this.bound.attach,mouseleave:this.bound.detach});this.detach();this.timer=clearInterval(this.timer); 31return this;},attach:function(){this.listener.addEvent("mousemove",this.bound.getCoords);},detach:function(){this.listener.removeEvent("mousemove",this.bound.getCoords); 32this.timer=clearInterval(this.timer);},getCoords:function(a){this.page=(this.listener.get("tag")=="body")?a.client:a.page;if(!this.timer){this.timer=this.scroll.periodical(Math.round(1000/this.options.fps),this); 33}},scroll:function(){var c=this.element.getSize(),a=this.element.getScroll(),h=this.element!=this.docBody?this.element.getOffsets():{x:0,y:0},d=this.element.getScrollSize(),g={x:0,y:0},e=this.options.area.top||this.options.area,b=this.options.area.bottom||this.options.area; 34for(var f in this.page){if(this.page[f]<(e+h[f])&&a[f]!=0){g[f]=(this.page[f]-e-h[f])*this.options.velocity;}else{if(this.page[f]+b>(c[f]+h[f])&&a[f]+c[f]!=d[f]){g[f]=(this.page[f]-c[f]+b-h[f])*this.options.velocity; 35}}g[f]=g[f].round();}if(g.y||g.x){this.fireEvent("change",[a.x+g.x,a.y+g.y]);}}}); 36 37/* 38--- 39description: scrollGallery 40 41authors: 42- Benedikt Morschheuser (http://software.bmo-design.de) 43
44license: 45- MIT-style license 46 47requires: 48- core/1.3.1: '*' 49- more/1.3.1: 'Fx.Scroll, Scroller' 50 51provides: [scrollGallery] 52 53... 54*/ 55var scrollGallery = null; 56 57(function($){ 58 59 scrollGallery = new Class({ 60 61 Implements: [Events, Options], 62 63 options: { 64 'start': 1, 65 'area': 200, 66 'thumbarea': 'thumbarea', 67 'imagearea': 'imagearea', 68 'speed': 0.1, 69 'clickable': true, 70 'autoScroll': false, 71 'diashowDelay': null, 72 'toElementClass': null, 73 'enableSwipeMode': false, 74 'thumbOpacity': 100 75 /* Events...*/ 76 }, 77 78 initialize: function(options){ 79 this.setOptions(options); 80 Scroller.implement(new Events, new Options); 81 82 this.tumbObjs=null; 83 this.imgObjs=null; 84 85 this.activeImgNum=0; 86 87 //Workaround 88 if((Browser.safari||Browser.chrome)&&this.safariWorkaround!=true){ 89 this.safariWorkaround=true; 90 91 window.addEvent('load', function() { 92 this.initialize.delay(10, this, options); 93 }.bind(this)); 94 } 95 //FX 96 if($(this.options.imagearea)){ 97 this.scrollimageareaFx = new Fx.Scroll(this.options.imagearea,{wheelStops: false}); 98 } 99 //AutoScroll 100 //init Thumb-Images 101 if($(this.options.thumbarea)){ 102 // init tumbObjs 103 this.tumbObjs = $(this.options.thumbarea).getElements('img'); 104 if($(this.options.imagearea)){ 105 Array.each(this.tumbObjs, function(imgObjekt, index){ 106 imgObjekt.addEvent('click', function(index){ 107 this.scrollToImg(index); 108 }.bind(this).pass(index)); 109 110 if(index==this.options.start){ 111 imgObjekt.fireEvent('click',this,10);//delay for safari 112 } 113 }.bind(this)); 114 } 115 //thumbOpacity 116 if(this.options.thumbOpacity.toInt()<100){ 117 if(this.options.thumbOpacity.toInt()<=0) 118 this.options.thumbOpacity=1; 119 if(this.options.thumbOpacity.toInt()<10) 120 this.options.thumbOpacity='0'+this.options.thumbOpacity.toInt().toString(); 121 Array.each(this.tumbObjs, function(thumbObjekt, index){ 122 if(this.activeImgNum==index){ 123 thumbObjekt.set('opacity','1'); 124 }else{ 125 thumbObjekt.set('opacity','.' + this.options.thumbOpacity); 126 } 127 }.bind(this)); 128 } 129 //scrollEvents 130 if($(this.options.thumbarea).getScrollSize().x>$(this.options.thumbarea).getSize().x){//check if scrollable 131 if(this.options.autoScroll==false){ 132 if(this.options.enableSwipeMode&&Browser.Features.Touch){//mobile version 133 //do nothing - user can swipe 134 }else{ 135 this.scrollthumbareaFx = new Scroller($(this.options.thumbarea), {area: this.options.area, velocity: this.options.speed, direction: "x"}); 136 $(this.options.thumbarea).setStyle('overflow-x', 'hidden'); 137 // Thumb Events 138 $(this.options.thumbarea).addEvent('mouseenter', this.scrollthumbareaFx.start.bind(this.scrollthumbareaFx)); 139 $(this.options.thumbarea).addEvent('mouseleave', this.scrollthumbareaFx.stop.bind(this.scrollthumbareaFx)); 140 } 141 }else{ 142 $(this.options.thumbarea).setStyle('overflow-x', 'hidden'); 143 var scrollSize = $(this.options.thumbarea).getScrollSize(); 144 var scrollTo = scrollSize.x; 145 var cloneContainer = this.tumbObjs[0].getParent("div"); 146 if($(this.options.thumbarea).getElements('img').length==this.tumbObjs.length){/*if not already cloned*/ 147 Array.each(this.tumbObjs, function(imgObjekt, index){ 148 if(imgObjekt.getParent().tagName!="DIV"&&imgObjekt.getParent().tagName!="div"){ 149 var theClone=imgObjekt.getParent().clone(); 150 cloneContainer.adopt(theClone); 151 theClone.getElement('img').cloneEvents(imgObjekt); 152 }else{ 153 cloneContainer.adopt(imgObjekt.clone().cloneEvents(imgObjekt)); 154 } 155 }.bind(this)); 156 157 this.scrollthumbareaFx = new Fx.Scroll(this.options.thumbarea,{ 158 'duration': 300*this.options.speed*scrollSize.x/2, 159 'transition': Fx.Transitions.linear, 160 'link': 'ignore', 161 onComplete: function(){ 162 this.scrollthumbareaFx.set(0,0); 163 this.scrollthumbareaFx.start(scrollTo,'x'); 164 }.bind(this), 165 onCancel: function(){ 166 var scrollTo = $(this.options.thumbarea).getScrollSize().x; 167 this.scrollthumbareaFx.start(scrollTo,'x'); 168 }.bind(this), 169 'wheelStops': false 170 }); 171 this.scrollthumbareaFx.set(0,0); 172 this.scrollthumbareaFx.start(scrollTo,'x'); 173 $(this.options.thumbarea).addEvent('mouseenter', function(){//little backup fix 174 var scrollTo = $(this.options.thumbarea).getScrollSize().x; 175 this.scrollthumbareaFx.start(scrollTo,'x'); 176 }.bind(this)); 177 } 178 } 179 }else{ 180 this.options.autoScroll=false; 181 } 182 }else{ 183 console.error('Missing thumbarea'); 184 } 185 //init Images 186 if($(this.options.imagearea)){ 187 $(this.options.imagearea).setStyle('overflow', 'hidden'); 188 $(this.options.imagearea).setStyle('overflow-x', 'hidden'); 189 // init imgObjs 190 if(this.options.toElementClass!=null){ 191 this.imgObjs=$(this.options.imagearea).getElements(this.options.toElementClass.toString()); 192 }else{ 193 this.imgObjs=$(this.options.imagearea).getElements('img'); 194 } 195 if(this.options.clickable){ 196 $(this.options.imagearea).getElement('div').setStyle('cursor', 'pointer'); 197 Array.each(this.imgObjs, function(imgObjekt, index){ 198 imgObjekt.addEvent('click', function(index){ 199 this.scrollToImg(index+1); 200 }.bind(this).pass(index)); 201 }.bind(this)); 202 } 203 if(this.options.enableSwipeMode&&Browser.Features.Touch){//mobile version optional 204 $(this.options.imagearea).removeEvents('swipe'); 205 $(this.options.imagearea).addEvent('swipe', function(event){ 206 if(event.direction=='right'){ 207 this.prev(); 208 }else{ 209 this.next(); 210 } 211 }.bind(this)); 212 } 213 this.initDiashow(); 214 }else{ 215 console.error('Missing imagearea'); 216 } 217 218 //check 219 if(this.imgObjs&&this.tumbObjs) 220 if(this.imgObjs.length!=this.tumbObjs.length) 221 console.error("Error: The number of images does not match!"); 222 }, 223 initDiashow: function(){ 224 if(this.options.diashowDelay!=null&&this.options.diashowDelay>=1){ 225 clearInterval(this.diashow); 226 this.diashow = this.next.periodical(this.options.diashowDelay*1000,this); 227 } 228 }, 229 scrollToImg: function(index){ 230 if(index>=this.imgObjs.length) 231 index=0; 232 if(this.options.thumbOpacity.toInt()<100&&$(this.options.thumbarea)){ 233 this.tumbObjs[index].set('opacity','1'); 234 if(index!=this.activeImgNum) 235 this.tumbObjs[this.activeImgNum].set('opacity','.' + this.options.thumbOpacity); 236 if(this.options.autoScroll!=false){ 237 var allclonedtumbObjs = $(this.options.thumbarea).getElements('img');
238 if(allclonedtumbObjs.length!=this.tumbObjs.length){ 239 allclonedtumbObjs[(this.tumbObjs.length+index)].set('opacity','1'); 240 if(index!=this.activeImgNum) 241 allclonedtumbObjs[(this.tumbObjs.length+this.activeImgNum)].set('opacity','.' + this.options.thumbOpacity); 242 } 243 } 244 } 245 this.scrollimageareaFx.toElement(this.imgObjs[index]); 246 this.activeImgNum=index; 247 this.initDiashow(); //reinit to reset time 248 }, 249 next: function(){ 250 this.scrollToImg(this.activeImgNum+1); 251 }, 252 prev: function(){ 253 this.scrollToImg(this.activeImgNum-1); 254 } 255 }); 256})(document.id);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.