1/* 2* - Gestion de la galerie photo 3* 4* Auteur : Dynamic Drive 5* Contact : http://www.dynamicdrive.com/contact.htm 6* 7* Image Thumbnail Viewer Script- By Dynamic Drive, available at : http://www.dynamicdrive.com 8* 9/* ----- Ne modifiez rien dans le code Javascript ci-dessous ----- */ 10 11var thumbnailviewer={ 12enableTitle: true, //Should "title" attribute of link be used as description? 13enableAnimation: true, //Enable fading animation? 14defineLoading: 'Chargement de l\'image...', //Define HTML for "loading" div 15 16scrollbarwidth: 16, 17opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1', 18targetlinks:[], //Array to hold links with rel="thumbnail" 19 20createthumbBox:function(){ 21 document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()" title="Cliquez pour fermer l\'image"><div id="thumbImage"></div></div>') 22 document.write('<div id="thumbLoading">'+this.defineLoading+'</div>') 23 this.thumbBox=document.getElementById("thumbBox") 24 this.thumbImage=document.getElementById("thumbImage") //Reference div that holds the shown image 25 this.thumbLoading=document.getElementById("thumbLoading") //Reference "loading" div that will be shown while image is fetched 26 this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes 27}, 28 29centerDiv:function(divobj){ //Centers a div element on the page 30 var ie=document.all && !window.opera 31 var dom=document.getElementById 32 var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset 33 var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset 34 var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth 35 var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight 36 var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight //Full scroll height of document 37 var objwidth=divobj.offsetWidth //width of div element 38 var objheight=divobj.offsetHeight //height of div element 39 var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2+"px" : scroll_top+10+"px" //Vertical position of div element: Either centered, or if element height larger than viewpoint height, 10px from top of viewpoint 40 divobj.style.left=docwidth/2-objwidth/2+"px" //Center div element horizontally 41 divobj.style.top=Math.floor(parseInt(topposition))+"px" 42 divobj.style.visibility="visible" 43}, 44 45showthumbBox:function(){ //Show ThumbBox div 46 this.centerDiv(this.thumbBox) 47 if (this.enableAnimation){ //If fading animation enabled 48 this.currentopacity=0.1 //Starting opacity value 49 this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20) 50 } 51}, 52 53loadimage:function(link){ //Load image function that gets attached to each link on the page with rel="thumbnail" 54 if (this.thumbBox.style.visibility=="visible") //if thumbox is visible on the page already 55 this.closeit() //Hide it first (not doing so causes triggers some positioning bug in Firefox 56 var imageHTML='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image 57 if (this.enableTitle && link.getAttribute("title")) //Use title attr of the link as description? 58 var imageHTML=link.getAttribute("title")+'<br />'; 59 imageHTML+='<img src="'+link.getAttribute("href")+'" style="'+this.opacitystring+'" />' //Construct HTML for shown image 60 imageHTML+='<br />'+link.getAttribute("title"); 61 this.centerDiv(this.thumbLoading) //Center and display "loading" div while we set up the image to be shown 62 this.thumbImage.innerHTML=imageHTML //Populate thumbImage div with shown image's HTML (while still hidden) 63 this.featureImage=this.thumbImage.getElementsByTagName("img")[0] //Reference shown image itself 64 this.featureImage.onload=function(){ //When target image has completely loaded 65 thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div 66 thumbnailviewer.showthumbBox() //Display "thumbbox" div to the world! 67 } 68 if (document.all && !window.createPopup) //Target IE5.0 browsers only. Address IE image cache not firing onload bug: panoramio.com/blog/onload-event/ 69 this.featureImage.src=link.getAttribute("href") 70 this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show 71 thumbnailviewer.thumbLoading.style.visibility="hidden" //Hide "loading" div, game over 72 } 73}, 74 75setimgopacity:function(value){ //Sets the opacity of "thumbimage" div per the passed in value setting (0 to 1 and in between) 76 var targetobject=this.featureImage 77 if (targetobject.filters && targetobject.filters[0]){ //IE syntax 78 if (typeof targetobject.filters[0].opacity=="number") //IE6 79 targetobject.filters[0].opacity=value*100 80 else //IE 5.5 81 targetobject.style.filter="alpha(opacity="+value*100+")" 82 } 83 else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax 84 targetobject.style.MozOpacity=value 85 else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax 86 targetobject.style.opacity=value 87 else //Non of the above, stop opacity animation 88 this.stopanimation() 89}, 90 91opacityanimation:function(){ //Gradually increase opacity function 92 this.setimgopacity(this.currentopacity) 93 this.currentopacity+=0.1 94 if (this.currentopacity>1) 95 this.stopanimation() 96}, 97 98stopanimation:function(){ 99 if (typeof this.opacitytimer!="undefined") 100 clearInterval(this.opacitytimer) 101}, 102 103closeit:function(){ //Close "thumbbox" div function 104 this.stopanimation() 105 this.thumbBox.style.visibility="hidden" 106 this.thumbImage.innerHTML="" 107 this.thumbBox.style.left="-2000px" 108 this.thumbBox.style.top="-2000px" 109}, 110 111cleanup:function(){ //Clean up routine on page unload 112 this.thumbLoading=null 113 if (this.featureImage) this.featureImage.onload=null 114 this.featureImage=null 115 this.thumbImage=null 116 for (var i=0; i<this.targetlinks.length; i++) 117 this.targetlinks[i].onclick=null 118 this.thumbBox=null 119}, 120 121dotask:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload) 122 var tasktype=(window.addEventListener)? tasktype : "on"+tasktype 123 if (target.addEventListener) 124 target.addEventListener(tasktype, functionref, false) 125 else if (target.attachEvent) 126 target.attachEvent(tasktype, functionref) 127}, 128 129init:function(){ //Initialize thumbnail viewer script by scanning page and attaching appropriate function to links with rel="thumbnail" 130 if (!this.enableAnimation) 131 this.opacitystring="" 132 var pagelinks=document.getElementsByTagName("a") 133 for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP 134 if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ //Begin if statement 135 pagelinks[i].onclick=function(){ 136 thumbnailviewer.stopanimation() //Stop any currently running fade animation on "thumbbox" div before proceeding 137 thumbnailviewer.loadimage(this) //Load image 138 return false 139 } 140 this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link 141 } //end if statement 142 } //END FOR LOOP 143 144 //Reposition "thumbbox" div when page is resized 145 this.dotask(window, function(){ 146 if (thumbnailviewer.thumbBox.style.visibility=="visible") 147 thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize") 148 } //END init() function 149} 150thumbnailviewer.createthumbBox() //Output HTML for the image thumbnail viewer 151thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") //Initialize script on page load 152thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")
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.