PageSourceSearch

http://www.scandoil.com/moxie-bm2/bm.assets/lightbox_sm.js

js scandoil.com collected 2026-10-02 12:46:47 UTC 9,589 bytes, 189 lines download raw bytes

1/*  ----------------------------------------------------------------------
2 *  This is a compressed and slightly modified version of:
3 * 	Lightbox v2.05
4 *	by Lokesh Dhakar - http://www.lokeshdhakar.com
5 *	Last Modification: 3/18/11
6 *
7 *	For more information, visit:
8 *	http://lokeshdhakar.com/projects/lightbox2/
9 *
10 *	Licensed under the Creative Commons Attribution 2.5 License
11 *  http://creativecommons.org/licenses/by/2.5/
12 *  - Free for use in both personal and commercial projects
13 *	- Attribution requires leaving author name, author link, and the license
14 *    info intact.
15 *	
16 *  Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com),
17 *  and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets.
18 *  Artemy Tregubenko (arty.name) for cleanup and help in updating to latest
19 *  ver of proto-aculous.
20 *  --------------------------------------------------------------------- */
21LightboxOptions=Object.extend({fileLoadingImage:BM.assetsDir+"/lightbox_loading.gif",fileBottomNavCloseImage:BM.assetsDir+"/lightbox_close.gif",overlayOpacity:0.8,animate:true,resizeSpeed:9,borderSize:10,labelImage:"",labelOf:"/"},window.LightboxOptions||{});
22var Lightbox=Class.create();
23Lightbox.prototype={imageArray:[],activeImage:undefined,initialize:function(){this.updateImageList(
23);
24this.keyboardAction=this.keyboardAction.bindAsEventListener(this);
25if(LightboxOptions.resizeSpeed>10){LightboxOptions.resizeSpeed=10
26}if(LightboxOptions.resizeSpeed<1){LightboxOptions.resizeSpeed=1
27}this.resizeDuration=LightboxOptions.animate?((11-LightboxOptions.resizeSpeed)*0.15):0;
28this.overlayDuration=LightboxOptions.animate?0.2:0;
29var b=(LightboxOptions.animate?250:1)+"px";
30var a=$$("body")[0];
31a.appendChild(Builder.node("div",{id:"bmlbox_overlay"}));
32a.appendChild(Builder.node("div",{id:"bmlbox_lightbox"},[Builder.node("div",{id:"bmlbox_outerImageContainer"},Builder.node("div",{id:"bmlbox_imageContainer"},[Builder.node("img",{id:"bmlbox_lightboxImage"}),Builder.node("div",{id:"bmlbox_hoverNav"},[Builder.node("a",{id:"bmlbox_prevLink",href:"#"}),Builder.node("a",{id:"bmlbox_nextLink",href:"#"})]),Builder.node("div",{id:"bmlbox_loading"},Builder.node("a",{id:"bmlbox_loadingLink",href:"#"},Builder.node("img",{src:LightboxOptions.fileLoadingImage})))])),Builder.node("div",{id:"bmlbox_imageDataContainer"},Builder.node("div",{id:"bmlbox_imageData"},[Builder.node("div",{id:"bmlbox_imageDetails"},[Builder.node("span",{id:"bmlbox_caption"}),Builder.node("span",{id:"bmlbox_numberDisplay"})]),Builder.node("div",{id:"bmlbox_bottomNav"},Builder.node("a",{id:"bmlbox_bottomNavClose",href:"#"},Builder.node("img",{src:LightboxOptions.fileBottomNavCloseImage})))]))]));
33$("bmlbox_overlay").hide().observe("click",(function(){this.end()
34}).bind(this));
35$("bmlbox_lightbox").hide().observe("click",(function(d){if(d.element().id=="lightbox"){this.end()
36}}).bind(this));
37$("bmlbox_outerImageContainer").setStyle({width:b,height:b});
38$("bmlbox_prevLink").observe("click",(function(d){d.stop();
39this.changeImage(this.activeImage-1)
40}).bindAsEventListener(this));
41$("bmlbox_nextLink").observe("click",(function(d){d.stop();
42this.changeImage(this.activeImage+1)
43}).bindAsEventListener(this));
44$("bmlbox_loadingLink").observe("click",(function(d){d.stop();
45this.end()
46}).bind(this));
47$("bmlbox_bottomNavClose").observe("click",(function(d){d.stop();
48this.end()
49}).bind(this));
50[$("bmlbox_prevLink"),$("bmlbox_nextLink")].each(function(d){d.setOpacity(0.3);
51d.onmouseover=function(){d.setOpacity(0.99)
52};
53d.onmouseout=function(){d.setOpacity(0.3)
54}
55});
56var c=this;
57(function(){var d="overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose";
58$w(d).each(function(e){c[e]=$("bmlbox_"+e)
59})
60}).defer()
61},updateImageList:function(){this.updateImageList=Prototype.emptyFunction;
62document.observe("click",(function(a){var b=a.findElement("a[rel^=bm_lightbox]")||a.findElement("area[rel^=bm_lightbox]");
63if(b){a.stop();
64this.start(b)
65}}).bind(this))
66},start:function(f){$$("select","object","embed").each(function(g){g.style.visibility="hidden"
67});
68var c=this.getPageSize();
69$("bmlbox_overlay").setStyle({width:c[0]+"px",height:c[1]+"px"});
70new Effect.Appear(this.overlay,{duration:this.overlayDuration,from:0,to:LightboxOptions.overlayOpacity});
71this.imageArray=[];
72var b=0;
73if((f.getAttribute("rel")=="bm_lightbox")){this.imageArray.push([f.href,f.title])
74}else{this.imageArray=$$(f.tagName+'[href][rel="'+f.rel+'"]').collect(function(g){return[g.href,g.title]
75}).uniq();
76while(this.imageArray[b][0]!=f.href){b++
77}}this.hovernavHeight=this.imageArray.length>1?35:0;
78this.lightboxImage.style.marginTop=this.hovernavHeight+"px";
79this.hoverNav.style.height=this.hovernavHeight?"100%":"0px";
80var a=document.viewport.getScrollOffsets();
81var e=a[1]+(document.viewport.getHeight()/20);
82var d=a[0];
83this.lightbox.setStyle({top:e+"px",left:d+"px"}).show();
84this.changeImage(b)
85},changeImage:function(b){this.activeImage=b;
86if(LightboxOptions.animate){this.loading.show()
87}this.lightboxImage.hide();
88this.hoverNav.hide();
89this.prevLink.hide();
90this.nextLink.hide();
91this.imageDataContainer.setStyle({opacity:0.0001});
92this.numberDisplay.hide();
93var a=new Image();
94a.onload=(function(){this.lightboxImage.src=this.imageArray[this.activeImage][0];
95var e=window.innerHeight||document.documentElement.clientHeight;
96var d=window.innerWidth||document.documentElement.clientWidth;
97var i=d<481?(d-40):800;
98var h=e*0.8;
99var c=a.height;
100var g=a.width;
101if(i<g){var f=i/g;
102g=Math.floor(f*g);
103c=Math.floor(f*c)
104}if(h<c){var f=h/c;
105c=Math.floor(f*c);
106g=Math.floor(f*g)
107}this.lightboxImage.width=g;
108this.lightboxImage.height=c;
109this.resizeImageContainer(g,c)
110}).bind(this);
111a.src=this.imageArray[this.activeImage][0]
112},resizeImageContainer:function(e,f){var h=this.outerImageContainer.getWidth();
113var c=this.outerImageContainer.getHeight();
114var g=(e+LightboxOptions.borderSize*2);
115var j=(f+LightboxOptions.borderSize*2);
116j=j+this.hovernavHeight;
117var k=(g/h)*100;
118var b=(j/c)*100;
119var i=h-g;
120var a=c-j;
121if(a!=0){new Effect.Scale(this.outerImageContainer,b,{scaleX:false,duration:this.resizeDuration,queue:"front"})
122}if(i!=0){new Effect.Scale(this.outerImageContainer,k,{scaleY:false,duration:this.resizeDuration})
123}var d=0;
124if((a==0)&&(i==0)){d=100;
125if(Prototype.Browser.IE){d=250
126}}(function(){this.prevLink.setStyle({height:f+"px"});
127this.nextLink.setStyle({height:f+"px"});
128this.imageDataContainer.setStyle({width:g+"px"});
129this.showImage()
130}).bind(this).delay(d/1000)
131},showImage:function(){this.loading.hide();
132new Effect.Appear(this.lightboxImage,{duration:this.resizeDuration,queue:"end",afterFinish:(function(){this.updateDetails()
133}).bind(this)});
134this.preloadNeighborImages()
135},updateDetails:function(){this.caption.update(this.imageArray[this.activeImage][1]).show();
136if(this.imageArray.length>
1361){this.numberDisplay.update(LightboxOptions.labelImage+" "+(this.activeImage+1)+" "+LightboxOptions.labelOf+"  "+this.imageArray.length).show()
137}new Effect.Parallel([new Effect.SlideDown(this.imageDataContainer,{sync:true,duration:this.resizeDuration,from:0,to:1}),new Effect.Appear(this.imageDataContainer,{sync:true,duration:this.resizeDuration})],{duration:this.resizeDuration,afterFinish:(function(){var a=this.getPageSize();
138this.overlay.setStyle({width:a[0]+"px",height:a[1]+"px"});
139this.updateNav()
140}).bind(this)})
141},updateNav:function(){this.hoverNav.show();
142if(this.activeImage>0){this.prevLink.show()
143}if(this.activeImage<(this.imageArray.length-1)){this.nextLink.show()
144}this.enableKeyboardNav()
145},enableKeyboardNav:function(){document.observe("keydown",this.keyboardAction)
146},disableKeyboardNav:function(){document.stopObserving("keydown",this.keyboardAction)
147},keyboardAction:function(d){var a=d.keyCode;
148var b;
149if(d.DOM_VK_ESCAPE){b=d.DOM_VK_ESCAPE
150}else{b=27
151}var c=String.fromCharCode(a).toLowerCase();
152if(c.match(/x|o|c/)||(a==b)){this.end()
153}else{if((c=="p")||(a==37)){if(this.activeImage!=0){this.disableKeyboardNav();
154this.changeImage(this.activeImage-1)
155}}else{if((c=="n")||(a==39)){if(this.activeImage!=(this.imageArray.length-1)){this.disableKeyboardNav();
156this.changeImage(this.activeImage+1)
157}}}}},preloadNeighborImages:function(){var a,b;
158if(this.imageArray.length>this.activeImage+1){a=new Image();
159a.src=this.imageArray[this.activeImage+1][0]
160}if(this.activeImage>0){b=new Image();
161b.src=this.imageArray[this.activeImage-1][0]
162}},end:function(){this.disableKeyboardNav();
163this.lightbox.hide();
164new Effect.Fade(this.overlay,{duration:this.overlayDuration});
165$$("select","object","embed").each(function(a){a.style.visibility="visible"
166})
167},getPageSize:function(){var c,a;
168if(window.innerHeight&&window.scrollMaxY){c=window.innerWidth+window.scrollMaxX;
169a=window.innerHeight+window.scrollMaxY
170}else{if(document.body.scrollHeight>document.body.offsetHeight){c=document.body.scrollWidth;
171a=document.body.scrollHeight
172}else{c=document.body.offsetWidth;
173a=document.body.offsetHeight
174}}var b,d;
175if(self.innerHeight){if(document.documentElement.clientWidth){b=document.documentElement.clientWidth
176}else{b=self.innerWidth
177}d=self.innerHeight
178}else{if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;
179d=document.documentElement.clientHeight
180}else{if(document.body){b=document.body.clientWidth;
181d=document.body.clientHeight
182}}}if(a<d){pageHeight=d
183}else{pageHeight=a
184}if(c<b){pageWidth=c
185}else{pageWidth=b
186}return[pageWidth,pageHeight]
187}};
188document.observe("dom:loaded",function(){new Lightbox()
189});

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.