1/* ------------------------------------------------------------------------ 2 Class: prettyPhoto 3 Use: Lightbox clone for jQuery 4 Author: Stephane Caron (http://www.no-margin-for-errors.com) 5 Version: 3.1.3 6------------------------------------------------------------------------- */ 7 8(function($) { 9 $.prettyPhoto = { 10 version: '3.1.3' 11 }; 12 $.fn.prettyPhoto = function(pp_settings) { 13 pp_settings = jQuery.extend({ 14 animation_speed: 'fast', 15 slideshow: 5000, 16 autoplay_slideshow: false, 17 opacity: 0.80, 18 show_title: true, 19 allow_resize: true, 20 default_width: 500, 21 default_height: 344, 22 counter_separator_label: '/', 23 theme: 'pp_default', 24 horizontal_padding: 20, 25 hideflash: false, 26 wmode: 'opaque', 27 autoplay: true, 28 modal: false, 29 deeplinking: true, 30 overlay_gallery: true, 31 keyboard_shortcuts: true, 32 changepicturecallback: function() {}, 33 callback: function() {}, 34 ie6_fallback: true, 35 markup: '<div class="pp_pic_holder"> \ 36 <div class="ppt"> </div> \ 37 <div class="pp_top"> \ 38 <div class="pp_left"></div> \ 39 <div class="pp_middle"></div> \ 40 <div class="pp_right"></div> \ 41 </div> \ 42 <div class="pp_content_container"> \ 43 <div class="pp_left"> \ 44 <div class="pp_right"> \ 45 <div class="pp_content"> \ 46 <div class="pp_loaderIcon"></div> \ 47 <div class="pp_fade"> \ 48 <a href="#" class="pp_expand" title="Expand the image">Expand</a> \ 49 <div class="pp_hoverContainer"> \ 50 <a class="pp_next" href="#">next</a> \ 51 <a class="pp_previous" href="#">previous</a> \ 52 </div> \ 53 <div id="pp_full_res"></div> \ 54 <div class="pp_details"> \ 55 <div class="pp_nav"> \ 56 <a href="#" class="pp_arrow_previous">Previous</a> \ 57 <p class="currentTextHolder">0/0</p> \ 58 <a href="#" class="pp_arrow_next">Next</a> \ 59 </div> \ 60 <p class="pp_description"></p> \ 61 <div class="pp_social">{pp_social}</div> \ 62 <a class="pp_close" href="#">Close</a> \ 63 </div> \ 64 </div> \ 65 </div> \ 66 </div> \ 67 </div> \ 68 </div> \ 69 <div class="pp_bottom"> \ 70 <div class="pp_left"></div> \ 71 <div class="pp_middle"></div> \ 72 <div class="pp_right"></div> \ 73 </div> \ 74 </div> \ 75 <div class="pp_overlay"></div>', 76 gallery_markup: '<div class="pp_gallery"> \ 77 <a href="#" class="pp_arrow_previous">Previous</a> \ 78 <div> \ 79 <ul> \ 80 {gallery} \ 81 </ul> \ 82 </div> \ 83 <a href="#" class="pp_arrow_next">Next</a> \ 84 </div>', 85 image_markup: '<img id="fullResImage" src="{path}" />', 86 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>', 87 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>', 88 iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>', 89 inline_markup: '<div class="pp_inline">{content}</div>', 90 custom_markup: '', 91 social_tools: '' 92 }, pp_settings); 93 var matchedObjects = this, 94 percentBased = false, 95 pp_dimensions, pp_open, pp_contentHeight, pp_contentWidth, pp_containerHeight, pp_containerWidth, windowHeight = $(window).height(), 96 windowWidth = $(window).width(), 97 pp_slideshow; 98 doresize = true, scroll_pos = _get_scroll(); 99 $(window).unbind('resize.prettyphoto').bind('resize.prettyphoto', function() { 100 _center_overlay(); 101 _resize_overlay(); 102 }); 103 if (pp_settings.keyboard_shortcuts) { 104 $(document).unbind('keydown.prettyphoto').bind('keydown.prettyphoto', function(e) { 105 if (typeof $pp_pic_holder != 'undefined') { 106 if ($pp_pic_holder.is(':visible')) { 107 switch (e.keyCode) { 108 case 37: 109 $.prettyPhoto.changePage('previous'); 110 e.preventDefault(); 111 break; 112 case 39: 113 $.prettyPhoto.changePage('next'); 114 e.preventDefault(); 115 break; 116 case 27: 117 if (!settings.modal) 118 $.prettyPhoto.close(); 119 e.preventDefault(); 120 break; 121 }; 122 }; 123 }; 124 }); 125 }; 126 $.prettyPhoto.initialize = function() { 127 settings = pp_settings; 128 if (settings.theme == 'pp_default') settings.horizontal_padding = 16; 129 if (settings.ie6_fallback && $.browser.msie && parseInt($.browser.version) == 6) settings.theme = "light_square"; 130 theRel = $(this).attr('rel'); 131 galleryRegExp = /\[(?:.*)\]/; 132 isSet = (galleryRegExp.exec(theRel)) ? true : false; 133 pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i) { 134 if ($(n).attr('rel').indexOf(theRel) != -1) return $(n).attr('href'); 135 }) : $.makeArray($(this).attr('href')); 136 pp_titles = (isSet) ? jQuery.map(matchedObjects, function(n, i) { 137 if ($(n).attr('rel').indexOf(theRel) != -1) return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : ""; 138 }) : $.makeArray($(this).find('img').attr('alt')); 139 pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i) { 140 if ($(n).attr('rel').indexOf(theRel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; 141 }) : $.makeArray($(this).attr('title'));
142 if (pp_images.length > 30) settings.overlay_gallery = false; 143 set_position = jQuery.inArray($(this).attr('href'), pp_images); 144 rel_index = (isSet) ? set_position : $("a[rel^='" + theRel + "']").index($(this)); 145 _build_overlay(this); 146 if (settings.allow_resize) 147 $(window).bind('scroll.prettyphoto', function() { 148 _center_overlay(); 149 }); 150 $.prettyPhoto.open(); 151 return false; 152 } 153 $.prettyPhoto.open = function(event) { 154 if (typeof settings == "undefined") { 155 settings = pp_settings; 156 if ($.browser.msie && $.browser.version == 6) settings.theme = "light_square"; 157 pp_images = $.makeArray(arguments[0]); 158 pp_titles = (arguments[1]) ? $.makeArray(arguments[1]) : $.makeArray(""); 159 pp_descriptions = (arguments[2]) ? $.makeArray(arguments[2]) : $.makeArray(""); 160 isSet = (pp_images.length > 1) ? true : false; 161 set_position = 0; 162 _build_overlay(event.target); 163 } 164 if ($.browser.msie && $.browser.version == 6) $('select').css('visibility', 'hidden'); 165 if (settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility', 'hidden'); 166 _checkPosition($(pp_images).size()); 167 $('.pp_loaderIcon').show(); 168 if (settings.deeplinking) 169 setHashtag(); 170 if (settings.social_tools) { 171 facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); 172 $pp_pic_holder.find('.pp_social').html(facebook_like_link); 173 } 174 if ($ppt.is(':hidden')) $ppt.css('opacity', 0).show(); 175 $pp_overlay.show().fadeTo(settings.animation_speed, settings.opacity); 176 $pp_pic_holder.find('.currentTextHolder').text((set_position + 1) + settings.counter_separator_label + $(pp_images).size()); 177 if (pp_descriptions[set_position] != "") { 178 $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position])); 179 } else { 180 $pp_pic_holder.find('.pp_description').hide(); 181 } 182 movie_width = (parseFloat(getParam('width', pp_images[set_position]))) ? getParam('width', pp_images[set_position]) : settings.default_width.toString(); 183 movie_height = (parseFloat(getParam('height', pp_images[set_position]))) ? getParam('height', pp_images[set_position]) : settings.default_height.toString(); 184 percentBased = false; 185 if (movie_height.indexOf('%') != -1) { 186 movie_height = parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 150); 187 percentBased = true; 188 } 189 if (movie_width.indexOf('%') != -1) { 190 movie_width = parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 150); 191 percentBased = true; 192 } 193 $pp_pic_holder.fadeIn(function() { 194 (settings.show_title && pp_titles[set_position] != "" && typeof pp_titles[set_position] != "undefined") ? $ppt.html(unescape(pp_titles[set_position])): $ppt.html(' '); 195 imgPreloader = ""; 196 skipInjection = false; 197 switch (_getFileType(pp_images[set_position])) { 198 case 'image': 199 imgPreloader = new Image(); 200 nextImage = new Image(); 201 if (isSet && set_position < $(pp_images).size() - 1) nextImage.src = pp_images[set_position + 1]; 202 prevImage = new Image(); 203 if (isSet && pp_images[set_position - 1]) prevImage.src = pp_images[set_position - 1]; 204 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = settings.image_markup.replace(/{path}/g, pp_images[set_position]); 205 imgPreloader.onload = function() { 206 pp_dimensions = _fitToViewport(imgPreloader.width, imgPreloader.height); 207 _showContent(); 208 }; 209 imgPreloader.onerror = function() { 210 alert('Image cannot be loaded. Make sure the path is correct and image exist.'); 211 $.prettyPhoto.close(); 212 }; 213 imgPreloader.src = pp_images[set_position]; 214 break; 215 case 'youtube': 216 pp_dimensions = _fitToViewport(movie_width, movie_height); 217 movie_id = getParam('v', pp_images[set_position]); 218 if (movie_id == "") { 219 movie_id = pp_images[set_position].split('youtu.be/'); 220 movie_id = movie_id[1]; 221 if (movie_id.indexOf('?') > 0) 222 movie_id = movie_id.substr(0, movie_id.indexOf('?')); 223 if (movie_id.indexOf('&') > 0) 224 movie_id = movie_id.substr(0, movie_id.indexOf('&'));
225 } 226 movie = 'http://www.youtube.com/embed/' + movie_id; 227 (getParam('rel', pp_images[set_position])) ? movie += "?rel=" + getParam('rel', pp_images[set_position]): movie += "?rel=1"; 228 if (settings.autoplay) movie += "&autoplay=1"; 229 toInject = settings.iframe_markup.replace(/{width}/g, pp_dimensions['width']).replace(/{height}/g, pp_dimensions['height']).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, movie); 230 break; 231 case 'vimeo': 232 pp_dimensions = _fitToViewport(movie_width, movie_height); 233 movie_id = pp_images[set_position]; 234 var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)/; 235 var match = movie_id.match(regExp); 236 movie = 'http://player.vimeo.com/video/' + match[2] + '?title=0&byline=0&portrait=0'; 237 if (settings.autoplay) movie += "&autoplay=1;"; 238 vimeo_width = pp_dimensions['width'] + '/embed/?moog_width=' + pp_dimensions['width']; 239 toInject = settings.iframe_markup.replace(/{width}/g, vimeo_width).replace(/{height}/g, pp_dimensions['height']).replace(/{path}/g, movie); 240 break; 241 case 'quicktime': 242 pp_dimensions = _fitToViewport(movie_width, movie_height); 243 pp_dimensions['height'] += 15; 244 pp_dimensions['contentHeight'] += 15; 245 pp_dimensions['containerHeight'] += 15; 246 toInject = settings.quicktime_markup.replace(/{width}/g, pp_dimensions['width']).replace(/{height}/g, pp_dimensions['height']).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, pp_images[set_position]).replace(/{autoplay}/g, settings.autoplay); 247 break; 248 case 'flash': 249 pp_dimensions = _fitToViewport(movie_width, movie_height); 250 flash_vars = pp_images[set_position]; 251 flash_vars = flash_vars.substring(pp_images[set_position].indexOf('flashvars') + 10, pp_images[set_position].length); 252 filename = pp_images[set_position]; 253 filename = filename.substring(0, filename.indexOf('?')); 254 toInject = settings.flash_markup.replace(/{width}/g, pp_dimensions['width']).replace(/{height}/g, pp_dimensions['height']).replace(/{wmode}/g, settings.wmode).replace(/{path}/g, filename + '?' + flash_vars); 255 break; 256 case 'iframe': 257 pp_dimensions = _fitToViewport(movie_width, movie_height); 258 frame_url = pp_images[set_position]; 259 frame_url = frame_url.substr(0, frame_url.indexOf('iframe') - 1); 260 toInject = settings.iframe_markup.replace(/{width}/g, pp_dimensions['width']).replace(/{height}/g, pp_dimensions['height']).replace(/{path}/g, frame_url); 261 break; 262 case 'ajax': 263 doresize = false; 264 pp_dimensions = _fitToViewport(movie_width, movie_height); 265 doresize = true; 266 skipInjection = true; 267 $.get(pp_images[set_position], function(responseHTML) { 268 toInject = settings.inline_markup.replace(/{content}/g, responseHTML); 269 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; 270 _showContent(); 271 }); 272 break; 273 case 'custom': 274 pp_dimensions = _fitToViewport(movie_width, movie_height); 275 toInject = settings.custom_markup; 276 break; 277 case 'inline': 278 myClone = $(pp_images[set_position]).clone().append('<br clear="all" />').css({ 279 'width': settings.default_width 280 }).wrapInner('<div id="pp_full_res"><div class="pp_inline"></div></div>').appendTo($('body')).show(); 281 doresize = false; 282 pp_dimensions = _fitToViewport($(myClone).width(), $(myClone).height()); 283 doresize = true; 284 $(myClone).remove(); 285 toInject = settings.inline_markup.replace(/{content}/g, $(pp_images[set_position]).html()); 286 break; 287 }; 288 if (!imgPreloader && !skipInjection) { 289 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; 290 _showContent(); 291 }; 292 }); 293 return false; 294 }; 295 $.prettyPhoto.changePage = function(direction) { 296 currentGalleryPage = 0; 297 if (direction == 'previous') { 298 set_position--; 299 if (set_position < 0) set_position = $(pp_images).size() - 1; 300 } else if (direction == 'next') { 301 set_position++; 302 if (set_position > $(pp_images).size() - 1) set_position = 0; 303 } else { 304 set_position = direction; 305 }; 306 rel_index = set_position; 307 if (!doresize) doresize = true; 308 $('.pp_contract').removeClass('pp_contract').addClass('pp_expand'); 309 _hideContent(function() { 310 $.prettyPhoto.open(); 311 }); 312 }; 313 $.prettyPhoto.changeGalleryPage = function(direction) { 314 if (direction == 'next') { 315 currentGalleryPage++; 316 if (currentGalleryPage > totalPage) currentGalleryPage = 0; 317 } else if (direction == 'previous') { 318 currentGalleryPage--; 319 if (currentGalleryPage < 0) currentGalleryPage = totalPage; 320 } else { 321 currentGalleryPage = direction; 322 }; 323 slide_speed = (direction == 'next' || direction == 'previous') ? settings.animation_speed : 0; 324 slide_to = currentGalleryPage * (itemsPerPage * itemWidth);
325 $pp_gallery.find('ul').animate({ 326 left: -slide_to 327 }, slide_speed); 328 }; 329 $.prettyPhoto.startSlideshow = function() { 330 if (typeof pp_slideshow == 'undefined') { 331 $pp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function() { 332 $.prettyPhoto.stopSlideshow(); 333 return false; 334 }); 335 pp_slideshow = setInterval($.prettyPhoto.startSlideshow, settings.slideshow); 336 } else { 337 $.prettyPhoto.changePage('next'); 338 }; 339 } 340 $.prettyPhoto.stopSlideshow = function() { 341 $pp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function() { 342 $.prettyPhoto.startSlideshow(); 343 return false; 344 }); 345 clearInterval(pp_slideshow); 346 pp_slideshow = undefined; 347 } 348 $.prettyPhoto.close = function() { 349 if ($pp_overlay.is(":animated")) return; 350 $.prettyPhoto.stopSlideshow(); 351 $pp_pic_holder.stop().find('object,embed').css('visibility', 'hidden'); 352 $('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed, function() { 353 $(this).remove(); 354 }); 355 $pp_overlay.fadeOut(settings.animation_speed, function() { 356 if ($.browser.msie && $.browser.version == 6) $('select').css('visibility', 'visible'); 357 if (settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility', 'visible'); 358 $(this).remove(); 359 $(window).unbind('scroll.prettyphoto'); 360 clearHashtag(); 361 settings.callback(); 362 doresize = true; 363 pp_open = false; 364 delete settings; 365 }); 366 }; 367 368 function _showContent() { 369 $('.pp_loaderIcon').hide(); 370 projectedTop = scroll_pos['scrollTop'] + ((windowHeight / 2) - (pp_dimensions['containerHeight'] / 2)); 371 if (projectedTop < 0) projectedTop = 0; 372 $ppt.fadeTo(settings.animation_speed, 1); 373 $pp_pic_holder.find('.pp_content').animate({ 374 height: pp_dimensions['contentHeight'], 375 width: pp_dimensions['contentWidth'] 376 }, settings.animation_speed); 377 $pp_pic_holder.animate({ 378 'top': projectedTop, 379 'left': (windowWidth / 2) - (pp_dimensions['containerWidth'] / 2), 380 width: pp_dimensions['containerWidth'] 381 }, settings.animation_speed, function() { 382 $pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(pp_dimensions['height']).width(pp_dimensions['width']); 383 $pp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed); 384 if (isSet && _getFileType(pp_images[set_position]) == "image") { 385 $pp_pic_holder.find('.pp_hoverContainer').show(); 386 } else { 387 $pp_pic_holder.find('.pp_hoverContainer').hide(); 388 } 389 if (pp_dimensions['resized']) { 390 $('a.pp_expand,a.pp_contract').show(); 391 } else { 392 $('a.pp_expand').hide(); 393 } 394 if (settings.autoplay_slideshow && !pp_slideshow && !pp_open) $.prettyPhoto.startSlideshow(); 395 settings.changepicturecallback(); 396 pp_open = true; 397 }); 398 _insert_gallery(); 399 }; 400 401 function _hideContent(callback) { 402 $pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility', 'hidden'); 403 $pp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed, function() { 404 $('.pp_loaderIcon').show(); 405 callback(); 406 }); 407 }; 408 409 function _checkPosition(setCount) { 410 (setCount > 1) ? $('.pp_nav').show(): $('.pp_nav').hide(); 411 }; 412 413 function _fitToViewport(width, height) { 414 resized = false; 415 _getDimensions(width, height); 416 imageWidth = width, imageHeight = height; 417 if (((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) && doresize && settings.allow_resize && !percentBased) { 418 resized = true, fitting = false; 419 while (!fitting) { 420 if ((pp_containerWidth > windowWidth)) { 421 imageWidth = (windowWidth - 200); 422 imageHeight = (height / width) * imageWidth; 423 } else if ((pp_containerHeight > windowHeight)) { 424 imageHeight = (windowHeight - 200); 425 imageWidth = (width / height) * imageHeight; 426 } else { 427 fitting = true; 428 }; 429 pp_containerHeight = imageHeight, pp_containerWidth = imageWidth; 430 }; 431 _getDimensions(imageWidth, imageHeight); 432 if ((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) { 433 _fitToViewport(pp_containerWidth, pp_containerHeight) 434 }; 435 }; 436 return { 437 width: Math.floor(imageWidth), 438 height: Math.floor(imageHeight), 439 containerHeight: Math.floor(pp_containerHeight), 440 containerWidth: Math.floor(pp_containerWidth) + (settings.horizontal_padding * 2), 441 contentHeight: Math.floor(pp_contentHeight), 442 contentWidth: Math.floor(pp_contentWidth), 443 resized: resized 444 }; 445 }; 446 447 function _getDimensions(width, height) { 448 width = parseFloat(width); 449 height = parseFloat(height); 450 $pp_details = $pp_pic_holder.find('.pp_details'); 451 $pp_details.width(width); 452 detailsHeight = parseFloat($pp_details.css('marginTop')) + parseFloat($pp_details.css('marginBottom')); 453 $pp_details = $pp_details.clone().addClass(settings.theme).width(width).appendTo($('body')).css({ 454 'position': 'absolute', 455 'top': -10000 456 }); 457 detailsHeight += $pp_details.height(); 458 detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight; 459 if ($.browser.msie && $.browser.version == 7) detailsHeight += 8; 460 $pp_details.remove(); 461 $pp_title = $pp_pic_holder.find('.ppt'); 462 $pp_title.width(width); 463 titleHeight = parseFloat($pp_title.css('marginTop')) + parseFloat($pp_title.css('marginBottom')); 464 $pp_title = $pp_title.clone().appendTo($('body')).css({ 465 'position': 'absolute', 466 'top': -10000 467 }); 468 titleHeight += $pp_title.height(); 469 $pp_title.remove(); 470 pp_contentHeight = height + detailsHeight; 471 pp_contentWidth = width; 472 pp_containerHeight = pp_contentHeight + titleHeight + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height(); 473 pp_containerWidth = width; 474 } 475
476 function _getFileType(itemSrc) { 477 if (itemSrc.match(/youtube\.com\/watch/i) || itemSrc.match(/youtu\.be/i)) { 478 return 'youtube'; 479 } else if (itemSrc.match(/vimeo\.com/i)) { 480 return 'vimeo'; 481 } else if (itemSrc.match(/\b.mov\b/i)) { 482 return 'quicktime'; 483 } else if (itemSrc.match(/\b.swf\b/i)) { 484 return 'flash'; 485 } else if (itemSrc.match(/\biframe=true\b/i)) { 486 return 'iframe'; 487 } else if (itemSrc.match(/\bajax=true\b/i)) { 488 return 'ajax'; 489 } else if (itemSrc.match(/\bcustom=true\b/i)) { 490 return 'custom'; 491 } else if (itemSrc.substr(0, 1) == '#') { 492 return 'inline'; 493 } else { 494 return 'image'; 495 }; 496 }; 497 498 function _center_overlay() { 499 if (doresize && typeof $pp_pic_holder != 'undefined') { 500 scroll_pos = _get_scroll(); 501 contentHeight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width(); 502 projectedTop = (windowHeight / 2) + scroll_pos['scrollTop'] - (contentHeight / 2); 503 if (projectedTop < 0) projectedTop = 0; 504 if (contentHeight > windowHeight) 505 return; 506 $pp_pic_holder.css({ 507 'top': projectedTop, 508 'left': (windowWidth / 2) + scroll_pos['scrollLeft'] - (contentwidth / 2) 509 }); 510 }; 511 }; 512 513 function _get_scroll() { 514 if (self.pageYOffset) { 515 return { 516 scrollTop: self.pageYOffset, 517 scrollLeft: self.pageXOffset 518 }; 519 } else if (document.documentElement && document.documentElement.scrollTop) { 520 return { 521 scrollTop: document.documentElement.scrollTop, 522 scrollLeft: document.documentElement.scrollLeft 523 }; 524 } else if (document.body) { 525 return { 526 scrollTop: document.body.scrollTop, 527 scrollLeft: document.body.scrollLeft 528 }; 529 }; 530 }; 531 532 function _resize_overlay() { 533 windowHeight = $(window).height(), windowWidth = $(window).width(); 534 if (typeof $pp_overlay != "undefined") $pp_overlay.height($(document).height()).width(windowWidth); 535 }; 536 537 function _insert_gallery() { 538 if (isSet && settings.overlay_gallery && _getFileType(pp_images[set_position]) == "image" && (settings.ie6_fallback && !($.browser.msie && parseInt($.browser.version) == 6))) { 539 itemWidth = 52 + 5; 540 navWidth = (settings.theme == "facebook" || settings.theme == "pp_default") ? 50 : 30; 541 itemsPerPage = Math.floor((pp_dimensions['containerWidth'] - 100 - navWidth) / itemWidth); 542 itemsPerPage = (itemsPerPage < pp_images.length) ? itemsPerPage : pp_images.length; 543 totalPage = Math.ceil(pp_images.length / itemsPerPage) - 1; 544 if (totalPage == 0) { 545 navWidth = 0; 546 $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').hide(); 547 } else { 548 $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').show(); 549 }; 550 galleryWidth = itemsPerPage * itemWidth; 551 fullGalleryWidth = pp_images.length * itemWidth; 552 $pp_gallery.css('margin-left', -((galleryWidth / 2) + (navWidth / 2))).find('div:first').width(galleryWidth + 5).find('ul').width(fullGalleryWidth).find('li.selected').removeClass('selected'); 553 goToPage = (Math.floor(set_position / itemsPerPage) < totalPage) ? Math.floor(set_position / itemsPerPage) : totalPage; 554 $.prettyPhoto.changeGalleryPage(goToPage); 555 $pp_gallery_li.filter(':eq(' + set_position + ')').addClass('selected'); 556 } else { 557 $pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave'); 558 } 559 } 560 561 function _build_overlay(caller) { 562 if (settings.social_tools) 563 facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); 564 settings.markup = settings.markup.replace('{pp_social}', (settings.social_tools) ? facebook_like_link : ''); 565 $('body').append(settings.markup); 566 $pp_pic_holder = $('.pp_pic_holder'), $ppt = $('.ppt'), $pp_overlay
566= $('div.pp_overlay'); 567 if (isSet && settings.overlay_gallery) { 568 currentGalleryPage = 0; 569 toInject = ""; 570 for (var i = 0; i < pp_images.length; i++) { 571 if (!pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)) { 572 classname = 'default'; 573 img_src = ''; 574 } else { 575 classname = ''; 576 img_src = pp_images[i]; 577 } 578 toInject += "<li class='" + classname + "'><a href='#'><img src='" + img_src + "' width='50' alt='' /></a></li>"; 579 }; 580 toInject = settings.gallery_markup.replace(/{gallery}/g, toInject); 581 $pp_pic_holder.find('#pp_full_res').after(toInject); 582 $pp_gallery = $('.pp_pic_holder .pp_gallery'), $pp_gallery_li = $pp_gallery.find('li'); 583 $pp_gallery.find('.pp_arrow_next').click(function() { 584 $.prettyPhoto.changeGalleryPage('next'); 585 $.prettyPhoto.stopSlideshow(); 586 return false; 587 }); 588 $pp_gallery.find('.pp_arrow_previous').click(function() { 589 $.prettyPhoto.changeGalleryPage('previous'); 590 $.prettyPhoto.stopSlideshow(); 591 return false; 592 }); 593 $pp_pic_holder.find('.pp_content').hover(function() { 594 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn(); 595 }, function() { 596 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut(); 597 }); 598 599 itemWidth = 52 + 5; 600 $pp_gallery_li.each(function(i) { 601 $(this).find('a').click(function() { 602 $.prettyPhoto.changePage(i); 603 $.prettyPhoto.stopSlideshow(); 604 return false; 605 }); 606 }); 607 }; 608 if (settings.slideshow) { 609 $pp_pic_holder.find('.pp_nav').prepend('<a href="#" class="pp_play">Play</a>') 610 $pp_pic_holder.find('.pp_nav .pp_play').click(function() { 611 $.prettyPhoto.startSlideshow(); 612 return false; 613 }); 614 } 615 $pp_pic_holder.attr('class', 'pp_pic_holder ' + settings.theme); 616 $pp_overlay.css({ 617 'opacity': 0, 618 'height': $(document).height(), 619 'width': $(window).width() 620 }).bind('click', function() { 621 if (!settings.modal) $.prettyPhoto.close(); 622 }); 623 $('a.pp_close').bind('click', function() { 624 $.prettyPhoto.close(); 625 return false; 626 }); 627 $('a.pp_expand').bind('click', function(e) { 628 if ($(this).hasClass('pp_expand')) { 629 $(this).removeClass('pp_expand').addClass('pp_contract'); 630 doresize = false; 631 } else { 632 $(this).removeClass('pp_contract').addClass('pp_expand'); 633 doresize = true; 634 }; 635 _hideContent(function() { 636 $.prettyPhoto.open(); 637 }); 638 return false; 639 }); 640 $pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click', function() { 641 $.prettyPhoto.changePage('previous'); 642 $.prettyPhoto.stopSlideshow(); 643 return false; 644 }); 645 $pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click', function() { 646 $.prettyPhoto.changePage('next'); 647 $.prettyPhoto.stopSlideshow(); 648 return false; 649 }); 650 _center_overlay(); 651 }; 652 if (!pp_alreadyInitialized && getHashtag()) { 653 pp_alreadyInitialized = true; 654 hashIndex = getHashtag(); 655 hashRel = hashIndex; 656 hashIndex = hashIndex.substring(hashIndex.indexOf('/') + 1, hashIndex.length - 1); 657 hashRel = hashRel.substring(0, hashRel.indexOf('/')); 658 setTimeout(function() { 659 $("a[rel^='" + hashRel + "']:eq(" + hashIndex + ")").trigger('click'); 660 }, 50); 661 } 662 return this.unbind('click.prettyphoto').bind('click.prettyphoto', $.prettyPhoto.initialize); 663 }; 664 665 function getHashtag() { 666 url = location.href; 667 hashtag = (url.indexOf('#!') != -1) ? decodeURI(url.substring(url.indexOf('#!') + 2, url.length)) : false; 668 return hashtag; 669 }; 670 671 function setHashtag() { 672 if (typeof theRel == 'undefined') return; 673 location.hash = '!' + theRel + '/' + rel_index + '/'; 674 }; 675 676 function clearHashtag() { 677 url = location.href; 678 hashtag = (url.indexOf('#!prettyPhoto')) ? true : false; 679 if (hashtag) location.hash = "!prettyPhoto"; 680 } 681 682 function getParam(name, url) { 683 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
684 var regexS = "[\\?&]" + name + "=([^&#]*)"; 685 var regex = new RegExp(regexS); 686 var results = regex.exec(url); 687 return (results == null) ? "" : results[1]; 688 } 689})(jQuery); 690var pp_alreadyInitialized = false;
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.