1/*! 2 * jQuery Lightbox Evolution - for jQuery 1.3+ 3 * http://codecanyon.net/item/jquery-lightbox-evolution/115655?ref=aeroalquimia 4 * 5 * Copyright (c) 2010, Eduardo Daniel Sada 6 * Released under CodeCanyon Regular License. 7 * http://codecanyon.net/wiki/buying/howto-buying/licensing/ 8 * 9 * Version: 1.5.5 (Oct 14 2011) 10 * 11 * Includes jQuery Easing v1.3 12 * http://gsgd.co.uk/sandbox/jquery/easing/ 13 * Copyright (c) 2008, George McGinley Smith 14 * Released under BSD License. 15 */ 16 17(function($) { 18 19 var is_ie6 = ($.browser.msie && parseInt($.browser.version, 10) < 7 && parseInt($.browser.version, 10) > 4); 20 var is_iphone = (navigator.userAgent.toLowerCase().indexOf('iphone') != -1); 21 var is_ipad = (navigator.userAgent.toLowerCase().indexOf('ipad') != -1); 22 23 // for jQuery 1.3 24 if ($.proxy === undefined) { 25 $.extend({ 26 proxy: function( fn, thisObject ) { 27 if ( fn ) { 28 proxy = function() { return fn.apply( thisObject || this, arguments ); }; 29 }; 30 return proxy; 31 } 32 }); 33 }; 34 35 // for jQuery 1.3 36 $.extend($.fx.prototype, { 37 update: function() { 38 if ( this.options.step ) { 39 this.options.step.call( this.elem, this.now, this ); 40 } 41 42 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); 43 } 44 }); 45 46 $.extend( $.easing, { 47 easeOutBack: function (x, t, b, c, d, s) { 48 if (s == undefined) s = 1.70158; 49 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 50 } 51 }); 52 53 $.extend({ 54 LightBoxObject: { 55 defaults : { 56 name : 'jquery-lightbox', 57 zIndex : 7000, 58 width : 470, 59 height : 280, 60 background : '#FFFFFF', 61 modal : false, 62 overlay : { 63 'opacity' : 0.6 64 }, 65 showDuration : 400, 66 closeDuration : 200, 67 moveDuration : 250, 68 resizeDuration : 250, 69 showTransition : 'swing', 70 closeTransition : 'swing', 71 moveTransition : 'swing', 72 resizeTransition : 'swing', 73 shake : { 74 'distance' : 10, 75 'duration' : 100, 76 'transition' : 'easeOutBack', 77 'loops' : 2 78 }, 79 flash : { 80 'width' : 640, 81 'height' : 360 82 }, 83 maps : { 84 'width' : 640, 85 'height' : 360 86 }, 87 emergefrom : 'top' 88 }, 89 options : {}, 90 animations : {}, 91 gallery : {}, 92 image : {}, 93 esqueleto : { 94 lightbox : [], 95 buttons : { 96 close : [], 97 prev : [], 98 max : [], 99 next : [] 100 }, 101 background : [], 102 html : [] 103 }, 104 visible : false, 105 maximized : false, 106 mode : 'image', 107 videoregs : { 108 swf: { 109 reg: /[^\.]\.(swf)\s*$/i 110 }, 111 youtube: { 112 reg: /youtube\.com\/watch/i, 113 split: '=', 114 index: 1, 115 iframe: 1, 116 url: "http://www.youtube.com/embed/%id%?autoplay=1&fs=1&rel=0&modestbranding=1&enablejsapi=1" 117 }, 118 metacafe: { 119 reg: /metacafe\.com\/watch/i, 120 split: '/', 121 index: 4, 122 url: "http://www.metacafe.com/fplayer/%id%/.swf?playerVars=autoPlay=yes" 123 }, 124 dailymotion: { 125 reg: /dailymotion\.com\/video/i, 126 split: '/', 127 index: 4, 128 url: "http://www.dailymotion.com/swf/video/%id%?additionalInfos=0&autoStart=1" 129 }, 130 google: { 131 reg: /google\.com\/videoplay/i, 132 split: '=', 133 index: 1, 134 url: "http://video.google.com/googleplayer.swf?autoplay=1&hl=en&docId=%id%" 135 }, 136 vimeo: { 137 reg: /vimeo\.com/i, 138 split: '/', 139 index: 3, 140 iframe: 1, 141 url: "http://player.vimeo.com/video/%id%?hd=1&autoplay=1&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" 142 }, 143 megavideo: { 144 reg: /megavideo.com/i, 145 split: '=', 146 index: 1, 147 url: "http://www.megavideo.com/v/%id%" 148 }, 149 gametrailers: { 150 reg: /gametrailers.com/i, 151 split: '/', 152 index: 5, 153 url: "http://www.gametrailers.com/remote_wrap.php?mid=%id%" 154 }, 155 collegehumornew: { 156 reg: /collegehumor.com\/video\//i, 157 split: 'video/', 158 index: 1, 159 url: "http://www.collegehumor.com/moogaloop/moogaloop.jukebox.swf?autostart=true&fullscreen=1&use_node_id=true&clip_id=%id%" 160 }, 161 collegehumor: { 162 reg: /collegehumor.com\/video:/i, 163 split: 'video:', 164 index: 1, 165 url: "http://www.collegehumor.com/moogaloop/moogaloop.swf?autoplay=true&fullscreen=1&clip_id=%id%" 166 }, 167 ustream: { 168 reg: /ustream.tv/i, 169 split: '/', 170 index: 4, 171 url: "http://www.ustream.tv/flash/video/%id%?loc=%2F&autoplay=true&vid=%id%&disabledComment=true&beginPercent=0.5331&endPercent=0.6292&locale=en_US" 172 }, 173 twitvid: { 174 reg: /twitvid.com/i, 175 split: '/', 176 index: 3, 177 url: "http://www.twitvid.com/player/%id%" 178 }, 179 wordpress: { 180 reg: /v.wordpress.com/i, 181 split: '/', 182 index: 3, 183 url: "http://s0.videopress.com/player.swf?guid=%id%&v=1.01" 184 }, 185 vzaar: { 186 reg: /vzaar.com\/videos/i, 187 split: '/', 188 index: 4, 189 url: "http://view.vzaar.com/%id%.flashplayer?autoplay=true&border=none" 190 } 191 }, 192 193 mapsreg: { 194 bing: { 195 reg: /bing.com\/maps/i, 196 split: '?', 197 index: 1,
198 url: "http://www.bing.com/maps/embed/?emid=3ede2bc8-227d-8fec-d84a-00b6ff19b1cb&w=%width%&h=%height%&%id%" 199 }, 200 streetview: { 201 reg: /maps.google.com(.*)layer=c/i, 202 split: '?', 203 index: 1, 204 url: "http://maps.google.com/?output=svembed&%id%" 205 }, 206 googlev2: { 207 reg: /maps.google.com\/maps\ms/i, 208 split: '?', 209 index: 1, 210 url: "http://maps.google.com/maps/ms?output=embed&%id%" 211 }, 212 google: { 213 reg: /maps.google.com/i, 214 split: '?', 215 index: 1, 216 url: "http://maps.google.com/maps?%id%&output=embed" 217 } 218 }, 219 220 imgsreg: /\.(jpg|jpeg|gif|png|bmp|tiff)(.*)?$/i, 221 222 overlay : { 223 create: function(options) { 224 this.options = options; 225 this.element = $('<div id="'+new Date().getTime()+'" class="'+this.options.name+'-overlay"></div>'); 226 this.element.css($.extend({}, { 227 'position' : 'fixed', 228 'top' : 0, 229 'left' : 0, 230 'opacity' : 0, 231 'display' : 'none', 232 'z-index' : this.options.zIndex 233 }, this.options.style)); 234 235 this.element.click( $.proxy(function(event) { 236 if (this.options.hideOnClick) { 237 if ($.isFunction(this.options.callback)) { 238 this.options.callback(); 239 } else { 240 this.hide(); 241 } 242 } 243 event.preventDefault(); 244 }, this)); 245 246 this.hidden = true; 247 this.inject(); 248 return this; 249 }, 250 251 inject: function() { 252 this.target = $(document.body); 253 this.target.append(this.element); 254 255 if (is_ie6) { 256 this.element.css({'position': 'absolute'}); 257 var zIndex = parseInt(this.element.css('zIndex')); 258 if (!zIndex) { 259 zIndex = 1; 260 var pos = this.element.css('position'); 261 if (pos == 'static' || !pos) { 262 this.element.css({'position': 'relative'}); 263 } 264 this.element.css({'zIndex': zIndex}); 265 } 266 zIndex = (!!(this.options.zIndex || this.options.zIndex === 0) && zIndex > this.options.zIndex) ? this.options.zIndex : zIndex - 1; 267 if (zIndex < 0) { 268 zIndex = 1; 269 } 270 this.shim = $('<iframe id="IF_'+new Date().getTime()+'" scrolling="no" frameborder=0 src=""></iframe>'); 271 this.shim.css({ 272 zIndex : zIndex, 273 position : 'absolute', 274 top : 0, 275 left : 0, 276 border : 'none', 277 width : 0, 278 height : 0, 279 opacity : 0 280 }); 281 this.shim.insertAfter(this.element); 282 $('html, body').css({ 283 'height' : '100%', 284 'width' : '100%', 285 'margin-left' : 0, 286 'margin-right': 0 287 }); 288 } 289 }, 290 291 resize: function(x, y) { 292 this.element.css({ 'height': 0, 'width': 0 }); 293 if (this.shim) { this.shim.css({ 'height': 0, 'width': 0 }); }; 294 295 var win = { x: $(document).width(), y: $(document).height() }; 296 297 this.element.css({ 298 'width' : '100%', 299 'height' : y ? y : win.y 300 }); 301 302 if (this.shim) { 303 this.shim.css({ 'height': 0, 'width': 0 }); 304 this.shim.css({ 305 'position': 'absolute', 306 'left' : 0, 307 'top' : 0, 308 'width' : this.element.width(), 309 'height' : y ? y : win.y 310 }); 311 } 312 return this; 313 }, 314 315 show: function(callback) { 316 if (!this.hidden) { return this; }; 317 if (this.transition) { this.transition.stop(); }; 318 if (this.shim) { this.shim.css({'display': 'block'}); }; 319 this.element.css({'display':'block', 'opacity':0}); 320 321 this.target.bind('resize', $.proxy(this.resize, this)); 322 this.resize(); 323 this.hidden = false;
324 325 this.transition = this.element.fadeTo(this.options.showDuration, this.options.style.opacity, $.proxy(function(){ 326 if (this.options.style.opacity) { this.element.css(this.options.style) }; 327 this.element.trigger('show'); 328 if ($.isFunction(callback)) { callback(); }; 329 }, this)); 330 331 return this; 332 }, 333 334 hide: function(callback) { 335 if (this.hidden) { return this; }; 336 if (this.transition) { this.transition.stop(); }; 337 if (this.shim) { this.shim.css({'display': 'none'}); }; 338 this.target.unbind('resize'); 339 this.hidden = true; 340 341 this.transition = this.element.fadeTo(this.options.closeDuration, 0, $.proxy(function(){ 342 this.element.trigger('hide'); 343 if ($.isFunction(callback)) { callback(); }; 344 this.element.css({ 'height': 0, 'width': 0, 'display': 'none' }); 345 }, this)); 346 347 return this; 348 } 349 }, 350 351 create: function(options) { 352 this.options = $.extend(true, this.defaults, options); 353 354 this.overlay.create({ 355 name : this.options.name, 356 style : this.options.overlay, 357 hideOnClick : !this.options.modal, 358 zIndex : this.options.zIndex-1, 359 callback : $.proxy(this.close, this), 360 showDuration : (is_ipad || is_iphone ? 2 : this.options.showDuration), 361 closeDuration : (is_ipad || is_iphone ? 2 : this.options.closeDuration) 362 }); 363 364 this.esqueleto.lightbox = $('<div class="'+this.options.name+' '+this.options.name+'-mode-image"><div class="'+this.options.name+'-border-top-left"></div><div class="'+this.options.name+'-border-top-middle"></div><div class="'+this.options.name+'-border-top-right"></div><a class="'+this.options.name+'-button-close" href="#close"><span>Close</span></a><div class="'+this.options.name+'-navigator"><a class="'+this.options.name+'-button-left" href="#"><span>Previous</span></a><a class="'+this.options.name+'-button-right" href="#"><span>Next</span></a></div><div class="'+this.options.name+'-buttons"><div class="'+this.options.name+'-buttons-init"></div><a class="'+this.options.name+'-button-left" href="#"><span>Previous</span></a><a class="'+this.options.name+'-button-max" href="#"><span>Maximize</span></a><div class="'+this.options.name+'-buttons-custom"></div><a class="'+this.options.name+'-button-right" href="#"><span>Next</span></a><div class="'+this.options.name+'-buttons-end"></div></div><div class="'+this.options.name+'-background"></div><div class="'+this.options.name+'-html"></div><div class="'+this.options.name+'-border-bottom-left"></div><div class="'+this.options.name+'-border-bottom-middle"></div><div class="'+this.options.name+'-border-bottom-right"></div></div>'); 365 this.esqueleto.navigator = $('.'+this.options.name+'-navigator', this.esqueleto.lightbox); 366 this.esqueleto.buttons.div = $('.'+this.options.name+'-buttons', this.esqueleto.lightbox); 367 this.esqueleto.buttons.close = $('.'+this.options.name+'-button-close', this.esqueleto.lightbox); 368 this.esqueleto.buttons.prev = $('.'+this.options.name+'-button-left', this.esqueleto.lightbox); 369 this.esqueleto.buttons.max = $('.'+this.options.name+'-button-max', this.esqueleto.lightbox); 370 this.esqueleto.buttons.next = $('.'+this.options.name+'-button-right', this.esqueleto.lightbox); 371 this.esqueleto.buttons.custom = $('.'+this.options.name+'-buttons-custom', this.esqueleto.lightbox); 372 this.esqueleto.background = $('.'+this.options.name+'-background', this.esqueleto.lightbox); 373 this.esqueleto.html = $('.'+this.options.name+'-html', this.esqueleto.lightbox); 374 375 this.esqueleto.move = $('<div class="'+this.options.name+'-move"></div>').append(this.esqueleto.lightbox); 376 this.esqueleto.move.css({ 377 'position' : 'absolute', 378 'z-index' : this.options.zIndex, 379 'top' : -999, 380 'left' : -999 381 }); 382 383 $('body').append(this.esqueleto.move); 384 385 this.addevents(); 386 return this.esqueleto.lightbox; 387 }, 388 389 addevents: function() { 390 this.esqueleto.buttons.close.bind('click', $.proxy(function(ev) { 391 this.close(); 392 ev.preventDefault(); 393 }, this)); 394 395 if (is_iphone || is_ipad) { 396 window.onorientationchange = function() { $(window).trigger('resize'); }; 397 }; 398 399 $(window).bind('resize', $.proxy(function() { 400 if (this.visible) { 401 this.overlay.resize(); 402 if (!this.maximized) { 403 this.movebox(); 404 } 405 } 406 }, this)); 407 408 $(window).bind('scroll', $.proxy(function() { 409 if (this.visible && !this.maximized) { 410 this.movebox(); 411 } 412 }, this)); 413 414 $(document).bind('keydown', $.proxy(function(event) { 415 if (this.visible) { 416 if (event.keyCode == 27 && this.overlay.options.hideOnClick) { // esc 417 this.close(); 418 } 419 if (this.gallery.total > 1) { 420 if (event.keyCode == 37){ 421 this.esqueleto.buttons.prev.triggerHandler('click', event); 422 } 423 424 if (event.keyCode == 39){ 425 this.esqueleto.buttons.next.triggerHandler('click', event); 426 } 427 } 428 } 429 }, this)); 430 431 this.esqueleto.buttons.max.bind('click', $.proxy(function(event) { 432 this.maximinimize(); 433 event.preventDefault(); 434 }, this)); 435 436 // heredamos los eventos, desde el overlay: 437 this.overlay.element.bind('show', $.proxy(function() { $(this).triggerHandler('show'); }, this)); 438 this.overlay.element.bind('hide', $.proxy(function() { $(this).triggerHandler('close'); }, this)); 439 }, 440 441 create_gallery: function(href) { 442 if ($.isArray(href) && href.length > 1) { 443 444 this.gallery.images = href; 445 this.gallery.current = 0; 446 this.gallery.total = href.length; 447 href = href[0]; 448 449 this.esqueleto.buttons.prev.unbind('click'); 450 this.esqueleto.buttons.next.unbind('click'); 451 452 this.esqueleto.buttons.prev.bind('click', $.proxy(function(event){ 453 if (this.gallery.current - 1 < 0) { 454 this.gallery.current = this.gallery.total - 1; 455 } else { 456 this.gallery.current = this.gallery.current - 1; 457 } 458 this.show(this.gallery.images[this.gallery.current]); 459 event.preventDefault(); 460 }, this)); 461 462 this.esqueleto.buttons.next.bind('click', $.proxy(function(event){ 463 if (this.gallery.current + 1 >= this.gallery.total) { 464 this.gallery.current = 0; 465 } else { 466 this.gallery.current = this.gallery.current + 1; 467 } 468 this.show(this.gallery.images[this.gallery.current]); 469 event.preventDefault(); 470 }, this)); 471 } 472 473 if (this.gallery.total > 1) { 474 if (this.esqueleto.navigator.css("display") == "none") { 475 this.esqueleto.buttons.div.show(); 476 } 477 this.esqueleto.buttons.prev.show(); 478 this.esqueleto.buttons.next.show(); 479 } else { 480 this.esqueleto.buttons.prev.hide(); 481 this.esqueleto.buttons.next.hide(); 482 } 483 }, 484 485 custombuttons: function(buttons, anchor) { 486 $.each(buttons, $.proxy(function(i, button) { 487 this.esqueleto.buttons.custom.append($('<a href="#" class="'+button['class']+'">'+button.html+'</a>').bind('click', $.proxy(function(e) { 488 if ($.isFunction(button.callback)) { 489 anchor = typeof anchor === "undefined" ? false : anchor[this.gallery.current || 0]; 490 button.callback(this.image.src, this, anchor); 491 } 492 e.preventDefault(); 493 }, this))); 494 }, this)); 495 this.esqueleto.buttons.div.show(); 496 }, 497 498 show: function(href, options, callback, anchor) { 499 var type = ''; 500 var beforeopen = false;
501 502 if (typeof href === "object" && href[0].nodeType) { 503 var tmpElement = href; 504 href = "#"; 505 type = 'element'; 506 } 507 this.lasthref = href; 508 509 if (($.isArray(href) && href.length <= 1) || href=='') { 510 return false; 511 }; 512 513 this.source = $(anchor); 514 this.options.width = this.source.outerWidth(); 515 this.options.height = this.source.outerHeight(); 516 if(!this.visible) $(this.esqueleto.move).css({ opacity : 0.3}); 517 518 this.loading(); 519 beforeopen = this.visible; 520 this.open(); 521 522 this.esqueleto.buttons.prev.hide(); 523 this.esqueleto.buttons.next.hide(); 524 525 if (!beforeopen) { this.movebox(); }; 526 527 if ($.isArray(href) && href.length > 1) { 528 href = href[0]; 529 } 530 var temp = href.split("%LIGHTBOX%"); 531 532 var href = temp[0]; 533 var title = temp[1] || ''; 534 535 options = $.extend(true, { 536 'width' : 0, 537 'height' : 0, 538 'modal' : 0, 539 'force' : '', 540 'title' : title, 541 'autoresize' : true, 542 'move' : -1, 543 'iframe' : false, 544 'flashvars' : '', 545 'cufon' : true, 546 'onOpen' : function() {}, 547 'onClose' : function() {} 548 }, options || {}); 549 550 this.options.onOpen = options.onOpen; 551 this.options.onClose = options.onClose; 552 this.options.cufon = options.cufon; 553 554 urloptions = this.unserialize(href); 555 options = $.extend({}, options, urloptions); 556 557 var size = { x: $(window).width(), y: (window.innerHeight ? window.innerHeight : $(window).height()) }; 558 // calcular porcentajes si es que existen: 559 if (options.width && (options.width+'').indexOf("p") > 0) { 560 options.width = (size.x-20) * options.width.substring(0, options.width.indexOf("p")) / 100; 561 } 562 if (options.height && (options.height+'').indexOf("p") > 0) { 563 options.height = (size.y-20) * options.height.substring(0, options.height.indexOf("p")) / 100; 564 } 565 566 this.esqueleto.background.unbind('complete'); 567 568 this.overlay.options.hideOnClick = !options.modal; 569 570 this.esqueleto.buttons.max.removeClass(this.options.name+'-button-min'); 571 this.esqueleto.buttons.max.addClass(this.options.name+'-button-max'); 572 573 this.maximized = !(options.move > 0 || (options.move == -1 && options.autoresize)); 574 575 if ($.isArray(options.buttons)) { 576 this.custombuttons(options.buttons, anchor); 577 } 578 579 if (!this.esqueleto.buttons.custom.is(":empty")) { 580 this.esqueleto.buttons.div.show(); 581 } 582 583 if (options.force != '') { 584 type = options.force; 585 } else if (options.iframe) { 586 type = 'iframe'; 587 } else if (href.match(this.imgsreg)) { 588 type = 'image'; 589 } else { 590 $.each(this.videoregs, $.proxy(function(i, e) { 591 if (href.split('?')[0].match(e.reg)) { 592 if (e.split) { 593 videoid = href.split(e.split)[e.index].split('?')[0].split('&')[0]; 594 href = e.url.replace("%id%", videoid); 595 } 596 type = e.iframe ? 'iframe' : 'flash'; 597 options.width = options.width ? options.width : this.options.flash.width; 598 options.height = options.height ? options.height : this.options.flash.height; 599 return false; 600 } 601 }, this)); 602 603 $.each(this.mapsreg, function(i, e) { 604 if (href.match(e.reg)) { 605 type = 'iframe'; 606 if (e.split) { 607 id = href.split(e.split)[e.index]; 608 href = e.url.replace("%id%", id).replace("%width%", options.width).replace("%height%", options.height); 609 } 610 options.width = options.width ? options.width : this.options.maps.width; 611 options.height = options.height ? options.height : this.options.maps.height; 612 return false;
613 } 614 }); 615 616 if (type=='') { 617 if (href.match(/#/)) { 618 obj = href.substr(href.indexOf("#")); 619 if ($(obj).length > 0) { 620 type = 'inline'; 621 href = obj; 622 } else { 623 type = 'ajax'; 624 } 625 } else { 626 type = 'ajax'; 627 } 628 } 629 } 630 631 if (type!='image') this.esqueleto.move.css({'opacity' : 1}); 632 if (type=='image') { 633 var image = new Image(); 634 image.onload = $.proxy(function() { 635 image.onload = function() {}; 636 637 if (!this.visible) { return false }; 638 639 this.image = { 640 width : image.width, 641 height : image.height, 642 src : image.src 643 }; 644 645 var width, height; 646 if (options.width) { 647 width = parseInt(options.width); 648 height = parseInt(options.height); 649 } else { 650 if (options.autoresize) { 651 var objsize = this.calculate(image.width, image.height); 652 width = objsize.width; 653 height = objsize.height; 654 if (image.width != width || image.height != height) { 655 this.esqueleto.buttons.div.show(); 656 this.esqueleto.buttons.max.show(); 657 } 658 } else { 659 width = image.width; 660 height = image.height; 661 } 662 } 663 664 this.resize(width, height); 665 666 this.esqueleto.buttons.div.css('opacity', 0); 667 this.esqueleto.buttons.close.css('opacity', 0); 668 this.esqueleto.buttons.max.hide(); 669 670 this.esqueleto.background.bind('complete', $.proxy(function() { 671 this.create_gallery(this.lasthref, options); 672 this.source = null; 673 674 if (!this.visible) { return false }; 675 676 this.changemode('image'); 677 678 this.esqueleto.background.empty(); 679 this.esqueleto.html.empty(); 680 681 if (options.title != '') { 682 this.esqueleto.background.append($('<div class="'+this.options.name+'-title"></div>').html(options.title)); 683 } 684 685 this.esqueleto.move.css({'opacity' : 1}); 686 this.esqueleto.background.append(image); 687 688 if (is_ie6 || is_ipad || is_iphone) { 689 this.esqueleto.background.removeClass(this.options.name+'-loading'); 690 } else { 691 $(image).hide() 692 $(image).stop().fadeIn(400, $.proxy(function() { 693 this.esqueleto.background.removeClass(this.options.name+'-loading'); 694 this.esqueleto.buttons.div.css('opacity', ''); 695 this.esqueleto.buttons.close.css('opacity', ''); 696 }, this)); 697 } 698 699 this.options.onOpen(); 700 701 }, this)); 702 }, this); 703 704 image.onerror = $.proxy(function() { 705 this.error("The requested image cannot be loaded. Please try again later."); 706 }, this); 707 image.src = href; 708 } else if (type=='flash' || type=='inline' || type=='ajax' || type=='element') { 709 this.esqueleto.move.css({opacity:1}); 710 if (type == 'inline') { 711 this.appendhtml($(href).clone(true).show(), options.width > 0 ? options.width : $(href).outerWidth(true), options.height > 0 ? options.height : $(href).outerHeight(true), 'html'); 712 713 } else if (type == 'ajax') { 714 if (options.width) { 715 width = options.width; 716 height = options.height; 717 } else { 718 this.error("You need to specify the size of the lightbox."); 719 return false; 720 } 721 722 if (this.animations.ajax) { this.animations.ajax.abort(); }; 723 this.animations.ajax = $.ajax({ 724 url : href, 725 type : "GET", 726 cache : false, 727 dataType : "html", 728 error : $.proxy(function() { this.error("The requested content cannot be loaded. Please try again later.") }, this), 729 success : $.proxy(function(html) { this.appendhtml($(html), width, height, 'html'); }, this) 730 }); 731 732 } else if (type == 'flash') { 733 var flash = this.swf2html(href, options.width, options.height, options.flashvars); 734 this.appendhtml($(flash), options.width, options.height, 'html'); 735 } else if (type=='element') { 736 this.appendhtml(tmpElement, options.width > 0 ? options.width : tmpElement.outerWidth(true), options.height > 0 ? options.height : tmpElement.outerHeight(true), 'html'); 737 } 738 } else if (type=='iframe') { 739 this.source = null; 740 if (options.width) { 741 width = options.width; 742 height = options.height; 743 } else { 744 this.error("You need to specify the size of the lightbox."); 745 return false;
746 } 747 this.appendhtml($('<iframe id="IF_'+(new Date().getTime())+'" frameborder="0" src="'+href+'" style="margin:0; padding:0;" allowTransparency="true"></iframe>').css(options), options.width, options.height, 'html'); 748 } 749 this.callback = $.isFunction(callback) ? callback : function(e) {}; 750 }, 751 752 swf2html: function(href, width, height, flashvars) { 753 if (typeof flashvars == 'undefined' || flashvars == '') flashvars = 'autostart=1&autoplay=1&fullscreenbutton=1'; 754 var str = '<object width="'+width+'" height="'+height+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="'+href+'" style="margin:0; padding:0;"></param>'; 755 str += '<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param>'; 756 str += '<param name="autostart" value="true"></param><param name="autoplay" value="true"></param><param name="flashvars" value="'+flashvars+'"></param>'; 757 str += '<param name="width" value="'+width+'"></param><param name="height" value="'+height+'"></param>'; 758 str += '<embed src="'+href+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" autostart="true" autoplay="true" flashvars="'+flashvars+'" wmode="transparent" width="'+width+'" height="'+height+'" style="margin:0; padding:0;"></embed></object>'; 759 return str; 760 }, 761 762 appendhtml: function(obj, width, height, mode) { 763 if (typeof mode !== 'undefined') { 764 this.changemode(mode); 765 } 766 767 this.resize(width + 30, height + 20); 768 769 this.esqueleto.background.bind('complete', $.proxy(function() { 770 this.esqueleto.background.removeClass(this.options.name+'-loading'); 771 this.esqueleto.html.html(obj); 772 this.esqueleto.html.html(obj);
772 // fix chrome bug 773 this.esqueleto.background.unbind('complete'); 774 if (this.options.cufon && typeof Cufon !== 'undefined') { 775 Cufon.refresh(); 776 } 777 this.options.onOpen(); 778 }, this)); 779 780 }, 781 782 movebox: function(w, h) { 783 var size = { x: $(window).width(), y: (window.innerHeight ? window.innerHeight : $(window).height()) }; 784 var scroll = { x: $(window).scrollLeft(), y: $(window).scrollTop() }; 785 var height = h!=null ? h : this.esqueleto.lightbox.outerHeight(); 786 var width = w!=null ? w : this.esqueleto.lightbox.outerWidth(); 787 var y = 0; 788 var x = 0; 789 790 //vertically center 791 x = scroll.x + ((size.x - width) / 2); 792 793 if (this.visible) { 794 y = scroll.y + (size.y - height) / 2; 795 } else if (this.options.emergefrom == "bottom") { 796 y = (scroll.y + size.y + 14); 797 } else {// top 798 y = (scroll.y - height) - 14; 799 } 800 801 if(this.source && this.source.length > 0) { 802 var offset = this.source.offset(); 803 x = offset.left -7; 804 y = offset.top - 7; 805 width = this.source.width; 806 height = this.source.height; 807 this.e 808 } 809 810 if (this.visible) { 811 if (!this.animations.move) { 812 this.morph(this.esqueleto.move, { 813 'left' : x 814 }, 'move'); 815 } 816 817 this.morph(this.esqueleto.move, { 818 'top' : y 819 }, 'move'); 820 821 } else { 822 823 this.esqueleto.move.css({ 824 'left' : x, 825 'top' : y 826 }); 827 } 828 }, 829 830 morph: function(el, prop, mode, callback, queue) { 831 832 var optall = $.speed({ 833 queue : queue || false, 834 duration : (is_ipad || is_iphone ? 2 : this.options[mode+'Duration']), 835 easing : this.options[mode+'Transition'], 836 complete : ($.isFunction(callback) ? $.proxy(callback, this) : null) 837 }); 838 839 //for jQuery 1.7 840 //function doAnimation(optall) { 841 return el[ optall.queue === false ? "each" : "queue" ](function() { 842 843 if (parseFloat($.fn.jquery) > 1.5) { 844 if ( optall.queue === false ) { 845 jQuery._mark( this ); 846 } 847 } 848 849 var opt = $.extend({}, optall), self = this; 850 851 opt.curAnim = $.extend({}, prop); 852 853 opt.animatedProperties = {}; 854 855 for ( p in prop ) { 856 name = p; 857 val = prop[ name ]; 858 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing'; 859 860 if ( val === "hide" && hidden || val === "show" && !hidden ) { 861 return opt.complete.call( this ); 862 } 863 } 864 865 $.each( prop, function( name, val ) { 866 var e = new $.fx( self, opt, name ); 867 868 e.custom( e.cur(true) || 0, val, "px" ); 869 }); 870 871 return true; 872 }); 873 //}; 874 //return optall.queue === false ? this.each( doAnimation(optall) ) : this.queue( optall.queue || "fx", doAnimation ); 875 }, 876 877 resize: function(x, y) { 878 if (this.visible) { 879 var size = { x: $(window).width(), y: (window.innerHeight ? window.innerHeight : $(window).height()) }; 880 var scroll = { x: $(window).scrollLeft(), y: $(window).scrollTop() }; 881 var left = (scroll.x + (size.x - (x + 14)) / 2); 882 var top = (scroll.y + (size.y - (y + 14)) / 2); 883 884 if ($.browser.msie || ($.browser.mozilla && (parseFloat($.browser.version) < 1.9))) { 885 y += 4; 886 } 887 888 this.animations.move = true; 889 890 this.morph(this.esqueleto.move.stop(), { 891 'left': (this.maximized && left < 0) ? 0 : left, 892 'top' : (this.maximized && (y + 14) > size.y) ? scroll.y : top 893 }, 'move', $.proxy(function() { this.move = false; }, this.animations)); 894 895 this.morph(this.esqueleto.html, { 'height': y - 20 }, 'resize'); 896 this.morph(this.esqueleto.lightbox.stop(), { 'width': (x + 14), 'height': y - 20 }, 'resize', {}, true); 897 this.morph(this.esqueleto.navigator, { 'width': x }, 'resize'); 898 this.morph(this.esqueleto.navigator, { 'top': (y - 90) / 2 }, 'move'); 899 this.morph(this.esqueleto.background.stop(), { 'width': x, 'height': y }, 'resize', function() { $(this.esqueleto.background).trigger('complete'); }); 900 } else { 901 902 this.esqueleto.html.css({ 'height': y - 20 }); 903 this.esqueleto.lightbox.css({ 'width': x + 14, 'height': y - 20 }); 904 this.esqueleto.background.css({ 'width': x, 'height': y }); 905 this.esqueleto.navigator.css({ 'width': x, 'height': 90 }); 906 } 907 }, 908 909 close: function(param) { 910 this.visible = false;
911 this.gallery = {}; 912 913 this.options.onClose(); 914 915 if ($.browser.msie || is_ipad || is_iphone) { 916 this.esqueleto.background.empty(); 917 this.esqueleto.html.hide().empty().show(); 918 this.esqueleto.buttons.custom.empty(); 919 this.esqueleto.move.css({'display': 'none'}); 920 this.movebox(); 921 } else { 922 this.esqueleto.move.animate({'opacity': 0}, { 923 queue : false, 924 complete : ($.proxy(function() { 925 this.esqueleto.background.empty(); 926 this.esqueleto.html.empty(); 927 this.esqueleto.buttons.custom.empty(); 928 this.movebox(); 929 this.esqueleto.move.css({'display': 'none', 'opacity': 1, 'overflow': 'visible'}); 930 }, this)) 931 }); 932 } 933 934 this.overlay.hide($.proxy(function() { 935 if ($.isFunction(this.callback)) 936 { 937 this.callback.apply(this, $.makeArray(param)); 938 } 939 }, this)); 940 941 this.esqueleto.background.stop(true, false); 942 this.esqueleto.background.unbind('complete'); 943 }, 944 945 open: function() { 946 this.visible = true; 947 if ($.browser.msie) { 948 this.esqueleto.move.get(0).style.removeAttribute('filter'); 949 } 950 this.esqueleto.move.css({ 'display' : 'block', 'overflow':'visible' }).show(); 951 this.overlay.show(); 952 }, 953 954 shake: function() { 955 var x = this.options.shake.distance; 956 var d = this.options.shake.duration; 957 var t = this.options.shake.transition; 958 var o = this.options.shake.loops; 959 var l = this.esqueleto.move.position().left; 960 var e = this.esqueleto.move; 961 962 for (i=0; i<o; i++) 963 { 964 e.animate({left: l+x}, d, t); 965 e.animate({left: l-x}, d, t); 966 }; 967 968 e.animate({left: l+x}, d, t); 969 e.animate({left: l}, d, t); 970 }, 971 972 changemode: function(mode) { 973 if (mode != this.mode) { 974 this.esqueleto.lightbox.removeClass(this.options.name+'-mode-'+this.mode); 975 this.mode = mode; 976 this.esqueleto.lightbox.addClass(this.options.name+'-mode-'+this.mode); 977 } 978 this.esqueleto.move.css({'overflow':'visible'}); 979 }, 980 981 error: function(msg) { 982 alert(msg); 983 this.close(); 984 }, 985 986 unserialize: function(data) { 987 var regex = /lightbox\[(.*)?\]$/i; 988 var serialised = {}; 989 990 if (data.match(/#/)) { 991 data = data.slice(0, data.indexOf("#")); 992 } 993 data = data.slice(data.indexOf('?') + 1).split("&"); 994 995 $.each(data, function() { 996 var properties = this.split("="); 997 var key = properties[0]; 998 var value = properties[1]; 999 1000 if (key.match(regex)) { 1001 if (isFinite(value)) { 1002 value = parseInt(value) 1003 } else if (value.toLowerCase() == "true") { 1004 value = true; 1005 } else if (value.toLowerCase() == "false") { 1006 value = false; 1007 } 1008 serialised[key.match(regex)[1]] = value; 1009 } 1010 }); 1011 1012 return serialised; 1013 }, 1014 1015 calculate: function(x, y) { 1016 // Resizing large images 1017 var maxx = $(window).width() - 50; 1018 var maxy = $(window).height() - 50; 1019 1020 if (x > maxx) 1021 { 1022 y = y * (maxx / x); 1023 x = maxx; 1024 if (y > maxy) 1025 { 1026 x = x * (maxy / y); 1027 y = maxy; 1028 } 1029 } 1030 else if (y > maxy) 1031 { 1032 x = x * (maxy / y); 1033 y = maxy; 1034 if (x > maxx) 1035 { 1036 y = y * (maxx / x); 1037 x = maxx; 1038 } 1039 } 1040 // End Resizing 1041 return {width: parseInt(x), height: parseInt(y)}; 1042 }, 1043 1044 loading: function() { 1045 this.changemode('image'); 1046 1047 this.esqueleto.background.empty(); 1048 this.esqueleto.html.empty(); 1049 this.esqueleto.background.addClass(this.options.name+'-loading'); 1050 1051 this.esqueleto.buttons.div.hide(); 1052 1053 if (this.visible == false) { 1054 this.movebox(this.options.width, this.options.height); 1055 this.resize(this.options.width, this.options.height); 1056 } 1057 }, 1058 1059 maximinimize: function() { 1060 if (this.maximized) { 1061 this.maximized = false;
1062 this.esqueleto.buttons.max.removeClass(this.options.name+'-button-min'); 1063 this.esqueleto.buttons.max.addClass(this.options.name+'-button-max'); 1064 var objsize = this.calculate(this.image.width, this.image.height); 1065 this.loading(); 1066 this.esqueleto.buttons.div.show(); 1067 this.resize(objsize.width, objsize.height); 1068 } else { 1069 this.maximized = true; 1070 this.esqueleto.buttons.max.removeClass(this.options.name+'-button-max'); 1071 this.esqueleto.buttons.max.addClass(this.options.name+'-button-min'); 1072 this.loading(); 1073 this.esqueleto.buttons.div.show(); 1074 this.resize(this.image.width, this.image.height); 1075 } 1076 } 1077 1078 }, //end object 1079 1080 lightbox: function(url, options, callback) { 1081 if (typeof url !== 'undefined') { 1082 return $.LightBoxObject.show(url, options, callback); 1083 } else { 1084 return $.LightBoxObject; 1085 } 1086 } 1087 1088 }); 1089 1090 $.fn.lightbox = function(options, callback) { 1091 return $(this).live('click', function(e) { 1092 $(this).blur(); 1093 1094 var sel = []; 1095 var rel = $.trim($(this).attr('rel')) || ''; 1096 var til = $.trim($(this).attr('title')) || ''; 1097 var lnk = $(this); 1098 1099 rel = rel.replace('[','\\\\['); 1100 rel = rel.replace(']','\\\\]'); 1101 1102 if (!rel || rel == '' || rel === 'nofollow') { 1103 sel = $(this).attr('href'); 1104 1105 copy_options = (til || til != '') ? $.extend({}, options, {'title': til}) : options; 1106 1107 } else { 1108 var rels = []; 1109 var antes = []; 1110 var desps = []; 1111 var encon = false; 1112 1113 $("a[rel], area[rel]", this.ownerDocument).filter("[rel=\"" + rel + "\"]").each($.proxy(function(i, el) { 1114 if (this == el) { 1115 antes.unshift(el); 1116 encon = true; 1117 } else if (encon == false) { 1118 desps.push(el); 1119 } else { 1120 antes.push(el); 1121 } 1122 }, this)); 1123 1124 rels = lnk = antes.concat(desps); 1125 1126 $.each(rels, function() { 1127 var title = $.trim($(this).attr('title')) || ''; 1128 title = title ? "%LIGHTBOX%" + title : ''; 1129 sel.push($(this).attr('href') + title); 1130 }); 1131 1132 if (sel.length == 1) { 1133 sel = sel[0]; 1134 } 1135 1136 copy_options = options; 1137 } 1138 1139 $.LightBoxObject.show(sel, copy_options, callback, lnk); 1140 1141 e.preventDefault(); 1142 e.stopPropagation(); 1143 }); 1144 }; 1145 1146 $(function() { 1147 if (parseFloat($.fn.jquery) > 1.2) { 1148 $.LightBoxObject.create(); 1149 } else { 1150 throw "The jQuery version that was loaded is too old. Lightbox Evolution requires jQuery 1.3+"; 1151 } 1152 }); 1153 1154})(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.