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