1(function($){ 2 3$.fn.overlayWithLoader = function(options, callback) { 4 var options = options || {}; 5 6 // 31.10.11jd - pokud je loadovany element v prvku s overflow:hidden, pak pouzijeme jeho rozmery 7 var $el = $(this); 8 9 if ( $(this).parent().css('overflow') == 'hidden' && $(this).parent().get(0).tagName.toLowerCase() != 'body' ) 10 $el = $(this).parent(); 11 12 var $loader = $('<div id="lightbox-loader"></div>').hide().css({ 13 'position' : 'absolute', 14 'background-color' : 'black', 15 'opacity' : 0.5, 16 'z-index' : 30, 17 'left' : $el.offset().left+parseInt($el.css('padding-left')), 18 'top' : $el.offset().top+parseInt($el.css('padding-top')) 19 }).css(options).appendTo('body'); 20 21 22 var $img = $('<img />').appendTo('body').addClass('hidden').bind('load',function(){ 23 $(this).css({'top':($el.height()-$(this).height())/2+'px','position':'relative'}).show().appendTo($loader).removeClass('hidden'); 24 25 if (typeof callback != 'undefined') 26 callback(); 27 }).attr('src', '/images/ajax-loader-black.gif'); 28 29 // 20120510jd - ve FF nefunguje load event, toto je pridano jako zaloha 30 setTimeout(function(){ 31 $img.trigger('load').unbind('load'); 32 },500); 33 34 $loader.fadeIn(); 35 $loader.width($el.width()); 36 $loader.height($el.height()); 37 38 return $loader; 39}; 40 41 42$.fn.fancyZoom = function(options){ 43 44 var options = $.extend({ 45 thumbsSelector: 'a.lightbox', 46 parseThumbSrc: function(src){return src;}, 47 parseThumbSrcInverse: function(src){return src;}, 48 customOnClose: function(){}, 49 customThumbOnclick: function(f, $thumb){f();} 50 }, options || {}); 51 52 var directory = options && options.directory ? options.directory : '/images/lightbox/'; 53 var zooming = false; 54 55// var debugUrlPrefix = '/_tools/delayed_image.php?delay=3&url='; 56 var debugUrlPrefix = ''; 57 var carouselPagesCount = 1; 58 var thumbsPerPage = 1; 59 var thumbnailWidth = 100; 60 var thumbnailHeight = 60; 61 var minPhotoPadding = 10; 62 var photosBarHeight = (thumbnailHeight+20); 63 var bigPhotoPadding = {top: 15, bottom: photosBarHeight + 15, left: 10, right: 10}; 64 65 // FIX-jd 2.8.2011 - pri opetovne inicializaci smazat predchozi kod 66 $('body > #lightbox, body > #zoom').remove(); 67 68 69 // Pro stare IEcka zapneme slowBrowser 70 var slowBrowser = ($.browser.msie == true && parseInt($.browser.version,10) < 9) || ($.browser.mozilla == true); 71 72 // Vytvorit udalost pro reakci na klik back buttonu 73 $(window).hashchange( function() { 74 if ((location.hash != '#lightbox' && location.hash != 'lightbox') && zooming==false) hideZoomBox(); 75 }); 76 // Pokud navstevnik prisel na url s #lightbox, nastavime priznak aby jsme pri zavirani nechodili o krok v historii zpet 77 pageLoadedWithHash = (location.hash == 'lightbox' || location.hash == '#lightbox'); 78 79 // Fronta fotek k preloadovani 80 var photosToPreload = new Array(); 81 82 if ($('#zoom').length == 0) { 83 var html = '<div id="zoom" style="display:none; z-index:100;"> \ 84 <div id="zoom_content"> \ 85 </div> \ 86 </div>'; 87 88 $('body').append(html); 89 } 90 91 var zoom = $('#zoom'); 92 var zoom_content = $('#zoom_content'); 93 94 // Vytvorit hlavni okno lightboxu 95 var $lightbox = $('<div class="'+LIGHTBOX_CLASS+'" id="lightbox"></div>').hide().appendTo('body'); 96 97 // Vytvorit pas fotek pro lightbox 98 var $photoBar = $('<div class="photosBar"></div>').css({ 99 height: photosBarHeight+'px' 100 }).appendTo($lightbox); 101 102 $('<a href="#">«</a>').addClass('prev').appendTo($photoBar).click(function(){ 103 slideCarousel(-1,$photos); 104 return false; 105 }); 106 var $photosWrapper = $('<div class="photosWrapper"></div>').appendTo($photoBar); 107 var $photosWrapperI = $('<div class="photosWrapperInner"></div>').appendTo($photosWrapper); 108 var $photos = $('<div class="photosCarousel"></div>').appendTo($photosWrapperI).attr('rel','0'); 109 110 // Pridat do ajaxu vychozi fotky nahledy 111 var totalWidth = 0; 112 113 $(options.thumbsSelector).each(function(i){ 114 115 var $photo = $('<a class="photo" href="#"></a>').css({ 116 width: thumbnailWidth, 117 height: thumbnailHeight 118 }).appendTo($photos).click(function(){ 119 $(this).addClass('clicked'); 120 // nacteme fotku a zobrazime do zoomcontentu 121 openBigPhoto($(this)); 122 123 return false; 124 }).hover(function(){ 125 $(this).addClass('hover').stop().fadeTo(200, 1); 126 },function(){ 127 if (!$(this).hasClass('selected')) 128 $(this).removeClass('hover').stop().fadeTo(200, LIGHTBOX_INACTIVE_THUMB_OPACITY); 129 }).css('opacity',LIGHTBOX_INACTIVE_THUMB_OPACITY); 130 131 if (i==0) $photo.addClass('first'); 132 var $img = $('img',this).clone().addClass('lightbox-thumb'); 133 134 135 // Pokud odkaz neobsahuje nahled, musime si ho zjistit podle hrefu (napr. v pripade vicestrankoveho vypisu fotek) 136 if ($('img',this).length == 0) { 137 $img = $('<img />') 138 .addClass('lightbox-thumb') 139 .attr('alt',$(this).attr('title')) 140 .attr('src', $(this).attr('href').replace('tn_zoom_','tn_')) 141 .attr('full_src', $(this).attr('href')); 142 } 143 $img.appendTo($photo) 144 145 146 // Pokud nahled neni na celou vysku, roztahneme ho na ni a width dopocitame 147 $('img',this).load(function(){ 148 var ratio = $(this).height() / $(this).width(); 149 var delta = ratio*thumbnailWidth - thumbnailHeight; 150 if (delta > 10) { 151 $img.css({'position':'relative','top':-(delta/2)}); 152 } 153 }); 154 155 156 totalWidth += ($photo.outerWidth() + $photo.outerWidth(true)); 157 }); 158 159 var singlePhoto = ($(options.thumbsSelector).length == 1); 160 161 // Vytvorit ovladaci panel 162 var $controls = $('<div class="controls"></div>') 163 .appendTo($lightbox) 164 .append($('<a class="prev" href="#"><span>'+PREDCHOZI+'</span></a>').click(function(){prev();return false;})) 165 .append($('<a class="next" href="#"><span>'+NASLEDUJICI+'</span></a>').click(function(){next();return false;})) 166 .append($('<a class="close" href="#"><span>'+ZAVRIT+'</span></a>').click(function(){hideZoomBox();return false;})); 167 168 if (!singlePhoto) { 169 bigPhotoPadding.top += $controls.height(); 170 } else { 171 $photoBar.hide(); 172 $('.prev,.next',$controls).hide(); 173 bigPhotoPadding.bottom -= photosBarHeight; 174 } 175 176 // Vypocitat thumbsPerPage pro prvni scrollovani pri otevreni (jeste nez se zavola resize) 177 //thumbsPerPage = ($photosWrapper.innerWidth()-120) / thumbnailWidth+10;
178 //carouselPagesCount = Math.ceil($('a.photo',$photos).length / Math.floor(thumbsPerPage)); 179 180 var mouseWheelPos = 0; 181 var lastMouseWheelPos = 0; 182 $(document).keydown(function(e){ 183 switch(e.which){ 184 case 37: 185 prev(); 186 break; 187 case 39: 188 next(); 189 break; 190 case 27: 191 hideZoomBox(); 192 break; 193 } 194 }).mousewheel(function(e, delta) { 195 if( !zoom.is(':visible')) return; 196 197 mouseWheelPos += delta; 198 if (mouseWheelPos >= 1) { 199 next(); 200 mouseWheelPos = 0; 201 } else if (mouseWheelPos <= -1) { 202 prev(); 203 mouseWheelPos = 0; 204 } 205 }); 206 207 $('.first',$photos).css('margin-left','5px'); 208 209 // Zaregistrovat funkci pro upravu velikosti a obrazku pru zmene velikosti okna 210 $(window).resize(function() { 211 212 var $img = $('img',zoom_content); 213 214 if( !$img.is(':visible')) return; 215 216 var width = $img.data('width'); 217 var height = $img.data('height'); 218 zoom.css(computeZoomBoxCSS(width, height, $img)); 219 220 // Prepocitat marginy nahledu v dolni liste 221 var thumbOuterWidth = thumbnailWidth+10; 222 thumbsPerPage = ($photosWrapper.innerWidth()-120) / thumbOuterWidth; 223 var thumbRemainder = thumbsPerPage - Math.floor(thumbsPerPage); 224 var remainderSize = Math.round(thumbOuterWidth * thumbRemainder)-20; 225 226 // V pripade ze jsou vsehcny fotky na jedne strance, pak jako doplneni po stranach pouzijeme sirku zbytku do cele stranky 227 // 20120606jd - $photos ma pevnou sirku, takze musime sirku vsech fotek vypocitat 228 var extraSpace = ($photosWrapper.width()-120) - (thumbnailWidth+10)*$('a',$photos).length/*$photos.width()*/; 229 if (extraSpace >= 0) { 230 remainderSize = extraSpace; /* -20 */ 231 } else { 232 remainderSize += 30; 233 } 234 235 // Centerovat thumby doprostred 236 $photosWrapperI.css('margin-left', 55+remainderSize/2); 237 $photosWrapperI.css('margin-right',55+remainderSize/2); 238 239 setFullPhotoIconPosition(); 240 241 // prepocitat pocet stranek 242 carouselPagesCount = Math.ceil($('a.photo',$photos).length / Math.floor(thumbsPerPage)); 243 244 // schovat controls pokud je jedna stranka. zaroven ale musime posunout na zacatek 245 checkCarouselControlsVisibility($photos); 246 }); 247 248 $photos.css({ 249 width: totalWidth 250 }); 251 252 253 254 255 $('<a href="#">»</a>').addClass('next').appendTo($photoBar).click(function(){ 256 slideCarousel(1,$photos); 257 return false; 258 }); 259 260 this.each(function(i) { 261 $(this).click(function(e){ 262 options.customThumbOnclick(function(){ 263 show(e); 264 }, $(this)); 265 return false; 266 }) 267 268// $(this).click(show); 269 }); 270 return this; 271 272 273 function setFullPhotoIconPosition() { 274 var $img = $('img',zoom_content); 275 276 // Naplacnout ikonu s full obrazekem do praveho dolniho rohu fotky 277 var $fullSize = $('a.fullsize'); 278 $fullSize.css({position: 'absolute', 279 left: $img.position().left + $img.width() - $fullSize.width(), 280 top:$img.position().top + $img.height() - $fullSize.height() 281 }); 282 } 283 284 function openBigPhoto($thumbA) { 285 // Pokud chceme nacitat fotku, ktera je nactena, nic nedelame 286 if ($('img',zoom_content).attr('thumb_src') == $('img',$thumbA).attr('src')) return; 287 288 // Pridat fotku do fronty nacitani, a to prednostne 289 preloadPhotos($thumbA, function($a){ 290 291 $('img',zoom_content).hide(); 292 293 var $img = $('img.preloaded',$a); 294 295 var width = $img.data('width'); 296 var height = $img.data('height'); 297 298 zoom.css(computeZoomBoxCSS(width, height, $img)); 299 300 301 // Presunout aktualni obrazek zpet k nahledu - jako by byl preloadnut 302 var $actualImg = $('img',zoom_content); 303 304 var $thumb_a = $('img[src*="'+$actualImg.attr('thumb_src')+'"]',$photos).parent().addClass('preloaded'); 305 if ($('img.preloaded',$thumb_a).length == 0) { 306 $actualImg 307 .addClass('hidden') 308 .addClass('preloaded') 309 .appendTo($thumb_a); 310 } 311 zoom_content.empty(); 312 313 // Presunout preloadnuty obrazek do zoomboxu 314 $img 315 .removeClass('hidden') 316 .removeClass('preloaded') 317 .hide() 318 .appendTo(zoom_content) 319 .show(); 320 //.fadeIn(); 321 322 323 // Zjistit a nastavit nadpis fotky. 324 var header = $('img.lightbox-thumb', $a).attr('alt'); 325 zoom_content.append($('<h1 class="photoTitle">'+((header===undefined)?'':header)+'</h1>')); 326 zoom_content.append( 327 createFullsizeIcon($img.attr('src').replace('tn_zoom_','')) 328 ); 329 setFullPhotoIconPosition(); 330 $(window).trigger('resize'); 331 checkThumbnailsSelection(); 332 }, true); 333 } 334 335 function preloadPhotos($aList, onLoad, highPriority) { 336 // Pridat fotky do fronty preloadovani 337 $aList.each(function(){ 338 // Do fronty ukladame element a jeho onload fci 339 var el = new Array(this, onLoad); 340 // Pokud je high priority, vkladame na zacatek 341 if (highPriority !== undefined &&highPriority == true) { 342 photosToPreload.unshift(el); 343 } else { 344 photosToPreload.push(el); 345 } 346 }); 347 preloadNextPhotoFromQueue(highPriority); 348 } 349 350 function preloadNextPhotoFromQueue(highPriority) { 351 var data = photosToPreload.shift(); 352 353 if (data === undefined) return; 354 355 var $a = $(data[0]); 356 var onLoad = data[1]; 357 358 var thumbSrc = $('img',$a).attr('src'); 359 360 // 26.6.2011 - jd - src velkeho obrazku brat z a href 361 var $parentA = $('img[src*="'+thumbSrc+'"]:not(.lightbox-thumb), img[src*="'+thumbSrc.replace('tn_filename_','tn_detail_filename_')+'"]:not(.lightbox-thumb)').parents('a'); 362 if ($parentA.length > 0) { 363 imageSrc = $parentA.attr('href'); 364 } else { 365 // pokud se ho neporadilo najit, napr v pripade vicestrankoveho vypisu, zkusime ho najit v atributu nahledoveho obrazku 366 var imageSrc = $('img',$a).attr('full_src'); 367 if (imageSrc.length == 0) { 368 // kdyz ani tam neni, tak ho zkusime ziskat explicitne 369 var prefix = ($('img',$a).hasClass('noPrefix')) ? '' : 'tn_zoom_'; 370 var imageSrc = $('img',$a).attr('src').replace('tn_',prefix).replace('tn2_',prefix); 371 } 372 } 373 374 // Pokud se fotka zrovna nacita, pak jen obrazku pridame custom onLoad a on se spusti jakmile se dokonci puvodni nacitani 375 if ($a.hasClass('preloading')) { 376 if ($a.hasClass('forcedPreloading')) return; 377 378 var $loader = $a.overlayWithLoader({'z-index':100000}); 379 var $preloadedThumb = $('img[src*="'+imageSrc+'"]'); 380 // Pridame classu abysme poznali, ze se uz bylo kliknuto tze nemusime pridavat loader 381 $a.addClass('forcedPreloading'); 382 $preloadedThumb.bind('load',function(){ 383 $loader.fadeOut(function(){ 384 $(this).remove(); 385 $a.removeClass('forcedPreloading'); 386 }); 387 if (onLoad !== undefined) onLoad($a); 388 }); 389 390 return; 391 } 392 393 // Pokud je fotka jiz nactena, jen zavolame custom onload fci 394 if ($a.hasClass('preloaded')) { 395 if (onLoad !== undefined) onLoad($a); 396 return; 397 } else { 398 // Pokud bylo na fotku kliknuto nasilne a je jeste okno otevrene, pak zobrazime loader 399 if (highPriority && zoom_content.is(':visible') && !zooming) { 400 var $loader = $a.overlayWithLoader({'z-index':100000}); 401 } 402 } 403 404 $a.addClass('preloading'); 405 var $img = $('<img />') 406 .addClass('hidden') 407 .addClass('preloaded') 408 .attr('thumb_src', thumbSrc) 409 .appendTo('body') 410 .load(function(){ 411 // nactenou fotku si pripojime do Acka aby jsme ho vzdycky nasli 412 $(this).appendTo($a); 413 $a.removeClass('preloading'); 414 $a.addClass('preloaded'); 415 416 if ($loader !== undefined) { 417 $loader.fadeOut(function(){$(this).remove()}); 418 } 419 420 // do dat si ulozime originalni velikost fotky 421 $(this).data('width',$(this).width()); 422 $(this).data('height',$(this).height()); 423
424 // zavolame cusotm onload fci 425 if (onLoad !== undefined) onLoad($a); 426 427 // spustime nacitani dalsi fotky, pokud se zrovna nejaka nenacita 428 if ($('.photosCarousel a.preloading').length == 0) 429 preloadNextPhotoFromQueue(false); 430 }); 431 // Kvuli ie je nutne nastavit src az po prirazeni load eventu 432 $img.attr('src',imageSrc); 433 } 434 435 function checkThumbnailsSelection() { 436 $('a.photo', $lightbox).each(function(){ 437 $(this).stop().removeClass('selected'); 438 // Pokud neni jiz zvyrazneny, odzvyraznime 439 if (!$(this).hasClass('clicked')) $(this).fadeTo(10,LIGHTBOX_INACTIVE_THUMB_OPACITY); 440 $(this).removeClass('clicked'); 441 442 if ($('img',this).attr('src') == $('img',zoom).attr('thumb_src')) { 443 444 $(this).addClass('selected').fadeTo(200,1); 445 // Pokud neni na prvni strance, slidneme na nej 446 slideCarouselTo($(this),$photos); 447 } 448 }) 449 450 var selectedIndex = $('a.selected',$lightbox).index(); 451 if (selectedIndex == 0) { 452 $('.controls .prev').addClass('disabled'); 453 } else { 454 $('.controls .prev').removeClass('disabled'); 455 } 456 if (selectedIndex == $('a.photo', $lightbox).length-1) { 457 $('.controls .next').addClass('disabled'); 458 } else { 459 $('.controls .next').removeClass('disabled'); 460 } 461 } 462 463 function slideCarouselTo($a, $carousel) { 464 if ($a == null || $a.length == 0) 465 $a = $('a.photo[src*="'+$('img',zoom_content).attr('thumb_src')+'"]',$lightbox); 466 if ($a.length == 0) return; 467 var pageNum = Math.ceil($a.prevAll().length/Math.floor(thumbsPerPage)+0.0000001); 468 slideCarousel((pageNum-1)-$photos.attr('rel'), $carousel, false); 469 } 470 471 function slideCarousel(offset, $carousel, noCheckContVis) { 472 var position = $carousel.attr('rel'); 473 474 if ( !(position<=0 && offset<0) && !(position >= (carouselPagesCount-1) && offset>0)) { 475 $carousel.attr('rel',parseInt($carousel.attr('rel'))+offset); 476 477 $carousel.animate({left:-$carousel.attr('rel')*($carousel.parent().width())}); 478 } 479 if (!noCheckContVis) 480 checkCarouselControlsVisibility($carousel); 481 } 482 483 function checkCarouselControlsVisibility($carousel) { 484 var pos = $carousel.attr('rel'); 485 486 487 488 var $prev = $('a.prev',$photoBar); 489 var $next = $('a.next',$photoBar); 490 if (carouselPagesCount == 1) { 491 if (!$prev.hasClass('disabled') || !$next.hasClass('disabled')) { 492 $prev.addClass('disabled'); 493 $next.addClass('disabled'); 494 slideCarouselTo(null,$photos); 495 } 496 } else { 497 if (pos == 0) { 498 $prev.addClass('disabled'); 499 } else { 500 $prev.removeClass('disabled'); 501 } 502 if (pos == carouselPagesCount-1) { 503 $next.addClass('disabled'); 504 } else { 505 $next.removeClass('disabled'); 506 } 507 } 508 } 509 510 function next() { 511 openBigPhoto($('a.selected',$photos).next()); 512 } 513 514 function prev() { 515 openBigPhoto($('a.selected',$photos).prev()); 516 } 517 518 function show(e) { 519// console.log(e) 520 // Priznak pro zamezeni vicenasobneho expandovani najednou 521 if (zooming) return false; 522 zooming = true; 523 524 location.hash = 'lightbox'; 525 526 527 // Najit nahledovy obrazek na ktery se kliknulo a zobrazit na nem loader 528 var $thumbImg = $(e.target); 529 530 // MiG - fix -> otevre se galerie i kdyz kliknu jen na odkaz nebo span v odkazu misto obrazku 531 var image = null; 532 if ($thumbImg.is("a")) 533 { 534 // pokud kliknu na odkaz kde ktery obsahu IMG 535 image = $thumbImg.children("img"); 536 } 537 else if ($thumbImg.is("span") && $thumbImg.parent("a").length > 0) 538 { 539 // pokud kliknu na span v acku kde se nachazi obrazek 540 image = $thumbImg.parent("a").children("img"); 541 } // end if 542 if (image != null && image.length > 0) $thumbImg = image; 543 // --- 544 545 var $loader = $thumbImg.overlayWithLoader(); 546 547 // Sestavit URL pro velky obrazek 548 549 550 // 26.6.2011 - jd - src velkeho obrazku brat z a href 551 var imageSrc = $thumbImg.parents('a').attr('href'); 552 553 // 31.10.11jd - pkud neni imageSrc, odvodime ho 554 if (imageSrc.length == 0 || imageSrc == '#') { 555 imageSrc = $thumbImg.attr('src').replace('tn_detail_','tn_zoom_'); 556 } 557 558 // ******************************************************************************************** 559 //TK20150831 - Stare verze sice maji jiny format, ale je potreba zachovat funkcnost i pro RT RT takze pokud
559soubor existuje, nedelat zadnou dalsi vyssi logiku 560 var http = null; 561 var fileExists = false; 562 563 if (window.XMLHttpRequest) 564 { 565 http = new XMLHttpRequest(); 566 } 567 else if (window.ActiveXObject) 568 { 569 http = new ActiveXObject("Microsoft.XMLHTTP"); 570 } 571 572 if (!!http) { 573 http.open('HEAD', imageSrc, true); 574 http.send(); 575 fileExists = (http.status != 404); 576 } 577 // ******************************************************************************************** 578 579 if (!fileExists && ( imageSrc.indexOf('tn_zoom_') == -1 )) { //PNV003213 stare verze RB maji jiny format tn_ 580 // imageSrc = imageSrc.replace('reality_photos/', 'reality_photos/tn_zoom_'); 581 //vk 17.8.2015 (D003242) 582 var index = imageSrc.lastIndexOf('/'); 583 imageSrc = imageSrc.substr(0, index + 1) + "tn_zoom_" + imageSrc.substr(index + 1); 584 } // end if 585 586 // Vytvorit obrazek a nabindovat obsluznou udalost po nacteni 587 // 20120420jd-2 - pri orezavani fotek se meni src, a puvodni se uklada do original_src -> pokud existuje pouzijeme ho misto src 588 var srcToParse = ( typeof $thumbImg.attr('original_src') !== 'undefined' && $thumbImg.attr('original_src').length>0) ? $thumbImg.attr('original_src') : $thumbImg.attr('src'); 589 590 var $img = $(new Image()).attr('thumb_src',options.parseThumbSrc(srcToParse)).attr('original_src',$thumbImg.attr('src')).load(function () { 591 $img = $(this); 592 593 // Schovat loader 594 $loader.fadeOut(function(){ 595 $(this).remove(); 596 }); 597 zoom_content.empty(); 598 599 // Odsunout z obrazu, pripojit na BODY, zjistit vysku a sirku a az pak vlozit do boxu 600 $img.addClass('hidden'); 601 $img.appendTo('body'); 602 var width = $img.outerWidth(); 603 var height = $img.outerHeight(); 604 $img.appendTo('#zoom_content'); 605 $img.css('width','100%'); 606 $img.css('height','100%'); 607 $img.removeClass('hidden'); 608 $img.data('width',width); 609 $img.data('height',height); 610 611 // Pridat nadpis fotky, odsoupnout ho pryc, aby v computeZoomBox sla zjistit height 612 var header = $thumbImg.attr('alt'); 613 var $photoTitle = $('<h1 class="photoTitle">'+((header===undefined)?'':header)+'</h1>').addClass('hidden').appendTo('body'); 614 zoom_content.append( 615 createFullsizeIcon(imageSrc.replace('tn_zoom_','')) 616 ); 617 618 $('#zoom_content>img, #zoom_content a:not(.close)').live({mouseover: function(){$('a.fullsize').show()}, mouseout: function(){$('a.fullsize').hide();}}); 619 620 // Resize pro zjisteni poctu stranek 621 $(window).trigger('resize'); 622 623 624 // Nastavit pocatecni vlastnosti zoomboxu 625 zoom.css({ 626 position : 'fixed', 627 top : ($thumbImg.offset().top+parseInt($thumbImg.css('padding-top'))-$(window).scrollTop()) + 'px', 628 left : ($thumbImg.offset().left+parseInt($thumbImg.css('padding-left'))-$(window).scrollLeft()) + 'px', 629 width : ($thumbImg.width())+'px', 630 height : ($thumbImg.height())+'px' 631 }); 632 zoom.show(); 633 634 $('#zoom, html').unbind('click').click(function(){ 635 hideZoomBox() 636 }); 637 638 // Zobrazit lightbox 639 if (slowBrowser) 640 $lightbox.show(); 641 else 642 $lightbox.fadeIn(); 643 644 645 // Schovat body scrollbar a misto nej nastavit margin aby body neskakalo 646 var bodyWidth = $('body').outerWidth(); 647 $('body').css({ 648 'overflow':'hidden' 649 }); 650 $('body').css('margin-right',$('body').outerWidth()-bodyWidth); 651 652 checkThumbnailsSelection(); 653 654 655 var openCallback = function() { 656 // Callback po otevreni 657 $(window).trigger('resize'); 658 659 var selectedIndex = $('.photosCarousel a.selected').index(); 660 preloadPhotos($('.photosCarousel a:gt('+selectedIndex+')')); 661 preloadPhotos($('.photosCarousel a:lt('+selectedIndex+')')); 662 663 664 zooming = false; 665 }; 666 667 // Rychle otevreni pro stare prohlizece 668 if (slowBrowser) { 669 zoom.css(computeZoomBoxCSS(width, height, $img)); 670 openCallback(); 671 } else { 672 zoom.animate(computeZoomBoxCSS(width, height, $img), 200, null, openCallback); 673 } 674 675 // Vysku nadpisu uz jsme zjistili, muzem nadpis dat kam patri 676 $photoTitle.removeClass('hidden').appendTo(zoom_content); 677 });
678 // Kvuli ie je nutne nastavit src az po prirazeni load eventu 679 $img.attr('src', imageSrc); 680 return false; 681 } 682 683 function createFullsizeIcon(src) { 684 // 201202131712tk - http://mantis.ebrana.cz/view.php?id=66802 685 return ''; 686 687 return $('<a class="fullsize" target="_blank" href="'+src+'"></a>').hide().click(function(event){ 688 event.stopPropagation(); 689 }) 690 } 691 692 693 694 function computeZoomBoxCSS(width, height, $img) { 695 $img.css({width:'100%',height:'100%'}); 696 697 var padding = bigPhotoPadding; 698 699 var titleHeight = $('h1.photoTitle').outerHeight(); 700 701 // pokud je fotka vyssi nebo sirsi nez velikost okna, napasujeme ji tam a druhy rozmer nechame dopocitat 702 if (($(window).height()-padding.bottom-titleHeight - padding.top) < height) { 703 704 // Pokud je oboje mensi, musime jeden rozmer dopocitavat numericky 705 if (($(window).width()-padding.left-padding.right) < width) { 706 height = $(window).height()-padding.bottom - padding.top-titleHeight; 707 width = ($img.data('width')/$img.data('height')) * height; 708 // Kdyz i tak fotka prekukuje, dopocitame i druhy rozmer 709 if (width > ($(window).width()-padding.left-padding.right)) { 710 width = $(window).width() - padding.left - padding.right; 711 height = ($img.data('height')/$img.data('width')) * width; 712 } 713 } else { 714 $img.css('width','auto'); 715 height = $(window).height() - padding.bottom - padding.top - titleHeight; 716 } 717 } else if (($(window).width()-padding.left-padding.right) < width) { 718 width = $(window).width()-padding.left-padding.right; 719 // nastavit obrazku auto, zjistit jeho height a nastavit ho zoomboxu 720 $img.css('height','auto'); 721 height = $img.data('height')/$img.data('width')*width; 722 } 723 724 var top = ( $(window).height() - height - titleHeight ) / 2 - ((padding.bottom)/2 + padding.top/2) + padding.top; 725 var left = ( $(window).width() - width ) / 2 - (padding.left/2 + padding.right/2) + padding.left; 726 727 return {'top':top, 'left':left, 'width':width, 'height':height}; 728 } 729 730 function hideZoomBox() { 731 732 if (zooming) return false; 733 734 photosToPreload = new Array(); 735 736 // Pokud je u velkeho obrazku ulozen original_src (v pripade odvozeni velkeho obrazku pouze z adresy nahledu), pouzijeme ho. Jinak pouzijeme thumb src 737 var thumbSrc = ((typeof $('img',zoom_content).attr('original_src') != 'undefined' && $('img',zoom_content).attr('original_src').length>0)?$('img',zoom_content).attr('original_src'):$('img',zoom_content).attr('thumb_src')); 738 var $thumbImg = $('img.lightbox[src*="'+thumbSrc+'"]:not(.lightbox-thumb):not(.cloned)'); 739 zooming = true; 740 741 // Pokud uzivatel neprisel rovnou na url s #lightbox, pak vratime o krok zpet 742 if ((location.hash=='#lightbox' || location.hash=='lightbox') && !pageLoadedWithHash) { 743 // Ulozit scrollovani a po vraceni historie (stranka skoci nahoru) nascrolovat kde to bylo 744 var scroll = $('body').scrollTop(); 745 history.go(-1); 746 747 setTimeout(function(){ 748 $('body').scrollTop(scroll); 749 },100); 750 } 751 752 // Pokud je obrazek otevreny ze slideru, pred zavrenim naslidujeme na spravnou stranu a zjistime si o kolik mame posunout cilovou pozici 753 var $slider = $thumbImg.parents('.nivoSlider'); 754 var extra_slide_distance = 0; 755 if ($slider.length > 0) { 756 var extra_slide_distance = $slider.data('nivoslider').moveTo($thumbImg); 757 } 758 759 // Zavolat custom close callback 760 options.customOnClose($thumbImg); 761 762 // Pokud neni platny $thumbImg (obrazek z nenactene stranky), pak do nej vlozime posledni platny nahled 763 if ($thumbImg.length == 0) { 764 $thumbImg = $('img.lightbox:last'); 765 766 // Zjistiti adresu kam mame presmerovat 767 var $a = $('a.lightbox[href*="'+$('img',zoom_content).attr('src').replace(debugUrlPrefix,'')+'"]'); 768 769 if ($a.length > 0) { 770 771 var url = location.href.substr(0,location.href.indexOf('?from=')); 772 773 // 20120710jd - pokud je v url i jiny param nez from, pak
773je potreba misto ? nahrazovat & a opacne 774 if (url.length == 0 ) url = location.href.substr(0,location.href.indexOf('&from=')); 775 var urlGlue = ( location.href.indexOf('?') >= 0 ) ? '&' : '?'; 776 777 if (url.length == 0) url = location.href; 778 779 url = url.replace('#lightbox',''); 780 781 var classList = $a.attr('class').split(/\s+/); 782 $.each( classList, function(index, item){ 783 if (item.indexOf('from-') == 0) { 784 url = url + urlGlue + "from="+item.substring(5); 785 } 786 }); 787 788 if (url.length > 0 && location.href != url && location.href != url+'#lightbox') { 789 $lightbox.overlayWithLoader({zIndex:30000}, function(){ 790 setTimeout(function(){ 791 location.href = url; 792 },200); 793 }); 794 return; 795 } 796 } 797 798 799 } 800 801 var lightboxHideCallback = function(){ 802 $('body').css({ 803 'overflow':'visible', 804 'margin-right': '0px' 805 }); 806 }; 807 808 if (slowBrowser) { 809 $lightbox.hide(); 810 lightboxHideCallback(); 811 } else { 812 $lightbox.fadeOut(lightboxHideCallback); 813 } 814 815 var props = { 816 top : ($thumbImg.offset().top +parseInt($thumbImg.css('padding-top'))-$(window).scrollTop())+'px', 817 left : ($thumbImg.offset().left+parseInt($thumbImg.css('padding-left'))-$(window).scrollLeft()+extra_slide_distance)+'px', 818 width : $thumbImg.width()+'px', 819 height : $thumbImg.height()+'px' 820 }; 821 var closeCallback = function() { 822 // Odbindovat z html udalost uzavreni 823 $('#zoom, html').unbind('click'); 824 825 // Smazat vsechny napreloadovane obrazky 826 $('a.photo img.preloaded',$photos).remove(); 827 $('a.preloaded',$photos).removeClass('preloaded'); 828 829 zoom.hide(); 830 zooming = false; 831 }; 832 // Pro stare prohlizece bez efektu 833 if (slowBrowser) { 834 zoom.css(props); 835 closeCallback(); 836 } else { 837 zoom.animate(props, 200, null, closeCallback); 838 } 839 840 841 842 return false; 843 } 844} 845})(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.