1/* 2 * Thickbox 3.1 - One Box To Rule Them All. 3 * By Cody Lindley (http://www.codylindley.com) 4 * Copyright (c) 2007 cody lindley 5 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php 6*/ 7 8var tb_pathToImage = "<URL>loadingAnimation.gif"; 9 10/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ 11 12 13 14 15//on page load call tb_init 16jQuery(document).ready(function(){ 17 tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox 18 imgLoader = new Image();// preload image 19 imgLoader.src = tb_pathToImage; 20}); 21 22//add thickbox to href & area elements that have a class of .thickbox 23function tb_init(domChunk){ 24 jQuery(domChunk).click(function(){ 25 var t = this.title || this.name || null; 26 var a = this.href || this.alt; 27 var g = this.rel || false; 28 tb_show(t,a,g); 29 this.blur(); 30 return false; 31 }); 32} 33 34function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link 35 36 try { 37 if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 38 jQuery("body","html").css({height: "100%", width: "100%"}); 39 jQuery("html").css("overflow","hidden"); 40 if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 41 jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>"); 42 jQuery("#TB_overlay").click(tb_remove); 43 } 44 }else{//all others 45 if(document.getElementById("TB_overlay") === null){ 46 jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>"); 47 jQuery("#TB_overlay").click(tb_remove); 48 } 49 } 50 51 if(tb_detectMacXFF()){ 52 jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash 53 }else{ 54 jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity 55 } 56 57 if(caption===null){caption="";} 58 jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page 59 jQuery('#TB_load').show();//show loader 60 61 var baseURL; 62 if(url.indexOf("?")!==-1){ //ff there is a query string involved 63 baseURL = url.substr(0, url.indexOf("?")); 64 }else{ 65 baseURL = url; 66 } 67 68 var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; 69 var urlType = baseURL.toLowerCase().match(urlString); 70 71 if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images 72 73 TB_PrevCaption = ""; 74 TB_PrevURL = ""; 75 TB_PrevHTML = ""; 76 TB_NextCaption = ""; 77 TB_NextURL = ""; 78 TB_NextHTML = ""; 79 TB_imageCount = ""; 80 TB_FoundURL = false; 81 if(imageGroup){ 82 TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get(); 83 for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { 84 var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); 85 if (!(TB_TempArray[TB_Counter].href == url)) { 86 if (TB_FoundURL) { 87 TB_NextCaption = TB_TempArray[TB_Counter].title; 88 TB_NextURL = TB_TempArray[TB_Counter].href; 89 TB_NextHTML = "<span id='TB_next'> <a href='#'>Weiter ></a></span>"; 90 } else { 91 TB_PrevCaption = TB_TempArray[TB_Counter].title; 92 TB_PrevURL = TB_TempArray[TB_Counter].href; 93 TB_PrevHTML = "<span id='TB_prev'> <a href='#'>< Zurück</a></span>"; 94 } 95 } else { 96 TB_FoundURL = true; 97 TB_imageCount = "Bild " + (TB_Counter + 1) +" von "+ (TB_TempArray.length); 98 } 99 } 100 } 101 102 imgPreloader = new Image(); 103 imgPreloader.onload = function(){ 104 imgPreloader.onload = null; 105 106 // Resizing large images - orginal by Christian Montoya edited by me. 107 var pagesize = tb_getPageSize(); 108 var x = pagesize[0] - 150; 109 var y = pagesize[1] - 150; 110 var imageWidth = imgPreloader.width; 111 var imageHeight = imgPreloader.height; 112 if (imageWidth > x) { 113 imageHeight = imageHeight * (x / imageWidth); 114 imageWidth = x; 115 if (imageHeight > y) { 116 imageWidth = imageWidth * (y / imageHeight); 117 imageHeight = y; 118 } 119 } else if (imageHeight > y) { 120 imageWidth = imageWidth * (y / imageHeight); 121 imageHeight = y; 122 if (imageWidth > x) { 123 imageHeight = imageHeight * (x / imageWidth); 124 imageWidth = x; 125 } 126 } 127 // End Resizing 128 129 TB_WIDTH = imageWidth + 30; 130 TB_HEIGHT = imageHeight + 60; 131 jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Schließen'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Cerrar'>Cerrar</a> o Esc Cerrar</div>"); 132 133 jQuery("#TB_closeWindowButton").click(tb_remove); 134 135 if (!(TB_PrevHTML === "")) { 136 function goPrev(){ 137 if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);} 138 jQuery("#TB_window").remove(); 139 jQuery("body").append("<div id='TB_window'></div>"); 140 tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); 141 return false; 142 } 143 jQuery("#TB_prev").click(goPrev); 144 } 145 146 if (!(TB_NextHTML === "")) { 147 function goNext(){ 148 jQuery("#TB_window").remove(); 149 jQuery("body").append("<div id='TB_window'></div>"); 150 tb_show(TB_NextCaption, TB_NextURL, imageGroup); 151 return false; 152 } 153 jQuery("#TB_next").click(goNext); 154 155 } 156 157 document.onkeydown = function(e){ 158 if (e == null) { // ie 159 keycode = event.keyCode; 160 } else { // mozilla 161 keycode = e.which; 162 } 163 if(keycode == 27){ // close 164 tb_remove(); 165 } else if(keycode == 190){ // display previous image 166 if(!(TB_NextHTML == "")){ 167 document.onkeydown = ""; 168 goNext(); 169 } 170 } else if(keycode == 188){ // display next image 171 if(!(TB_PrevHTML == "")){ 172 document.onkeydown = ""; 173 goPrev(); 174 } 175 } 176 }; 177 178 tb_position(); 179 jQuery("#TB_load").remove(); 180 jQuery("#TB_ImageOff").click(tb_remove); 181 jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show 182 }; 183 184 imgPreloader.src = url; 185 }else{//code to show html 186 187 var queryString = url.replace(/^[^\?]+\??/,''); 188 var params = tb_parseQuery( queryString ); 189 190 TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
191 TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL 192 ajaxContentW = TB_WIDTH - 30; 193 ajaxContentH = TB_HEIGHT - 45; 194 195 if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window 196 urlNoQuery = url.split('TB_'); 197 jQuery("#TB_iframeContent").remove(); 198 if(params['modal'] != "true"){//iframe no modal 199 jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Schließen'>Schließen</a> oder Esc drücken</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>"); 200 }else{//iframe modal 201 jQuery("#TB_overlay").unbind(); 202 jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>"); 203 } 204 }else{// not an iframe, ajax 205 if(jQuery("#TB_window").css("display") != "block"){ 206 if(params['modal'] != "true"){//ajax no modal 207 jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>Schließen</a> oder Esc drücken</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>"); 208 }else{//ajax modal 209 jQuery("#TB_overlay").unbind(); 210 jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>"); 211 } 212 }else{//this means the window is already up, we are just loading new content via ajax 213 jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; 214 jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; 215 jQuery("#TB_ajaxContent")[0].scrollTop = 0; 216 jQuery("#TB_ajaxWindowTitle").html(caption); 217 } 218 } 219 220 jQuery("#TB_closeWindowButton").click(tb_remove); 221 222 if(url.indexOf('TB_inline') != -1){ 223 jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); 224 jQuery("#TB_window").unload(function () { 225 jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished 226 }); 227 tb_position(); 228 jQuery("#TB_load").remove(); 229 jQuery("#TB_window").css({display:"block"}); 230 }else if(url.indexOf('TB_iframe') != -1){ 231 tb_position(); 232 if(jQuery.browser.safari){//safari needs help because it will not fire iframe onload 233 jQuery("#TB_load").remove(); 234 jQuery("#TB_window").css({display:"block"}); 235 } 236 }else{ 237 jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method 238 tb_position(); 239 jQuery("#TB_load").remove(); 240 tb_init("#TB_ajaxContent a.thickbox"); 241 jQuery("#TB_window").css({display:"block"}); 242 }); 243 } 244 245 } 246 247 if(!params['modal']){ 248 document.onkeyup = function(e){ 249 if (e == null) { // ie 250 keycode = event.keyCode; 251 } else { // mozilla 252 keycode = e.which; 253 } 254 if(keycode == 27){ // close 255 tb_remove(); 256 } 257 }; 258 } 259 260 } catch(e) { 261 //nothing here 262 } 263} 264 265//helper functions below 266function tb_showIframe(){ 267 jQuery("#TB_load").remove(); 268 jQuery("#TB_window").css({display:"block"}); 269} 270 271function tb_remove() { 272 jQuery("#TB_imageOff").unbind("click"); 273 jQuery("#TB_closeWindowButton").unbind("click"); 274 jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); 275 jQuery("#TB_load").remove(); 276 if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 277 jQuery("body","html").css({height: "auto", width: "auto"}); 278 jQuery("html").css("overflow",""); 279 } 280 document.onkeydown = ""; 281 document.onkeyup = ""; 282 return false; 283} 284 285function tb_position() { 286jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); 287 if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 288 jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); 289 } 290} 291 292function tb_parseQuery ( query ) { 293 var Params = {}; 294 if ( ! query ) {return Params;}// return empty object 295 var Pairs = query.split(/[;&]/); 296 for ( var i = 0; i < Pairs.length; i++ ) { 297 var KeyVal = Pairs[i].split('='); 298 if ( ! KeyVal || KeyVal.length != 2 ) {continue;} 299 var key = unescape( KeyVal[0] ); 300 var val = unescape( KeyVal[1] ); 301 val = val.replace(/\+/g, ' '); 302 Params[key] = val; 303 } 304 return Params; 305} 306 307function tb_getPageSize(){ 308 var de = document.documentElement; 309 var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
310 var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; 311 arrayPageSize = [w,h]; 312 return arrayPageSize; 313} 314 315function tb_detectMacXFF() { 316 var userAgent = navigator.userAgent.toLowerCase(); 317 if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { 318 return true; 319 } 320} 321 322 323 324
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.