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