1/** 2 * @preserve jQuery lightBox plugin 3 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/) 4 * and adapted to me for use like a plugin from jQuery. 5 * @name jquery-lightbox-0.5.js 6 * @author Leandro Vieira Pinho - http://leandrovieira.com 7 * @version 0.5.1 8 * @date April 11, 2008 9 * @category jQuery plugin 10 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com) 11 * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US 12 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin 13 * 14 * @updates by Ivaylo Stamatov aka avioli @ FULLER http://fuller.com.au/ 15 * @date 2011-08-04 16 */ 17/** 18 * Informations for developers: 19 * 20 * The minified file can be generated with Google Closure Compiler (https://github.com/google/closure-compiler) 21 * The "preserve" keyword at the top enables to keep the content of the header in the minified file 22 * You can compile the file by running the following command in the javascript directory 23 * java -jar /path/to/compiler --js_output_file=jquery.lightbox.min.js jquery.lightbox.js 24 * 25 */ 26// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias 27var lightbox_path = 'lightboxJQuery/images/'; 28 29function loadlightbox() { 30 (function ($) { 31 /** 32 * $ is an alias to jQuery object 33 * 34 */ 35 $.fn.lightBox = function (settings) { 36 // Settings to configure the jQuery lightBox plugin how you like 37 settings = jQuery.extend({ 38 // Configuration related to overlay 39 overlayBgColor: '#000', // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color. 40 overlayOpacity: 0.8, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9 41 // Configuration related to navigation 42 fixedNavigation: false, // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface. 43 // Configuration related to images 44 imageLoading: lightbox_path + 'lightbox-ico-loading.gif', // (string) Path and the name of the loading icon 45 imageBtnPrev: lightbox_path + 'prev.gif', // (string) Path and the name of the prev button image 46 imageBtnNext: lightbox_path + 'next.gif', // (string) Path and the name of the next button image 47 imageBtnClose: lightbox_path + 'close.gif', // (string) Path and the name of the close btn 48 imageBlank: lightbox_path + 'lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel) 49 // Configuration related to container image box 50 containerBorderSize: 10, // (integer) If you adjust the padding in the CSS for the container, #imagedetails, you will need to update this value 51 containerResizeSpeed: 400, // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default. 52 // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts. 53 txtImage: 'Bild', // (string) Specify text "Image" 54 txtOf: 'von', // (string) Specify text "of" 55 sprachid: '0', 56 imgCopyright: 'Copyright', 57 imgAltText: 'Alternativtext', 58 imgQuelle: 'Quelle', 59 imgLongDesc: 'Fotobeschreibung', 60 btnCloseLabel: 'Schliessen', 61 bildInformation: 'Bildinformation', 62 btnNextImage: 'Nächstes Bild', 63 btnPreviousImage: 'Vorheriges Bild', 64 // Configuration related to keyboard navigation 65 keyToClose: 'c', // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to. 66 keyToPrev: 'p', // (string) (p = previous) Letter to show the previous image 67 keyToNext: 'n', // (string) (n = next) Letter to show the next image. 68 // Don´t alter these variables in any way 69 imageArray: [], 70 activeImage: 0, 71 captionPosition: '', 72 shrinkToFit: true // (boolean) Shrinks the image to fit withing the current viewport *** FULLER 73 , 74 shrinkPadding: 50 // (integer) The padding amount for the shrinking calculation *** FULLER 75 , 76 grouping: true // (boolean) Treats the all the same rel="ligthbox[groupName]" as singular group set *** FULLER 77 }, settings); 78 // Caching the jQuery object with all elements matched 79 var jQueryMatchedObj = this; // This, in this context, refer to jQuery object 80 var previousActiveElement = null;
80 // store element that had focus before opening the lightbox 81 /** 82 * Initializing the plugin calling the start function 83 * 84 * @return boolean false 85 */ 86 function _initialize() { 87 _start(this, jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked 88 return false; // Avoid the browser following the link 89 } 90 91 function ImgEntry(href, position, data) { 92 this.href = href; 93 this.position = position; 94 this.data = data; 95 } 96 97 /** 98 * Start the jQuery lightBox plugin 99 * 100 * @param object objClicked The object (link) whick the user have clicked 101 * @param object jQueryMatchedObj The jQuery object with all elements matched 102 */ 103 function _start(objClicked, jQueryMatchedObj) { 104 // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay. 105 $('embed, object, select').css({ 106 'visibility': 'hidden' 107 }); 108 // Call the function to create the markup structure; style some elements; assign events in some elements. 109 _set_interface(); 110 // Unset total images in imageArray 111 settings.imageArray.length = 0; 112 // Unset image active information 113 settings.activeImage = 0; 114 /* FULLER */ 115 var allImages = false, 116 rel; 117 if (settings.grouping) { 118 if ((rel = objClicked.getAttribute('data-lbgroup'))) { 119 allImages = jQueryMatchedObj; 120 jQueryMatchedObj = []; 121 allImages.each(function (i, el) { 122 if (rel == el.getAttribute('data-lbgroup')) jQueryMatchedObj.push(el); 123 }); 124 } 125 } 126 /* F */ 127 // We have an image set? Or just an image? Let´s see it. 128 if (jQueryMatchedObj.length == 1) { 129 if (settings.captionPosition == 'gallery') var position = jQuery(objClicked).parent().next().html(); 130 else var position = objClicked.getAttribute('title'); 131 settings.imageArray.push(new ImgEntry(objClicked.getAttribute('href'), position, jQuery(objClicked).data())); 132 } else { 133 // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references 134 for (var i = 0; i < jQueryMatchedObj.length; i++) { 135 if (settings.captionPosition != 'gallery') { 136 var position = jQueryMatchedObj[i].getAttribute('title'); 137 settings.imageArray.push(new ImgEntry(jQueryMatchedObj[i].getAttribute('href'), position, jQuery(jQueryMatchedObj[i]).data())); 138 } else { 139 if (i > 1) { 140 if (!(jQueryMatchedObj[i - 1].getAttribute('href') != jQueryMatchedObj[i].getAttribute('href') && jQuery(jQueryMatchedObj[i - 1]).parent().parent().children().children().attr('href') == jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'))) { 141 var position = jQuery(jQueryMatchedObj[i]).parent().next().html(); 142 settings.imageArray.push(new ImgEntry(jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'), position, jQuery(jQueryMatchedObj[i]).data())); 143 } 144 } else { 145 var position = jQuery(jQueryMatchedObj[i]).parent().next().html(); 146 settings.imageArray.push(new ImgEntry(jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'), position, jQuery(jQueryMatchedObj[i]).data())); 147 } 148 } 149 } 150 } 151 while (settings.imageArray[settings.activeImage].href != objClicked.getAttribute('href')) { 152 settings.activeImage++; 153 } 154 /* FULLER */ 155 if (settings.grouping && allImages) { 156 jQueryMatchedObj = allImages; 157 allImages = false; 158 } 159 /* F */ 160 // Call the function that prepares image exibition 161 _set_image_to_view(); 162 } 163 /** 164 * Create the jQuery lightBox plugin interface 165 * 166 * The HTML markup will be like that: 167 <div id="jquery-overlay"></div> 168 <div id="jquery-lightbox"> 169 <div id="imagedetails imagedetails"> 170 <div id="lightbox-container-image"> 171 <img src="../fotos/XX.jpg" id="lightbox-image" alt="Bildbeschreibung"> 172 <div id="lightbox-nav"> 173 <a href="#" id="lightbox-nav-btnPrev"></a> 174 <a href="#" id="lightbox-nav-btnNext"></a> 175 </div> 176 <div id="lightbox-loading"> 177 <a href="#" id="lightbox-loading-link"> 178 <img src="../images/lightbox-ico-loading.gif"> 179 </a> 180 </div> 181 </div> 182 </div> 183 <div id="outerImageContainer outerImageContainer"> 184 <div id="imageDataContainer imageDataContainer"> 185 <div id="lightbox-image-details">
186 <span id="caption"></span> 187 <span id="numberDisplay"></span> 188 <span id="lightboxdescription lightboxdescription"></span> 189 </div> 190 <div id="lightbox-secNav"> 191 <a href="#" id="lightbox-secNav-btnClose"> 192 <img src="../images/lightbox-btn-close.gif"> 193 </a> 194 </div> 195 </div> 196 </div> 197 </div> 198 * 199 */ 200 function getParameterByName(name, hash) { 201 var match = RegExp('[?&]' + name + '=([^&]*)').exec(hash); 202 return match && decodeURIComponent(match[1].replace(/\\+/g, ' ')); 203 } 204 205 function _getmetadata(FileId) { 206 if (settings.imageArray[settings.activeImage].fileinfo) { 207 _set_fileinfo(settings.imageArray[settings.activeImage].fileinfo); 208 return; 209 } 210 var thisEnvUrl = envurl; 211 settings.imageArray[settings.activeImage].fileinfo = ""; 212 if (FileId != null && FileId != "" && !isNaN(FileId)) { 213 jQuery.ajax({ 214 url: thisEnvUrl + "system/web/services/files/filesinfo.asmx/GetFileInfo", 215 data: '{ FileID : "' + FileId + '", SprachId: "' + settings.sprachid + '" }', 216 dataType: "json", 217 type: "POST", 218 contentType: "application/json; charset=utf-8", 219 error: function (xhr, ajaxOptions, thrownError) { 220 alert(xhr.status); 221 alert(thrownError); 222 }, 223 success: function (data) { 224 settings.imageArray[settings.activeImage].fileinfo = data.d; 225 _set_fileinfo() 226 } 227 }); 228 } 229 } 230 231 function _set_fileinfo() { 232 var htmlString = ''; 233 var caption; 234 fileinfo = settings.imageArray[settings.activeImage].fileinfo; 235 if (settings.imageArray[settings.activeImage].position) { 236 caption = settings.imageArray[settings.activeImage].position; 237 } 238 if (!(settings.imageArray[settings.activeImage].data && settings.imageArray[settings.activeImage].data.description)) { 239 var ldesc = ''; 240 if (fileinfo.Longdesc != null && fileinfo.Longdesc != "" && (caption && caption.indexOf(decodeURIComponent(fileinfo.Longdesc)) == -1)) 241 ldesc = fileinfo.Longdesc; 242 else if (fileinfo.Alttext != null && (caption && caption.indexOf(fileinfo.Alttext) == -1)) 243 ldesc = fileinfo.Alttext; 244 if (ldesc.startsWith('<p')) { 245 htmlString += ldesc; 246 } else { 247 htmlString += '<p>' + ldesc + '</p>'; 248 } 249 } else { 250 var desc = decodeURIComponent(settings.imageArray[settings.activeImage].data.description).replace(/\+/g, " ") 251 if (caption.indexOf(desc) == -1) 252 if (desc.startsWith('<p')) { 253 htmlString += desc; 254 } else { 255 htmlString += '<p>' + desc + '</p>'; 256 } 257 } 258 if (fileinfo.Copyright != null && fileinfo.Copyright != '' && (caption && caption.indexOf(String.fromCharCode(169)) == -1)) 259 htmlString += '<p>' + settings.imgCopyright + ': ' + fileinfo.Copyright + '</p>'; 260 if (fileinfo.Quelle != null && fileinfo.Quelle != '' && (caption && caption.indexOf(decodeURIComponent(fileinfo.Quelle)) == -1)) 261 htmlString += '<p>' + settings.imgQuelle + ': ' + fileinfo.Quelle + '</p>'; 262 if (settings.imageArray[settings.activeImage].data && settings.imageArray[settings.activeImage].data.downloadlink) { 263 htmlString += '<p>' + decodeURIComponent(settings.imageArray[settings.activeImage].data.downloadlink).replace(/\+/g, " ") + '</p>'; 264 } 265 $('#lightboxdescription').html(htmlString).show(); 266 $('#lightbox-image').attr('alt', fileinfo.Alttext); 267 } 268 function _set_interface() { 269 _enable_keyboard_navigation(); 270 271 try { 272 previousActiveElement = document.activeElement; 273 } catch (e) { 274 previousActiveElement = null; 275 } 276 277 $('body').append( 278 '<div id="jquery-overlay"></div>' + 279 '<dialog id="jquery-lightbox" tabindex="-1">' + 280 '<div id="imagedetails">' + 281 '<div id="lightbox-container-image">' + 282 '<img id="lightbox-image" alt="">' + 283 '<div style="" id="lightbox-nav">' + 284 '<a href="#" id="lightbox-nav-btnPrev" aria-label="' + settings.btnPreviousImage
284+ '"></a>' + 285 '<a href="#" id="lightbox-nav-btnNext" aria-label="' + settings.btnNextImage + '"></a>' + 286 '</div>' + 287 '<div id="lightbox-loading">' + 288 '<a href="#" id="lightbox-loading-link" aria-label="' + settings.btnCloseLabel + '">' + 289 '<img src="' + settings.imageLoading + '" alt="Laden...">' + 290 '</a>' + 291 '</div>' + 292 '</div>' + 293 '</div>' + 294 '<div id="outerImageContainer">' + 295 '<div id="imageDataContainer">' + 296 '<div id="lightbox-image-details">' + 297 '<span id="caption"></span>' + 298 '<span id="numberDisplay"></span>' + 299 '<span id="lightboxdescription"></span>' + 300 '</div>' + 301 '<div id="lightbox-secNav">' + 302 '<a href="#" id="lightbox-secNav-btnClose" aria-label="' + settings.btnCloseLabel + '">' + 303 '<img src="' + settings.imageBtnClose + '" alt="" aria-hidden="true">' + 304 '</a>' + 305 '</div>' + 306 '</div>' + 307 '</div>' + 308 '</dialog>' 309 ); 310 311 // Opens in the Top Layer position:fixed is now viewport-anchored.
312 // showModal() focuses the dialog natively; no separate .focus() needed. 313 $('#jquery-lightbox')[0].showModal(); 314 315 // Prevent background scroll while modal is open. 316 // The Top Layer focus-tracking otherwise snaps the document back to 317 // expose a focused element that appears to sit at an absolute page offset. 318 document.body.style.overflow = 'hidden'; 319 320 $('#jquery-overlay').css({ 321 backgroundColor: settings.overlayBgColor, 322 opacity: settings.overlayOpacity 323 }).fadeIn(); 324 325 _resize_jquery_lightbox(); 326 327 // Overlay click closes the lightbox. 328 $('#jquery-overlay').click(function () { 329 _finish(); 330 }); 331 // For the dialog, only close when the click target IS the dialog element itself. 332 // ::backdrop clicks bubble up as a click on the dialog with e.target === dialog, 333 // so this correctly handles backdrop-click without firing on inner content clicks. 334 $('#jquery-lightbox').on('click', function (e) { 335 if (e.target === this) { 336 _finish(); 337 } 338 }); 339 340 $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function () { 341 _finish(); 342 return false; 343 }); 344 345 // Intercept the browser's native cancel event (fired on ESC before keydown 346 // reaches us). Preventing default stops the browser calling .close() silently, 347 // so _finish() owns the full cleanup sequence exclusively. 348 $('#jquery-lightbox')[0].addEventListener('cancel', function (e) { 349 e.preventDefault(); 350 _finish(); 351 }); 352 353 $(document).on("keydown", function (e) { 354 if (e.keyCode == 27) { 355 _finish(); 356 return false; 357 } 358 }); 359 360 $(window).resize(function () { 361 _resize_jquery_lightbox(); 362 $(window).bind('resize', function (e) { 363 window.resizeEvt; 364 $(window).resize(function () { 365 clearTimeout(window.resizeEvt); 366 window.resizeEvt = setTimeout(function () { 367 var intCurrentWidth = document.getElementById("lightbox-image").naturalWidth; 368 var intCurrentHeight = document.getElementById("lightbox-image").naturalHeight; 369 _resize_container_image_box(intCurrentWidth, intCurrentHeight); 370 }, 250); 371 }); 372 }); 373 }); 374 } 375 /** 376 * Prepares image exibition; doing a image´s preloader to calculate it´s size 377 * 378 */ 379 function _set_image_to_view() { // show the loading 380 // Show the loading 381 $('#lightbox-loading').show(); 382 if (settings.fixedNavigation) { 383 $('#lightbox-image,#outerImageContainer,#numberDisplay,#lightboxdescription').hide(); 384 } else { 385 // Hide some elements 386 $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#outerImageContainer,#numberDisplay,#lightboxdescription').hide(); 387 } 388 // Image preload process 389 var objImagePreloader = new Image(); 390 objImagePreloader.onload = function () { 391 $('#lightbox-image').attr('src', settings.imageArray[settings.activeImage].href); 392 // Perfom an effect in the image container resizing it 393 _resize_container_image_box(objImagePreloader.width, objImagePreloader.height); 394 // clear onLoad, IE behaves irratically with animated gifs otherwise 395 objImagePreloader.onload = function () { }; 396 }; 397 objImagePreloader.src = settings.imageArray[settings.activeImage].href; 398 }; 399 /** 400 * Resize the lightbox depending on the current screen resolution 401 * 402 */ 403 404 function _resize_jquery_lightbox() { 405 // Get page sizes 406 var arrPageSizes = ___getPageSize(); 407 // Style overlay and show it 408 $('#jquery-overlay').css({ 409 width: arrPageSizes[0], 410 height: arrPageSizes[1] 411 }); 412 // Get page scroll 413 var arrPageScroll = ___getPageScroll(); 414 // Calculate top and left offset for the jquery-lightbox div object and show it 415 $('#jquery-lightbox').css({ 416 // If the shrinkToFit feature is enabled, the shrinkPadding property is used. If not, top is 10th of the page height 417 top: arrPageScroll[1] + (settings.shrinkToFit ? settings.shrinkPadding : arrPageSizes[3] / 10), 418 left: arrPageScroll[0], 419 width: arrPageSizes[0] 420 }); 421 }; 422 /** 423 * Perfom an effect in the image container resizing it 424 * 425 * @param integer intImageWidth The image´s width that will be showed 426 * @param integer intImageHeight The image´s height that will be showed 427 */ 428 function _resize_container_image_box(intImageWidth, intImageHeight) { 429 // Get current width and height 430 var intCurrentWidth = $('#imagedetails').width();
431 var intCurrentHeight = $('#imagedetails').height(); 432 /* FULLER */ 433 if (settings.shrinkToFit) { 434 var arrPageSizes = ___getPageSize(); 435 // The 0.9 percentage ensures that controls under the modal are (mostly) visible even with a very small shrinkPadding 436 // shrinkPadding is doubled to give same padding all around the modal 437 var imageRatio = intImageWidth / intImageHeight; 438 if (intImageHeight > arrPageSizes[3] * 0.9 - settings.shrinkPadding * 2) { 439 intImageHeight = arrPageSizes[3] * 0.9 - settings.shrinkPadding * 2; 440 intImageWidth = intImageHeight * imageRatio; 441 } 442 if (intImageWidth > arrPageSizes[0] - settings.shrinkPadding * 2) { 443 intImageWidth = arrPageSizes[0] - settings.shrinkPadding * 2; 444 intImageHeight = intImageWidth / imageRatio; 445 } 446 } 447 /* F */ 448 // Get the width and height of the selected image plus the padding 449 var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value 450 var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value 451 // Diferences 452 var intDiffW = intCurrentWidth - intWidth; 453 var intDiffH = intCurrentHeight - intHeight; 454 // Perfom the effect 455 $('#imagedetails').animate({ 456 width: intWidth, 457 height: intHeight 458 }, settings.containerResizeSpeed, function () { 459 _show_image(false); 460 _getmetadata(getParameterByName("fileid", String(settings.imageArray[settings.activeImage].href).toLowerCase())); 461 }); 462 $('#outerImageContainer').animate({ 463 width: intWidth 464 }, settings.containerResizeSpeed, function () { 465 _show_image(true); 466 }); 467 if ((intDiffW == 0) && (intDiffH == 0)) { 468 if ($.browser.msie) { 469 ___pause(250); 470 } else { 471 ___pause(100); 472 } 473 } 474 //$('#outerImageContainer').css({ 475 // width: intWidth 476 //}); 477 $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 478 height: intImageHeight + (settings.containerBorderSize * 2) 479 }); 480 }; 481 /** 482 * Show the prepared image 483 * 484 */ 485 function _show_image(getmetadata) { 486 $('#lightbox-loading').hide(); 487 $('#lightbox-image').fadeIn(function () { 488 _show_image_data(); 489 _set_navigation(); 490 if (getmetadata) 491 _getmetadata(getParameterByName("fileid", String(settings.imageArray[settings.activeImage].href).toLowerCase())); 492 493 }); 494 _preload_neighbor_images(); 495 }; 496 /** 497 * Show the image information 498 * 499 */ 500 function _show_image_data() { 501 $('#outerImageContainer').slideDown('fast'); 502 $('#caption').hide(); 503 $('#lightboxdescription').hide(); 504 if (settings.imageArray[settings.activeImage].position) { 505 $('#caption').html(settings.imageArray[settings.activeImage].position).show(); 506 } 507 // If we have a image set, display 'Image X of X' 508 if (settings.imageArray.length > 1) { 509 $('#numberDisplay').html(settings.txtImage + ' ' + (settings.activeImage + 1) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show(); 510 } 511 if (settings.imageArray[settings.activeImage].data && settings.imageArray[settings.activeImage].data.description) { 512 $('#lightboxdescription').html(decodeURIComponent(settings.imageArray[settings.activeImage].data.description).replace(/\+/g, " ")).show(); 513 } 514 if (settings.imageArray[settings.activeImage].data && settings.imageArray[settings.activeImage].data.copyright) { 515 $('#lightboxdescription').append('<div>' + settings.imgCopyright + ': ' + decodeURIComponent(settings.imageArray[settings.activeImage].data.copyright).replace(/\+/g, " ") + '</div>').show(); 516 } 517 } 518 /**
519 * Display the button navigations 520 * 521 */ 522 function _set_navigation() { 523 $('#lightbox-nav').show(); 524 // Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just. 525 $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 526 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' 527 }); 528 // Show the prev button, if not the first image in set 529 if (settings.activeImage != 0) { 530 if (settings.fixedNavigation) { 531 $('#lightbox-nav-btnPrev').css({ 532 'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' 533 }).unbind().bind('click', function () { 534 settings.activeImage = settings.activeImage - 1; 535 _set_image_to_view(); 536 return false; 537 }); 538 } else { 539 // Show the images button for Next buttons 540 $('#lightbox-nav-btnPrev').unbind().hover(function () { 541 $(this).css({ 542 'background': 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' 543 }); 544 }, function () { 545 $(this).css({ 546 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' 547 }); 548 }).show().bind('click', function () { 549 settings.activeImage = settings.activeImage - 1; 550 _set_image_to_view(); 551 return false; 552 }); 553 } 554 } 555 // Show the next button, if not the last image in set 556 if (settings.activeImage != (settings.imageArray.length - 1)) { 557 if (settings.fixedNavigation) { 558 $('#lightbox-nav-btnNext').css({ 559 'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat' 560 }).unbind().bind('click', function () { 561 settings.activeImage = settings.activeImage + 1; 562 _set_image_to_view(); 563 return false; 564 }); 565 } else { 566 // Show the images button for Next buttons 567 $('#lightbox-nav-btnNext').unbind().hover(function () { 568 $(this).css({ 569 'background': 'url(' + settings.imageBtnNext + ') right 15% no-repeat' 570 }); 571 }, function () { 572 $(this).css({ 573 'background': 'transparent url(' + settings.imageBlank + ') no-repeat' 574 }); 575 }).show().bind('click', function () { 576 settings.activeImage = settings.activeImage + 1; 577 _set_image_to_view(); 578 return false; 579 }); 580 } 581 } 582 } 583 /** 584 * Enable a support to keyboard navigation 585 * 586 */ 587 function _enable_keyboard_navigation() { 588 $(document).keydown(function (objEvent) { 589 _keyboard_action(objEvent); 590 }); 591 } 592 /** 593 * Disable the support to keyboard navigation 594 * 595 */ 596 function _disable_keyboard_navigation() { 597 // Only remove keydown handlers that we added instead of unbinding everything 598 $(document).off('keydown'); 599 } 600 /** 601 * Perform the keyboard actions 602 * 603 */ 604 function _keyboard_action(objEvent) { 605 // To ie 606 if (objEvent == null) { 607 keycode = event.keyCode; 608 escapeKey = 27; 609 // To Mozilla 610 } else { 611 keycode = objEvent.keyCode; 612 escapeKey = objEvent.DOM_VK_ESCAPE; 613 } 614 // Get the key in lower case form 615 key = String.fromCharCode(keycode).toLowerCase(); 616 // Verify the keys to close the ligthBox 617 if ((key == settings.keyToClose) || (key == 'x') || (keycode == escapeKey)) { 618 _finish(); 619 }
620 // Verify the key to show the previous image 621 if ((key == settings.keyToPrev) || (keycode == 37)) { 622 // If we´re not showing the first image, call the previous 623 if (settings.activeImage != 0) { 624 settings.activeImage = settings.activeImage - 1; 625 _set_image_to_view(); 626 } 627 } 628 // Verify the key to show the next image 629 if ((key == settings.keyToNext) || (keycode == 39)) { 630 // If we´re not showing the last image, call the next 631 if (settings.activeImage != (settings.imageArray.length - 1)) { 632 settings.activeImage = settings.activeImage + 1; 633 _set_image_to_view(); 634 } 635 } 636 } 637 /** 638 * Preload prev and next images being showed 639 * 640 */ 641 function _preload_neighbor_images() { 642 if ((settings.imageArray.length - 1) > settings.activeImage) { 643 objNext = new Image(); 644 objNext.src = settings.imageArray[settings.activeImage + 1].href; 645 } 646 if (settings.activeImage > 0) { 647 objPrev = new Image(); 648 objPrev.src = settings.imageArray[settings.activeImage - 1].href; 649 } 650 } 651 /** 652 * Remove jQuery lightBox plugin HTML markup 653 * 654 */ 655 function _finish() { 656 _disable_keyboard_navigation(); 657 658 // Restore background scroll before any DOM changes. 659 document.body.style.overflow = ''; 660 661 // Explicitly close the dialog before removing from DOM. 662 // Removing an open showModal() dialog without .close() first leaves 663 // the Top Layer in an inconsistent state in some browsers. 664 var dlg = document.getElementById('jquery-lightbox'); 665 if (dlg && dlg.open) { 666 dlg.close(); 667 } 668 669 $('#jquery-lightbox').remove(); 670 $('#jquery-overlay').fadeOut(function () { 671 $('#jquery-overlay').remove(); 672 try { 673 if (previousActiveElement && typeof previousActiveElement.focus === 'function') { 674 previousActiveElement.focus(); 675 } 676 } catch (e) { } 677 }); 678 $('embed, object, select').css({ 'visibility': 'visible' }); 679 } 680 /** 681 / THIRD FUNCTION 682 * getPageSize() by quirksmode.com 683 * 684 * @return Array Return an array with page width, height and window width, height 685 */ 686 function ___getPageSize() { 687 var elementToGetSizeFrom = document.getElementById("main"); 688 var xScroll, yScroll; 689 if (window.innerHeight && window.scrollMaxY) { 690 xScroll = window.innerWidth + window.scrollMaxX; 691 yScroll = window.innerHeight + window.scrollMaxY; 692 } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac 693 xScroll = document.body.scrollWidth; 694 yScroll = document.body.scrollHeight; 695 } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari 696 xScroll = document.body.offsetWidth; 697 yScroll = document.body.offsetHeight; 698 } 699 var windowWidth, windowHeight; 700 if (self.innerHeight) { // all except Explorer 701 if (elementToGetSizeFrom.clientWidth > document.documentElement.clientWidth) { 702 windowWidth = elementToGetSizeFrom.clientWidth; 703 } else if (document.documentElement.clientWidth) { 704 windowWidth = document.documentElement.clientWidth; 705 } else { 706 windowWidth = self.innerWidth; 707 }
708 windowHeight = self.innerHeight; 709 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 710 windowWidth = document.documentElement.clientWidth; 711 windowHeight = document.documentElement.clientHeight; 712 } else if (document.body) { // other Explorers 713 windowWidth = document.body.clientWidth; 714 windowHeight = document.body.clientHeight; 715 } 716 // for small pages with total height less then height of the viewport 717 if (yScroll < windowHeight) { 718 pageHeight = windowHeight; 719 } else { 720 pageHeight = yScroll; 721 } 722 // for small pages with total width less then width of the viewport 723 if (elementToGetSizeFrom.clientWidth > document.documentElement.clientWidth) { 724 pageWidth = elementToGetSizeFrom.clientWidth; 725 } else if (xScroll < windowWidth) { 726 pageWidth = xScroll; 727 } else { 728 pageWidth = windowWidth; 729 } 730 arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight); 731 return arrayPageSize; 732 }; 733 /** 734 / THIRD FUNCTION 735 * getPageScroll() by quirksmode.com 736 * 737 * @return Array Return an array with x,y page scroll values. 738 */ 739 function ___getPageScroll() { 740 var xScroll, yScroll; 741 if (self.pageYOffset) { 742 yScroll = self.pageYOffset; 743 xScroll = self.pageXOffset; 744 } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict 745 yScroll = document.documentElement.scrollTop; 746 xScroll = document.documentElement.scrollLeft; 747 } else if (document.body) { // all other Explorers 748 yScroll = document.body.scrollTop; 749 xScroll = document.body.scrollLeft; 750 } 751 arrayPageScroll = new Array(xScroll, yScroll); 752 return arrayPageScroll; 753 }; 754 /** 755 * Stop the code execution from a escified time in milisecond 756 * 757 */ 758 function ___pause(ms) { 759 var date = new Date(); 760 curDate = null; 761 do { 762 var curDate = new Date(); 763 } 764 while (curDate - date < ms); 765 }; 766 // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once 767 return this.unbind('click').click(_initialize); 768 }; 769 })(jQuery); // Call and execute the function immediately passing the jQuery object 770}; 771loadlightbox();
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.