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