1/* ------------------------------------------------------------------------ 2Class: prettyPhoto 3Use: Lightbox clone for jQuery 4Author: Stephane Caron (http://www.no-margin-for-errors.com) 5Version: 3.1.6 6------------------------------------------------------------------------- */ 7(function($) { 8 $.ggPrettyPhoto = {version: '3.1.6'}; 9 10 11 // Define all plugin global variables to play nice with stict mode when combined together with other scripts in minify plugins 12 var settings, 13 theRel, 14 galleryRegExp, 15 isSet, 16 pp_images, 17 pp_titles, 18 pp_descriptions, 19 set_position, 20 rel_index, 21 $pp_pic_holder, 22 $ppt, 23 $pp_overlay, 24 currentGalleryPage, 25 toInject, 26 classname, 27 img_src, 28 thumbnail, 29 $pp_gallery, 30 $pp_gallery_li, 31 itemWidth, 32 contentHeight, 33 contentwidth, 34 projectedTop, 35 movie_width, 36 movie_height, 37 imgPreloader, 38 skipInjection, 39 nextImage, 40 prevImage, 41 resized, 42 $pp_details, 43 detailsHeight, 44 $pp_title, 45 titleHeight, 46 imageWidth, 47 imageHeight, 48 fitting, 49 navWidth, 50 itemsPerPage, 51 totalPage, 52 galleryWidth, 53 fullGalleryWidth, 54 goToPage, 55 slide_speed, 56 slide_to, 57 doresize, 58 scroll_pos; 59 60 $.fn.ggPrettyPhoto = function(pp_settings) { 61 var ppTranslationVar = pp_settings.ppTranslates || {} 62 , markupHtml; 63 64 if(typeof(pp_settings.isShowAttributes) == 'undefined') { 65 pp_settings.isShowAttributes = false; 66 } 67 if(pp_settings.isShowAttributes) { 68 if(typeof(pp_settings.attributesPosition) == 'undefined') { 69 pp_settings.attributesPosition = 'right'; 70 } 71 if(typeof(pp_settings.attributesWidth) == 'undefined') { 72 pp_settings.attributesWidth = '200'; 73 } 74 var attributesHtml = '<div class="pp_attributes_container" style="width:' + pp_settings.attributesWidth + 'px"><div id="ppCustomAttributes"></div>'; 75 76 if(pp_settings.isShowButtonLink) { 77 attributesHtml += '<div id="ppAttributeButton"><a target="_blank" href="#" style="' + pp_settings.buttonLinkStyle + '"></a></div>'; 78 } 79 attributesHtml += '</div>'; 80 } 81 82 markupHtml = 83 '<div class="pp_pic_holder">' + 84 '<div class="ppt"> </div>' + 85 '<div class="pp_top">' + 86 '<div class="pp_left"></div>' + 87 '<div class="pp_middle"></div>' + 88 '<div class="pp_right"></div>' + 89 '</div>' + 90 '<div class="pp_content_container">' + 91 '<div class="pp_left">' + 92 '<div class="pp_right">' + 93 '<div class="pp_content">' + 94 '<div class="pp_loaderIcon"></div>' + 95 '<div class="pp_fade">' + 96 '<a href="#" class="pp_expand" title="' + ppTranslationVar['cExpandStr'] + '">' + ppTranslationVar['cExpand'] + '</a>' + 97 '<div class="pp_hoverContainer">' + 98 '<a class="pp_next" href="#">' + 99 '<span class="pp-button-conainer pp-round-left">' + 100 '<i class="fa fa-chevron-right" aria-hidden="true"></i>' + 101 '<i class="pp-bc-nextstr">' + ppTranslationVar['next'] + '</i>' + 102 '</span>' + 103 '</a>' + 104 '<a class="pp_previous" href="#">'+ 105 '<span class="pp-button-conainer pp-round-right">' + 106 '<i class="pp-bc-nextstr">' + ppTranslationVar['prev'] + '</i>' + 107 '<i class="fa fa-chevron-left" aria-hidden="true"></i>' + 108 '</span>' + 109 '</a>' + 110 '</div>'; 111 if(pp_settings.isShowAttributes) { 112 if(pp_settings.attributesPosition == 'left') { 113 markupHtml += attributesHtml + '<div id="pp_full_res" style="float:left;"></div>'; 114 } else { 115 markupHtml += '<div id="pp_full_res" style="float:left;"></div>' + attributesHtml; 116 } 117 } else { 118 markupHtml += '<div id="pp_full_res"></div>'; 119 } 120 markupHtml += '<div class="pp_details">' + 121 '<div class="pp_nav">' + 122 '<a href="#" class="pp_arrow_previous">' + ppTranslationVar['cPrevious'] + '</a>' + 123 '<p class="currentTextHolder">0/0</p>' + 124 '<a href="#" class="pp_arrow_next">' + ppTranslationVar['cNext'] + '</a>' + 125 '</div>' + 126 '<p class="pp_description"></p>'; 127 if(pp_settings.isShowHovThumbnail == 1) { 128 markupHtml += '<div class="sggTheme6OnHoverThumbWr" data-show-on-hover="1"><img src="" alt="" class="sggT6OnHoverThumbImg"/></div>'; 129 } 130 markupHtml += '<div class="pp_social">{pp_social}</div>' + 131 '<div class="sggTheme6PopupBtns">'; 132 if(pp_settings.isShowLinkBtn == 1) { 133 markupHtml += '<a target="_blank" class="sggLinkBtn" data-popup-theme-id="6" data-gg-id="' + pp_settings.galleryId + '" href="#">
133' + 134 '<span class="pp-button-conainer pp-round-all">' + 135 '<i class="pp-bc-nextstr">' + ppTranslationVar['cDetails'] + '</i>' + 136 '<i class="fa fa-link" aria-hidden="true"></i>' + 137 '</span>' + 138 '</a>'; 139 } 140 141 if(pp_settings.isShowRotateBtn == 1) { 142 markupHtml += '<a class="sggRotateBtn" data-popup-theme-id="6" data-gg-id="' + pp_settings.galleryId + '" href="#">' + 143 '<span class="pp-button-conainer pp-round-all">' + 144 '<i class="pp-bc-nextstr">' + ppTranslationVar['cRotate'] + '</i>' + 145 '<i class="fa fa-refresh" aria-hidden="true"></i>' + 146 '</span>' + 147 '</a>'; 148 } 149 markupHtml += '<a class="pp_close" href="#">' + 150 '<span class="pp-button-conainer pp-round-all">' + 151 '<i class="pp-bc-nextstr">' + ppTranslationVar['close'] + '</i>' + 152 '<i class="fa fa-times" aria-hidden="true"></i>' + 153 '</span>' + 154 '</a>' + 155 '</div>' + 156 '</div>' + 157 '</div>' + 158 '</div>' + 159 '</div>' + 160 '</div>' + 161 '</div>' + 162 '<div class="pp_bottom">' + 163 '<div class="pp_left"></div>' + 164 '<div class="pp_middle"></div>' + 165 '<div class="pp_right"></div>' + 166 '</div>' + 167 '</div>' + 168 '<div class="pp_overlay"></div>'; 169 170 pp_settings = jQuery.extend({ 171 hook: 'rel', /* the attribute tag to use for prettyPhoto hooks. default: 'rel'. For HTML5, use "data-rel" or similar. */ 172 animation_speed: 'fast', /* fast/slow/normal */ 173 ajaxcallback: function() {}, 174 slideshow: 5000, /* false OR interval time in ms */ 175 autoplay_slideshow: false, /* true/false */ 176 opacity: 0.80, /* Value between 0 and 1 */ 177 show_title: true, /* true/false */ 178 allow_resize: true, /* Resize the photos bigger than viewport. true/false */ 179 allow_expand: true, /* Allow the user to expand a resized image. true/false */ 180 default_width: 500, 181 default_height: 344, 182 default_movie_width: 500, 183 default_movie_height: 344, 184 counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */ 185 theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */ 186 horizontal_padding: 20, /* The padding on each side of the picture */ 187 hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */ 188 wmode: 'opaque', /* Set the flash wmode attribute */ 189 autoplay: false, /* Automatically start videos: True/False */ 190 modal: false, /* If set to true, only the close button will close the window */ 191 deeplinking: true, /* Allow prettyPhoto to update the url to enable deeplinking. */ 192 overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */ 193 overlay_gallery_max: 9999, /* Maximum number of pictures in the overlay gallery */ 194 keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */ 195 changepicturecallback: function(){}, /* Called everytime an item is shown/changed */ 196 'setImageTitleForPrepare': function($element) {}, 197 callback: function(){}, /* Called when prettyPhoto is closed */ 198 getTitle: function(){return 'test'}, 199 getImageDimensions: function(){}, /* used in _fitToViewportImage wrapper to get proper dimensions on images*/ 200 ie6_fallback: true, 201 'is_lazy_load': 0, 202 markup: markupHtml, 203 gallery_markup: '<div style="clear: both;"></div><div class="pp_gallery">' + 204 '<a href="#" class="pp_arrow_previous">' + ppTranslationVar['cPrevious'] + '</a>' + 205 '<div>' + 206 '<ul>' + 207 '{gallery}' + 208 '</ul>' + 209 '</div>' + 210 '<a href="#" class="pp_arrow_next">' + ppTranslationVar['cNext'] + '</a>' + 211 '</div>', 212 image_markup: '<img id="fullResImage" src="{path}" data-rotate-angl="0"/>', 213 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>', 214 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>', 215 html5_markup: '<video controls="" style="margin-bottom: 0px;"><source src="{path}" height="{height}" width="{width}"></video>', 216 iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" allowfullscreen="true" frameborder="no" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>', 217 inline_markup: '<div class="pp_inline">{content}</div>', 218 custom_markup: '', 219 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>' /* html or false to disable */ 220 }, pp_settings); 221 222 // Global variables accessible only by prettyPhoto 223 var matchedObjects = this 224 , percentBased = false 225 , pp_dimensions 226 , pp_open 227 // prettyPhoto container specific 228 , pp_contentHeight 229 , pp_contentWidth 230 , pp_attributesWidth = (pp_settings.isShowAttributes ? parseFloat(pp_settings.attributesWidth) : 0) 231 , pp_containerHeight 232 , pp_containerWidth 233 // Window size 234 , windowHeight = $(window).height() 235 , windowWidth = $(window).width() 236 // Global elements 237 , pp_slideshow 238 , doresize = true 239 , scroll_pos = _get_scroll() 240 , $selfPp = this; 241 242 $selfPp.pp_settings = pp_settings; 243
244 // Window/Keyboard events 245 $(window).unbind('resize.prettyphoto').bind('resize.prettyphoto',function(){ _center_overlay(); _resize_overlay(); }); 246 247 if(pp_settings.keyboard_shortcuts) { 248 $(document).unbind('keydown.prettyphoto').bind('keydown.prettyphoto',function(e){ 249 if(typeof $pp_pic_holder != 'undefined'){ 250 if($pp_pic_holder.is(':visible')){ 251 switch(e.keyCode){ 252 case 37: 253 $selfPp.changePage('previous'); 254 e.preventDefault(); 255 break; 256 case 39: 257 $selfPp.changePage('next'); 258 e.preventDefault(); 259 break; 260 case 27: 261 if(!settings.modal) 262 $selfPp.close(); 263 e.preventDefault(); 264 break; 265 }; 266 // return false; 267 }; 268 }; 269 }); 270 }; 271 272 /** 273 * Refresh prettyPhoto. 274 */ 275 $selfPp.refresh = function($imgList) { 276 matchedObjects = $imgList; 277 matchedObjects.off('click.prettyphoto').on('click.prettyphoto', this.initialize); 278 } 279 280 /** 281 * Initialize prettyPhoto. 282 */ 283 $selfPp.initialize = function() { 284 285 settings = pp_settings; 286 287 if(settings.theme == 'pp_default') settings.horizontal_padding = 16; 288 289 // Find out if the picture is part of a set 290 theRel = $(this).attr(settings.hook); 291 galleryRegExp = /\[(?:.*)\]/; 292 isSet = (galleryRegExp.exec(theRel)) ? true : false; 293 294 // Put the SRCs, TITLEs, ALTs into an array. 295 pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return $(n).attr('href'); }) : $.makeArray($(this).attr('href')) ; 296 pp_titles = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : ""; }) : $.makeArray($(this).find('img').attr('alt')); 297 pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel) != -1) return ($(n).attr('title')) ? $(n).attr('title') : ""; }) : $.makeArray($(this).attr('title')); 298 299 300 301 if(pp_images.length > settings.overlay_gallery_max) settings.overlay_gallery = false; 302 303 set_position = jQuery.inArray($(this).attr('href'), pp_images); // Define where in the array the clicked item is positionned 304 rel_index = (isSet) ? set_position : $("a["+settings.hook+"^='"+theRel+"']").index($(this)); 305 306 _build_overlay(this); // Build the overlay {this} being the caller 307 308 if(settings.allow_resize) 309 $(window).bind('scroll.prettyphoto',function(){ _center_overlay(); }); 310 311 312 $selfPp.open(); 313 314 return false; 315 } 316 317 318 /** 319 * Opens the prettyPhoto modal box. 320 * @param image {String,Array} Full path to the image to be open, can also be an array containing full images paths. 321 * @param title {String,Array} The title to be displayed with the picture, can also be an array containing all the titles. 322 * @param description {String,Array} The description to be displayed with the picture, can also be an array containing all the descriptions. 323 */ 324 $selfPp.open = function(event) { 325 if(typeof settings == "undefined"){ // Means it's an API call, need to manually get the settings and set the variables 326 settings = pp_settings; 327 pp_images = $.makeArray(arguments[0]); 328 pp_titles = (arguments[1]) ? $.makeArray(arguments[1]) : $.makeArray(""); 329 pp_descriptions = (arguments[2]) ? $.makeArray(arguments[2]) : $.makeArray(""); 330 isSet = (pp_images.length > 1) ? true : false;
331 set_position = (arguments[3])? arguments[3]: 0; 332 _build_overlay(event.target); // Build the overlay {this} being the caller 333 } 334 335 if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','hidden'); // Hide the flash 336 337 _checkPosition($(pp_images).length); // Hide the next/previous links if on first or last images. 338 339 $('.pp_loaderIcon').show(); 340 341 if(settings.deeplinking) 342 setHashtag(); 343 344 // Rebuild Facebook Like Button with updated href 345 if(settings.social_tools){ 346 facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); 347 $pp_pic_holder.find('.pp_social').html(facebook_like_link); 348 } 349 350 // Fade the content in 351 if($ppt.is(':hidden')) $ppt.css('opacity',0).show(); 352 $pp_overlay.show().fadeTo(settings.animation_speed,settings.opacity); 353 354 // Display the current position 355 $pp_pic_holder.find('.currentTextHolder').text((set_position+1) + settings.counter_separator_label + $(pp_images).length); 356 357 // Set the description 358 if(typeof pp_descriptions[set_position] != 'undefined' && pp_descriptions[set_position] != ""){ 359 settings.getTitle(); 360 $pp_pic_holder.find('.pp_description').show().html( 361 // unescape(pp_descriptions[set_position]) 362 // unescapte to allow html descriptions 363 //aa_test 364 $("<div/>").html(pp_descriptions[set_position]).text() 365 ) 366 }else{ 367 $pp_pic_holder.find('.pp_description').hide(); 368 } 369 370 // Get the dimensions 371 movie_width = ( parseFloat(getParam('width',pp_images[set_position])) ) ? getParam('width',pp_images[set_position]) : settings.default_movie_width.toString(); 372 movie_height = ( parseFloat(getParam('height',pp_images[set_position])) ) ? getParam('height',pp_images[set_position]) : settings.default_movie_height.toString(); 373 374 // If the size is % based, calculate according to window dimensions 375 percentBased=false; 376 if(movie_height.indexOf('%') != -1) { movie_height = parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 150); percentBased = true; } 377 if(movie_width.indexOf('%') != -1) { movie_width = parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 150); percentBased = true; } 378 379 if(pp_settings.popup_border_enable && pp_settings.popup_border_color 380 && pp_settings.popup_border_type && pp_settings.popup_border_width) 381 { 382 $pp_pic_holder.css({ 383 "border-color": pp_settings.popup_border_color, 384 "border-width": pp_settings.popup_border_width +"px", 385 "border-style": pp_settings.popup_border_type, 386 //"box-sizing": 'content-box' 387 }); 388 } 389 390 391 // Fade the holder 392 $pp_pic_holder.fadeIn(function(){ 393 // Set the title 394 (settings.show_title && pp_titles[set_position] != "" && typeof pp_titles[set_position] != "undefined") ? $ppt.html(unescape(pp_titles[set_position])) : $ppt.html(' '); 395 396 imgPreloader = ""; 397 skipInjection = false; 398 // Inject the proper content 399 switch(_getFileType(pp_images[set_position])){ 400 401 case 'image': 402 imgPreloader = new Image(); 403 404 // Preload the neighbour images 405 nextImage = new Image(); 406 if(isSet && set_position < $(pp_images).length -1) nextImage.src = pp_images[set_position + 1]; 407 prevImage = new Image(); 408 if(isSet && pp_images[set_position - 1]) prevImage.src = pp_images[set_position - 1]; 409 410 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = settings.image_markup.replace(/{path}/g,pp_images[set_position]); 411 412 413 imgPreloader.onload = function(){ 414 // Fit item to viewport 415 pp_dimensions = _fitToViewportImage(imgPreloader.width,imgPreloader.height); 416 417 _showContent(); 418 }; 419 420 imgPreloader.onerror = function(){ 421 alert('Image cannot be loaded. Make sure the path is correct and image exist.'); 422 $selfPp.close(); 423 }; 424 425 imgPreloader.src = pp_images[set_position]; 426 break; 427 428 case 'youtube': 429 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 430 431 //plugin doesnt work with links like %embed% 432 if(pp_images[set_position].indexOf("embed") == -1 ){ 433 // Regular youtube link 434 movie_id = getParam('v',pp_images[set_position]); 435 436 // youtu.be link 437 if(movie_id == ""){ 438 movie_id = pp_images[set_position].split('youtu.be/'); 439 movie_id = movie_id[1]; 440 if(movie_id.indexOf('?') > 0) 441 movie_id = movie_id.substr(0,movie_id.indexOf('?')); // Strip anything after the ? 442 443 if(movie_id.indexOf('&') > 0) 444 movie_id = movie_id.substr(0,movie_id.indexOf('&')); // Strip anything after the & 445 } 446 447 movie = '//www.youtube.com/embed/'+movie_id; 448 }else{ 449 movie = pp_images[set_position]; 450 } 451 452 (getParam('rel',pp_images[set_position])) ? movie+="?rel="+getParam('rel',pp_images[set_position]) : movie+="?rel=1"; 453 454 // if(settings.autoplay) movie += "&autoplay=1"; 455 456 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); 457 break; 458 459 case 'vimeo': 460 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 461 462 movie_id = pp_images[set_position]; 463 var regExp = /(?:https?:)?\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/; 464 var match = movie_id.match(regExp); 465 movie = 'https://player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0'; 466 // if(settings.autoplay) movie += "&autoplay=1;"; 467 468 vimeo_width = pp_dimensions['width'] + '/embed/?moog_width='+ pp_dimensions['width']; 469 470 toInject = settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,movie); 471 break; 472 473 case 'quicktime': 474 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 475 pp_dimensions['height']+=15; pp_dimensions['contentHeight']+=15; pp_dimensions['containerHeight']+=15; // Add space for the control bar 476 477 toInject = settings.quicktime_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}
477/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay); 478 break; 479 480 case 'html5': 481 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 482 pp_dimensions['height']+=15; pp_dimensions['contentHeight']+=15; pp_dimensions['containerHeight']+=15; // Add space for the control bar 483 if(settings.autoplay){ 484 settings.autoplay = 'autoplay'; 485 } else { 486 settings.autoplay = ''; 487 } 488 toInject = settings.html5_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); 489 break; 490 491 case 'flash': 492 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 493 494 flash_vars = pp_images[set_position]; 495 flash_vars = flash_vars.substring(pp_images[set_position].indexOf('flashvars') + 10,pp_images[set_position].length); 496 497 filename = pp_images[set_position]; 498 filename = filename.substring(0,filename.indexOf('?')); 499 500 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); 501 break; 502 503 case 'iframe': 504 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 505 frame_url = pp_images[set_position]; 506 frame_url = frame_url.substr(0,frame_url.indexOf('iframe')-1); 507 toInject = pp_images[set_position].replace('watch?v=', 'embed/'); 508 509 var container = $("<div>" + toInject + "</div>"); 510 container.find("iframe").attr("width", pp_dimensions['width'] + 'px'); 511 container.find("iframe").attr("height", pp_dimensions['height'] + 'px'); 512 513 toInject = container.html(); 514 515 // toInject = settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,frame_url); 516 517 break; 518 519 case 'ajax': 520 doresize = false; // Make sure the dimensions are not resized. 521 pp_dimensions = _fitToViewport(movie_width,movie_height); 522 doresize = true; // Reset the dimensions 523 524 skipInjection = true; 525 $.get(pp_images[set_position],function(responseHTML){ 526 toInject = settings.inline_markup.replace(/{content}/g,responseHTML); 527 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; 528 _showContent(); 529 }); 530 break; 531 532 case 'custom': 533 pp_dimensions = _fitToViewport(movie_width,movie_height); // Fit item to viewport 534 535 toInject = settings.custom_markup; 536 break; 537 538 case 'inline': 539 // to get the item height clone it, apply default width, wrap it in the prettyPhoto containers , then delete 540 myClone = $(pp_images[set_position]).clone().append('<br clear="all" />').css({'width':settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline"></div></div>').appendTo($('body')).show(); 541 doresize = false; // Make sure the dimensions are not resized. 542 pp_dimensions = _fitToViewport($(myClone).width(),$(myClone).height()); 543 doresize = true; // Reset the dimensions 544 $(myClone).remove(); 545 toInject = settings.inline_markup.replace(/{content}/g,$(pp_images[set_position]).html()); 546 break; 547 }; 548 549 if(!imgPreloader && !skipInjection){ 550 $pp_pic_holder.find('#pp_full_res')[0].innerHTML = toInject; 551 552 // Show content 553 _showContent(); 554 }; 555 }); 556 557 return false;
558 }; 559 560 $selfPp.getImagesList = function() { 561 return pp_images; 562 }; 563 564 /** 565 * Change page in the prettyPhoto modal box 566 * @param direction {String} Direction of the paging, previous or next. 567 */ 568 $selfPp.changePage = function(direction){ 569 currentGalleryPage = 0; 570 571 if(direction == 'previous') { 572 set_position--; 573 if (set_position < 0) set_position = $(pp_images).length-1; 574 }else if(direction == 'next'){ 575 set_position++; 576 if(set_position > $(pp_images).length-1) set_position = 0; 577 }else{ 578 set_position=direction; 579 }; 580 581 rel_index = set_position; 582 583 if(!doresize) doresize = true; // Allow the resizing of the images 584 if(settings.allow_expand) { 585 $('.pp_contract').removeClass('pp_contract').addClass('pp_expand'); 586 } 587 588 _hideContent(function(){ $selfPp.open(); }); 589 }; 590 591 592 /** 593 * Change gallery page in the prettyPhoto modal box 594 * @param direction {String} Direction of the paging, previous or next. 595 */ 596 $selfPp.changeGalleryPage = function(direction){ 597 if(direction=='next'){ 598 currentGalleryPage ++; 599 600 if(currentGalleryPage > totalPage) currentGalleryPage = 0; 601 }else if(direction=='previous'){ 602 currentGalleryPage --; 603 604 if(currentGalleryPage < 0) currentGalleryPage = totalPage; 605 }else{ 606 currentGalleryPage = direction; 607 }; 608 609 slide_speed = (direction == 'next' || direction == 'previous') ? settings.animation_speed : 0; 610 611 slide_to = currentGalleryPage * (itemsPerPage * itemWidth); 612 613 $pp_gallery.find('ul').animate({left:-slide_to},slide_speed); 614 }; 615 616 617 /** 618 * Start the slideshow... 619 */ 620 $selfPp.startSlideshow = function(){ 621 if(typeof pp_slideshow == 'undefined'){ 622 if(!$pp_pic_holder.find('.pp_play').hasClass('stop') 623 && !$pp_pic_holder.find('.pp_pause').hasClass('stop')){ 624 $pp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function(){ 625 $selfPp.stopSlideshow(); 626 return false; 627 }); 628 pp_slideshow = setInterval($selfPp.startSlideshow,settings.slideshow); 629 } 630 }else{ 631 $selfPp.changePage('next'); 632 }; 633 } 634 635 636 /** 637 * Stop the slideshow... 638 */ 639 $selfPp.stopSlideshow = function(){ 640 $pp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function(){ 641 $selfPp.startSlideshow(); 642 return false; 643 }); 644 clearInterval(pp_slideshow); 645 pp_slideshow=undefined; 646 } 647 648 649 /** 650 * Closes prettyPhoto. 651 */ 652 $selfPp.close = function(){ 653 if($pp_overlay.is(":animated")) return; 654 655 $selfPp.stopSlideshow(); 656 657 $pp_pic_holder.stop().find('object,embed').css('visibility','hidden'); 658 659 $('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed,function(){ $(this).remove(); }); 660 661 $pp_overlay.fadeOut(settings.animation_speed, function(){ 662 663 if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','visible'); // Show the flash 664 665 $(this).remove(); // No more need for the prettyPhoto markup 666 667 $(window).unbind('scroll.prettyphoto'); 668 669 clearHashtag(); 670 671 settings.callback(); 672 673 doresize = true; 674 675 pp_open = false; 676 677 settings = undefined; 678 }); 679 }; /** 680 * Closes prettyPhoto. 681 */ 682 683 $selfPp.resize = function(width, height){ 684 _fitToViewport(width, height); 685 _resize_overlay(); 686 _center_overlay(); 687 }; 688 689 /** 690 * Set the proper sizes on the containers and animate the content in. 691 */ 692 function _showContent(changeWidthAndHeight, currImgRotateVal, notRunOnHoverInit){ 693 $('.pp_loaderIcon').hide(); 694 695 // Calculate the opened top position of the pic holder 696 projectedTop = scroll_pos['scrollTop'] + ((windowHeight/2) - (pp_dimensions['containerHeight']/2)); 697 if(projectedTop < 0) projectedTop = 0; 698 699 $ppt.fadeTo(settings.animation_speed,1); 700 701 702 // Resize the content holder 703 $pp_pic_holder.find('.pp_content') 704 .animate({ 705 'height': pp_dimensions['contentHeight'] 706 , 'width': pp_dimensions['contentWidth'] 707 } 708 , settings.animation_speed 709 , function(){ 710 // Resize picture the holder 711 $pp_pic_holder.animate({ 712 'top': projectedTop, 713 'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0 : (windowWidth/2) - (pp_dimensions['containerWidth']/2), 714 width:pp_dimensions['containerWidth'] 715 },settings.animation_speed,function(){ 716 var $ppHoverContainer = $pp_pic_holder.find('.pp_hoverContainer') 717 , $ppImageWrapper = $pp_pic_holder.find('#pp_full_res') 718 , $ppPopupImage = $pp_pic_holder.find('#fullResImage'); 719 720 $ppHoverContainer.height(pp_dimensions['height']).width(pp_dimensions['width']); 721 $ppPopupImage.height(pp_dimensions['height']).width(pp_dimensions['width']); 722 723 if(settings.isShowRotateBtn && window.prettyPhotoShowContent) { 724 window.prettyPhotoShowContent( 725 changeWidthAndHeight 726 , currImgRotateVal 727 , $ppPopupImage 728 , $ppImageWrapper 729 , pp_dimensions 730 ); 731 } 732 733 $pp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed); // Fade the new content 734 735 // Show the nav 736 if(isSet && _getFileType(pp_images[set_position])=="image") { $pp_pic_holder.find('.pp_hoverContainer').show(); }else{ $pp_pic_holder.find('.pp_hoverContainer').hide(); } 737 738 if(settings.isShowAttributes) { 739 if(settings.attributesPosition == 'left') { 740 $ppHoverContainer.css('left', pp_attributesWidth); 741 } else { 742 $('a.pp_expand').css('right', pp_attributesWidth + 10 + 'px'); 743 } 744 $pp_pic_holder.find('#ppCustomAttributes').height(pp_dimensions['height'] - (settings.isShowButtonLink ? $pp_pic_holder.find('#ppAttributeButton').height() + 5 : 0)); 745 } 746 747 if(settings.allow_expand) { 748 if(pp_dimensions['resized']){ // Fade the resizing link if the image is resized 749 $('a.pp_expand,a.pp_contract').show(); 750 }else{ 751 $('a.pp_expand').hide(); 752 } 753 } 754 755 if(settings.autoplay_slideshow && !pp_slideshow && !pp_open) $selfPp.startSlideshow(); 756 settings.changepicturecallback($('[href="' + pp_images[set_position] + '"]')); 757 758 if(!notRunOnHoverInit) { 759 if(window.prettyPhotoInitOnHoverThumb) { 760 // init "popup image on hover" event for next image 761 window.prettyPhotoInitOnHoverThumb($('[href="' + pp_images[set_position] + '"]'), pp_settings.galleryId, $selfPp.setDimensionsAndShowCont); 762 } 763 } 764 765 pp_open = true; 766 }); 767 }); 768 769 _insert_gallery(); 770 pp_settings.ajaxcallback(); 771 //centered popup after init with real width params 772 setTimeout(function () { 773 $pp_pic_holder.animate({ 774 'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0 : (windowWidth/2) - ($pp_pic_holder.outerWidth()/2), 775 width:pp_dimensions['containerWidth'] 776 }); 777 }, 600); 778 779 }; 780 781 $selfPp.initRotate = (function() { 782 if(pp_settings.isShowRotateBtn && window.prettyPhotoInitRotate) { 783 window.prettyPhotoInitRotate(function(toFitWidth, toFitHeigth, currImgRotateVal) { 784 pp_dimensions = _fitToViewportImage(toFitWidth, toFitHeigth); 785 _showContent(true, currImgRotateVal); 786 }); 787 } 788 }); 789 790 $selfPp.setDimensionsAndShowCont = (function(toFitWidth, toFitHeigth, currImgRotateVal) { 791 // fixed pp_dimensions 792 pp_dimensions = _fitToViewportImage(toFitWidth, toFitHeigth); 793 _showContent(true, currImgRotateVal, 1); 794 }); 795 796 $selfPp.initOnHoverPreview = (function($aLink, galleryId) { 797 if(pp_settings.isShowHovThumbnail && window.prettyPhotoInitOnHoverThumb) { 798 window.prettyPhotoInitOnHoverThumb($aLink, galleryId, $selfPp.setDimensionsAndShowCont); 799 } 800 }); 801 802 /** 803 * Hide the content...DUH! 804 */ 805 function _hideContent(callback){ 806 // Fade out the current picture 807 $pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden'); 808 $pp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed,function(){ 809 $('.pp_loaderIcon').show(); 810 811 callback(); 812 }); 813 }; 814 815 /** 816 * Check the item position in the gallery array, hide or show the navigation links 817 * @param setCount {integer} The total number of items in the set 818 */ 819 function _checkPosition(setCount){ 820 (setCount > 1) ? $('.pp_nav').show() : $('.pp_nav').hide(); // Hide the bottom nav if it's not a set. 821 }; 822 823 /** 824 * Wrapper for _fitToViewport for responsive image opening and also use gallery image popup sizes 825 * @param width 826 * @param height 827 * @returns {{width, height, containerHeight, containerWidth, contentHeight, contentWidth, resized}|An} 828 * @private 829 */ 830 function _fitToViewportImage(width,height){ 831 var dimensions = settings.getImageDimensions(); 832 if(dimensions == undefined){ 833 return _fitToViewport(width,height); 834 }else{ 835 windowWidth = dimensions.width; 836 windowHeight = dimensions.height; 837 838 var response = _fitToViewport(width,height); 839 840 winWidth = $(window).width(); 841 winHeight = $(window).height(); 842 843 if(response.containerWidth > winWidth || response.containerHeight > winHeight) 844 { 845 if(response.containerWidth > winWidth) { 846 windowWidth -= (response.containerWidth - winWidth); 847 } else if(response.containerHeight > winHeight) { 848 windowHeight -= (response.containerHeight - winHeight); 849 } 850 response = _fitToViewport(response.width, response.height); 851 } 852 windowWidth = winWidth; 853 windowHeight = winHeight; 854 855 return response; 856 } 857 } 858 859 860 /** 861 * Resize the item dimensions if it's bigger than the viewport 862 * @param width {integer} Width of the item to be opened 863 * @param height {integer} Height of the item to be opened 864 * @return An array containin the "fitted" dimensions 865 */ 866 function _fitToViewport(width,height){ 867 resized = false;
868 869 _getDimensions(width,height); 870 // Define them in case there's no resize needed 871 imageWidth = width, imageHeight = height; 872 if( ((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)) && doresize && settings.allow_resize && !percentBased) { 873 resized = true, fitting = false; 874 875 while (!fitting){ 876 877 if((pp_containerWidth > windowWidth)){ 878 imageWidth = (windowWidth - 60 - pp_attributesWidth); 879 imageHeight = (height/width) * imageWidth; 880 } else if((pp_containerHeight > windowHeight)){ 881 imageHeight = (windowHeight - 80 ); 882 imageWidth = (width/height) * imageHeight; 883 } 884 885 if(!(pp_containerWidth > windowWidth) && !(pp_containerHeight > windowHeight)){ 886 fitting = true; 887 }; 888 889 pp_containerHeight = imageHeight, pp_containerWidth = imageWidth; 890 }; 891 892 if((pp_containerWidth > windowWidth) || (pp_containerHeight > windowHeight)){ 893 894 _fitToViewport(pp_containerWidth,pp_containerHeight) 895 }; 896 _getDimensions(imageWidth,imageHeight); 897 }; 898 899 900 return { 901 // - 20px necessary for centering popup img 902 width:Math.floor(imageWidth), 903 height:Math.floor(imageHeight), 904 containerHeight:Math.floor(pp_containerHeight), 905 containerWidth:Math.floor(pp_containerWidth) + (settings.horizontal_padding * 2), 906 contentHeight:Math.floor(pp_contentHeight), 907 contentWidth:Math.floor(pp_contentWidth), 908 resized:resized 909 }; 910 }; 911 912 /** 913 * Get the containers dimensions according to the item size 914 * @param width {integer} Width of the item to be opened 915 * @param height {integer} Height of the item to be opened 916 */ 917 function _getDimensions(width,height){ 918 width = parseFloat(width) + pp_attributesWidth; 919 height = parseFloat(height); 920 921 // Get the details height, to do so, I need to clone it since it's invisible 922 $pp_details = $pp_pic_holder.find('.pp_details'); 923 $pp_details.width(width); 924 detailsHeight = parseFloat($pp_details.css('marginTop')) + parseFloat($pp_details.css('marginBottom')); 925 926 $pp_details = $pp_details.clone().addClass(settings.theme).width(width).appendTo($('body')).css({ 927 'position':'absolute', 928 'top':-10000 929 }); 930 931 $pp_details.find('.pp_description') 932 .html(settings.setImageTitleForPrepare($('[href="' + pp_images[set_position] + '"]'))); 933 detailsHeight += $pp_details.height(); 934 detailsHeight = (detailsHeight <= 34) ? 36 : detailsHeight; // Min-height for the details 935 $pp_details.remove(); 936 937 // Get the titles height, to do so, I need to clone it since it's invisible 938 $pp_title = $pp_pic_holder.find('.ppt'); 939 $pp_title.width(width); 940 titleHeight = parseFloat($pp_title.css('marginTop')) + parseFloat($pp_title.css('marginBottom')); 941 $pp_title = $pp_title.clone().appendTo($('body')).css({ 942 'position':'absolute', 943 'top':-10000 944 }); 945 titleHeight += $pp_title.height(); 946 $pp_title.remove(); 947 948 // Get the container size, to resize the holder to the right dimensions 949 pp_contentHeight = height + detailsHeight; 950 pp_contentWidth = width; 951 pp_containerHeight = pp_contentHeight + titleHeight + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height(); 952 pp_containerWidth = width; 953 } 954 955 function _getFileType(itemSrc){ 956 if(itemSrc.match(/<iframe(.+)<\/iframe>/i)){ 957 return 'iframe'; 958 } 959 else if (itemSrc.match(/youtube\.com\/watch/i) || itemSrc.match(/youtu\.be/i) || itemSrc.match(/youtube\.com\/embed/i)) { 960 return 'youtube'; 961 }else if (itemSrc.match(/vimeo\.com/i)) { 962 return 'vimeo'; 963 }else if(itemSrc.match(/\b.mov\b/i)){ 964 return 'quicktime'; 965 }else if(itemSrc.match(/\b.avi\b/i)){ 966 return 'html5'; 967 }else if(itemSrc.match(/\b.mp4\b/i)){ 968 return 'html5'; 969 }else if(itemSrc.match(/\b.swf\b/i)){ 970 return 'flash'; 971 // }else if(itemSrc.match(/\biframe=true\b/i)){ 972 // }else if(itemSrc.match(/<iframe(.+)<\/iframe>/i)){ 973 // return 'iframe'; 974 }else if(itemSrc.match(/\bajax=true\b/i)){ 975 return 'ajax'; 976 }else if(itemSrc.match(/\bcustom=true\b/i)){ 977 return 'custom'; 978 }else if(itemSrc.substr(0,1) == '#'){ 979 return 'inline'; 980 }else{ 981 return 'image'; 982 }; 983 }; 984 985 function _center_overlay(){ 986 if(doresize && typeof $pp_pic_holder != 'undefined') { 987 scroll_pos = _get_scroll(); 988 contentHeight = $pp_pic_holder.height(), contentwidth = $pp_pic_holder.width(); 989 990 projectedTop = (windowHeight/2) + scroll_pos['scrollTop'] - (contentHeight/2); 991 if(projectedTop < 0) projectedTop = 0; 992 993 if(contentHeight > windowHeight) 994 return; 995 996 $pp_pic_holder.css({ 997 'top': projectedTop, 998 'left': (windowWidth/2) + scroll_pos['scrollLeft'] - (contentwidth/2) 999 }); 1000 1001 }; 1002 }; 1003 1004 function _get_scroll(){ 1005 if (self.pageYOffset) { 1006 return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}; 1007 } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict 1008 return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}; 1009 } else if (document.body) {// all other Explorers 1010 return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}; 1011 }; 1012 }; 1013 1014 function _resize_overlay() { 1015 windowHeight = $(window).height(), windowWidth = $(window).width(); 1016 1017 if(typeof $pp_overlay != "undefined") $pp_overlay.height($(document).height()).width(windowWidth); 1018 }; 1019 1020 function _insert_gallery(){ 1021 if(isSet && settings.overlay_gallery && (_getFileType(pp_images[set_position])=="image" || _getFileType(pp_images[set_position])=="iframe")) { 1022 itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. 1023 navWidth = (settings.theme == "facebook" || settings.theme == "pp_default") ? 50 : 30; // Define the arrow width depending on the theme 1024 1025 itemsPerPage = Math.floor((pp_dimensions['containerWidth'] - 100 - pp_attributesWidth - navWidth) / itemWidth); 1026 itemsPerPage = (itemsPerPage < pp_images.length) ? itemsPerPage : pp_images.length;
1027 totalPage = Math.ceil(pp_images.length / itemsPerPage) - 1; 1028 1029 // Hide the nav in the case there's no need for links 1030 if(totalPage == 0){ 1031 navWidth = 0; // No nav means no width! 1032 $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').hide(); 1033 }else{ 1034 $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').show(); 1035 }; 1036 1037 galleryWidth = itemsPerPage * itemWidth; 1038 fullGalleryWidth = pp_images.length * itemWidth; 1039 1040 // Set the proper width to the gallery items 1041 $pp_gallery 1042 .css('margin-left',-((galleryWidth/2) + (navWidth/2) + (settings.isShowAttributes ? pp_attributesWidth/2 * (settings.attributesPosition == 'left' ? -1 : 1) : 0))) 1043 .find('div:first').width(galleryWidth+5) 1044 .find('ul').width(fullGalleryWidth) 1045 .find('li.selected').removeClass('selected'); 1046 1047 goToPage = (Math.floor(set_position/itemsPerPage) < totalPage) ? Math.floor(set_position/itemsPerPage) : totalPage; 1048 1049 $selfPp.changeGalleryPage(goToPage); 1050 1051 $pp_gallery_li.filter(':eq('+set_position+')').addClass('selected'); 1052 }else{ 1053 $pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave'); 1054 // $pp_gallery.hide(); 1055 } 1056 } 1057 1058 function _build_overlay(caller){ 1059 1060 // Inject Social Tool markup into General markup 1061 if(settings.social_tools) 1062 facebook_like_link = settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); 1063 1064 settings.markup = settings.markup.replace('{pp_social}',''); 1065 1066 $('body').append(settings.markup); // Inject the markup 1067 $selfPp.initRotate(); 1068 $selfPp.initOnHoverPreview($(caller), pp_settings.galleryId); 1069 1070 $pp_pic_holder = $('.pp_pic_holder') , $ppt = $('.ppt'), $pp_overlay
1070= $('div.pp_overlay'); // Set my global selectors 1071 1072 // disable contextmenu 1073 if (settings.isDisableRightClick) { 1074 $pp_pic_holder.off('contextmenu').on('contextmenu', function(e){return false;}); 1075 } 1076 1077 // Inject the inline gallery! 1078 if(isSet && settings.overlay_gallery) { 1079 currentGalleryPage = 0; 1080 toInject = ""; 1081 for (var i=0; i < pp_images.length; i++) { 1082 img_src = pp_images[i]; 1083 thumbnail = $('[href="' +img_src + '"]').find('.crop > img'); 1084 if(!(thumbnail.length && thumbnail.attr('data-gg-remote-image') == '1') && !pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)){ 1085 classname = 'default'; 1086 img_src = ''; 1087 }else{ 1088 classname = ''; 1089 //img_src = pp_images[i]; 1090 //thumbnail = $('[href="' +img_src + '"]').find('.crop > img'); 1091 if(thumbnail.length) { 1092 if(pp_settings.is_lazy_load) { 1093 img_src = thumbnail.attr('data-gg-real-image-href'); 1094 } else { 1095 img_src = thumbnail.attr('src'); 1096 } 1097 } 1098 } 1099 toInject += "<li class='"+classname+"'><a href='#'><img src='" + img_src + "' width='50' alt='' /></a></li>"; 1100 }; 1101 1102 toInject = settings.gallery_markup.replace(/{gallery}/g,toInject); 1103 1104 $pp_pic_holder.find(settings.isShowAttributes && settings.attributesPosition == 'right' ? '.pp_attributes_container' : '#pp_full_res').after(toInject); 1105 1106 $pp_gallery = $('.pp_pic_holder .pp_gallery'), $pp_gallery_li = $pp_gallery.find('li'); // Set the gallery selectors 1107 1108 $pp_gallery.find('.pp_arrow_next').click(function(){ 1109 $selfPp.changeGalleryPage('next'); 1110 $selfPp.stopSlideshow(); 1111 return false; 1112 }); 1113 1114 $pp_gallery.find('.pp_arrow_previous').click(function(){ 1115 $selfPp.changeGalleryPage('previous'); 1116 $selfPp.stopSlideshow(); 1117 return false; 1118 }); 1119 1120 $pp_pic_holder.find('.pp_content').hover( 1121 function(){ 1122 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn(); 1123 }, 1124 function(){ 1125 $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut(); 1126 }); 1127 1128 itemWidth = 52+5; // 52 beign the thumb width, 5 being the right margin. 1129 $pp_gallery_li.each(function(i){ 1130 $(this) 1131 .find('a') 1132 .click(function(){ 1133 $selfPp.changePage(i); 1134 $selfPp.stopSlideshow(); 1135 return false; 1136 }); 1137 }); 1138 }; 1139 1140 1141 // Inject the play/pause if it's a slideshow 1142 if(settings.slideshow){ 1143 $pp_pic_holder.find('.pp_nav').prepend('<a href="#" class="pp_play">Play</a>') 1144 $pp_pic_holder.find('.pp_nav .pp_play').click(function(){ 1145 $selfPp.startSlideshow(); 1146 return false; 1147 }); 1148 } 1149 1150 $pp_pic_holder.attr('class','pp_pic_holder ' + settings.theme); // Set the proper theme 1151 1152 $pp_overlay 1153 .css({ 1154 'opacity':0, 1155 'height':$(document).height(), 1156 'width':$(window).width() 1157 }) 1158 .bind('click',function(){ 1159 if(!settings.modal) $selfPp.close(); 1160 }); 1161 1162 $('a.pp_close').bind('click',function(){ $selfPp.close(); return false; }); 1163 1164 1165 if(settings.allow_expand) { 1166 $('a.pp_expand').bind('click',function(e){ 1167 // Expand the image 1168 if($(this).hasClass('pp_expand')){ 1169 $(this).removeClass('pp_expand').addClass('pp_contract'); 1170 doresize = false;
1171 }else{ 1172 $(this).removeClass('pp_contract').addClass('pp_expand'); 1173 doresize = true; 1174 }; 1175 1176 _hideContent(function(){ $selfPp.open(); }); 1177 1178 return false; 1179 }); 1180 } 1181 1182 $pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){ 1183 $('.pp_nav a.pp_pause').removeClass('stop'); 1184 $('.pp_nav a.pp_play').removeClass('stop'); 1185 $selfPp.changePage('previous'); 1186 $selfPp.stopSlideshow(); 1187 return false; 1188 }); 1189 1190 $pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){ 1191 $('.pp_nav a.pp_pause').removeClass('stop'); 1192 $('.pp_nav a.pp_play').removeClass('stop'); 1193 $selfPp.changePage('next'); 1194 $selfPp.stopSlideshow(); 1195 return false; 1196 }); 1197 1198 _center_overlay(); // Center it 1199 1200 }; 1201 1202 if(!ggpp_alreadyInitialized && getHashtag()){ 1203 ggpp_alreadyInitialized = true; 1204 1205 // Grab the rel index to trigger the click on the correct element 1206 hashIndex = getHashtag(); 1207 hashRel = hashIndex; 1208 hashIndex = hashIndex.substring(hashIndex.indexOf('/')+1,hashIndex.length-1); 1209 hashRel = hashRel.substring(0,hashRel.indexOf('/')); 1210 1211 // Little timeout to make sure all the prettyPhoto initialize scripts has been run. 1212 // Useful in the event the page contain several init scripts. 1213 setTimeout(function(){ $("a["+pp_settings.hook+"^='"+hashRel+"']:eq("+hashIndex+")").trigger('click'); },50); 1214 } 1215 1216 return $selfPp.off('click.prettyphoto').on('click.prettyphoto',$selfPp.initialize); // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once 1217 }; 1218 1219 function getHashtag(){ 1220 var url = location.href, 1221 hashtag = (url.indexOf('#prettyPhoto') !== -1) ? decodeURI(url.substring(url.indexOf('#prettyPhoto')+1,url.length)) : false; 1222 if(hashtag){ hashtag = hashtag.replace(/<|>/g,''); } 1223 return hashtag; 1224 }; 1225 1226 function setHashtag(){ 1227 if(typeof theRel == 'undefined') return; // theRel is set on normal calls, it's impossible to deeplink using the API 1228 location.hash = theRel + '/'+rel_index+'/'; 1229 }; 1230 1231 function clearHashtag(){ 1232 if ( location.href.indexOf('#prettyPhoto') !== -1 ) location.hash = "prettyPhoto"; 1233 } 1234 1235 function getParam(name,url){ 1236 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 1237 var regexS = "[\\?&]"+name+"=([^&#]*)"; 1238 var regex = new RegExp( regexS ); 1239 var results = regex.exec( url ); 1240 return ( results == null ) ? "" : results[1]; 1241 } 1242 1243})(jQuery); 1244 1245var ggpp_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.