https://libertocleanersnola.com/wp-content/plugins/photoMosaic/inc…/jquery.prettyPhoto.js?ver=6.0.16
1/* ------------------------------------------------------------------------ 2 Class: prettyPhoto 3 Use: Lightbox clone for jQuery 4 Author: Stephane Caron (http://www.no-margin-for-errors.com) 5 Version: 3.0 6------------------------------------------------------------------------- */ 7 8(function($) { 9 $.prettyPhoto = {version: '3.0'}; 10 11 $.fn.prettyPhoto = function(pp_settings) { 12 pp_settings = $.extend({ 13 animation_speed: 'fast', /* fast/slow/normal */ 14 slideshow: false, /* false OR interval time in ms */ 15 autoplay_slideshow: false, /* true/false */ 16 opacity: 0.80, /* Value between 0 and 1 */ 17 show_title: true, /* true/false */ 18 allow_resize: true, /* Resize the photos bigger than viewport. true/false */ 19 default_width: 500, 20 default_height: 344, 21 counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */ 22 theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */ 23 hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */ 24 wmode: 'opaque', /* Set the flash wmode attribute */ 25 autoplay: true, /* Automatically start videos: True/False */ 26 modal: false, /* If set to true, only the close button will close the window */ 27 overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */ 28 keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */ 29 changepicturecallback: function(){}, /* Called everytime an item is shown/changed */ 30 callback: function(){}, /* Called when prettyPhoto is closed */ 31 markup: '<div class="pp_pic_holder"> \ 32 <div class="ppt"> </div> \ 33 <div class="pp_top"> \ 34 <div class="pp_left"></div> \ 35 <div class="pp_middle"></div> \ 36 <div class="pp_right"></div> \ 37 </div> \ 38 <div class="pp_content_container"> \ 39 <div class="pp_left"> \ 40 <div class="pp_right"> \ 41 <div class="pp_content"> \ 42 <div class="pp_loaderIcon"></div> \ 43 <div class="pp_fade"> \ 44 <a href="#" class="pp_expand" title="Expand the image">Expand</a> \ 45 <div class="pp_hoverContainer"> \ 46 <a class="pp_next" href="#">next</a> \ 47 <a class="pp_previous" href="#">previous</a> \ 48 </div> \ 49 <div id="pp_full_res"></div> \ 50 <div class="pp_details clearfix"> \ 51 <p class="pp_description"></p> \ 52 <a class="pp_close" href="#">Close</a> \ 53 <div class="pp_nav"> \ 54 <a href="#" class="pp_arrow_previous">Previous</a> \ 55 <p class="currentTextHolder">0/0</p> \ 56 <a href="#" class="pp_arrow_next">Next</a> \ 57 </div> \ 58 </div> \ 59 </div> \ 60 </div> \ 61 </div> \ 62 </div> \ 63 </div> \ 64 <div class="pp_bottom"> \ 65 <div class="pp_left"></div> \ 66 <div class="pp_middle"></div> \ 67 <div class="pp_right"></div> \ 68 </div> \ 69 </div> \ 70 <div class="pp_overlay"></div>', 71 gallery_markup: '<div class="pp_gallery"> \ 72 <a href="#" class="pp_arrow_previous">Previous</a> \ 73 <ul> \ 74 {gallery} \ 75 </ul> \ 76 <a href="#" class="pp_arrow_next">Next</a> \ 77 </div>', 78 image_markup: '<img id="fullResImage" src="" />', 79 flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>', 80 quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>', 81 iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>', 82 inline_markup: '<div class="pp_inline clearfix">{content}</div>', 83 custom_markup: '' 84 }, pp_settings); 85 86 // Global variables accessible only by prettyPhoto 87 var matchedObjects = this, percentBased = false, correctSizes, pp_open, 88 89 // prettyPhoto container specific 90 pp_contentHeight, pp_contentWidth, pp_containerHeight, pp_containerWidth, 91 92 // Window size 93 windowHeight = $(window).height(), windowWidth = $(window).width(), 94 95 // Global elements 96 pp_slideshow; 97 98 doresize = true, scroll_pos = _get_scroll(); 99 100 // Window/Keyboard events 101 // $(window).unbind('resize').resize(function(){ _center_overlay(); _resize_overlay(); }); 102 $(window).unbind('resize.prettyPhoto').bind('resize.prettyPhoto', function(){ 103 _center_overlay(); 104 _resize_overlay(); 105 }); 106 107 if(pp_settings.keyboard_shortcuts) { 108 $(document).unbind('keydown.prettyPhoto').bind('keydown.prettyPhoto', function(e){ 109 if(typeof $pp_pic_holder != 'undefined'){ 110 if($pp_pic_holder.is(':visible')){ 111 switch(e.keyCode){ 112 case 37: 113 $.prettyPhoto.changePage('previous'); 114 break; 115 case 39: 116 $.prettyPhoto.changePage('next'); 117 break; 118 case 27: 119 if(!settings.modal) 120 $.prettyPhoto.close(); 121 break; 122 }; 123 return false;
124 }; 125 }; 126 }); 127 } 128 129 130 /** 131 * Initialize prettyPhoto. 132 */ 133 $.prettyPhoto.initialize = function() { 134 settings = pp_settings; 135 136 if($.browser.msie && parseInt($.browser.version) == 6) settings.theme = "light_square"; // Fallback to a supported theme for IE6 137 138 _buildOverlay(this); // Build the overlay {this} being the caller 139 140 if(settings.allow_resize) 141 $(window).bind('scroll.prettyPhoto', function(){ _center_overlay(); }); 142 143 _center_overlay(); 144 145 set_position = $.inArray($(this).attr('href'), pp_images); // Define where in the array the clicked item is positionned 146 147 $.prettyPhoto.open(); 148 149 return false; 150 } 151 152 153 /** 154 * Opens the prettyPhoto modal box. 155 * @param image {String,Array} Full path to the image to be open, can also be an array containing full images paths. 156 * @param title {String,Array} The title to be displayed with the picture, can also be an array containing all the titles. 157 * @param description {String,Array} The description to be displayed with the picture, can also be an array containing all the descriptions. 158 */ 159 $.prettyPhoto.open = function() { 160 if(typeof settings == "undefined"){ // Means it's an API call, need to manually get the settings and set the variables 161 settings = pp_settings; 162 if($.browser.msie && $.browser.version == 6) settings.theme = "light_square"; // Fallback to a supported theme for IE6 163 _buildOverlay(this); // Build the overlay {this} being the caller 164 pp_images = $.makeArray(arguments[0]); 165 pp_titles = (arguments[1]) ? $.makeArray(arguments[1]) : $.makeArray(""); 166 pp_descriptions = (arguments[2]) ? $.makeArray(arguments[2]) : $.makeArray(""); 167 isSet = (pp_images.length > 1) ? true : false; 168 set_position = 0; 169 } 170 171 if($.browser.msie && $.browser.version == 6) $('select').css('visibility','hidden'); // To fix the bug with IE select boxes 172 173 if(settings.hideflash) $('object,embed').css('visibility','hidden'); // Hide the flash 174 175 _checkPosition($(pp_images).size()); // Hide the next/previous links if on first or last images. 176 177 $('.pp_loaderIcon').show(); 178 179 // Fade the content in 180 if($ppt.is(':hidden')) $ppt.css('opacity',0).show(); 181 $pp_overlay.show().fadeTo(settings.animation_speed,settings.opacity); 182 183 // Display the current position 184 $pp_pic_holder.find('.currentTextHolder').text((set_position+1) + settings.counter_separator_label + $(pp_images).size()); 185 186 // Set the description 187 $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position])); 188 189 // Set the title 190 (settings.show_title && pp_titles[set_position] != "") ? $ppt.html(unescape(pp_titles[set_position])) : $ppt.html(' '); 191 192 // Get the dimensions 193 movie_width = ( parseFloat(grab_param('width',pp_images[set_position])) ) ? grab_param('width',pp_images[set_position]) : settings.default_width.toString(); 194 movie_height = ( parseFloat(grab_param('height',pp_images[set_position])) ) ? grab_param('height',pp_images[set_position]) : settings.default_height.toString(); 195 196 // If the size is % based, calculate according to window dimensions 197 if(movie_width.indexOf('%') != -1 || movie_height.indexOf('%') != -1){ 198 movie_height = parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 150); 199 movie_width = parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 150); 200 percentBased = true; 201 }else{ 202 percentBased = false; 203 } 204 205 // Fade the holder 206 $pp_pic_holder.fadeIn(function(){ 207 imgPreloader = ""; 208 209 // Inject the proper content 210 switch(_getFileType(pp_images[set_position])){ 211 case 'image': 212 imgPreloader = new Image(); 213 214 // Preload the neighbour images 215 nextImage = new Image(); 216 if(isSet && set_position > $(pp_images).size()) nextImage.src = pp_images[set_position + 1]; 217 prevImage = new Image(); 218 if(isSet && pp_images[set_position - 1]) prevImage.src = pp_images[set_position - 1]; 219 220 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = settings.image_markup; 221 $pp_pic_holder.find('#fullResImage').attr('src',pp_images[set_position]); 222 223 imgPreloader.onload = function(){ 224 // Fit item to viewport 225 correctSizes = _fitToViewport(imgPreloader.width,imgPreloader.height); 226 227 _showContent(); 228 }; 229 230 imgPreloader.onerror = function(){ 231 alert('Image cannot be loaded. Make sure the path is correct and image exist.'); 232 $.prettyPhoto.close(); 233 }; 234 235 imgPreloader.src = pp_images[set_position]; 236 break; 237 238 case 'youtube': 239 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 240 241 movie = 'http://www.youtube.com/v/'+grab_param('v',pp_images[set_position]); 242 if(settings.autoplay) movie += "&autoplay=1"; 243 244 toInject = settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie); 245 break; 246 247 case 'vimeo': 248 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 249 250 movie_id = pp_images[set_position]; 251 var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)/; 252 var match = movie_id.match(regExp); 253 254 movie = 'http://player.vimeo.com/video/'+ match[2] +'?title=0&byline=0&portrait=0'; 255 if(settings.autoplay) movie += "&autoplay=1;"; 256 257 vimeo_width = correctSizes['width'] + '/embed/?moog_width='+ correctSizes['width']; 258 259 toInject = settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,correctSizes['height']).replace(/{path}/g,movie); 260 break; 261 262 case 'quicktime': 263 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 264 correctSizes['height']+=15; correctSizes['contentHeight']+=15; correctSizes['containerHeight']+=15; // Add space for the control bar 265 266 toInject = settings.quicktime_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}
266/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay); 267 break; 268 269 case 'flash': 270 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 271 272 flash_vars = pp_images[set_position]; 273 flash_vars = flash_vars.substring(pp_images[set_position].indexOf('flashvars') + 10,pp_images[set_position].length); 274 275 filename = pp_images[set_position]; 276 filename = filename.substring(0,filename.indexOf('?')); 277 278 toInject = settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars); 279 break; 280 281 case 'iframe': 282 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 283 284 frame_url = pp_images[set_position]; 285 frame_url = frame_url.substr(0,frame_url.indexOf('iframe')-1); 286 287 toInject = settings.iframe_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{path}/g,frame_url); 288 break; 289 290 case 'custom': 291 correctSizes = _fitToViewport(movie_width,movie_height); // Fit item to viewport 292 293 toInject = settings.custom_markup; 294 break; 295 296 case 'inline': 297 // to get the item height clone it, apply default width, wrap it in the prettyPhoto containers , then delete 298 myClone = $(pp_images[set_position]).clone().css({'width':settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo($('body')); 299 correctSizes = _fitToViewport($(myClone).width(),$(myClone).height()); 300 $(myClone).remove(); 301 toInject = settings.inline_markup.replace(/{content}/g,$(pp_images[set_position]).html()); 302 break; 303 }; 304 305 if(!imgPreloader){ 306 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; 307 308 // Show content 309 _showContent(); 310 }; 311 }); 312 313 return false; 314 }; 315 316 317 /** 318 * Change page in the prettyPhoto modal box 319 * @param direction {String} Direction of the paging, previous or next. 320 */ 321 $.prettyPhoto.changePage = function(direction){ 322 currentGalleryPage = 0; 323 324 if(direction == 'previous') { 325 set_position--; 326 if (set_position < 0){ 327 set_position = 0; 328 return; 329 }; 330 }else if(direction == 'next'){ 331 set_position++; 332 if(set_position > $(pp_images).size()-1) { 333 set_position = 0; 334 } 335 }else{ 336 set_position=direction; 337 }; 338 339 if(!doresize) doresize = true; // Allow the resizing of the images 340 $('.pp_contract').removeClass('pp_contract').addClass('pp_expand'); 341 342 _hideContent(function(){ $.prettyPhoto.open(); }); 343 }; 344 345 346 /** 347 * Change gallery page in the prettyPhoto modal box 348 * @param direction {String} Direction of the paging, previous or next. 349 */ 350 $.prettyPhoto.changeGalleryPage = function(direction){ 351 if(direction=='next'){ 352 currentGalleryPage ++; 353 354 if(currentGalleryPage > totalPage){ 355 currentGalleryPage = 0; 356 }; 357 }else if(direction=='previous'){ 358 currentGalleryPage --; 359 360 if(currentGalleryPage < 0){ 361 currentGalleryPage = totalPage; 362 }; 363 }else{ 364 currentGalleryPage = direction; 365 }; 366 367 // Slide the pages, if we're on the last page, find out how many items we need to slide. To make sure we don't have an empty space. 368 itemsToSlide = (currentGalleryPage == totalPage) ? pp_images.length - ((totalPage) * itemsPerPage) : itemsPerPage; 369 370 $pp_pic_holder.find('.pp_gallery li').each(function(i){ 371 $(this).animate({ 372 'left': (i * itemWidth) - ((itemsToSlide * itemWidth) * currentGalleryPage) 373 }); 374 }); 375 }; 376 377 378 /** 379 * Start the slideshow... 380 */ 381 $.prettyPhoto.startSlideshow = function(){ 382 if(typeof pp_slideshow == 'undefined'){ 383 $pp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function(){ 384 $.prettyPhoto.stopSlideshow(); 385 return false; 386 }); 387 pp_slideshow = setInterval($.prettyPhoto.startSlideshow,settings.slideshow); 388 }else{ 389 $.prettyPhoto.changePage('next'); 390 }; 391 } 392 393 394 /** 395 * Stop the slideshow... 396 */ 397 $.prettyPhoto.stopSlideshow = function(){ 398 $pp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function(){ 399 $.prettyPhoto.startSlideshow(); 400 return false;
401 }); 402 clearInterval(pp_slideshow); 403 pp_slideshow=undefined; 404 } 405 406 407 /** 408 * Closes prettyPhoto. 409 */ 410 $.prettyPhoto.close = function(){ 411 412 clearInterval(pp_slideshow); 413 414 $pp_pic_holder.stop().find('object,embed').css('visibility','hidden'); 415 416 $('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed,function(){ $(this).remove(); }); 417 418 $pp_overlay.fadeOut(settings.animation_speed, function(){ 419 if($.browser.msie && $.browser.version == 6) $('select').css('visibility','visible'); // To fix the bug with IE select boxes 420 421 if(settings.hideflash) $('object,embed').css('visibility','visible'); // Show the flash 422 423 $(this).remove(); // No more need for the prettyPhoto markup 424 425 $(window).unbind('scroll.prettyPhoto'); 426 427 settings.callback(); 428 429 doresize = true; 430 431 pp_open = false; 432 433 delete settings; 434 }); 435 }; 436 437 /** 438 * Set the proper sizes on the containers and animate the content in. 439 */ 440 _showContent = function(){ 441 $('.pp_loaderIcon').hide(); 442 443 $ppt.fadeTo(settings.animation_speed,1); 444 445 // Calculate the opened top position of the pic holder 446 projectedTop = scroll_pos['scrollTop'] + ((windowHeight/2) - (correctSizes['containerHeight']/2)); 447 if(projectedTop < 0) projectedTop = 0; 448 449 // Resize the content holder 450 $pp_pic_holder.find('.pp_content').animate({'height':correctSizes['contentHeight']},settings.animation_speed); 451 452 // Resize picture the holder 453 $pp_pic_holder.animate({ 454 'top': projectedTop, 455 'left': (windowWidth/2) - (correctSizes['containerWidth']/2), 456 'width': correctSizes['containerWidth'] 457 },settings.animation_speed,function(){ 458 $pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(correctSizes['height']).width(correctSizes['width']); 459 460 $pp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed); // Fade the new content 461 462 // Show the nav 463 if(isSet && _getFileType(pp_images[set_position])=="image") { $pp_pic_holder.find('.pp_hoverContainer').show(); }else{ $pp_pic_holder.find('.pp_hoverContainer').hide(); } 464 465 if(correctSizes['resized']) $('a.pp_expand,a.pp_contract').fadeIn(settings.animation_speed); // Fade the resizing link if the image is resized 466 467 if(settings.autoplay_slideshow && !pp_slideshow && !pp_open) $.prettyPhoto.startSlideshow(); 468 469 settings.changepicturecallback(); // Callback! 470 471 pp_open = true; 472 }); 473 474 _insert_gallery(); 475 }; 476 477 /** 478 * Hide the content...DUH! 479 */ 480 function _hideContent(callback){ 481 // Fade out the current picture 482 $pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden'); 483 $pp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed,function(){ 484 $('.pp_loaderIcon').show(); 485 486 callback(); 487 }); 488 }; 489 490 /** 491 * Check the item position in the gallery array, hide or show the navigation links 492 * @param setCount {integer} The total number of items in the set 493 */ 494 function _checkPosition(setCount){ 495 // If at the end, hide the next link 496 if(set_position == setCount-1) { 497 $pp_pic_holder.find('a.pp_next').css('visibility','hidden'); 498 $pp_pic_holder.find('a.pp_next').addClass('disabled').unbind('click'); 499 }else{ 500 $pp_pic_holder.find('a.pp_next').css('visibility','visible'); 501 $pp_pic_holder.find('a.pp_next.disabled').removeClass('disabled').bind('click',function(){ 502 $.prettyPhoto.changePage('next'); 503 return false; 504 }); 505 }; 506 507 // If at the beginning, hide the previous link 508 if(set_position == 0) { 509 $pp_pic_holder 510 .find('a.pp_previous') 511 .css('visibility','hidden') 512 .addClass('disabled') 513 .unbind('click'); 514 }else{ 515 $pp_pic_holder.find('a.pp_previous.disabled') 516 .css('visibility','visible') 517 .removeClass('disabled') 518 .bind('click',function(){ 519 $.prettyPhoto.changePage('previous'); 520 return false; 521 }); 522 }; 523 524 (setCount > 1) ? $('.pp_nav').show() : $('.pp_nav').hide(); // Hide the bottom nav if it's not a set. 525 }; 526 527 /** 528 * Resize the item dimensions if it's bigger than the viewport 529 * @param width {integer} Width of the item to be opened 530 * @param height {integer} Height of the item to be opened 531 * @return An array containin the "fitted" dimensions 532 */ 533 function _fitToViewport(width,height){ 534 resized = false;
535 536 _getDimensions(width,height); 537 538 // Define them in case there's no resize needed 539 imageWidth = width, imageHeight = height; 540 541 if( ((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) && doresize && settings.allow_resize && !percentBased) { 542 resized = true, fitting = false; 543 544 while (!fitting){ 545 if((pp_containerWidth > windowWidth)){ 546 imageWidth = (windowWidth - 200); 547 imageHeight = (height/width) * imageWidth; 548 }else if((pp_containerHeight > windowHeight)){ 549 imageHeight = (windowHeight - 200); 550 imageWidth = (width/height) * imageHeight; 551 }else{ 552 fitting = true; 553 }; 554 555 pp_containerHeight = imageHeight, pp_containerWidth = imageWidth; 556 }; 557 558 _getDimensions(imageWidth,imageHeight); 559 }; 560 561 return { 562 width:Math.floor(imageWidth), 563 height:Math.floor(imageHeight), 564 containerHeight:Math.floor(pp_containerHeight), 565 containerWidth:Math.floor(pp_containerWidth) + 40, // 40 behind the side padding 566 contentHeight:Math.floor(pp_contentHeight), 567 contentWidth:Math.floor(pp_contentWidth), 568 resized:resized 569 }; 570 }; 571 572 /** 573 * Get the containers dimensions according to the item size 574 * @param width {integer} Width of the item to be opened 575 * @param height {integer} Height of the item to be opened 576 */ 577 function _getDimensions(width,height){ 578 width = parseFloat(width); 579 height = parseFloat(height); 580 581 // Get the details height, to do so, I need to clone it since it's invisible 582 $pp_details = $pp_pic_holder.find('.pp_details'); 583 $pp_details.width(width); 584 detailsHeight = parseFloat($pp_details.css('marginTop')) + parseFloat($pp_details.css('marginBottom')); 585 $pp_details = $pp_details.clone().appendTo($('body')).css({ 586 'position':'absolute', 587 'top':-10000 588 }); 589 detailsHeight += $pp_details.height(); 590 detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight; // Min-height for the details 591 if($.browser.msie && $.browser.version==7) detailsHeight+=8; 592 $pp_details.remove(); 593 594 // Get the container size, to resize the holder to the right dimensions 595 pp_contentHeight = height + detailsHeight; 596 pp_contentWidth = width; 597 pp_containerHeight = pp_contentHeight + $ppt.height() + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height(); 598 pp_containerWidth = width; 599 } 600 601 function _getFileType(itemSrc){ 602 if (itemSrc.match(/youtube\.com\/watch/i)) { 603 return 'youtube'; 604 }else if (itemSrc.match(/vimeo\.com/i)) { 605 return 'vimeo'; 606 }else if(itemSrc.indexOf('.mov') != -1){ 607 return 'quicktime'; 608 }else if(itemSrc.indexOf('.swf') != -1){ 609 return 'flash'; 610 }else if(itemSrc.indexOf('iframe') != -1){ 611 return 'iframe'; 612 }else if(itemSrc.indexOf('custom') != -1){ 613 return 'custom'; 614 }else if(itemSrc.substr(0,1) == '#'){ 615 return 'inline'; 616 }else{ 617 return 'image'; 618 }; 619 }; 620 621 function _center_overlay(){ 622 if(doresize && typeof $pp_pic_holder != 'undefined') { 623 scroll_pos = _get_scroll(); 624 625 titleHeight = $ppt.height(), contentHeight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width(); 626 627 projectedTop = (windowHeight/2) + scroll_pos['scrollTop'] - (contentHeight/2); 628 629 $pp_pic_holder.css({ 630 'top': projectedTop, 631 'left': (windowWidth/2) + scroll_pos['scrollLeft'] - (contentwidth/2) 632 }); 633 }; 634 }; 635 636 function _get_scroll(){ 637 if (self.pageYOffset) { 638 return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}; 639 } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict 640 return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}; 641 } else if (document.body) {// all other Explorers 642 return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}; 643 }; 644 }; 645 646 function _resize_overlay() { 647 windowHeight = $(window).height(), windowWidth = $(window).width(); 648 649 if(typeof $pp_overlay != "undefined") $pp_overlay.height($(document).height()); 650 }; 651 652 function _insert_gallery(){ 653 if(isSet && settings.overlay_gallery && _getFileType(pp_images[set_position])=="image") { 654 itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. 655 navWidth = (settings.theme == "facebook") ? 58 : 38; // Define the arrow width depending on the theme 656 657 itemsPerPage = Math.floor((correctSizes['containerWidth'] - 100 - navWidth) / itemWidth); 658 itemsPerPage = (itemsPerPage < pp_images.length) ? itemsPerPage : pp_images.length;
659 totalPage = Math.ceil(pp_images.length / itemsPerPage) - 1; 660 661 // Hide the nav in the case there's no need for links 662 if(totalPage == 0){ 663 navWidth = 0; // No nav means no width! 664 $pp_pic_holder.find('.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous').hide(); 665 }else{ 666 $pp_pic_holder.find('.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous').show(); 667 }; 668 669 galleryWidth = itemsPerPage * itemWidth + navWidth; 670 671 // Set the proper width to the gallery items 672 $pp_pic_holder.find('.pp_gallery') 673 .width(galleryWidth) 674 .css('margin-left',-(galleryWidth/2)); 675 676 $pp_pic_holder 677 .find('.pp_gallery ul') 678 .width(itemsPerPage * itemWidth) 679 .find('li.selected') 680 .removeClass('selected'); 681 682 goToPage = (Math.floor(set_position/itemsPerPage) <= totalPage) ? Math.floor(set_position/itemsPerPage) : totalPage; 683 684 685 if(itemsPerPage) { 686 $pp_pic_holder.find('.pp_gallery').hide().show().removeClass('disabled'); 687 }else{ 688 $pp_pic_holder.find('.pp_gallery').hide().addClass('disabled'); 689 } 690 691 $.prettyPhoto.changeGalleryPage(goToPage); 692 693 $pp_pic_holder 694 .find('.pp_gallery ul li:eq('+set_position+')') 695 .addClass('selected'); 696 }else{ 697 $pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave'); 698 $pp_pic_holder.find('.pp_gallery').hide(); 699 } 700 } 701 702 function _buildOverlay(caller){ 703 // Find out if the picture is part of a set 704 theRel = $(caller).attr('rel'); 705 galleryRegExp = /\[(?:.*)\]/; 706 isSet = (galleryRegExp.exec(theRel)) ? true : false; 707 708 // Put the SRCs, TITLEs, ALTs into an array. 709 pp_images = (isSet) ? $.map(matchedObjects, function(n, i){ if($(n).attr('rel').indexOf(theRel) != -1) return $(n).attr('href'); }) : $.makeArray($(caller).attr('href')); 710 pp_titles = (isSet) ? $.map(matchedObjects, function(n, i){ if($(n).attr('rel').indexOf(theRel) != -1) return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : ""; }) : $.makeArray($(caller).find('img').attr('alt')); 711 pp_descriptions = (isSet) ? $.map(matchedObjects, function(n, i){ if($(n).attr('rel').indexOf(theRel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; }) : $.makeArray($(caller).attr('title')); 712 713 $('body').append(settings.markup); // Inject the markup 714 715 $pp_pic_holder = $('.pp_pic_holder') , $ppt = $('.ppt'), $pp_overlay
715= $('div.pp_overlay'); // Set my global selectors 716 717 // Inject the inline gallery! 718 if(isSet && settings.overlay_gallery) { 719 currentGalleryPage = 0; 720 toInject = ""; 721 for (var i=0; i < pp_images.length; i++) { 722 var regex = new RegExp("(.*?)\.(jpg|jpeg|png|gif)$"); 723 var results = regex.exec( pp_images[i] ); 724 if(!results){ 725 classname = 'default'; 726 }else{ 727 classname = ''; 728 } 729 toInject += "<li class='"+classname+"'><a href='#'><img src='" + pp_images[i] + "' width='50' alt='' /></a></li>"; 730 }; 731 732 toInject = settings.gallery_markup.replace(/{gallery}/g,toInject); 733 734 $pp_pic_holder.find('#pp_full_res').after(toInject); 735 736 $pp_pic_holder.find('.pp_gallery .pp_arrow_next').click(function(){ 737 $.prettyPhoto.changeGalleryPage('next'); 738 $.prettyPhoto.stopSlideshow(); 739 return false; 740 }); 741 742 $pp_pic_holder.find('.pp_gallery .pp_arrow_previous').click(function(){ 743 $.prettyPhoto.changeGalleryPage('previous'); 744 $.prettyPhoto.stopSlideshow(); 745 return false; 746 }); 747 748 $pp_pic_holder.find('.pp_content').hover( 749 function(){ 750 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn(); 751 }, 752 function(){ 753 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut(); 754 }); 755 756 itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. 757 $pp_pic_holder.find('.pp_gallery ul li').each(function(i){ 758 $(this).css({ 759 'position':'absolute', 760 'left': i * itemWidth 761 }); 762 763 $(this).find('a').unbind('click').click(function(){ 764 $.prettyPhoto.changePage(i); 765 $.prettyPhoto.stopSlideshow(); 766 return false; 767 }); 768 }); 769 }; 770 771 772 // Inject the play/pause if it's a slideshow 773 if(settings.slideshow){ 774 $pp_pic_holder.find('.pp_nav').prepend('<a href="#" class="pp_play">Play</a>') 775 $pp_pic_holder.find('.pp_nav .pp_play').click(function(){ 776 $.prettyPhoto.startSlideshow(); 777 return false; 778 }); 779 } 780 781 $pp_pic_holder.attr('class','pp_pic_holder ' + settings.theme); // Set the proper theme 782 783 $pp_overlay 784 .css({ 785 'opacity':0, 786 'height':$(document).height(), 787 'width':$(document).width() 788 }) 789 .bind('click',function(){ 790 if(!settings.modal) $.prettyPhoto.close(); 791 }); 792 793 $('a.pp_close').bind('click',function(){ $.prettyPhoto.close(); return false; }); 794 795 $('a.pp_expand').bind('click',function(e){ 796 // Expand the image 797 if($(this).hasClass('pp_expand')){ 798 $(this).removeClass('pp_expand').addClass('pp_contract'); 799 doresize = false; 800 }else{ 801 $(this).removeClass('pp_contract').addClass('pp_expand'); 802 doresize = true; 803 }; 804 805 _hideContent(function(){ $.prettyPhoto.open(); }); 806 807 return false; 808 }); 809 810 $pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){ 811 $.prettyPhoto.changePage('previous'); 812 $.prettyPhoto.stopSlideshow(); 813 return false; 814 }); 815 816 $pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){ 817 $.prettyPhoto.changePage('next'); 818 $.prettyPhoto.stopSlideshow(); 819 return false; 820 }); 821 822 _center_overlay(); // Center it 823 }; 824 825 return this.unbind('click').click($.prettyPhoto.initialize); // Return the $ object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once 826 }; 827 828 function grab_param(name,url){ 829 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 830 var regexS = "[\\?&]"+name+"=([^&#]*)"; 831 var regex = new RegExp( regexS ); 832 var results = regex.exec( url ); 833 return ( results == null ) ? "" : results[1]; 834 } 835 836})(JQPM);
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.