1/* 2 * FancyBox - waJSQuery Plugin 3 * Simple and fancy lightbox alternative 4 * 5 * Examples and documentation at: http://fancybox.net 6 * 7 * Copyright (c) 2008 - 2010 Janis Skarnelis 8 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. 9 * 10 * Version: 1.3.4 (11/11/2010) 11 * Requires: waJSQuery v1.3+ 12 * 13 * Dual licensed under the MIT and GPL licenses: 14 * http://www.opensource.org/licenses/mit-license.php 15 * http://www.gnu.org/licenses/gpl.html 16 */ 17 18 19 20function _waFancyBoxSort(a, b) 21{ 22 23 var _grp1 = waJSQuery(a).attr("rel") 24 var _grp2 = waJSQuery(b).attr("rel") 25// 26 27 var _i1 = parseInt(extractParamInfo(waJSQuery(a),"index")) 28 var _i2 = parseInt(extractParamInfo(waJSQuery(b),"index")) 29// alert(_i1+" "+_i2) 30 if (_i1==_i2) return 0 31 if (_i1<_i2) return -1 32 return 1 33} 34 35function _waIncreaseZindex(_o) 36{ 37 38 var _z = _o.css("z-index") 39 var _n= parseInt(_z) 40 if (isNaN(_n)==false) 41 { 42 43 _o.css("z-index",1001101) 44 // alert(_o.css("z-index")) 45 } 46 else 47 { 48 _o.css("z-index",10000000) 49 } 50 51} 52 53;(function(waJSQuery) { 54 var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right, 55 56 selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [], 57 58 ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i, 59 60 loadingTimer, loadingFrame = 1,loadingFrameElapsed=0, 61 62 titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx
62= waJSQuery.extend(waJSQuery('<div/>')[0], { prop: 0 }), 63 64 isIE6 = waJSQuery.browser.msie && waJSQuery.browser.version < 7 && !window.XMLHttpRequest, 65 66 /* 67 * Private methods 68 */ 69 70 _abort = function() { 71 loading.hide(); 72 73 imgPreloader.onerror = imgPreloader.onload = null; 74 75 if (ajaxLoader) { 76 ajaxLoader.abort(); 77 } 78 79 tmp.empty(); 80 }, 81 82 _error = function() { 83 if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) { 84 loading.hide(); 85 busy = false; 86 return; 87 } 88 89 selectedOpts.titleShow = false; 90 91 selectedOpts.width = 'auto'; 92 selectedOpts.height = 'auto'; 93 94 tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' ); 95 96 _process_inline(); 97 }, 98 99 _start = function() { 100 var obj = selectedArray[ selectedIndex ], 101 href, 102 type, 103 title, 104 str, 105 emb, 106 ret; 107 108 _abort(); 109 110 selectedOpts = waJSQuery.extend({}, waJSQuery.fn.fancybox.defaults, (typeof waJSQuery(obj).data('fancybox') == 'undefined' ? selectedOpts : waJSQuery(obj).data('fancybox'))); 111 112 ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts); 113 114 if (ret === false) { 115 busy = false; 116 return; 117 } else if (typeof ret == 'object') { 118 selectedOpts = waJSQuery.extend(selectedOpts, ret); 119 } 120 121//alert(waJSQuery(obj).attr('title')+" "+extractParamInfo(waJSQuery(obj),"url")) 122 123 var _htmlTitle = waJSQuery(obj).attr('title'); 124 if (_htmlTitle==undefined) _htmlTitle="" 125 var _urlTitle = extractParamInfo(waJSQuery(obj),"url"); 126 var _urlTarget = extractParamInfo(waJSQuery(obj),"url_target"); 127 //alert(_urlTitle) 128 if (_urlTitle.length>0) 129 { 130 //alert(_htmlTitle) 131 if (_htmlTitle.length>0) 132 { 133 _htmlTitle +="<br>" 134 } 135 _htmlTitle+="<a href='"+_urlTitle+"' target='"+_urlTarget+"'>"+_urlTitle+"</a>" 136 } 137 138 139 140 title = selectedOpts.title || (obj.nodeName ? _htmlTitle: obj.title) || ''; 141 142 if (obj.nodeName && !selectedOpts.orig) { 143 selectedOpts.orig = waJSQuery(obj).children("img:first").length ? waJSQuery(obj).children("img:first") : waJSQuery(obj); 144 } 145 146 if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) { 147 title = selectedOpts.orig.attr('alt'); 148 } 149 150 href = selectedOpts.href || (obj.nodeName ? waJSQuery(obj).attr('href') : obj.href) || null; 151 152 if ((/^(?:javascript)/i).test(href) || href == '#') { 153 href = null; 154 } 155 156 if (selectedOpts.type) { 157 type = selectedOpts.type; 158 159 if (!href) { 160 href = selectedOpts.content; 161 } 162 163 } else if (selectedOpts.content) { 164 type = 'html'; 165 166 } else if (href) { 167 if (href.match(imgRegExp)) { 168 type = 'image'; 169 170 } else if (href.match(swfRegExp)) { 171 type = 'swf'; 172 173 } else if (waJSQuery(obj).hasClass("iframe")) { 174 type = 'iframe'; 175 176 } else if (href.indexOf("#") === 0) { 177 type = 'inline'; 178 179 } else { 180 type = 'ajax'; 181 } 182 } 183 184 if (!type) { 185 _error(); 186 return; 187 } 188 189 if (type == 'inline') { 190 obj = href.substr(href.indexOf("#")); 191 type = waJSQuery(obj).length > 0 ? 'inline' : 'ajax'; 192 } 193 194 selectedOpts.type = type; 195 selectedOpts.href = href; 196 selectedOpts.title = title; 197 198 if (selectedOpts.autoDimensions) { 199 if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') { 200 selectedOpts.width = 'auto'; 201 selectedOpts.height = 'auto'; 202 } else { 203 selectedOpts.autoDimensions = false; 204 } 205 } 206 207 if (selectedOpts.modal) { 208 selectedOpts.overlayShow = true; 209 selectedOpts.hideOnOverlayClick = false; 210 selectedOpts.hideOnContentClick = false; 211 selectedOpts.enableEscapeButton = false; 212 selectedOpts.showCloseButton = false; 213 } 214 215 selectedOpts.padding = parseInt(selectedOpts.padding, 10); 216 selectedOpts.margin = parseInt(selectedOpts.margin, 10); 217 218 tmp.css('padding', (selectedOpts.padding + selectedOpts.margin)); 219 220 waJSQuery('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { 221 waJSQuery(this).replaceWith(content.children()); 222 }); 223 224 switch (type) { 225 case 'html' : 226 tmp.html( selectedOpts.content ); 227 _process_inline(); 228 break; 229 230 case 'inline' : 231 if ( waJSQuery(obj).parent().is('#fancybox-content') === true) { 232 busy = false; 233 return; 234 } 235 236 waJSQuery('<div class="fancybox-inline-tmp" />') 237 .hide() 238 .insertBefore( waJSQuery(obj) ) 239 .bind('fancybox-cleanup', function() { 240 waJSQuery(this).replaceWith(content.children()); 241 }).bind('fancybox-cancel', function() { 242 waJSQuery(this).replaceWith(tmp.children()); 243 });
244 245 waJSQuery(obj).appendTo(tmp); 246 247 _process_inline(); 248 break; 249 250 case 'image': 251 busy = false; 252 253 waJSQuery.fancybox.showActivity(); 254 255 imgPreloader = new Image(); 256 257 imgPreloader.onerror = function() { 258 _error(); 259 }; 260 261 imgPreloader.onload = function() { 262 busy = true; 263 264 imgPreloader.onerror = imgPreloader.onload = null; 265 266 _process_image(); 267 }; 268 269 imgPreloader.src = href; 270 break; 271 272 case 'swf': 273 selectedOpts.scrolling = 'no'; 274 275 str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>'; 276 emb = ''; 277 278 waJSQuery.each(selectedOpts.swf, function(name, val) { 279 str += '<param name="' + name + '" value="' + val + '"></param>'; 280 emb += ' ' + name + '="' + val + '"'; 281 }); 282 283 str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>'; 284 285 tmp.html(str); 286 287 _process_inline(); 288 break; 289 290 case 'ajax': 291 busy = false; 292 293 waJSQuery.fancybox.showActivity(); 294 295 selectedOpts.ajax.win = selectedOpts.ajax.success; 296 297 ajaxLoader = waJSQuery.ajax(waJSQuery.extend({}, selectedOpts.ajax, { 298 url : href, 299 data : selectedOpts.ajax.data || {}, 300 error : function(XMLHttpRequest, textStatus, errorThrown) { 301 if ( XMLHttpRequest.status > 0 ) { 302 _error(); 303 } 304 }, 305 success : function(data, textStatus, XMLHttpRequest) { 306 var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; 307 if (o.status == 200) { 308 if ( typeof selectedOpts.ajax.win == 'function' ) { 309 ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); 310 311 if (ret === false) { 312 loading.hide(); 313 return; 314 } else if (typeof ret == 'string' || typeof ret == 'object') { 315 data = ret; 316 } 317 } 318 319 tmp.html( data ); 320 _process_inline(); 321 } 322 } 323 })); 324 325 break; 326 327 case 'iframe': 328 _show(); 329 break; 330 } 331 }, 332 333 _process_inline = function() { 334 var 335 w = selectedOpts.width, 336 h = selectedOpts.height; 337 338 if (w.toString().indexOf('%') > -1) { 339 w = parseInt( (waJSQuery(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px'; 340 341 } else { 342 w = w == 'auto' ? 'auto' : w + 'px'; 343 } 344 345 if (h.toString().indexOf('%') > -1) { 346 h = parseInt( (waJSQuery(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px'; 347 348 } else { 349 h = h == 'auto' ? 'auto' : h + 'px'; 350 } 351 352 tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>'); 353 354 selectedOpts.width = tmp.width(); 355 selectedOpts.height = tmp.height(); 356 357 _show(); 358 }, 359 360 _process_image = function() { 361 selectedOpts.width = imgPreloader.width; 362 selectedOpts.height = imgPreloader.height; 363 364 waJSQuery("<img />").attr({ 365 'id' : 'fancybox-img', 366 'src' : imgPreloader.src, 367 'alt' : selectedOpts.title 368 }).appendTo( tmp ); 369 370 _show(); 371 }, 372 373 _show = function() { 374 375 waSetVisibilityMainPageContenair(false) 376 var pos, equal; 377 378 loading.hide(); 379 380 if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 381 waJSQuery.event.trigger('fancybox-cancel'); 382 383 busy = false; 384 return; 385 } 386 387 busy = true; 388 389 waJSQuery(content.add( overlay )).unbind(); 390 391 waJSQuery(window).unbind("resize.fb scroll.fb"); 392 waJSQuery(document).unbind('keydown.fb'); 393 394 if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') { 395 wrap.css('height', wrap.height()); 396 } 397 398 currentArray = selectedArray; 399 currentIndex = selectedIndex; 400 currentOpts = selectedOpts; 401 402 if (currentOpts.overlayShow) { 403 overlay.css({ 404 'background-color' : currentOpts.overlayColor, 405 'opacity' : currentOpts.overlayOpacity, 406 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto', 407 'height' : waJSQuery(document).height(), 408 'width' : waJSQuery(document).width() 409 }); 410 411 if (!overlay.is(':visible')) { 412 if (isIE6) { 413 waJSQuery('select:not(#fancybox-tmp select)').filter(function() { 414 return this.style.visibility !== 'hidden'; 415 }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() { 416 this.style.visibility = 'inherit'; 417 });
418 } 419 420 overlay.show(); 421 } 422 } else { 423 overlay.hide(); 424 } 425 426 final_pos = _get_zoom_to(); 427 428 _process_title(); 429 430 if (wrap.is(":visible")) { 431 waJSQuery( close.add( nav_left ).add( nav_right ) ).hide(); 432 433 pos = wrap.position(), 434 435 start_pos = { 436 top : pos.top, 437 left : pos.left, 438 width : wrap.width(), 439 height : wrap.height() 440 }; 441 442 equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); 443 444 content.fadeTo(currentOpts.changeFade, 0.3, function() { 445 var finish_resizing = function() { 446 content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish); 447 }; 448 449 waJSQuery.event.trigger('fancybox-change'); 450 451 content 452 .empty() 453 .removeAttr('filter') 454 .css({ 455 'border-width' : currentOpts.padding, 456 'width' : final_pos.width - currentOpts.padding * 2, 457 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 458 }); 459 460 if (equal) { 461 finish_resizing(); 462 463 } else { 464 fx.prop = 0; 465 466 waJSQuery(fx).animate({prop: 1}, { 467 duration : currentOpts.changeSpeed, 468 easing : currentOpts.easingChange, 469 step : _draw, 470 complete : finish_resizing 471 }); 472 } 473 }); 474 475 return; 476 } 477 478 wrap.removeAttr("style"); 479 480 content.css('border-width', currentOpts.padding); 481 482 if (currentOpts.transitionIn == 'elastic') { 483 start_pos = _get_zoom_from(); 484 485 content.html( tmp.contents() ); 486 487 wrap.show(); 488 489 if (currentOpts.opacity) { 490 final_pos.opacity = 0; 491 } 492 493 fx.prop = 0; 494 495 waJSQuery(fx).animate({prop: 1}, { 496 duration : currentOpts.speedIn, 497 easing : currentOpts.easingIn, 498 step : _draw, 499 complete : _finish 500 }); 501 502 return; 503 } 504 505 if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { 506 title.show(); 507 } 508 509 content 510 .css({ 511 'width' : final_pos.width - currentOpts.padding * 2, 512 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 513 }) 514 .html( tmp.contents() ); 515 516 wrap 517 .css(final_pos) 518 .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); 519 }, 520 521 _format_title = function(title) { 522 if (title && title.length) { 523 if (currentOpts.titlePosition == 'float') { 524 return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>'; 525 } 526 527 return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>'; 528 } 529 530 return false; 531 }, 532 533 _process_title = function() { 534 titleStr = currentOpts.title || ''; 535 titleHeight = 0; 536 537 title 538 .empty() 539 .removeAttr('style') 540 .removeClass(); 541 542 if (currentOpts.titleShow === false) { 543 title.hide(); 544 return; 545 } 546 547 titleStr = waJSQuery.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr); 548 549 if (!titleStr || titleStr === '') { 550 title.hide(); 551 return; 552 } 553 554 title 555 .addClass('fancybox-title-' + currentOpts.titlePosition) 556 .html( titleStr ) 557 .appendTo( 'body' ) 558 .show(); 559 560 switch (currentOpts.titlePosition) { 561 case 'inside': 562 title 563 .css({ 564 'width' : final_pos.width - (currentOpts.padding * 2), 565 'marginLeft' : currentOpts.padding, 566 'marginRight' : currentOpts.padding 567 }); 568 569 titleHeight = title.outerHeight(true); 570 571 title.appendTo( outer ); 572 573 final_pos.height += titleHeight; 574 break; 575 576 case 'over': 577 title 578 .css({ 579 'marginLeft' : currentOpts.padding, 580 'width' : final_pos.width - (currentOpts.padding * 2), 581 'bottom' : currentOpts.padding 582 }) 583 .appendTo( outer ); 584 break; 585 586 case 'float': 587 title 588 .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1) 589 .appendTo( wrap ); 590 break; 591 592 default: 593 title 594 .css({ 595 'width' : final_pos.width - (currentOpts.padding * 2), 596 'paddingLeft' : currentOpts.padding, 597 'paddingRight' : currentOpts.padding 598 }) 599 .appendTo( wrap ); 600 break; 601 } 602 603 title.hide(); 604 }, 605 606 _set_navigation = function() { 607 if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) { 608 waJSQuery(document).bind('keydown.fb', function(e) { 609 if (e.keyCode == 27 && currentOpts.enableEscapeButton) { 610 e.preventDefault(); 611 waJSQuery.fancybox.close(); 612 613 } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') { 614 e.preventDefault(); 615 waJSQuery.fancybox[ e.keyCode == 37 ? 'prev' : 'next'](); 616 } 617 }); 618 } 619 620 if (!currentOpts.showNavArrows) { 621 nav_left.hide(); 622 nav_right.hide(); 623 return; 624 } 625 626 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { 627 nav_left.show(); 628 } 629 630 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { 631 nav_right.show(); 632 } 633 }, 634 635 _finish = function () { 636 if (!waJSQuery.support.opacity) { 637 content.get(0).style.removeAttribute('filter'); 638 wrap.get(0).style.removeAttribute('filter'); 639 } 640 641 if (selectedOpts.autoDimensions) { 642 content.css('height', 'auto'); 643 } 644 645 wrap.css('height', 'auto'); 646 647 if (titleStr && titleStr.length) { 648 title.show(); 649 } 650 651 if (currentOpts.showCloseButton) { 652 close.show(); 653 } 654 655 _set_navigation(); 656 657 if (currentOpts.hideOnContentClick) { 658 content.bind('click', waJSQuery.fancybox.close); 659 } 660 661 if (currentOpts.hideOnOverlayClick) { 662 overlay.bind('click', waJSQuery.fancybox.close); 663 } 664 665 waJSQuery(window).bind("resize.fb", waJSQuery.fancybox.resize); 666 667 if (currentOpts.centerOnScroll) { 668 waJSQuery(window).bind("scroll.fb", waJSQuery.fancybox.center); 669 } 670 671 if (currentOpts.type == 'iframe') { 672 waJSQuery('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + (waJSQuery.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content); 673 } 674 675 wrap.show(); 676 677 busy = false; 678 679 waJSQuery.fancybox.center(); 680 681 currentOpts.onComplete(currentArray, currentIndex, currentOpts); 682 683 _preload_images(); 684 }, 685 686 _preload_images = function() { 687 var href, 688 objNext; 689 690 if ((currentArray.length -1) > currentIndex) { 691 href = currentArray[ currentIndex + 1 ].href; 692 693 if (typeof href !== 'undefined' && href.match(imgRegExp)) { 694 objNext = new Image(); 695 objNext.src = href; 696 } 697 } 698 699 if (currentIndex > 0) { 700 href = currentArray[ currentIndex - 1 ].href; 701 702 if (typeof href !== 'undefined' && href.match(imgRegExp)) { 703 objNext = new Image(); 704 objNext.src = href; 705 } 706 } 707 }, 708 709 _draw = function(pos) { 710 var dim = { 711 width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10), 712 height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10), 713 714 top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10), 715 left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10) 716 }; 717 718 if (typeof final_pos.opacity !== 'undefined') { 719 dim.opacity = pos < 0.5 ? 0.5 : pos; 720 } 721 722 wrap.css(dim); 723 724 content.css({ 725 'width' : dim.width - currentOpts.padding * 2,
726 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2 727 }); 728 }, 729 730 _get_viewport = function() { 731 return [ 732 waJSQuery(window).width() - (currentOpts.margin * 2), 733 waJSQuery(window).height() - (currentOpts.margin * 2), 734 waJSQuery(document).scrollLeft() + currentOpts.margin, 735 waJSQuery(document).scrollTop() + currentOpts.margin 736 ]; 737 }, 738 739 _get_zoom_to = function () { 740 var view = _get_viewport(), 741 to = {}, 742 resize = currentOpts.autoScale, 743 double_padding = currentOpts.padding * 2, 744 ratio; 745 746 if (currentOpts.width.toString().indexOf('%') > -1) { 747 to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10); 748 } else { 749 to.width = currentOpts.width + double_padding; 750 } 751 752 if (currentOpts.height.toString().indexOf('%') > -1) { 753 to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10); 754 } else { 755 to.height = currentOpts.height + double_padding; 756 } 757 758 if (resize && (to.width > view[0] || to.height > view[1])) { 759 if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { 760 ratio = (currentOpts.width ) / (currentOpts.height ); 761 762 if ((to.width ) > view[0]) { 763 to.width = view[0]; 764 to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10); 765 } 766 767 if ((to.height) > view[1]) { 768 to.height = view[1]; 769 to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10); 770 } 771 772 } else { 773 to.width = Math.min(to.width, view[0]); 774 to.height = Math.min(to.height, view[1]); 775 } 776 } 777 778 to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10); 779 to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10); 780 781 return to; 782 }, 783 784 _get_obj_pos = function(obj) { 785 var pos = obj.offset(); 786 787 pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0; 788 pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0; 789 790 pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0; 791 pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0; 792 793 pos.width = obj.width(); 794 pos.height = obj.height(); 795 796 return pos; 797 }, 798 799 _get_zoom_from = function() { 800 var orig = selectedOpts.orig ? waJSQuery(selectedOpts.orig) : false, 801 from = {}, 802 pos, 803 view; 804 805 if (orig && orig.length) { 806 pos = _get_obj_pos(orig); 807 808 from = { 809 width : pos.width + (currentOpts.padding * 2), 810 height : pos.height + (currentOpts.padding * 2), 811 top : pos.top - currentOpts.padding - 20, 812 left : pos.left - currentOpts.padding - 20 813 }; 814 815 } else { 816 view = _get_viewport(); 817 818 from = { 819 width : currentOpts.padding * 2, 820 height : currentOpts.padding * 2, 821 top : parseInt(view[3] + view[1] * 0.5, 10), 822 left : parseInt(view[2] + view[0] * 0.5, 10) 823 }; 824 } 825 826 return from; 827 }, 828 829 _animate_loading = function() { 830 if (!loading.is(':visible')){ 831 clearInterval(loadingTimer); 832 return; 833 } 834 835 waJSQuery('div', loading).css('top', (loadingFrame * -40) + 'px'); 836 837 /* 838 loadingFrameElapsed++; 839 if (loadingFrameElapsed<20) 840 { 841 waJSQuery('div', loading).hide() 842 } 843 else 844 { 845 waJSQuery('div', loading).show() 846 } 847 */ 848 849 loadingFrame = (loadingFrame + 1) % 12; 850 }; 851 852 /* 853 * Public methods 854 */ 855 856 waJSQuery.fn.fancybox = function(options) { 857 if (!waJSQuery(this).length) { 858 return this; 859 } 860 861 waJSQuery(this) 862 .data('fancybox', waJSQuery.extend({}, options, (waJSQuery.metadata ? waJSQuery(this).metadata() : {}))) 863 .unbind('click.fb') 864 .bind('click.fb', function(e) { 865 e.preventDefault(); 866 867 if (busy) { 868 return; 869 } 870 871 busy = true; 872 873 waJSQuery(this).blur(); 874 875 selectedArray = []; 876 selectedIndex = 0; 877 878 var rel = waJSQuery(this).attr('rel') || ''; 879 880 if (!rel || rel == '' || rel === 'nofollow') { 881 selectedArray.push(this); 882 883 } else { 884 selectedArray = waJSQuery("a[rel=" + rel + "], area[rel=" + rel + "]"); 885 886 887 //waFancyBoxSort 888 889 selectedArray.sort(_waFancyBoxSort)
890 ////////// 891 selectedIndex = selectedArray.index( this ); 892 893 } 894 895 896 //selectedIndex = 897 898 //alert(tmp) 899 _start(); 900 901 return; 902 }); 903 904 return this; 905 }; 906 907 waJSQuery.fancybox = function(obj) { 908 var opts; 909 910 if (busy) { 911 return; 912 } 913 914 busy = true; 915 opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; 916 917 selectedArray = []; 918 selectedIndex = parseInt(opts.index, 10) || 0; 919 920 if (waJSQuery.isArray(obj)) { 921 for (var i = 0, j = obj.length; i < j; i++) { 922 if (typeof obj[i] == 'object') { 923 waJSQuery(obj[i]).data('fancybox', waJSQuery.extend({}, opts, obj[i])); 924 } else { 925 obj[i] = waJSQuery({}).data('fancybox', waJSQuery.extend({content : obj[i]}, opts)); 926 } 927 } 928 929 selectedArray = waJSQuery.merge(selectedArray, obj); 930 931 } else { 932 if (typeof obj == 'object') { 933 waJSQuery(obj).data('fancybox', waJSQuery.extend({}, opts, obj)); 934 } else { 935 obj = waJSQuery({}).data('fancybox', waJSQuery.extend({content : obj}, opts)); 936 } 937 938 selectedArray.push(obj); 939 } 940 941 942 943 944 945 946 if (selectedIndex > selectedArray.length || selectedIndex < 0) { 947 selectedIndex = 0; 948 } 949 950 _start(); 951 }; 952 953 waJSQuery.fancybox.showActivity = function() { 954 clearInterval(loadingTimer); 955 956 loading.show(); 957 loadingTimer = setInterval(_animate_loading, 66); 958 }; 959 960 waJSQuery.fancybox.hideActivity = function() { 961 loading.hide(); 962 }; 963 964 waJSQuery.fancybox.next = function() { 965 return waJSQuery.fancybox.pos( currentIndex + 1); 966 }; 967 968 waJSQuery.fancybox.prev = function() { 969 return waJSQuery.fancybox.pos( currentIndex - 1); 970 }; 971 972 waJSQuery.fancybox.pos = function(pos) { 973 if (busy) { 974 return; 975 } 976 /* 977 var tmp = currentArray[0] 978 currentArray[0]=currentArray[1] 979 currentArray[1] = tmp 980 */ 981 982 //alert(currentArray[0]) 983 // currentArray.sort(waFancyBoxSort) 984//alert("ff "+currentArray.length) 985 pos = parseInt(pos); 986 987 selectedArray = currentArray; 988 989 if (pos > -1 && pos < currentArray.length) { 990 selectedIndex = pos; 991 _start(); 992 993 } else if (currentOpts.cyclic && currentArray.length > 1) { 994 selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1; 995 _start(); 996 } 997 998 return; 999 }; 1000 1001 waJSQuery.fancybox.cancel = function() { 1002 if (busy) { 1003 return; 1004 } 1005 1006 busy = true; 1007 1008 waJSQuery.event.trigger('fancybox-cancel'); 1009 1010 _abort(); 1011 1012 selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); 1013 1014 busy = false; 1015 }; 1016 1017 // Note: within an iframe use - parent.waJSQuery.fancybox.close(); 1018 waJSQuery.fancybox.close = function() { 1019 if (busy || wrap.is(':hidden')) { 1020 return; 1021 } 1022 1023 waSetVisibilityMainPageContenair(true) 1024 busy = true; 1025 1026 if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 1027 busy = false; 1028 return; 1029 } 1030 1031 _abort(); 1032 1033 waJSQuery(close.add( nav_left ).add( nav_right )).hide(); 1034 1035 waJSQuery(content.add( overlay )).unbind(); 1036 1037 waJSQuery(window).unbind("resize.fb scroll.fb"); 1038 waJSQuery(document).unbind('keydown.fb'); 1039 1040 content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank'); 1041 1042 if (currentOpts.titlePosition !== 'inside') { 1043 title.empty(); 1044 } 1045 1046 wrap.stop(); 1047 1048 function _cleanup() { 1049 overlay.fadeOut('fast'); 1050 1051 title.empty().hide(); 1052 wrap.hide(); 1053 1054 waJSQuery.event.trigger('fancybox-cleanup'); 1055 1056 content.empty(); 1057 1058 currentOpts.onClosed(currentArray, currentIndex, currentOpts); 1059 1060 currentArray = selectedOpts = []; 1061 currentIndex = selectedIndex = 0; 1062 currentOpts = selectedOpts = {}; 1063 1064 busy = false; 1065 } 1066 1067 if (currentOpts.transitionOut == 'elastic') { 1068 start_pos = _get_zoom_from(); 1069 1070 var pos = wrap.position(); 1071 1072 final_pos = { 1073 top : pos.top , 1074 left : pos.left, 1075 width : wrap.width(), 1076 height : wrap.height() 1077 }; 1078 1079 if (currentOpts.opacity) { 1080 final_pos.opacity = 1; 1081 } 1082 1083 title.empty().hide(); 1084 1085 fx.prop = 1; 1086 1087 waJSQuery(fx).animate({ prop: 0 }, { 1088 duration : currentOpts.speedOut, 1089 easing : currentOpts.easingOut, 1090 step : _draw, 1091 complete : _cleanup 1092 }); 1093 1094 } else { 1095 wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup); 1096 } 1097 }; 1098 1099 waJSQuery.fancybox.resize = function() { 1100 if (overlay.is(':visible')) { 1101 overlay.css('height', waJSQuery(document).height()); 1102 } 1103 1104 waJSQuery.fancybox.center(true); 1105 }; 1106 1107 waJSQuery.fancybox.center = function() { 1108 var view, align; 1109 1110 if (busy) { 1111 return; 1112 } 1113 1114 align = arguments[0] === true ? 1 : 0; 1115 view = _get_viewport(); 1116 1117 if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) { 1118 return; 1119 } 1120 1121 wrap 1122 .stop() 1123 .animate({ 1124 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)), 1125 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding)) 1126 }, typeof arguments[0] == 'number' ? arguments[0] : 200); 1127 }; 1128 1129 waJSQuery.fancybox.init = function() { 1130 if (waJSQuery("#fancybox-wrap").length) { 1131 return; 1132 } 1133 1134//waJSQuery("#wa-dialog-content") 1135 waJSQuery('body') 1136 .append( 1137 tmp = waJSQuery('<div id="fancybox-tmp"></div>'), 1138 loading = waJSQuery('<div id="fancybox-loading"><div></div></div>'), 1139 overlay = waJSQuery('<div id="fancybox-overlay"></div>'), 1140 wrap = waJSQuery('<div id="fancybox-wrap"></div>') 1141 ); 1142 1143 1144 // alert(overlay.css("z-index")+100000) 1145 //overlay.css("z-index",tmp.css("z-index")+100000) 1146 1147 1148 1149 outer = waJSQuery('<div id="fancybox-outer"></div>') 1150 .append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>') 1151 .appendTo( wrap ); 1152 1153 outer.append( 1154 content = waJSQuery('<div id="fancybox-content"></div>'),
1155 close = waJSQuery('<a id="fancybox-close"></a>'), 1156 title = waJSQuery('<div id="fancybox-title"></div>'), 1157 1158 nav_left = waJSQuery('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), 1159 nav_right = waJSQuery('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>') 1160 ); 1161 1162 /////augmente z-index 1163 /* 1164 _waIncreaseZindex(overlay) 1165 _waIncreaseZindex(loading) 1166 _waIncreaseZindex(wrap) 1167 _waIncreaseZindex(outer) 1168 _waIncreaseZindex(content) 1169 */ 1170 1171 1172 close.click(waJSQuery.fancybox.close); 1173 loading.click(waJSQuery.fancybox.cancel); 1174 1175 nav_left.click(function(e) { 1176 e.preventDefault(); 1177 waJSQuery.fancybox.prev(); 1178 }); 1179 1180 nav_right.click(function(e) { 1181 e.preventDefault(); 1182 waJSQuery.fancybox.next(); 1183 }); 1184 1185 1186 1187 overlay.touchwipe({ 1188 wipeLeft: function() { 1189 waJSQuery.fancybox.next(); 1190 return false 1191 }, 1192 wipeRight: function() { 1193 waJSQuery.fancybox.prev(); 1194 return false 1195 } 1196 , 1197 preventDefaultEvents: true 1198 } 1199 ) 1200 1201 1202 wrap.touchwipe({ 1203 wipeLeft: function() { 1204 waJSQuery.fancybox.next(); 1205 return false 1206 }, 1207 wipeRight: function() { 1208 waJSQuery.fancybox.prev(); 1209 return false 1210 } 1211 , 1212 preventDefaultEvents: true 1213 } 1214 ) 1215 1216 1217 1218/* if (waJSQuery.fn.mousewheel) { 1219 wrap.bind('mousewheel.fb', function(e, delta) { 1220 if (busy) { 1221 e.preventDefault(); 1222 1223 } else if (waJSQuery(e.target).get(0).clientHeight == 0 || waJSQuery(e.target).get(0).scrollHeight === waJSQuery(e.target).get(0).clientHeight) { 1224 1225 // alert("debug"+delta) 1226 e.preventDefault(); 1227 waJSQuery.fancybox[ delta > 0 ? 'prev' : 'next'](); 1228 } 1229 }); 1230 }*/ 1231 1232 if (!waJSQuery.support.opacity) { 1233 wrap.addClass('fancybox-ie'); 1234 } 1235 1236 if (isIE6) { 1237 loading.addClass('fancybox-ie6'); 1238 wrap.addClass('fancybox-ie6'); 1239 1240 waJSQuery('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer); 1241 } 1242 1243 }; 1244 1245 waJSQuery.fn.fancybox.defaults = { 1246 padding : 10, 1247 margin : 40, 1248 opacity : false, 1249 modal : false, 1250 cyclic : false, 1251 scrolling : 'auto', // 'auto', 'yes' or 'no' 1252 1253 width : 560, 1254 height : 340, 1255 1256 autoScale : true, 1257 autoDimensions : true, 1258 centerOnScroll : false, 1259 1260 ajax : {}, 1261 swf : { wmode: 'transparent' }, 1262 1263 hideOnOverlayClick : true, 1264 hideOnContentClick : false, 1265 1266 overlayShow : true, 1267 overlayOpacity : 0.7, 1268 overlayColor : '#777', 1269 1270 titleShow : true, 1271 titlePosition : 'float', // 'float', 'outside', 'inside' or 'over' 1272 titleFormat : null, 1273 titleFromAlt : false, 1274 1275 transitionIn : 'fade', // 'elastic', 'fade' or 'none' 1276 transitionOut : 'fade', // 'elastic', 'fade' or 'none' 1277 1278 speedIn : 300, 1279 speedOut : 300, 1280 1281 changeSpeed : 300, 1282 changeFade : 'fast', 1283 1284 easingIn : 'swing', 1285 easingOut : 'swing', 1286 1287 showCloseButton : true, 1288 showNavArrows : true, 1289 enableEscapeButton : true, 1290 enableKeyboardNav : true, 1291 1292 onStart : function(){}, 1293 onCancel : function(){}, 1294 onComplete : function(){}, 1295 onCleanup : function(){}, 1296 onClosed : function(){}, 1297 onError : function(){} 1298 }; 1299 1300 waJSQuery(document).ready(function() { 1301 waJSQuery.fancybox.init(); 1302 }); 1303 1304})(waJSQuery);
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.