1var scr=document.getElementsByTagName('script'); 2var zoombox_path = scr[scr.length-1].getAttribute("src").replace('zoombox.js',''); 3 4(function($){ 5 6var options = { 7 theme : 'zoombox', //available themes : zoombox,lightbox, prettyphoto, darkprettyphoto, simple 8 opacity : 0.8, // Black overlay opacity 9 duration : 800, // Animation duration 10 animation : true, // Do we have to animate the box ? 11 width : 600, // Default width 12 height : 400, // Default height 13 gallery : true, // Allow gallery thumb view 14 autoplay : false, // Autoplay for video 15 overflow : false // Allow images bigger than screen ? 16} 17var images; // Gallery Array [gallery name][link] 18var elem; // HTML element currently used to display box 19var isOpen = false; // Zoombox already opened ? 20var link; // Shortcut for the link 21var width; 22var height; 23var timer; // Timing for img loading 24var i = 0; // iteration variable 25var content; // The content of the box 26var type = 'multimedia'; // Content type 27var position = false; 28var imageset = false; 29var state = 'closed'; 30 31/** 32* You can edit the html code generated by zoombox for specific reasons. 33* */ 34var html = '<div id="zoombox"> \ 35 <div class="zoombox_mask"></div>\ 36 <div class="zoombox_container">\ 37 <div class="zoombox_content"></div>\ 38 <div class="zoombox_title"></div>\ 39 <div class="zoombox_next"></div>\ 40 <div class="zoombox_prev"></div>\ 41 <div class="zoombox_close"></div>\ 42 </div>\ 43 <div class="zoombox_gallery"></div>\ 44 </div>'; 45// Regular expressions needed for the content 46var filtreImg= /(\.jpg)|(\.jpeg)|(\.bmp)|(\.gif)|(\.png)/i; 47var filtreMP3= /(\.mp3)/i; 48var filtreFLV= /(\.flv)/i; 49var filtreSWF= /(\.swf)/i; 50var filtreQuicktime= /(\.mov)|(\.mp4)/i; 51var filtreWMV= /(\.wmv)|(\.avi)/i; 52var filtreDailymotion= /(http:\/\/www.dailymotion)|(http:\/\/dailymotion)/i; 53var filtreVimeo= /(http:\/\/www.vimeo)|(http:\/\/vimeo)/i; 54var filtreYoutube= /(youtube\.)/i; 55var filtreKoreus= /(http:\/\/www\.koreus)|(http:\/\/koreus)/i; 56var galleryLoaded = 0; 57 58$.zoombox = function(el,options) { 59 60} 61$.zoombox.options = options; 62$.zoombox.close = function() { 63 close(); 64} 65$.zoombox.open = function(tmplink,opts){ 66 elem = null; 67 link = tmplink; 68 options = $.extend({},$.zoombox.options,opts); 69 load(); 70} 71$.zoombox.html = function(cont,opts){ 72 content = cont; 73 options = $.extend({},$.zoombox.options,opts); 74 width = options.width; 75 height = options.height; 76 elem = null; 77 open(); 78} 79$.fn.zoombox = function(opts){ 80 81 images = new Array(); // allow multiple call on one page, for content loaded from ajax 82 83 /** 84 * Bind the behaviour on every Elements 85 */ 86 return this.each(function(){ 87 // No zoombox for IE6 88 if($.browser && $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest){ 89 return false; 90 } 91 var obj = this; 92 var galleryRegExp = /zgallery([0-9]+)/; 93 var skipRegExp = /zskip/; 94 var gallery = galleryRegExp.exec($(this).attr("class")); 95 var skip = skipRegExp.exec($(this).attr("class")); 96 var tmpimageset = false; 97 if(gallery != null){ 98 if(!images[gallery[1]]){ 99 images[gallery[1]]=new Array(); 100 } 101 if (skip == null) { 102 images[gallery[1]].push($(this)); 103 } 104 var pos = images[gallery[1]].length-1; 105 tmpimageset = images[gallery[1]]; 106 } 107 $(this).unbind('click').click(function(){ 108 options = $.extend({},$.zoombox.options,opts); 109 if(state!='closed') return false; 110 if (skip != null) { 111 if (pos < images[gallery[1]].length-1) { 112 elem = images[gallery[1]][pos+1]; 113 } 114 } else { 115 elem = $(obj); 116 } 117 imageset = tmpimageset; 118 link = elem.attr('href'); 119 position = pos; 120 load(); 121 return false;
122 }); 123 }); 124} 125 126/** 127 * Load the content (with or without loader) and call open() 128 * */ 129function load(){ 130 if(state=='closed') isOpen = false; 131 state = 'load'; 132 setDim(); 133 if(filtreImg.test(link)){ 134 img=new Image(); 135 img.src=link; 136 $("body").append('<div id="zoombox_loader"></div>'); 137 $("#zoombox_loader").css("marginTop",scrollY()); 138 timer = window.setInterval(function(){loadImg(img);},100); 139 }else{ 140 setContent(); 141 open(); 142 } 143} 144 145/** 146 * Build the HTML Structure of the box 147 * */ 148function build(){ 149 // We add the HTML Code on our page 150 $('body').append(html); 151 $(window).keydown(function(event){ 152 shortcut(event.which); 153 }); 154 $(window).resize(function(){ 155 resize(); 156 }); 157 $('#zoombox .zoombox_mask').hide(); 158 // We add a specific class to define the box theme 159 $('#zoombox').addClass(options.theme); 160 // We bind the close behaviour (click on the mask / click on the close button) 161 $('#zoombox .zoombox_mask,.zoombox_close').click(function(){ 162 close(); 163 return false; 164 }); 165 // Next/Prev button 166 if(imageset == false){ 167 $('#zoombox .zoombox_next,#zoombox .zoombox_prev').remove(); 168 }else{ 169 $('#zoombox .zoombox_next').click(function(){ 170 next(); 171 }); 172 $('#zoombox .zoombox_prev').click(function(){ 173 prev(); 174 }); 175 } 176} 177 178/**
179* Gallery System (with slider if too much images) 180*/ 181function gallery(){ 182 var loaded = 0; 183 var width = 0; 184 var contentWidth = 0; 185 if(options.gallery){ 186 if(imageset === false){ 187 $('#zoombox .zoombox_gallery').remove(); 188 return false; 189 } 190 for(var i in imageset){ 191 var imgSrc = zoombox_path+'img/video.png'; 192 var img = $('<img src="'+imgSrc+'" class="video gallery'+(i*1)+'"/>'); 193 if(filtreImg.test(imageset[i].attr('href'))){ 194 imgSrc = imageset[i].attr('href') 195 img = $('<img src="'+imgSrc+'" class="gallery'+(i*1)+'"/>'); 196 } 197 img.data('id',i).appendTo('#zoombox .zoombox_gallery') 198 img.click(function(){ 199 gotoSlide($(this).data('id')); 200 $('#zoombox .zoombox_gallery img').removeClass('current'); 201 $(this).addClass('current'); 202 }); 203 if(i==position){ img.addClass('current'); } 204 205 // Listen the loading of Images 206 $("<img/>").data('img',img).attr("src", imgSrc).load(function() { 207 loaded++; 208 var img = $(this).data('img'); 209 img.width(Math.round(img.height() * this.width/this.height)); 210 if(loaded == $('#zoombox .zoombox_gallery img').length){ 211 var width = 0; 212 $('#zoombox .zoombox_gallery img').each(function(){ 213 width += $(this).outerWidth(); 214 $(this).data('left',width); 215 }); 216 var div = $('<div>').css({ 217 position:'absolute', 218 top:0, 219 left:0, 220 width: width 221 }); 222 $('#zoombox .zoombox_gallery').wrapInner(div); 223 contentWidth = $('#zoombox .zoombox_gallery').width(); 224 $('#zoombox').trigger('change'); 225 } 226 }); 227 } 228 $('#zoombox .zoombox_gallery').show().animate({bottom:0},options.duration); 229 } 230 231 $('#zoombox').bind('change',function(e,css){ 232 if($('#zoombox .zoombox_gallery div').width() < $('#zoombox .zoombox_gallery').width){ 233 return true; 234 } 235 var d = 0; 236 var center = 0; 237 if(css != null){ 238 d = options.duration; 239 center = css.width / 2; 240 }else{ 241 center = $('#zoombox .zoombox_gallery').width()/2; 242 } 243 var decal = - $('#zoombox .zoombox_gallery img.current').data('left') + $('#zoombox .zoombox_gallery img.current').width() / 2; 244 var left = decal + center; 245 if(left < center * 2 - $('#zoombox .zoombox_gallery div').width() ){ 246 left = center * 2 - $('#zoombox .zoombox_gallery div').width(); 247 } 248 if(left > 0){ 249 left = 0; 250 } 251 $('#zoombox .zoombox_gallery div').animate({left:left},d); 252 }); 253 254} 255 256 257/** 258 * Open the box 259 **/ 260function open(){ 261 if(isOpen == false) build(); else $('#zoombox .zoombox_title').empty(); 262 $('#zoombox .close').hide(); 263 $('#zoombox .zoombox_container').removeClass('multimedia').removeClass('img').addClass(type); 264 265 // We add a title if we find one on the link 266 if(elem != null && elem.attr('title')){ 267 $('#zoombox .zoombox_title').append(elem.attr('title')); 268 } 269 270 271 272 // And after... Animation or not depending of preferences 273 // We empty the content 274 $('#zoombox .zoombox_content').empty(); 275 // If it's an image we load the content now (to get a good animation) 276 if(type=='img' && isOpen == false && options.animation == true){ 277 $('#zoombox .zoombox_content').append(content); 278 } 279 // Default position/size of the box to make the "zoom effect" 280 if(elem != null && elem.find('img').length != 0 && isOpen == false){ 281 var min = elem.find('img'); 282 $('#zoombox .zoombox_container').css({ 283 width : min.width(), 284 height: min.height(), 285 top : min.offset().top, 286 left : min.offset().left, 287 opacity:0, 288 marginTop : min.css('marginTop') 289 }); 290 }else if(elem != null && isOpen == false){ 291 $('#zoombox .zoombox_container').css({ 292 width: elem.width(), 293 height: elem.height(), 294 top:elem.offset().top, 295 left:elem.offset().left 296 }); 297 }else if(isOpen == false){ 298 $('#zoombox .zoombox_container').css({ 299 width: 100, 300 height: 100, 301 top:windowH()/2-50,
302 left:windowW()/2-50 303 }) 304 } 305 // Final position/size of the box after the animation 306 var css = { 307 width : width, 308 height: height, 309 left : (windowW() - width) / 2, 310 top : (windowH() - height) / 2, 311 marginTop : scrollY(), 312 opacity:1 313 }; 314 315 // Trigger the change event 316 $('#zoombox').trigger('change',css); 317 318 // Do we animate or not ? 319 if(options.animation == true){ 320 $('#zoombox .zoombox_title').hide(); 321 $('#zoombox .zoombox_close').hide(); 322 $('#zoombox .zoombox_container').animate(css,options.duration,function(){ 323 if(type == 'multimedia' || isOpen == true){ 324 $('#zoombox .zoombox_content').append(content); 325 } 326 if(type == 'image' || isOpen == true){ 327 $('#zoombox .zoombox_content img').css('opacity',0).fadeTo(300,1); 328 } 329 $('#zoombox .zoombox_title').fadeIn(300); 330 $('#zoombox .zoombox_close').fadeIn(300); 331 state = 'opened'; 332 if(!isOpen){ 333 gallery(); 334 } 335 isOpen = true; 336 }); 337 $('#zoombox .zoombox_mask').fadeTo(200,options.opacity); 338 }else{ 339 $('#zoombox .zoombox_content').append(content); 340 $('#zoombox .zoombox_close').show(); 341 $('#zoombox .zoombox_gallery').show(); 342 $('#zoombox .zoombox_container').css(css); 343 $('#zoombox .zoombox_mask').show(); 344 $('#zoombox .zoombox_mask').css('opacity',options.opacity); 345 if(!isOpen){ 346 gallery(); 347 } 348 isOpen = true; 349 state = 'opened'; 350 } 351} 352/** 353 * Close the box 354 * **/ 355function close(){ 356 state = 'closing'; 357 window.clearInterval(timer); 358 $(window).unbind('keydown'); 359 $(window).unbind('resize'); 360 if(type == 'multimedia'){ 361 $('#zoombox .zoombox_container').empty(); 362 } 363 var css = {}; 364 if(elem != null && elem.find('img').length > 0){ 365 var min = elem.find('img'); 366 css ={ 367 width : min.width(), 368 height: min.height(), 369 top : min.offset().top, 370 left : min.offset().left, 371 opacity:0, 372 marginTop : min.css('marginTop') 373 }; 374 }else if(elem!=null){ 375 css = { 376 width: elem.width(), 377 height: elem.height(), 378 top:elem.offset().top, 379 left:elem.offset().left, 380 marginTop:0, 381 opacity:0 382 }; 383 }else{ 384 css = { 385 width: 100, 386 height: 100, 387 top:windowH()/2-50,
388 left:windowW()/2-50, 389 opacity : 0 390 }; 391 } 392 if(options.animation == true){ 393 $('#zoombox .zoombox_mask').fadeOut(200); 394 $('#zoombox .zoombox_gallery').animate({bottom:-$('#zoombox .zoombox_gallery').innerHeight()},options.duration); 395 $('#zoombox .zoombox_container').animate(css,options.duration,function(){ 396 $('#zoombox').remove(); 397 state = 'closed'; 398 isOpen = false; 399 }); 400 }else{ 401 $('#zoombox').remove(); 402 state = 'closed'; 403 isOpen = false; 404 } 405} 406 407/** 408 * Set the HTML Content of the box 409 * */ 410function setContent(){ 411 // Overtflow 412 if(options.overflow == false){ 413 if(width*1 + 50 > windowW()){ 414 height = (windowW() - 50) * height / width; 415 width = windowW() - 50; 416 } 417 if(height*1 + 50 > windowH()){ 418 width = (windowH()-50) * width / height; 419 height = windowH() - 50; 420 } 421 } 422 var url = link; 423 type = 'multimedia'; 424 if(filtreImg.test(url)){ 425 type = 'img'; 426 content='<img src="'+link+'" width="100%" height="100%"/>'; 427 }else if(filtreMP3.test(url)){ 428 width=300; 429 height=40; 430 content ='<object type="application/x-shockwave-flash" data="'+MP3Player+'?son='+url+'" width="'+width+'" height="'+height+'">'; 431 content+='<param name="movie" value="'+MP3Player+'?son='+url+'" /></object>'; 432 }else if(filtreFLV.test(url)){ 433 var autostart = 0; 434 if(options.autoplay==true){ autostart = 1; } 435 content='<object type="application/x-shockwave-flash" data="'+zoombox_path+'FLVplayer.swf" width="'+width+'" height="'+height+'">\ 436<param name="allowFullScreen" value="true">\ 437<param name="scale" value="noscale">\ 438<param name="wmode" value="transparent">\ 439<param name="flashvars" value="flv='+url+'&autoplay='+autostart+'">\ 440<embed src="'+zoombox_path+'FLVplayer.swf" width="'+width+'" height="'+height+'" allowscriptaccess="always" allowfullscreen="true" flashvars="flv='+url+'" wmode="transparent" />\ 441</object>'; 442 }else if(filtreSWF.test(url)){ 443 content='<object width="'+width+'" height="'+height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+url+'" /><embed src="'+url+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+width+'" height="'+height+'" wmode="transparent"></embed></object>'; 444 }else if(filtreQuicktime.test(url)){ 445 content='<embed src="'+url+'" width="'+width+'" height="'+height+'" controller="true" cache="true" autoplay="true"/>'; 446 // HTML5 Code 447 //content='<video controls src="'+url+'" width="'+width+'" height="'+height+'">Your browser does not support this format</video>' 448 }else if(filtreWMV.test(url)){ 449 content='<embed src="'+url+'" width="'+width+'" height="'+height+'" controller="true" cache="true" autoplay="true" wmode="transparent" />'; 450 }else if(filtreDailymotion.test(url)){ 451 var id=url.split('_'); 452 id=id[0].split('/'); 453 id=id[id.length-1]+'?'; 454 if(options.autoplay==true){ 455 id = id + 'autoPlay=1&'; 456 } 457 content='<iframe frameborder="0" width="'+width+'" height="'+height+'" src="http://www.dailymotion.com/embed/video/'+id+'?wmode=transparent"></iframe>'; 458 }else if(filtreVimeo.test(url)){ 459 var id=url.split('/'); 460 id=id[3]+'?'; 461 if(options.autoplay==true){ 462 id = id + 'autoplay=1&'; 463 } 464 content='<iframe src="http://player.vimeo.com/video/'+id+'title=0&byline=0&portrait=0&wmode=transparent" width="'+width+'" height="'+height+'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' 465 }else if(filtreYoutube.test(url)){ 466 var id=url.split('watch?v='); 467 id=id[1].split('&'); 468 id=id[0]+'?'; 469 if(options.autoplay==true){ 470 id = id + 'autoplay=1&'; 471 } 472 content='<iframe width="'+width+'" height="'+height+'" src="https://www.youtube.com/embed/'+id+'wmode=Opaque" frameborder="0" allowfullscreen></iframe>'; 473 }else if(filtreKoreus.test(url)){ 474 url=url.split('.html'); 475 url=url[0]; 476 content='<object type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+url+'"><embed src="'+url+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent"></embed></object>'; 477 }else{ 478 content='<iframe src="'+url+'" width="'+width+'" height="'+height+'" border="0"></iframe>'; 479 } 480 return content; 481} 482/** 483 * Handle Image loading 484 **/ 485function loadImg(img){ 486 if(img.complete){ 487 i=0; 488 window.clearInterval(timer); 489 width=img.width; 490 height=img.height; 491 $('#zoombox_loader').remove(); 492 setContent(); 493 open(); 494 } 495 // On anim le loader 496 $('#zoombox_loader').css({'background-position': "0px "+i+"px"}); 497 i=i-40; 498 if(i<(-440)){i=0;} 499} 500
501function gotoSlide(i){ 502 if(state != 'opened'){ return false; } 503 if (imageset) { 504 position = i; 505 elem = imageset[position]; 506 link = elem.attr('href'); 507 if($('#zoombox .zoombox_gallery img').length > 0){ 508 $('#zoombox .zoombox_gallery img').removeClass('current'); 509 $('#zoombox .zoombox_gallery img:eq('+i+')').addClass('current'); 510 } 511 load(); 512 } 513 return false; 514} 515 516function next(){ 517 i = position+1; 518 if(i > imageset.length-1){ 519 i = 0; 520 } 521 gotoSlide(i); 522} 523 524function prev(){ 525 i = position-1; 526 if(i < 0){ 527 i = imageset.length-1; 528 } 529 gotoSlide(i); 530} 531 532/** 533 * GENERAL FUNCTIONS 534 * */ 535/** 536 * Resize 537 **/ 538function resize(){ 539 $('#zoombox .zoombox_container').css({ 540 top : (windowH() - $('#zoombox .zoombox_container').outerHeight(true)) / 2, 541 left : (windowW() - $('#zoombox .zoombox_container').outerWidth(true)) / 2 542 }); 543} 544/** 545 * Keyboard Shortcut 546 **/ 547function shortcut(key){ 548 if(key == 37){ 549 prev(); 550 } 551 if(key == 39){ 552 next(); 553 } 554 if(key == 27){ 555 close(); 556 } 557 558} 559/** 560 * Parse Width/Height of a link and insert it in the width and height variables 561 * */ 562function setDim(){ 563 width = options.width; 564 height = options.height; 565 if(elem!=null){ 566 var widthReg = /w([0-9]+)/; 567 var w = widthReg.exec(elem.attr("class")); 568 if(w != null){ 569 if(w[1]){ 570 width = w[1]; 571 } 572 } 573 var heightReg = /h([0-9]+)/; 574 var h = heightReg.exec(elem.attr("class")); 575 if(h != null){ 576 if(h[1]){ 577 height = h[1]; 578 } 579 } 580 } 581 return false; 582} 583/** 584* Return the window height 585* */ 586function windowH(){ 587 if (window.innerHeight) return window.innerHeight ; 588 else{return $(window).height();} 589} 590 591/** 592 * Return the window width 593 * */ 594function windowW(){ 595 if (window.innerWidth) return window.innerWidth ; 596 else{return $(window).width();} 597} 598 599/** 600 * Return the position of the top 601 * */ 602function scrollY() { 603 scrOfY = 0; 604 if( typeof( window.pageYOffset ) == 'number' ) { 605 //Netscape compliant 606 scrOfY = window.pageYOffset; 607 } else if( document.body && ( document.body.scrollTop ) ) { 608 //DOM compliant 609 scrOfY = document.body.scrollTop; 610 } else if( document.documentElement && ( document.documentElement.scrollTop ) ) { 611 //IE6 standards compliant mode 612 scrOfY = document.documentElement.scrollTop; 613 } 614 return scrOfY; 615} 616 617/** 618 * Return the position of the left scroll 619 * */ 620function scrollX(){ 621 scrOfX = 0; 622 if( typeof( window.pageXOffset ) == 'number' ) { 623 //Netscape compliant 624 scrOfX = window.pageXOffset; 625 } else if( document.body && ( document.body.scrollLeft ) ) { 626 //DOM compliant 627 scrOfX = document.body.scrollLeft; 628 } else if( document.documentElement && ( document.documentElement.scrollLeft ) ) { 629 //IE6 standards compliant mode 630 scrOfX = document.documentElement.scrollLeft; 631 } 632 return scrOfX; 633} 634 635})(jQuery);
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.