PageSourceSearch

https://www.cognashene.com/prettyPhoto/js/jquery.prettyPhoto.js

js cognashene.com collected 2026-10-02 00:15:55 UTC 36,318 bytes, 942 lines download raw bytes

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

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.