PageSourceSearch

https://giving.nes.ru/assets/js/jquery.prettyPhoto.js

js nes.ru collected 2026-10-01 06:27:58 UTC 45,369 bytes, 1,008 lines download raw bytes

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

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.