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