PageSourceSearch

https://www.anphabe.com/sites/all/modules/fixed/lightbox2/js/lightbox.js?suyevr

js anphabe.com collected 2026-09-24 08:33:57 UTC 60,543 bytes, 1,346 lines download raw bytes

1/* $Id: lightbox.js 2570 2012-08-31 10:01:07Z thanhnp $ */
2
3/**
4 * jQuery Lightbox
5 * @author
6 *   Stella Power, <http://drupal.org/user/66894>
7 *
8 * Based on Lightbox v2.03.3 by Lokesh Dhakar
9 * <http://www.huddletogether.com/projects/lightbox2/>
10 * Also partially based on the jQuery Lightbox by Warren Krewenki
11 *   <http://warren.mesozen.com>
12 *
13 * Permission has been granted to Mark Ashmead & other Drupal Lightbox2 module
14 * maintainers to distribute this file via Drupal.org
15 * Under GPL license.
16 *
17 * Slideshow, iframe and video functionality added by Stella Power.
18 */
19
20var Lightbox;
21(function ($) {
22    Lightbox = {
23        auto_modal: false,
24        overlayOpacity: 0.8, // Controls transparency of shadow overlay.
25        overlayColor: '000', // Controls colour of shadow overlay.
26        disableCloseClick: true,
27        // Controls the order of the lightbox resizing animation sequence.
28        resizeSequence: 0, // 0: simultaneous, 1: width then height, 2: height then width.
29        resizeSpeed: 'normal', // Controls the speed of the lightbox resizing animation.
30        fadeInSpeed: 'normal', // Controls the speed of the image appearance.
31        slideDownSpeed: 'slow', // Controls the speed of the image details appearance.
32        minWidth: 240,
33        borderSize: 10,
34        boxColor: 'fff',
35        fontColor: '000',
36        topPosition: '',
37        infoHeight: 20,
38        alternative_layout: false,
39        imageArray: [],
40        imageNum: null,
41        total: 0,
42        activeImage: null,
43        inprogress: false,
44        disableResize: false,
45        disableZoom: false,
46        isZoomedIn: false,
47        rtl: false,
48        loopItems: false,
49        keysClose: ['c', 'x', 27],
50        keysPrevious: ['p', 37],
51        keysNext: ['n', 39],
52        keysZoom: ['z'],
53        keysPlayPause: [32],
54
55        // Slideshow options.
56        slideInterval: 5000, // In milliseconds.
57        showPlayPause: true,
58        autoStart: true,
59        autoExit: true,
60        pauseOnNextClick: false, // True to pause the slideshow when the "Next" button is clicked.
61        pauseOnPrevClick: true, // True to pause the slideshow when the "Prev" button is clicked.
62        slideIdArray: [],
63        slideIdCount: 0,
64        isSlideshow: false,
65        isPaused: false,
66        loopSlides: false,
67
68        // Iframe options.
69        isLightframe: false,
70        iframe_width: 600,
71        iframe_height: 400,
72        iframe_border: 1,
73
74        // Video and modal options.
75        enableVideo: false,
76        flvPlayer: '/flvplayer.swf',
77        flvFlashvars: '',
78        isModal: false,
79        isVideo: false,
80        videoId: false,
81        modalWidth: 400,
82        modalHeight: 400,
83        modalHTML: null,
84
85
86        // initialize()
87        // Constructor runs on completion of the DOM loading.
88        // The function inserts html at the bottom of the page which is used
89        // to display the shadow overlay and the image container.
90        initialize: function () {
91
92            var s = Drupal.settings.lightbox2;
93            Lightbox.overlayOpacity = s.overlay_opacity;
94            Lightbox.overlayColor = s.overlay_color;
95            Lightbox.disableCloseClick = s.disable_close_click;
96            Lightbox.resizeSequence = s.resize_sequence;
97            Lightbox.resizeSpeed = s.resize_speed;
98            Lightbox.fadeInSpeed = s.fade_in_speed;
99            Lightbox.slideDownSpeed = s.slide_down_speed;
100            Lightbox.borderSize = s.border_size;
101            Lightbox.boxColor = s.box_color;
102            Lightbox.fontColor = s.font_color;
103            Lightbox.topPosition = s.top_position;
104            Lightbox.rtl = s.rtl;
105            Lightbox.loopItems = s.loop_items;
106            Lightbox.keysClose = s.keys_close.split(" ");
107            Lightbox.keysPrevious = s.keys_previous.split(" ");
108            Lightbox.keysNext = s.keys_next.split(" ");
109            Lightbox.keysZoom = s.keys_zoom.split(" ");
110            Lightbox.keysPlayPause = s.keys_play_pause.split(" ");
111            Lightbox.disableResize = s.disable_resize;
112            Lightbox.disableZoom = s.disable_zoom;
113            Lightbox.slideInterval = s.slideshow_interval;
114            Lightbox.showPlayPause = s.show_play_pause;
115            Lightbox.showCaption = s.show_caption;
116            Lightbox.autoStart = s.slideshow_automatic_start;
117            Lightbox.autoExit = s.slideshow_automatic_exit;
118            Lightbox.pauseOnNextClick = s.pause_on_next_click;
119            Lightbox.pauseOnPrevClick = s.pause_on_previous_click;
120            Lightbox.loopSlides = s.loop_slides;
121            Lightbox.alternative_layout = s.use_alt_layout;
122            Lightbox.iframe_width = s.iframe_width;
123            Lightbox.iframe_height = s.iframe_height;
124            Lightbox.iframe_border = s.iframe_border;
125            Lightbox.enableVideo = s.enable_video;
126            if (s.enable_video) {
127                Lightbox.flvPlayer = s.flvPlayer;
128                Lightbox.flvFlashvars = s.flvFlashvars;
129            }
130
131            // Make the lightbox divs.
132            var layout_class = (s.use_alt_layout ? 'lightbox2-alt-layout' : 'lightbox2-orig-layout');
133            var output = '<div id="lightbox2-overlay" style="display: none;"></div>\
134      <div id="lightbox" style="display: none;" class="' + layout_class + '">\
135        <div id="outerImageContainer"></div>\
136      </div>';
137            var imageDataContainer = '<div id="imageDataContainer" style="display:none;" class="clearfix"><div id="imageData"></div></div>';
138            var loading = '';//'<div id="loading"><a href="#" id="loadingLink"></a></div>';
139            var modal = '<div id="modalContainer" style="display: none;"></div>';
140            var frame = '<div id="frameContainer" style="visibility: hidden;"></div>';
141            var imageContainer = '<div id="imageContainer" style="display: none;"></div>';
142            var details = '<div id="imageDetails"></div>';
143            var bottomNav = '<div id="bottomNav"></div>';
144            var image = '<img id="lightboxImage" alt="" />';
145            var hoverNav = '<div id="hoverNav"><a id="prevLink" href="#"></a><a id="nextLink" href="#"></a></div>';
146            var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" href="#"></a><a id="frameNextLink" href="#"></a></div>';
147            var hoverNav = '<div id="hoverNav"><a id="prevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="nextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
148            var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="frameNextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
149            var caption = '<span id="caption"></span>';
150            var numberDisplay = '<span id="numberDisplay"></span>';
151            var close = '<a id="bottomNavClose" title="' + Drupal.t('Press Esc to close') + '" href="#"></a>';
152            var zoom = '<a id="bottomNavZoom" href="#"></a>';
153            var zoomOut = '<a id="bottomNavZoomOut" href="#"></a>';
154            var pause = '<a id="lightshowPause" title="' + Drupal.t('Pause Slideshow') + '" href="#" style="display: none;"></a>';
155            var play = '<a id="lightshowPlay" title="' + Drupal.t('Play Slideshow') + '" href="#" style="display: none;"></a>';
156
157            $("body").append(output);
158            $('#outerImageContainer').append(modal + frame + imageContainer + loading + imageDataContainer);
159            if (!s.use_alt_layout) {
160                $('#imageContainer').append(image + hoverNav);
161                $('#imageData').append(details + bottomNav);
162                $('#imageDetails').append(caption + numberDisplay);
163                $('#bottomNav').append(frameNav + close + zoom + zoomOut + pause + play);
164            }
165            else {
166                $('#outerImageContainer').append(bottomNav);
167                $('#imageContainer').append(image);
168                $('#bottomNav').append(close + zoom + zoomOut);
169                $('#imageData').append(hoverNav + details);
170                $('#imageDetails').append(caption + numberDisplay + pause + play);
171            }
172
173            // Setup onclick handlers.
174            if (Lightbox.disableCloseClick) {
175                $('#lightbox2-overlay').click(function () {
176                    Lightbox.end();
177                    return false;
178                }).hide();
179            }
180            $('#loadingLink, #bottomNavClose').click(function () {
181                Lightbox.end('forceClose');
182                return false;
183            });
184            $('#prevLink, #framePrevLink').click(function () {
185                Lightbox.changeData(Lightbox.activeImage - 1);
186                return false;
187            });
188            $('#nextLink, #frameNextLink').click(function () {
189                Lightbox.changeData(Lightbox.activeImage + 1);
190                return false;
191            });
192            $('#bottomNavZoom').click(function () {
193                Lightbox.changeData(Lightbox.activeImage, true);
194                return false;
195            });
196            $('#bottomNavZoomOut').click(function () {
197                Lightbox.changeData(Lightbox.activeImage, false);
198                return false;
199            });
200            $('#lightshowPause').click(function () {
201                Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
202                return false;
203            });
204            $('#lightshowPlay').click(function () {
205                Lightbox.togglePlayPause("lightshowPlay", "lightshowPause");
206                return false;
207            });
208
209            // Fix positioning.
210            $('#prevLink, #nextLink, #framePrevLink, #frameNextLink').css({'paddingTop': Lightbox.borderSize + 'px'});
211            $('#imageContainer, #frameContainer, #modalContainer').css({'padding': Lightbox.borderSize + 'px'});
212            //@thanhnp edit here clear background color for bottomNavCloas
213            //$('#outerImageContainer, #imageDataContainer, #bottomNavClose').css({'backgroundColor': '#' + Lightbox.boxColor, 'color': '#'+Lightbox.fontColor});
214            if (Lightbox.alternative_layout) {
215                $('#bottomNavZoom, #bottomNavZoomOut').css({
216                    'bottom': Lightbox.borderSize + 'px',
217                    'right': Lightbox.borderSize + 'px'
218                });
219            }
220            else if (Lightbox.rtl == 1 && $.browser.msie) {
221                $('#bottomNavZoom, #bottomNavZoomOut').css({'left': '0px'});
222            }
223
224            // Force navigation links to always be displayed
225            if (s.force_show_nav) {
226                $('#prevLink, #nextLink').addClass("force_show_nav");
227            }
228
229        },
230
231        // initList()
232        // Loops through anchor tags looking for 'lightbox', 'lightshow' and
233        // 'lightframe', etc, references and applies onclick events to appropriate
234        // links. You can rerun after dynamically adding images w/ajax.
235        initList: function (context) {
236
237            if (context == undefined || context == null) {
238                context = document;
239            }
240
241            // Attach lightbox to any links with rel 'lightbox', 'lightshow' or
242            // 'lightframe', etc.
243            $("a[rel^='lightbox']:not(.lightbox-processed), area[rel^='lightbox']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
244                if (Lightbox.disableCloseClick) {
245                    $('#lightbox').unbind('click');
246                    $('#lightbox').click(function () {
247                        Lightbox.end('forceClose');
248                    });
249                }
250                Lightbox.start(this, false, false, false, false);
251                if (e.preventDefault) {
252                    e.preventDefault();
253                }
254                return false;
255            });
256            $("a[rel^='lightshow']:not(.lightbox-processed), area[rel^='lightshow']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
257                if (Lightbox.disableCloseClick) {
258                    $('#lightbox').unbind('click');
259                    $('#lightbox').click(function () {
260                        Lightbox.end('forceClose');
261                    });
262                }
263                Lightbox.start(this, true, false, false, false);
264                if (e.preventDefault) {
265                    e.preventDefault();
266                }
267                return false;
268            });
269            $("a[rel^='lightframe']:not(.lightbox-processed):not(.lightbox-processed), area[rel^='lightframe']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
270                if (Lightbox.disableCloseClick) {
271                    $('#lightbox').unbind('click');
272                    $('#lightbox').click(function () {
273                        Lightbox.end('forceClose');
274                    });
275                }
276                Lightbox.start(this, false, true, false, false);
277                if (e.preventDefault) {
278                    e.preventDefault();
279                }
280                return false;
281            });
282            if (Lightbox.enableVideo) {
283                $("a[rel^='lightvideo']:not(.lightbox-processed), area[rel^='lightvideo']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
284                    if (Lightbox.disableCloseClick) {
285                        $('#lightbox').unbind('click');
286                        $('#lightbox').click(function () {
287                            Lightbox.end('forceClose');
288                        });
289                    }
290                    Lightbox.start(this, false, false, true, false);
291                    if (e.preventDefault) {
292                        e.preventDefault();
293                    }
294                    return false;
295                });
296            }
297            $("a[rel^='lightmodal']:not(.lightbox-processed), area[rel^='lightmodal']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
298                $('#lightbox').unbind('click');
299                // Add classes from the link to the lightbox div - don't include lightbox-processed
300                $('#lightbox').addClass($(this).attr('class'));
301                $('#lightbox').removeClass('lightbox-processed');
302                Lightbox.start(this, false, false, false, true);
303                if (e.preventDefault) {
304                    e.preventDefault();
305                }
306                return false;
307            });
308            $("#lightboxAutoModal:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function (e) {
309                Lightbox.auto_modal = true;
310                $('#lightbox').unbind('click');
311                Lightbox.start(this, false, false, false, true);
312                if (e.preventDefault) {
313                    e.preventDefault();
314                }
315                return false;
316            });
317        },
318
319        // start()
320        // Display overlay and lightbox. If image is part of a set, add siblings to
321        // imageArray.
322        start: function (imageLink, slideshow, lightframe, lightvideo, lightmodal) {
323
324            Lightbox.isPaused = !Lightbox.autoStart;
325
326            // Replaces hideSelectBoxes() and hideFlash() calls in original lightbox2.
327            Lightbox.toggleSelectsFlash('hide');
328
329            // Stretch overlay to fill page and fade in.
330            var arrayPageSize = Lightbox.getPageSize();
331            $("#lightbox2-overlay").hide().css({
332                'width': '100%',
333                'zIndex': '10090',
334                'height': arrayPageSize[1] + 'px',
335                'backgroundColor': '#' + Lightbox.overlayColor
336            });
337            // Detect OS X FF2 opacity + flash issue.
338            if (lightvideo && this.detectMacFF2()) {
339                $("#lightbox2-overlay").removeClass("overlay_default");
340                $("#lightbox2-overlay").addClass("overlay_macff2");
341                $("#lightbox2-overlay").css({'opacity': null});
342            }
343            else {
344                $("#lightbox2-overlay").removeClass("overlay_macff2");
345                $("#lightbox2-overlay").addClass("overlay_default");
346                $("#lightbox2-overlay").css({'opacity': Lightbox.overlayOpacity});
347            }
348            $("#lightbox2-overlay").fadeIn(Lightbox.fadeInSpeed);
349
350
351            Lightbox.isSlideshow = slideshow;
352            Lightbox.isLightframe = lightframe;
353            Lightbox.isVideo = lightvideo;
354            Lightbox.isModal = lightmodal;
355            Lightbox.imageArray = [];
356            Lightbox.imageNum = 0;
357
358            var anchors = $(imageLink.tagName);
359            var anchor = null;
360            var rel_parts = Lightbox.parseRel(imageLink);
361            var rel = rel_parts["rel"];
362            var rel_group = rel_parts["group"];
363            var title = (rel_parts["title"] ? rel_parts["title"] : imageLink.title);
364            var rel_style = null;
365            var i = 0;
366
367            if (rel_parts["flashvars"]) {
368                Lightbox.flvFlashvars = Lightbox.flvFlashvars + '&' + rel_parts["flashvars"];
369            }
370
371            // Set the title for image alternative text.
372            var alt = imageLink.title;
373            if (!alt) {
374                var img = $(imageLink).find("img");
375                if (img && $(img).attr("alt")) {
376                    alt = $(img).attr("alt");
377                }
378                else {
379                    alt = title;
380                }
381            }
382
383            if ($(imageLink).attr('id') == 'lightboxAutoModal') {
384                rel_style = rel_parts["style"];
385                Lightbox.imageArray.push(['#lightboxAutoModal > *', title, alt, rel_style, 1]);
386            }
387            else {
388                // Handle lightbox images with no grouping.
389                if ((rel == 'lightbox' || rel == 'lightshow') && !rel_group) {
390                    Lightbox.imageArray.push([imageLink.href, title, alt]);
391                }
392
393                // Handle other items with no grouping.
394                else if (!rel_group) {
395                    rel_style = rel_parts["style"];
396                    //@thanhnp: them command vao trong src
397                    rel_command = '';
398                    if (Lightbox.isLightframe) {
399                        if (rel_parts["command"]) {
400                            rel_command = rel_parts["command"];
401                        }
402                        else {
403                            // ri: redirect inline
404                            rel_command = 'ri';
405                        }
406                    }
407                    Lightbox.imageArray.push([imageLink.href, title, alt, rel_style, rel_command]);
408                }
409
410                // Handle grouped items.
411                else {
412
413                    // Loop through anchors and add them to imageArray.
414                    for (i = 0; i < anchors.length; i++) {
415                        anchor = anchors[i];
416                        if (anchor.href && typeof(anchor.href) == "string" && $(anchor).attr('rel')) {
417                            var rel_data = Lightbox.parseRel(anchor);
418                            var anchor_title = (rel_data["title"] ? rel_data["title"] : anchor.title);
419                            img_alt = anchor.title;
420                            if (!img_alt) {
421                                var anchor_img = $(anchor).find("img");
422                                if (anchor_img && $(anchor_img).attr("alt")) {
423                                    img_alt = $(anchor_img).attr("alt");
424                                }
425                                else {
426                                    img_alt = title;
427                                }
428                            }
429                            if (rel_data["rel"] == rel) {
430                                if (rel_data["group"] == rel_group) {
431                                    if (Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) {
432                                        rel_style = rel_data["style"];
433                                    }
434                                    //@thanhnp: them command vao trong src
435                                    rel_command = '';
436                                    if (Lightbox.isLightframe) {
437                                        if (rel_data["command"]) {
438                                            rel_command = rel_data["command"];
439                                        }
440                                        else {
441                                            rel_command = 'ri';
442                                        }
443                                    }
444                                    Lightbox.imageArray.push([anchor.href, anchor_title, img_alt, rel_style, rel_command]);
445                                }
446                            }
447                        }
448                    }
449
450                    // Remove duplicates.
451                    for (i = 0; i < Lightbox.imageArray.length; i++) {
452                        for (j = Lightbox.imageArray.length - 1; j > i; j--) {
453                            if (Lightbox.imageArray[i][0] == Lightbox.imageArray[j][0]) {
454                                Lightbox.imageArray.splice(j, 1);
455                            }
456                        }
457                    }
458                    while (Lightbox.imageArray[Lightbox.imageNum][0] != imageLink.href) {
459                        Lightbox.imageNum++;
460                    }
461                }
462            }
463
464            if (Lightbox.isSlideshow && Lightbox.showPlayPause && Lightbox.isPaused) {
465                $('#lightshowPlay').show();
466                $('#lightshowPause').hide();
467            }
468
469            // Calculate top and left offset for the lightbox.
470            var arrayPageScroll = Lightbox.getPageScroll();
471            var lightboxTop = arrayPageScroll[1] + (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
472
473            //lightboxTop = 100;
474            var lightboxLeft = arrayPageScroll[0];
475            $('#frameContainer').css('visibility', 'hidden');
476            $('#modalContainer, #lightboxImage').hide();
477            $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
478            $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
479            $('#outerImageContainer').css({'width': '250px', 'height': '250px'});
480            $('#lightbox').css({
481                'zIndex': '10500',
482                'top': lightboxTop + 'px',
483                'left': lightboxLeft + 'px'
484            }).show();
485
486            Lightbox.total = Lightbox.imageArray.length;
487            Lightbox.changeData(Lightbox.imageNum);
488        },
489
490        // changeData()
491        // Hide most elements and preload image in preparation for resizing image
492        // container.
493        changeData: function (imageNum, zoomIn) {
494
495            if (Lightbox.inprogress === false) {
496                if (Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) {
497                    if (imageNum >= Lightbox.total) imageNum = 0;
498                    if (imageNum < 0) imageNum = Lightbox.total - 1;
499                }
500
501                if (Lightbox.isSlideshow) {
502                    for (var i = 0; i < Lightbox.slideIdCount; i++) {
503                        window.clearTimeout(Lightbox.slideIdArray[i]);
504                    }
505                }
506                Lightbox.inprogress = true;
507                Lightbox.activeImage = imageNum;
508
509                if (Lightbox.disableResize && !Lightbox.isSlideshow) {
510                    zoomIn = true;
511                }
512                Lightbox.isZoomedIn = zoomIn;
513
514
515                // Hide elements during transition.
516                $('#loading').css({'zIndex': '10500'}).show();
517                if (!Lightbox.alternative_layout) {
518                    $('#imageContainer').hide();
519                }
520                $('#frameContainer').css('visibility', 'hidden');
521                $('#modalContainer, #lightboxImage').hide();
522                $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
523                $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
524
525                // Preload image content, but not iframe pages.
526                if (!Lightbox.isLightframe && !Lightbox.isVideo && !Lightbox.isModal) {
527                    $("#lightbox #imageDataContainer").removeClass('lightbox2-alt-layout-data');
528                    imgPreloader = new Image();
529                    imgPreloader.onerror = function () {
530                        Lightbox.imgNodeLoadingError(this);
531                    };
532
533                    imgPreloader.onload = function () {
534                        var photo = document.getElementById('lightboxImage');
535                        photo.src = Lightbox.imageArray[Lightbox.activeImage][0];
536                        photo.alt = Lightbox.imageArray[Lightbox.activeImage][2];
537
538                        var imageWidth = imgPreloader.width;
539                        var imageHeight = imgPreloader.height;
540
541                        // Resize code.
542                        var arrayPageSize = Lightbox.getPageSize();
543                        var targ = {
544                            w: arrayPageSize[2] - (Lightbox.borderSize * 2),
545                            h: arrayPageSize[3] - (Lightbox.borderSize * 6) - (Lightbox.infoHeight * 4) - (arrayPageSize[3] / 10)
546                        };
547                        var orig = {w: imgPreloader.width, h: imgPreloader.height};
548
549                        // Image is very large, so show a smaller version of the larger image
550                        // with zoom button.
551                        if (zoomIn !== true) {
552                            var ratio = 1.0; // Shrink image with the same aspect.
553                            $('#bottomNavZoomOut, #bottomNavZoom').hide();
554                            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
555                                ratio = ((targ.w / orig.w) < (targ.h / orig.h)) ? targ.w / orig.w : targ.h / orig.h;
556                                if (!Lightbox.disableZoom && !Lightbox.isSlideshow) {
557                                    $('#bottomNavZoom').css({'zIndex': '10500'}).show();
558                                }
559                            }
560
561                            imageWidth = Math.floor(orig.w * ratio);
562                            imageHeight = Math.floor(orig.h * ratio);
563                        }
564
565                        else {
566                            $('#bottomNavZoom').hide();
567                            // Only display zoom out button if the image is zoomed in already.
568                            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
569                                // Only display zoom out button if not a slideshow and if the
570                                // buttons aren't disabled.
571                                if (!Lightbox.disableResize && Lightbox.isSlideshow === false && !Lightbox.disableZoom) {
572                                    $('#bottomNavZoomOut').css({'zIndex': '10500'}).show();
573                                }
574                            }
575                        }
576
577                        photo.style.width = (imageWidth) + 'px';
578                        photo.style.height = (imageHeight) + 'px';
579                        Lightbox.resizeContainer(imageWidth, imageHeight);
580
581                        // Clear onLoad, IE behaves irratically with animated gifs otherwise.
582                        imgPreloader.onload = function () {
583                        };
584                    };
585
586                    imgPreloader.src = Lightbox.imageArray[Lightbox.activeImage][0];
587                    imgPreloader.alt = Lightbox.imageArray[Lightbox.activeImage][2];
588                }
589
590                // Set up frame size, etc.
591                else if (Lightbox.isLightframe) {
592                    $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
593                    var src = Lightbox.imageArray[Lightbox.activeImage][0];
594                    //@thanhnp: add more flag to src before request iframe
595                    if (!/popup=/.test(src)) {
596                        src = /\?/.test(src) ? src + '&popup=' + Lightbox.imageArray[Lightbox.activeImage][4] : src + '?popup=' + Lightbox.imageArray[Lightbox.activeImage][4];
597                    }
598                    if (Lightbox.imageArray[Lightbox.activeImage][4] === 'dcc' || Lightbox.imageArray[Lightbox.activeImage][4] === 'eb-dcc') {
599                        $('#lightbox').unbind('click');
600                        $('#lightbox2-overlay').unbind('click');
601                        $('#bottomNavClose').unbind('click').hide();
602                    }
603                    else {
604                        $('#lightbox').click(function () {
605                            Lightbox.end('forceClose');
606                        });
607                        $('#lightbox2-overlay').click(function () {
608                            Lightbox.end('forceClose');
609                        });
610                        $('#bottomNavClose').click(function () {
611                            Lightbox.end('forceClose');
612                        }).show();
613                    }
614
615                    $('#frameContainer').html('<iframe id="lightboxFrame" scrolling="no" style="display: none;" src="' + src + '"></iframe>');
616                    // Enable swf support in Gecko browsers.
617                    if ($.browser.mozilla && src.indexOf('.swf') != -1) {
618                        setTimeout(function () {
619                            document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
620                        }, 1000);
621                    }
622
623                    if (!Lightbox.iframe_border) {
624                        $('#lightboxFrame').css({'border': 'none'});
625                        $('#lightboxFrame').attr('frameborder', '0');
626                    }
627                    var iframe = document.getElementById('lightboxFrame');
628                    var iframeStyles = Lightbox.imageArray[Lightbox.activeImage][3];
629                    iframe = Lightbox.setStyles(iframe, iframeStyles);
630                    Lightbox.resizeContainer(parseInt(iframe.width, 10), parseInt(iframe.height, 10));
631                }
632                else if (Lightbox.isVideo || Lightbox.isModal) {
633                    $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
634                    var container = document.getElementById('modalContainer');
635                    var modalStyles = Lightbox.imageArray[Lightbox.activeImage][3];
636                    container = Lightbox.setStyles(container, modalStyles);
637                    if (Lightbox.isVideo) {
638                        Lightbox.modalHeight = parseInt(container.height, 10) - 10;
639                        Lightbox.modalWidth = parseInt(container.width, 10) - 10;
640                        Lightvideo.startVideo(Lightbox.imageArray[Lightbox.activeImage][0]);
641                    }
642                    Lightbox.resizeContainer(parseInt(container.width, 10), parseInt(container.height, 10));
643                }
644            }
645        },
646
647        // imgNodeLoadingError()
648        imgNodeLoadingError: function (image) {
649            var s = Drupal.settings.lightbox2;
650            var original_image = Lightbox.imageArray[Lightbox.activeImage][0];
651            if (s.display_image_size !== "") {
652                original_image = original_image.replace(new RegExp("." + s.display_image_size), "");
653            }
654            Lightbox.imageArray[Lightbox.activeImage][0] = original_image;
655            image.onerror = function () {
656                Lightbox.imgLoadingError(image);
657            };
658            image.src = original_image;
659        },
660
661        // imgLoadingError()
662        imgLoadingError: function (image) {
663            var s = Drupal.settings.lightbox2;
664            Lightbox.imageArray[Lightbox.activeImage][0] = s.default_image;
665            image.src = s.default_image;
666        },
667
668        // resizeContainer()
669        resizeContainer: function (imgWidth, imgHeight) {
670
671            imgWidth = (imgWidth < Lightbox.minWidth ? Lightbox.minWidth : imgWidth);
672
673            this.widthCurrent = $('#outerImageContainer').width();
674            this.heightCurrent = $('#outerImageContainer').height();
675
676            var widthNew = (imgWidth + (Lightbox.borderSize * 2));
677            var heightNew = (imgHeight + (Lightbox.borderSize * 2));
678
679            // Scalars based on change from old to new.
680            this.xScale = ( widthNew / this.widthCurrent) * 100;
681            this.yScale = ( heightNew / this.heightCurrent) * 100;
682
683            // Calculate size difference between new and old image, and resize if
684            // necessary.
685            wDiff = this.widthCurrent - widthNew;
686            hDiff = this.heightCurrent - heightNew;
687
688            $('#modalContainer').css({'width': imgWidth, 'height': imgHeight});
689            // Detect animation sequence.
690            if (Lightbox.resizeSequence) {
691                var animate1 = {width: widthNew};
692                var animate2 = {height: heightNew};
693                if (Lightbox.resizeSequence == 2) {
694                    animate1 = {height: heightNew};
695                    animate2 = {width: widthNew};
696                }
697                $('#outerImageContainer').animate(animate1, Lightbox.resizeSpeed).animate(animate2, Lightbox.resizeSpeed, 'linear', function () {
698                    Lightbox.showData();
699                });
700            }
701            // Simultaneous.
702            else {
703                $('#outerImageContainer').slideDown('slow', function () {
704                    $('#outerImageContainer').css({'width': widthNew, 'height': heightNew});
705                    Lightbox.showData();
706                });
707                //$('#outerImageContainer').animate({'width': widthNew, 'height': heightNew}, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); });
708            }
709
710            // quocnt/anphabe: Change lightbox position to fixed.
711            innerHeight = window.innerHeight;
712            if (heightNew > innerHeight) {
713                topNew = 10;
714            }
715            else {
716                topNew = (innerHeight - heightNew) / 2;
717            }
718
719            // anphabe/thanhnp: Change lightbox position to fixed.
720            topNew=10;
721            $('#lightbox').css({
722                'position': '   fixed',
723                'top': topNew + 'px'
724            });
725            // end quocnt fixed
726
727
728            // If new and old image are same size and no scaling transition is necessary
729            // do a quick pause to prevent image flicker.
730            if ((hDiff === 0) && (wDiff === 0)) {
731                if ($.browser.msie) {
732                    Lightbox.pause(250);
733                }
734                else {
735                    Lightbox.pause(100);
736                }
737            }
738
739            var s = Drupal.settings.lightbox2;
740            if (!s.use_alt_layout) {
741                $('#prevLink, #nextLink').css({'height': imgHeight + 'px'});
742            }
743            $('#imageDataContainer').css({'width': widthNew + 'px'});
744        },
745
746        // showData()
747        // Display image and begin preloading neighbors.
748        showData: function () {
749
750
751            if (Lightbox.isLightframe || Lightbox.isVideo || Lightbox.isModal) {
752                Lightbox.updateDetails();
753                if (Lightbox.isLightframe) {
754                    //@thanhnp edit here
755                    $('#lightboxFrame').load(function () {
756                        $('#loading').hide();
757                        $('#outerImageContainer, #imageDataContainer').css({'color': '#' + Lightbox.fontColor});
758                        // Handler for .load() called.
759
760                        $('#frameContainer').css('visibility', 'visible');
761                    });
762                    if ($.browser.safari || Lightbox.fadeInSpeed === 0) {
763                        $('#lightboxFrame').css({'zIndex': '10500'}).show();
764                    }
765                    else {
766                        $('#lightboxFrame').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
767                    }
768                    // $('#frameContainer').show();
769                }
770                else {
771                    $('#loading').hide();
772                    if (Lightbox.isVideo) {
773                        $("#modalContainer").html(Lightbox.modalHTML).click(function () {
774                            return false;
775                        }).css('zIndex', '10500').show();
776                    }
777                    else {
778                        var src = unescape(Lightbox.imageArray[Lightbox.activeImage][0]);
779                        if (Lightbox.imageArray[Lightbox.activeImage][4]) {
780                            $(src).appendTo("#modalContainer");
781                            $('#modalContainer').css({'zIndex': '10500'}).show();
782                        }
783                        else {
784                            // Use a callback to show the new image, otherwise you get flicker.
785                            $("#modalContainer").hide().load(src, function () {
786                                $('#modalContainer').css({'zIndex': '10500'}).show();
787                            });
788                        }
789                        $('#modalContainer').unbind('click');
790                    }
791                    // This might be needed in the Lightframe section above.
792                    //$('#modalContainer').css({'zIndex': '10500'}).show();
793                }
794            }
795
796            // Handle display of image content.
797            else {
798                $('#loading').hide();
799                $('#imageContainer').show();
800                if ($.browser.safari || Lightbox.fadeInSpeed === 0) {
801                    $('#lightboxImage').css({'zIndex': '10500'}).show();
802                }
803                else {
804                    $('#lightboxImage').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
805                }
806                Lightbox.updateDetails();
807                this.preloadNeighborImages();
808            }
809            Lightbox.inprogress = false;
810
811            // Slideshow specific stuff.
812            if (Lightbox.isSlideshow) {
813                if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
814                    if (Lightbox.autoExit) {
815                        Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {
816                            Lightbox.end('slideshow');
817                        }, Lightbox.slideInterval);
818                    }
819                }
820                else {
821                    if (!Lightbox.isPaused && Lightbox.total > 1) {
822                        Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {
823                            Lightbox.changeData(Lightbox.activeImage + 1);
824                        }, Lightbox.slideInterval);
825                    }
826                }
827                if (Lightbox.showPlayPause && Lightbox.total > 1 && !Lightbox.isPaused) {
828                    $('#lightshowPause').show();
829                    $('#lightshowPlay').hide();
830                }
831                else if (Lightbox.showPlayPause && Lightbox.total > 1) {
832                    $('#lightshowPause').hide();
833                    $('#lightshowPlay').show();
834                }
835            }
836
837            // Adjust the page overlay size.
838            var arrayPageSize = Lightbox.getPageSize();
839            var arrayPageScroll = Lightbox.getPageScroll();
840            var pageHeight = arrayPageSize[1];
841            if (Lightbox.isZoomedIn && arrayPageSize[1] > arrayPageSize[3]) {
842                var lightboxTop = (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
843                pageHeight = pageHeight + arrayPageScroll[1] + lightboxTop;
844            }
845            $('#lightbox2-overlay').css({'height': pageHeight + 'px', 'width': arrayPageSize[0] + 'px'});
846
847            // Gecko browsers (e.g. Firefox, SeaMonkey, etc) don't handle pdfs as
848            // expected.
849            if ($.browser.mozilla) {
850                if (Lightbox.imageArray[Lightbox.activeImage][0].indexOf(".pdf") != -1) {
851                    setTimeout(function () {
852                        document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
853                    }, 1000);
854                }
855            }
856        },
857
858        // updateDetails()
859        // Display caption, image number, and bottom nav.
860        updateDetails: function () {
861
862            $("#imageDataContainer").hide();
863
864            var s = Drupal.settings.lightbox2;
865
866            if (s.show_caption) {
867                var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]);
868                if (!caption) caption = '';
869                $('#caption').html(caption).css({'zIndex': '10500'}).show();
870            }
871
872            // If image is part of set display 'Image x of x'.
873            var numberDisplay = null;
874            if (s.image_count && Lightbox.total > 1) {
875                var currentImage = Lightbox.activeImage + 1;
876                if (!Lightbox.isLightframe && !Lightbox.isModal && !Lightbox.isVideo) {
877                    numberDisplay = s.image_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
878                }
879                else if (Lightbox.isVideo) {
880                    numberDisplay = s.video_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
881                }
882                else {
883                    numberDisplay = s.page_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
884                }
885                //@thanhnp : alway hide this information, because it not necessary
886                //$('#numberDisplay').html(numberDisplay).css({'zIndex': '10500'}).show();
887            }
888            else {
889                $('#numberDisplay').hide();
890            }
891
892            $("#imageDataContainer").hide().slideDown(Lightbox.slideDownSpeed, function () {
893                $("#bottomNav").show();
894            });
895            if (Lightbox.rtl == 1) {
896                $("#bottomNav").css({'float': 'left'});
897            }
898            Lightbox.updateNav();
899        },
900
901        // updateNav()
902        // Display appropriate previous and next hover navigation.
903        updateNav: function () {
904            $('#hoverNav').css({'zIndex': '10500'}).show();
905            var prevLink = '#prevLink';
906            var nextLink = '#nextLink';
907
908            // Slideshow is separated as we need to show play / pause button.
909            if (Lightbox.isSlideshow) {
910                if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage !== 0) {
911                    $(prevLink).css({'zIndex': '10500'}).show().click(function () {
912                        if (Lightbox.pauseOnPrevClick) {
913                            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
914                        }
915                        Lightbox.changeData(Lightbox.activeImage - 1);
916                        return false;
917                    });
918                }
919                else {
920                    $(prevLink).hide();
921                }
922
923                // If not last image in set, display next image button.
924                if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage != (Lightbox.total - 1)) {
925                    $(nextLink).css({'zIndex': '10500'}).show().click(function () {
926                        if (Lightbox.pauseOnNextClick) {
927                            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
928                        }
929                        Lightbox.changeData(Lightbox.activeImage + 1);
930                        return false;
931                    });
932                }
933                // Safari browsers need to have hide() called again.
934                else {
935                    $(nextLink).hide();
936                }
937            }
938
939            // All other types of content.
940            else {
941
942                if ((Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) && !Lightbox.alternative_layout) {
943                    $('#frameHoverNav').css({'zIndex': '10500'}).show();
944                    $('#hoverNav').css({'zIndex': '10500'}).hide();
945                    prevLink = '#framePrevLink';
946                    nextLink = '#frameNextLink';
947                }
948
949                // If not first image in set, display prev image button.
950                if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage !== 0) {
951                    // Unbind any other click handlers, otherwise this adds a new click handler
952                    // each time the arrow is clicked.
953                    $(prevLink).css({'zIndex': '10500'}).show().unbind().click(function () {
954                        Lightbox.changeData(Lightbox.activeImage - 1);
955                        return false;
956                    });
957                }
958                // Safari browsers need to have hide() called again.
959                else {
960                    $(prevLink).hide();
961                }
962
963                // If not last image in set, display next image button.
964                if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage != (Lightbox.total - 1)) {
965                    // Unbind any other click handlers, otherwise this adds a new click handler
966                    // each time the arrow is clicked.
967                    $(nextLink).css({'zIndex': '10500'}).show().unbind().click(function () {
968                        Lightbox.changeData(Lightbox.activeImage + 1);
969                        return false;
970                    });
971                }
972                // Safari browsers need to have hide() called again.
973                else {
974                    $(nextLink).hide();
975                }
976            }
977
978            // Don't enable keyboard shortcuts so forms will work.
979            if (!Lightbox.isModal) {
980                this.enableKeyboardNav();
981            }
982        },
983
984
985        // enableKeyboardNav()
986        enableKeyboardNav: function () {
987            $(document).bind("keydown", this.keyboardAction);
988        },
989
990        // disableKeyboardNav()
991        disableKeyboardNav: function () {
992            $(document).unbind("keydown", this.keyboardAction);
993        },
994
995        // keyboardAction()
996        keyboardAction: function (e) {
997            if (e === null) { // IE.
998                keycode = event.keyCode;
999                escapeKey = 27;
1000            }
1001            else { // Mozilla.
1002                keycode = e.keyCode;
1003                escapeKey = e.DOM_VK_ESCAPE;
1004            }
1005
1006            key = String.fromCharCode(keycode).toLowerCase();
1007
1008            // Close lightbox.
1009            if (Lightbox.checkKey(Lightbox.keysClose, key, keycode)) {
1010                Lightbox.end('forceClose');
1011            }
1012            // Display previous image (p, <-).
1013            else if (Lightbox.checkKey(Lightbox.keysPrevious, key, keycode)) {
1014                if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage !== 0) {
1015                    Lightbox.changeData(Lightbox.activeImage - 1);
1016                }
1017
1018            }
1019            // Display next image (n, ->).
1020            else if (Lightbox.checkKey(Lightbox.keysNext, key, keycode)) {
1021                if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage != (Lightbox.total - 1)) {
1022                    Lightbox.changeData(Lightbox.activeImage + 1);
1023                }
1024            }
1025            // Zoom in.
1026            else if (Lightbox.checkKey(Lightbox.keysZoom, key, keycode) && !Lightbox.disableResize && !Lightbox.disableZoom && !Lightbox.isSlideshow && !Lightbox.isLightframe) {
1027                if (Lightbox.isZoomedIn) {
1028                    Lightbox.changeData(Lightbox.activeImage, false);
1029                }
1030                else if (!Lightbox.isZoomedIn) {
1031                    Lightbox.changeData(Lightbox.activeImage, true);
1032                }
1033                return false;
1034            }
1035            // Toggle play / pause (space).
1036            else if (Lightbox.checkKey(Lightbox.keysPlayPause, key, keycode) && Lightbox.isSlideshow) {
1037
1038                if (Lightbox.isPaused) {
1039                    Lightbox.togglePlayPause("lightshowPlay", "lightshowPause");
1040                }
1041                else {
1042                    Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
1043                }
1044                return false;
1045            }
1046        },
1047
1048        preloadNeighborImages: function () {
1049
1050            if ((Lightbox.total - 1) > Lightbox.activeImage) {
1051                preloadNextImage = new Image();
1052                preloadNextImage.src = Lightbox.imageArray[Lightbox.activeImage + 1][0];
1053            }
1054            if (Lightbox.activeImage > 0) {
1055                preloadPrevImage = new Image();
1056                preloadPrevImage.src = Lightbox.imageArray[Lightbox.activeImage - 1][0];
1057            }
1058
1059        },
1060
1061        end: function (caller) {
1062            var closeClick = (caller == 'slideshow' ? false : true);
1063            if (Lightbox.isSlideshow && Lightbox.isPaused && !closeClick) {
1064                return;
1065            }
1066            // To prevent double clicks on navigation links.
1067            if (Lightbox.inprogress === true && caller != 'forceClose') {
1068                return;
1069            }
1070            Lightbox.disableKeyboardNav();
1071            $('#lightbox').hide();
1072            $("#lightbox2-overlay").fadeOut();
1073            Lightbox.isPaused = true;
1074            Lightbox.inprogress = false;
1075            // Replaces calls to showSelectBoxes() and showFlash() in original
1076            // lightbox2.
1077            Lightbox.toggleSelectsFlash('visible');
1078            if (Lightbox.isSlideshow) {
1079                for (var i = 0; i < Lightbox.slideIdCount; i++) {
1080                    window.clearTimeout(Lightbox.slideIdArray[i]);
1081                }
1082                $('#lightshowPause, #lightshowPlay').hide();
1083            }
1084            else if (Lightbox.isLightframe) {
1085                $('#frameContainer').empty();
1086                $('#frameContainer').css('visibility', 'hidden');
1087                $('#outerImageContainer, #imageDataContainer').attr('style', '');
1088            }
1089            else if (Lightbox.isVideo || Lightbox.isModal) {
1090                if (!Lightbox.auto_modal) {
1091                    $('#modalContainer').hide().html("");
1092                }
1093                Lightbox.auto_modal = false;
1094            }
1095        },
1096
1097
1098        // getPageScroll()
1099        // Returns array with x,y page scroll values.
1100        // Core code from - quirksmode.com.
1101        getPageScroll: function () {
1102
1103            var xScroll, yScroll;
1104
1105            if (self.pageYOffset || self.pageXOffset) {
1106                yScroll = self.pageYOffset;
1107                xScroll = self.pageXOffset;
1108            }
1109            else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {  // Explorer 6 Strict.
1110                yScroll = document.documentElement.scrollTop;
1111                xScroll = document.documentElement.scrollLeft;
1112            }
1113            else if (document.body) {// All other Explorers.
1114                yScroll = document.body.scrollTop;
1115                xScroll = document.body.scrollLeft;
1116            }
1117
1118            arrayPageScroll = [xScroll, yScroll];
1119            return arrayPageScroll;
1120        },
1121
1122        // getPageSize()
1123        // Returns array with page width, height and window width, height.
1124        // Core code from - quirksmode.com.
1125        // Edit for Firefox by pHaez.
1126
1127        getPageSize: function () {
1128
1129            var xScroll, yScroll;
1130
1131            if (window.innerHeight && window.scrollMaxY) {
1132                xScroll = window.innerWidth + window.scrollMaxX;
1133                yScroll = window.innerHeight + window.scrollMaxY;
1134            }
1135            else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac.
1136                xScroll = document.body.scrollWidth;
1137                yScroll = document.body.scrollHeight;
1138            }
1139            else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari.
1140                xScroll = document.body.offsetWidth;
1141                yScroll = document.body.offsetHeight;
1142            }
1143
1144            var windowWidth, windowHeight;
1145
1146            if (self.innerHeight) { // All except Explorer.
1147                if (document.documentElement.clientWidth) {
1148                    windowWidth = document.documentElement.clientWidth;
1149                }
1150                else {
1151                    windowWidth = self.innerWidth;
1152                }
1153                windowHeight = self.innerHeight;
1154            }
1155            else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode.
1156                windowWidth = document.documentElement.clientWidth;
1157                windowHeight = document.documentElement.clientHeight;
1158            }
1159            else if (document.body) { // Other Explorers.
1160                windowWidth = document.body.clientWidth;
1161                windowHeight = document.body.clientHeight;
1162            }
1163            // For small pages with total height less than height of the viewport.
1164            if (yScroll < windowHeight) {
1165                pageHeight = windowHeight;
1166            }
1167            else {
1168                pageHeight = yScroll;
1169            }
1170            // For small pages with total width less than width of the viewport.
1171            if (xScroll < windowWidth) {
1172                pageWidth = xScroll;
1173            }
1174            else {
1175                pageWidth = windowWidth;
1176            }
1177            arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
1178            return arrayPageSize;
1179        },
1180
1181
1182        // pause(numberMillis)
1183        pause: function (ms) {
1184            var date = new Date();
1185            var curDate = null;
1186            do {
1187                curDate = new Date();
1188            }
1189            while (curDate - date < ms);
1190        },
1191
1192
1193        // toggleSelectsFlash()
1194        // Hide / unhide select lists and flash objects as they appear above the
1195        // lightbox in some browsers.
1196        toggleSelectsFlash: function (state) {
1197            if (state == 'visible') {
1198                $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").show();
1199            }
1200            else if (state == 'hide') {
1201                $("select:visible, embed:visible, object:visible").not('#lightboxAutoModal select, #lightboxAutoModal embed, #lightboxAutoModal object').addClass("lightbox_hidden");
1202                $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").hide();
1203            }
1204        },
1205
1206
1207        // parseRel()
1208        parseRel: function (link) {
1209            var parts = [];
1210            parts["rel"] = parts["title"] = parts["group"] = parts["style"] = parts["flashvars"] = null;
1211            if (!$(link).attr('rel')) return parts;
1212            parts["rel"] = $(link).attr('rel').match(/\w+/)[0];
1213
1214            if ($(link).attr('rel').match(/\[(.*)\]/)) {
1215                var info = $(link).attr('rel').match(/\[(.*?)\]/)[1].split('|');
1216                parts["group"] = info[0];
1217                parts["style"] = info[1];
1218                //@thanhnp add here
1219                parts["command"] = info[2];
1220                if (parts["style"] != undefined && parts["style"].match(/flashvars:\s?(.*?);/)) {
1221                    parts["flashvars"] = parts["style"].match(/flashvars:\s?(.*?);/)[1];
1222                }
1223            }
1224            if ($(link).attr('rel').match(/\[.*\]\[(.*)\]/)) {
1225                parts["title"] = $(link).attr('rel').match(/\[.*\]\[(.*)\]/)[1];
1226            }
1227            return parts;
1228        },
1229
1230        // setStyles()
1231        setStyles: function (item, styles) {
1232            item.width = Lightbox.iframe_width;
1233            item.height = Lightbox.iframe_height;
1234            item.scrolling = "auto";
1235
1236            if (!styles) return item;
1237            var stylesArray = styles.split(';');
1238            for (var i = 0; i < stylesArray.length; i++) {
1239                if (stylesArray[i].indexOf('width:') >= 0) {
1240                    var w = stylesArray[i].replace('width:', '');
1241                    item.width = jQuery.trim(w);
1242                }
1243                else if (stylesArray[i].indexOf('height:') >= 0) {
1244                    var h = stylesArray[i].replace('height:', '');
1245                    item.height = jQuery.trim(h);
1246                }
1247                else if (stylesArray[i].indexOf('scrolling:') >= 0) {
1248                    var scrolling = stylesArray[i].replace('scrolling:', '');
1249                    item.scrolling = jQuery.trim(scrolling);
1250                }
1251                else if (stylesArray[i].indexOf('overflow:') >= 0) {
1252                    var overflow = stylesArray[i].replace('overflow:', '');
1253                    item.overflow = jQuery.trim(overflow);
1254                }
1255            }
1256            return item;
1257        },
1258
1259
1260        // togglePlayPause()
1261        // Hide the pause / play button as appropriate.  If pausing the slideshow also
1262        // clear the timers, otherwise move onto the next image.
1263        togglePlayPause: function (hideId, showId) {
1264            if (Lightbox.isSlideshow && hideId == "lightshowPause") {
1265                for (var i = 0; i < Lightbox.slideIdCount; i++) {
1266                    window.clearTimeout(Lightbox.slideIdArray[i]);
1267                }
1268            }
1269            $('#' + hideId).hide();
1270            $('#' + showId).show();
1271
1272            if (hideId == "lightshowPlay") {
1273                Lightbox.isPaused = false;
1274                if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
1275                    Lightbox.end();
1276                }
1277                else if (Lightbox.total > 1) {
1278                    Lightbox.changeData(Lightbox.activeImage + 1);
1279                }
1280            }
1281            else {
1282                Lightbox.isPaused = true;
1283            }
1284        },
1285
1286        triggerLightbox: function (rel_type, rel_group) {
1287            if (rel_type.length) {
1288                if (rel_group && rel_group.length) {
1289                    $("a[rel^='" + rel_type + "\[" + rel_group + "\]'], area[rel^='" + rel_type + "\[" + rel_group + "\]']").eq(0).trigger("click");
1290                }
1291                else {
1292                    $("a[rel^='" + rel_type + "'], area[rel^='" + rel_type + "']").eq(0).trigger("click");
1293                }
1294            }
1295        },
1296
1297        detectMacFF2: function () {
1298            var ua = navigator.userAgent.toLowerCase();
1299            if (/firefox[\/\s](\d+\.\d+)/.test(ua)) {
1300                var ffversion = new Number(RegExp.$1);
1301                if (ffversion < 3 && ua.indexOf('mac') != -1) {
1302                    return true;
1303                }
1304            }
1305            return false;
1306        },
1307
1308        checkKey: function (keys, key, code) {
1309            return (jQuery.inArray(key, keys) != -1 || jQuery.inArray(String(code), keys) != -1);
1310        },
1311
1312        filterXSS: function (str, allowed_tags) {
1313            var output = "";
1314            $.ajax({
1315                url: Drupal.settings.basePath + '?q=system/lightbox2/filter-xss',
1316                data: {
1317                    'string': str,
1318                    'allowed_tags': allowed_tags
1319                },
1320                type: "POST",
1321                async: false,
1322                dataType: "json",
1323                success: function (data) {
1324                    output = data;
1325                }
1326            });
1327            return output;
1328        }
1329
1330    };
1331
1332// Initialize the lightbox.
1333    Drupal.behaviors.initLightbox = {
1334        attach: function (context) {
1335
1336            $('body:not(.lightbox-processed)', context).addClass('lightbox-processed').each(function () {
1337                Lightbox.initialize();
1338                return false; // Break the each loop.
1339            });
1340
1341            // Attach lightbox to any links with lightbox rels.
1342            Lightbox.initList(context);
1343            $('#lightboxAutoModal', context).triggerHandler('click');
1344        }
1345    };
1346})(jQuery);

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.