/* * thickbox 3.1 - one box to rule them all. * by cody lindley (http://www.codylindley.com) * copyright (c) 2007 cody lindley * licensed under the mit license: http://www.opensource.org/licenses/mit-license.php */ if ( typeof tb_pathtoimage != 'string' ) { var tb_pathtoimage = thickboxl10n.loadinganimation; } /*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ //on page load call tb_init jquery(document).ready(function(){ tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox imgloader = new image();// preload image imgloader.src = tb_pathtoimage; }); //add thickbox to href & area elements that have a class of .thickbox function tb_init(domchunk){ jquery('body').on('click', domchunk, tb_click); } function tb_click(){ var t = this.title || this.name || null; var a = this.href || this.alt; var g = this.rel || false; tb_show(t,a,g); this.blur(); return false; } function tb_show(caption, url, imagegroup) {//function called when the user clicks on a thickbox link try { if (typeof document.body.style.maxheight === "undefined") {//if ie 6 jquery("body","html").css({height: "100%", width: "100%"}); jquery("html").css("overflow","hidden"); if (document.getelementbyid("tb_hideselect") === null) {//iframe to hide select elements in ie6 jquery("body").append("
"); jquery("#tb_overlay").click(tb_remove); } }else{//all others if(document.getelementbyid("tb_overlay") === null){ jquery("body").append(""); jquery("#tb_overlay").click(tb_remove); jquery( 'body' ).addclass( 'modal-open' ); } } if(tb_detectmacxff()){ jquery("#tb_overlay").addclass("tb_overlaymacffbghack");//use png overlay so hide flash }else{ jquery("#tb_overlay").addclass("tb_overlaybg");//use background and opacity } if(caption===null){caption="";} jquery("body").append("");//add loader to the page jquery('#tb_load').show();//show loader var baseurl; if(url.indexof("?")!==-1){ //ff there is a query string involved baseurl = url.substr(0, url.indexof("?")); }else{ baseurl = url; } var urlstring = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; var urltype = baseurl.tolowercase().match(urlstring); if(urltype == '.jpg' || urltype == '.jpeg' || urltype == '.png' || urltype == '.gif' || urltype == '.bmp'){//code to show images tb_prevcaption = ""; tb_prevurl = ""; tb_prevhtml = ""; tb_nextcaption = ""; tb_nexturl = ""; tb_nexthtml = ""; tb_imagecount = ""; tb_foundurl = false; if(imagegroup){ tb_temparray = jquery("a[rel="+imagegroup+"]").get(); for (tb_counter = 0; ((tb_counter < tb_temparray.length) && (tb_nexthtml === "")); tb_counter++) { var urltypetemp = tb_temparray[tb_counter].href.tolowercase().match(urlstring); if (!(tb_temparray[tb_counter].href == url)) { if (tb_foundurl) { tb_nextcaption = tb_temparray[tb_counter].title; tb_nexturl = tb_temparray[tb_counter].href; tb_nexthtml = " "+thickboxl10n.next+""; } else { tb_prevcaption = tb_temparray[tb_counter].title; tb_prevurl = tb_temparray[tb_counter].href; tb_prevhtml = " "+thickboxl10n.prev+""; } } else { tb_foundurl = true; tb_imagecount = thickboxl10n.image + ' ' + (tb_counter + 1) + ' ' + thickboxl10n.of + ' ' + (tb_temparray.length); } } } imgpreloader = new image(); imgpreloader.onload = function(){ imgpreloader.onload = null; // resizing large images - original by christian montoya edited by me. var pagesize = tb_getpagesize(); var x = pagesize[0] - 150; var y = pagesize[1] - 150; var imagewidth = imgpreloader.width; var imageheight = imgpreloader.height; if (imagewidth > x) { imageheight = imageheight * (x / imagewidth); imagewidth = x; if (imageheight > y) { imagewidth = imagewidth * (y / imageheight); imageheight = y; } } else if (imageheight > y) { imagewidth = imagewidth * (y / imageheight); imageheight = y; if (imagewidth > x) { imageheight = imageheight * (x / imagewidth); imagewidth = x; } } // end resizing tb_width = imagewidth + 30; tb_height = imageheight + 60; jquery("#tb_window").append(""+thickboxl10n.close+"" + ""); jquery("#tb_closewindowbutton").click(tb_remove); if (!(tb_prevhtml === "")) { function goprev(){ if(jquery(document).unbind("click",goprev)){jquery(document).unbind("click",goprev);} jquery("#tb_window").remove(); jquery("body").append(""); tb_show(tb_prevcaption, tb_prevurl, imagegroup); return false; } jquery("#tb_prev").click(goprev); } if (!(tb_nexthtml === "")) { function gonext(){ jquery("#tb_window").remove(); jquery("body").append(""); tb_show(tb_nextcaption, tb_nexturl, imagegroup); return false; } jquery("#tb_next").click(gonext); } jquery(document).bind('keydown.thickbox', function(e){ if ( e.which == 27 ){ // close tb_remove(); } else if ( e.which == 190 ){ // display previous image if(!(tb_nexthtml == "")){ jquery(document).unbind('thickbox'); gonext(); } } else if ( e.which == 188 ){ // display next image if(!(tb_prevhtml == "")){ jquery(document).unbind('thickbox'); goprev(); } } return false; }); tb_position(); jquery("#tb_load").remove(); jquery("#tb_imageoff").click(tb_remove); jquery("#tb_window").css({'visibility':'visible'}); //for safari using css instead of show }; imgpreloader.src = url; }else{//code to show html var querystring = url.replace(/^[^\?]+\??/,''); var params = tb_parsequery( querystring ); tb_width = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to url tb_height = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to url ajaxcontentw = tb_width - 30; ajaxcontenth = tb_height - 45; if(url.indexof('tb_iframe') != -1){// either iframe or ajax window urlnoquery = url.split('tb_'); jquery("#tb_iframecontent").remove(); if(params['modal'] != "true"){//iframe no modal jquery("#tb_window").append("