1/** 2* Lightbox 3* 4* This libary is used to create a lightbox in a web application. This library 5* requires the Prototype 1.6 library and Script.aculo.us core, effects, and dragdrop 6* libraries. To use, add a div containing the content to be displayed anywhere on 7* the page. To create the lightbox, add the following code: 8* 9* var test; 10* 11* Event.observe(window, 'load', function () { 12* test = new Lightbox('idOfMyDiv'); 13* }); 14* 15* Event.observe('lightboxLink', 'click', function () { 16* test.open(); 17* }); 18* 19* Event.observe('closeLink', 'click', function () { 20* test.close(); 21* }); 22* 23*/ 24var Lightbox = Class.create({ 25 open : function () { 26 this._centerWindow(this.container); 27 this._fade('open', this.container); 28 }, 29 close : function () { 30 this._fade('close', this.container); 31 }, 32 _fade : function fadeBg(userAction,whichDiv){ 33 if(userAction=='close'){ 34 new Effect.Opacity('bg_fade', 35 {duration:.2, 36 from:0.6, 37 to:0, 38 afterFinish:this._makeInvisible, 39 afterUpdate:this._hideLayer(whichDiv)}); 40 }else{ 41 new Effect.Opacity('bg_fade', 42 {duration:.2, 43 from:0, 44 to:0.6, 45 beforeUpdate:this._makeVisible, 46 afterFinish:this._showLayer(whichDiv)}); 47 } 48 }, 49 _makeVisible : function makeVisible(){ 50 $("bg_fade").style.visibility="visible"; 51 }, 52 _makeInvisible : function makeInvisible(){ 53 $("bg_fade").style.visibility="hidden"; 54 }, 55 _showLayer : function showLayer(userAction){ 56 $(userAction).style.display="block"; 57 }, 58 _hideLayer : function hideLayer(userAction){ 59 $(userAction).style.display="none"; 60 }, 61 _centerWindow : function centerWindow(element) { 62 var windowHeight = parseFloat($(element).getHeight())/2; 63 var windowWidth = parseFloat($(element).getWidth())/2; 64 if(typeof window.innerHeight != 'undefined') { 65 $(element).style.top = Math.round(document.body.offsetTop + ((window.innerHeight - $(element).getHeight()))/2)+'px'; 66 $(element).style.left = Math.round(document.body.offsetLeft + ((window.innerWidth - $(element).getWidth()))/2)+'px'; 67 } else { 68 $(element).style.top = Math.round(document.body.offsetTop + ((document.documentElement.offsetHeight - $(element).getHeight()))/2)+'px'; 69 $(element).style.left = Math.round(document.body.offsetLeft + ((document.documentElement.offsetWidth - $(element).getWidth()))/2)+'px'; 70 } 71 }, 72 initialize : function(containerDiv) { 73 this.container = containerDiv; 74 if($('bg_fade') == null) { 75 var screen = new Element('div', {'id': 'bg_fade'}); 76 document.body.appendChild(screen); 77 } 78 this._hideLayer(this.container); 79 } 80});
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.