vendor: 37,729 bytes, lines 1-1714
1/*! Magnific Popup - v0.9.9 - 2014-09-06 2* http://dimsemenov.com/plugins/magnific-popup/ 3* Copyright (c) 2014 Dmitry Semenov; */ 4;(function($) { 5 6/*>>core*/ 7/** 8 * 9 * Magnific Popup Core JS file 10 * 11 */ 12 13 14/** 15 * Private static constants 16 */ 17var CLOSE_EVENT = 'Close', 18 BEFORE_CLOSE_EVENT = 'BeforeClose', 19 AFTER_CLOSE_EVENT = 'AfterClose', 20 BEFORE_APPEND_EVENT = 'BeforeAppend', 21 MARKUP_PARSE_EVENT = 'MarkupParse', 22 OPEN_EVENT = 'Open', 23 CHANGE_EVENT = 'Change', 24 NS = 'mfp', 25 EVENT_NS = '.' + NS, 26 READY_CLASS = 'mfp-ready', 27 REMOVING_CLASS = 'mfp-removing', 28 PREVENT_CLOSE_CLASS = 'mfp-prevent-close'; 29 30 31/** 32 * Private vars 33 */ 34var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this' 35 MagnificPopup = function(){}, 36 _isJQ = !!(window.jQuery), 37 _prevStatus, 38 _window = $(window), 39 _body, 40 _document, 41 _prevContentType, 42 _wrapClasses, 43 _currPopupType; 44 45 46/** 47 * Private functions 48 */ 49var _mfpOn = function(name, f) { 50 mfp.ev.on(NS + name + EVENT_NS, f); 51 }, 52 _getEl = function(className, appendTo, html, raw) { 53 var el = document.createElement('div'); 54 el.className = 'mfp-'+className; 55 if(html) { 56 el.innerHTML = html; 57 } 58 if(!raw) { 59 el = $(el); 60 if(appendTo) { 61 el.appendTo(appendTo); 62 } 63 } else if(appendTo) { 64 appendTo.appendChild(el); 65 } 66 return el; 67 }, 68 _mfpTrigger = function(e, data) { 69 mfp.ev.triggerHandler(NS + e, data); 70 71 if(mfp.st.callbacks) { 72 // converts "mfpEventName" to "eventName" callback and triggers it if it's present 73 e = e.charAt(0).toLowerCase() + e.slice(1); 74 if(mfp.st.callbacks[e]) { 75 mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]); 76 } 77 } 78 }, 79 _getCloseBtn = function(type) { 80 if(type !== _currPopupType || !mfp.currTemplate.closeBtn) { 81 mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) ); 82 _currPopupType = type; 83 } 84 return mfp.currTemplate.closeBtn; 85 }, 86 // Initialize Magnific Popup only when called at least once 87 _checkInstance = function() { 88 if(!$.magnificPopup.instance) { 89 mfp = new MagnificPopup(); 90 mfp.init(); 91 $.magnificPopup.instance = mfp; 92 } 93 }, 94 // CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr 95 supportsTransitions = function() { 96 var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist 97 v = ['ms','O','Moz','Webkit']; // 'v' for vendor 98 99 if( s['transition'] !== undefined ) { 100 return true; 101 } 102 103 while( v.length ) { 104 if( v.pop() + 'Transition' in s ) { 105 return true; 106 } 107 } 108 109 return false; 110 }; 111 112 113 114/** 115 * Public functions 116 */ 117MagnificPopup.prototype = { 118 119 constructor: MagnificPopup, 120 121 /** 122 * Initializes Magnific Popup plugin. 123 * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed 124 */ 125 init: function() { 126 var appVersion = navigator.appVersion; 127 mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1; 128 mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1; 129 mfp.isLowIE = mfp.isIE7 || mfp.isIE8; 130 mfp.isAndroid = (/android/gi).test(appVersion); 131 mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion); 132 mfp.supportsTransition = supportsTransitions(); 133 134 // We disable fixed positioned lightbox on devices that don't handle it nicely. 135 // If you know a better way of detecting this - let me know. 136 mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) ); 137 _document = $(document); 138 139 mfp.popupsCache = {}; 140 }, 141 142 /** 143 * Opens popup 144 * @param data [description] 145 */ 146 open: function(data) { 147 148 if(!_body) { 149 _body = $(document.body); 150 } 151 152 var i; 153 154 if(data.isObj === false) { 155 // convert jQuery collection to array to avoid conflicts later 156 mfp.items = data.items.toArray(); 157 158 mfp.index = 0; 159 var items = data.items, 160 item; 161 for(i = 0; i < items.length; i++) { 162 item = items[i]; 163 if(item.parsed) { 164 item = item.el[0]; 165 } 166 if(item === data.el[0]) { 167 mfp.index = i; 168 break; 169 } 170 } 171 } else { 172 mfp.items = $.isArray(data.items) ? data.items : [data.items]; 173 mfp.index = data.index || 0; 174 } 175 176 // if popup is already opened - we just update the content 177 if(mfp.isOpen) { 178 mfp.updateItemHTML(); 179 return; 180 } 181 182 mfp.types = []; 183 _wrapClasses = ''; 184 if(data.mainEl && data.mainEl.length) { 185 mfp.ev = data.mainEl.eq(0); 186 } else { 187 mfp.ev = _document; 188 } 189 190 if(data.key) { 191 if(!mfp.popupsCache[data.key]) { 192 mfp.popupsCache[data.key] = {}; 193 } 194 mfp.currTemplate = mfp.popupsCache[data.key]; 195 } else { 196 mfp.currTemplate = {}; 197 } 198 199 200 201 mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data ); 202 mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos; 203 204 if(mfp.st.modal) { 205 mfp.st.closeOnContentClick = false; 206 mfp.st.closeOnBgClick = false; 207 mfp.st.showCloseBtn = false; 208 mfp.st.enableEscapeKey = false; 209 } 210 211 212 // Building markup 213 // main containers are created only once 214 if(!mfp.bgOverlay) { 215 216 // Dark overlay 217 mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() { 218 mfp.close(); 219 }); 220 221 mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) { 222 if(mfp._checkIfClose(e.target)) { 223 mfp.close(); 224 } 225 }); 226 227 mfp.container = _getEl('container', mfp.wrap); 228 } 229 230 mfp.contentContainer = _getEl('content'); 231 if(mfp.st.preloader) { 232 mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading); 233 } 234 235 236 // Initializing modules 237 var modules = $.magnificPopup.modules; 238 for(i = 0; i < modules.length; i++) { 239 var n = modules[i]; 240 n = n.charAt(0).toUpperCase() + n.slice(1); 241 mfp['init'+n].call(mfp); 242 } 243 _mfpTrigger('BeforeOpen'); 244 245 246 if(mfp.st.showCloseBtn) { 247 // Close button 248 if(!mfp.st.closeBtnInside) { 249 mfp.wrap.append( _getCloseBtn() ); 250 } else { 251 _mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) { 252 values.close_replaceWith = _getCloseBtn(item.type); 253 }); 254 _wrapClasses += ' mfp-close-btn-in'; 255 } 256 } 257 258 if(mfp.st.alignTop) { 259 _wrapClasses += ' mfp-align-top'; 260 } 261 262 263 264 if(mfp.fixedContentPos) { 265 mfp.wrap.css({ 266 overflow: mfp.st.overflowY, 267 overflowX: 'hidden', 268 overflowY: mfp.st.overflowY 269 }); 270 } else { 271 mfp.wrap.css({ 272 top: _window.scrollTop(), 273 position: 'absolute' 274 }); 275 } 276 if( mfp.st.fixedBgPos === false || (mfp.st.fixedBgPos === 'auto' && !mfp.fixedContentPos) ) { 277 mfp.bgOverlay.css({ 278 height: _document.height(), 279 position: 'absolute' 280 }); 281 } 282 283 284 285 if(mfp.st.enableEscapeKey) { 286 // Close on ESC key 287 _document.on('keyup' + EVENT_NS, function(e) { 288 if(e.keyCode === 27) { 289 mfp.close(); 290 } 291 }); 292 } 293 294 _window.on('resize' + EVENT_NS, function() { 295 mfp.updateSize(); 296 }); 297 298 299 if(!mfp.st.closeOnContentClick) { 300 _wrapClasses += ' mfp-auto-cursor'; 301 } 302 303 if(_wrapClasses) 304 mfp.wrap.addClass(_wrapClasses); 305 306 307 // this triggers recalculation of layout, so we get it once to not to trigger twice 308 var windowHeight = mfp.wH = _window.height(); 309 310 311 var windowStyles = {}; 312 313 if( mfp.fixedContentPos ) { 314 if(mfp._hasScrollBar(windowHeight)){ 315 var s = mfp._getScrollbarSize(); 316 if(s) { 317 windowStyles.marginRight = s; 318 } 319 } 320 } 321 322 if(mfp.fixedContentPos) { 323 if(!mfp.isIE7) { 324 windowStyles.overflow = 'hidden'; 325 } else { 326 // ie7 double-scroll bug 327 $('body, html').css('overflow', 'hidden'); 328 } 329 } 330 331 332 333 var classesToadd = mfp.st.mainClass; 334 if(mfp.isIE7) { 335 classesToadd += ' mfp-ie7'; 336 } 337 if(classesToadd) { 338 mfp._addClassToMFP( classesToadd ); 339 } 340 341 // add content 342 mfp.updateItemHTML(); 343 344 _mfpTrigger('BuildControls'); 345 346 // remove scrollbar, add margin e.t.c 347 $('html').css(windowStyles); 348 349 // add everything to DOM 350 mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || _body ); 351 352 // Save last focused element 353 mfp._lastFocusedEl = document.activeElement; 354 355 // Wait for next cycle to allow CSS transition 356 setTimeout(function() { 357 358 if(mfp.content) { 359 mfp._addClassToMFP(READY_CLASS); 360 mfp._setFocus(); 361 } else { 362 // if content is not defined (not loaded e.t.c) we add class only for BG 363 mfp.bgOverlay.addClass(READY_CLASS); 364 } 365 366 // Trap the focus in popup 367 _document.on('focusin' + EVENT_NS, mfp._onFocusIn); 368 369 }, 16); 370 371 mfp.isOpen = true; 372 mfp.updateSize(windowHeight); 373 _mfpTrigger(OPEN_EVENT); 374 375 return data; 376 }, 377 378 /** 379 * Closes the popup 380 */ 381 close: function() { 382 if(!mfp.isOpen) return; 383 _mfpTrigger(BEFORE_CLOSE_EVENT); 384 385 mfp.isOpen = false; 386 // for CSS3 animation 387 if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) { 388 mfp._addClassToMFP(REMOVING_CLASS); 389 setTimeout(function() { 390 mfp._close(); 391 }, mfp.st.removalDelay); 392 } else { 393 mfp._close(); 394 } 395 }, 396 397 /** 398 * Helper for close() function 399 */ 400 _close: function() { 401 _mfpTrigger(CLOSE_EVENT); 402 403 var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' '; 404 405 mfp.bgOverlay.detach(); 406 mfp.wrap.detach(); 407 mfp.container.empty(); 408 409 if(mfp.st.mainClass) { 410 classesToRemove += mfp.st.mainClass + ' '; 411 } 412 413 mfp._removeClassFromMFP(classesToRemove); 414 415 if(mfp.fixedContentPos) { 416 var windowStyles = {marginRight: ''}; 417 if(mfp.isIE7) { 418 $('body, html').css('overflow', ''); 419 } else { 420 windowStyles.overflow = ''; 421 } 422 $('html').css(windowStyles); 423 } 424 425 _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS); 426 mfp.ev.off(EVENT_NS); 427 428 // clean up DOM elements that aren't removed 429 mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style'); 430 mfp.bgOverlay.attr('class', 'mfp-bg'); 431 mfp.container.attr('class', 'mfp-container'); 432 433 // remove close button from target element 434 if(mfp.st.showCloseBtn && 435 (!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true)) { 436 if(mfp.currTemplate.closeBtn) 437 mfp.currTemplate.closeBtn.detach(); 438 } 439 440 441 if(mfp._lastFocusedEl) { 442 //$(mfp._lastFocusedEl).focus(); // put tab focus back 443 } 444 mfp.currItem = null; 445 mfp.content = null; 446 mfp.currTemplate = null; 447 mfp.prevHeight = 0; 448 449 _mfpTrigger(AFTER_CLOSE_EVENT); 450 }, 451 452 updateSize: function(winHeight) { 453 454 if(mfp.isIOS) { 455 // fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2 456 var zoomLevel = document.documentElement.clientWidth / window.innerWidth; 457 var height = window.innerHeight * zoomLevel; 458 mfp.wrap.css('height', height); 459 mfp.wH = height; 460 } else { 461 mfp.wH = winHeight || _window.height(); 462 } 463 // Fixes #84: popup incorrectly positioned with position:relative on body 464 if(!mfp.fixedContentPos) { 465 mfp.wrap.css('height', mfp.wH); 466 } 467 468 _mfpTrigger('Resize'); 469 470 }, 471 472 /** 473 * Set content of popup based on current index 474 */ 475 updateItemHTML: function() { 476 var item = mfp.items[mfp.index]; 477 478 // Detach and perform modifications 479 mfp.contentContainer.detach(); 480 481 if(mfp.content) 482 mfp.content.detach(); 483 484 if(!item.parsed) { 485 item = mfp.parseEl( mfp.index ); 486 } 487 488 var type = item.type; 489 490 _mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]); 491 // BeforeChange event works like so: 492 // _mfpOn('BeforeChange', function(e, prevType, newType) { }); 493 494 mfp.currItem = item; 495 496 497 498 499 500 if(!mfp.currTemplate[type]) { 501 var markup = mfp.st[type] ? mfp.st[type].markup : false; 502 503 // allows to modify markup 504 _mfpTrigger('FirstMarkupParse', markup); 505 506 if(markup) { 507 mfp.currTemplate[type] = $(markup); 508 } else { 509 // if there is no markup found we just define that template is parsed 510 mfp.currTemplate[type] = true; 511 } 512 } 513 514 if(_prevContentType && _prevContentType !== item.type) { 515 mfp.container.removeClass('mfp-'+_prevContentType+'-holder'); 516 } 517 518 var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]); 519 mfp.appendContent(newContent, type); 520 521 item.preloaded = true; 522 523 _mfpTrigger(CHANGE_EVENT, item); 524 _prevContentType = item.type; 525 526 // Append container back after its content changed 527 mfp.container.prepend(mfp.contentContainer); 528 529 _mfpTrigger('AfterChange'); 530 }, 531 532 533 /** 534 * Set HTML content of popup 535 */ 536 appendContent: function(newContent, type) { 537 mfp.content = newContent; 538 539 if(newContent) { 540 if(mfp.st.showCloseBtn && mfp.st.closeBtnInside && 541 mfp.currTemplate[type] === true) { 542 // if there is no markup, we just append close button element inside 543 if(!mfp.content.find('.mfp-close').length) { 544 mfp.content.append(_getCloseBtn()); 545 } 546 } else { 547 mfp.content = newContent; 548 } 549 } else { 550 mfp.content = ''; 551 } 552 553 _mfpTrigger(BEFORE_APPEND_EVENT); 554 mfp.container.addClass('mfp-'+type+'-holder'); 555 556 mfp.contentContainer.append(mfp.content); 557 }, 558 559 560 561 562 /** 563 * Creates Magnific Popup data object based on given data 564 * @param {int} index Index of item to parse 565 */ 566 parseEl: function(index) { 567 var item = mfp.items[index], 568 type; 569 570 if(item.tagName) { 571 item = { el: $(item) }; 572 } else { 573 type = item.type; 574 item = { data: item, src: item.src }; 575 } 576 577 if(item.el) { 578 var types = mfp.types; 579 580 // check for 'mfp-TYPE' class 581 for(var i = 0; i < types.length; i++) { 582 if( item.el.hasClass('mfp-'+types[i]) ) { 583 type = types[i]; 584 break; 585 } 586 } 587 588 item.src = item.el.attr('data-mfp-src'); 589 if(!item.src) { 590 item.src = item.el.attr('href'); 591 } 592 } 593 594 item.type = type || mfp.st.type || 'inline'; 595 item.index = index; 596 item.parsed = true; 597 mfp.items[index] = item; 598 _mfpTrigger('ElementParse', item); 599 600 return mfp.items[index]; 601 }, 602 603 604 /** 605 * Initializes single popup or a group of popups 606 */ 607 addGroup: function(el, options) { 608 var eHandler = function(e) { 609 e.mfpEl = this; 610 mfp._openClick(e, el, options); 611 }; 612 613 if(!options) { 614 options = {}; 615 } 616 617 var eName = 'click.magnificPopup'; 618 options.mainEl = el; 619 620 if(options.items) { 621 options.isObj = true; 622 el.off(eName).on(eName, eHandler); 623 } else { 624 options.isObj = false; 625 if(options.delegate) { 626 el.off(eName).on(eName, options.delegate , eHandler); 627 } else { 628 options.items = el; 629 el.off(eName).on(eName, eHandler); 630 } 631 } 632 }, 633 _openClick: function(e, el, options) { 634 var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick; 635 636 637 if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey ) ) { 638 return; 639 } 640 641 var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn; 642 643 if(disableOn) { 644 if($.isFunction(disableOn)) { 645 if( !disableOn.call(mfp) ) { 646 return true; 647 } 648 } else { // else it's number 649 if( _window.width() < disableOn ) { 650 return true; 651 } 652 } 653 } 654 655 if(e.type) { 656 e.preventDefault(); 657 658 // This will prevent popup from closing if element is inside and popup is already opened 659 if(mfp.isOpen) { 660 e.stopPropagation(); 661 } 662 } 663 664 665 options.el = $(e.mfpEl); 666 if(options.delegate) { 667 options.items = el.find(options.delegate); 668 } 669 mfp.open(options); 670 }, 671 672 673 /** 674 * Updates text on preloader 675 */ 676 updateStatus: function(status, text) { 677 678 if(mfp.preloader) { 679 if(_prevStatus !== status) { 680 mfp.container.removeClass('mfp-s-'+_prevStatus); 681 } 682 683 if(!text && status === 'loading') { 684 text = mfp.st.tLoading; 685 } 686 687 var data = { 688 status: status, 689 text: text 690 }; 691 // allows to modify status 692 _mfpTrigger('UpdateStatus', data); 693 694 status = data.status; 695 text = data.text; 696 697 mfp.preloader.html(text); 698 699 mfp.preloader.find('a').on('click', function(e) { 700 e.stopImmediatePropagation(); 701 }); 702 703 mfp.container.addClass('mfp-s-'+status); 704 _prevStatus = status; 705 } 706 }, 707 708 709 /* 710 "Private" helpers that aren't private at all 711 */ 712 // Check to close popup or not 713 // "target" is an element that was clicked 714 _checkIfClose: function(target) { 715 716 if($(target).hasClass(PREVENT_CLOSE_CLASS)) { 717 return; 718 } 719 720 var closeOnContent = mfp.st.closeOnContentClick; 721 var closeOnBg = mfp.st.closeOnBgClick; 722 723 if(closeOnContent && closeOnBg) { 724 return true; 725 } else { 726 727 // We close the popup if click is on close button or on preloader. Or if there is no content. 728 if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) { 729 return true; 730 } 731 732 // if click is outside the content 733 if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) { 734 if(closeOnBg) { 735 // last check, if the clicked element is in DOM, (in case it's removed onclick) 736 if( $.contains(document, target) ) { 737 return true; 738 } 739 } 740 } else if(closeOnContent) { 741 return true; 742 } 743 744 } 745 return false; 746 }, 747 _addClassToMFP: function(cName) { 748 mfp.bgOverlay.addClass(cName); 749 mfp.wrap.addClass(cName); 750 }, 751 _removeClassFromMFP: function(cName) { 752 this.bgOverlay.removeClass(cName); 753 mfp.wrap.removeClass(cName); 754 }, 755 _hasScrollBar: function(winHeight) { 756 return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) ); 757 }, 758 _setFocus: function() { 759 (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus(); 760 }, 761 _onFocusIn: function(e) { 762 if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) { 763 mfp._setFocus(); 764 return false; 765 } 766 }, 767 _parseMarkup: function(template, values, item) { 768 var arr; 769 if(item.data) { 770 values = $.extend(item.data, values); 771 } 772 _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] ); 773 774 $.each(values, function(key, value) { 775 if(value === undefined || value === false) { 776 return true; 777 } 778 arr = key.split('_'); 779 if(arr.length > 1) { 780 var el = template.find(EVENT_NS + '-'+arr[0]); 781 782 if(el.length > 0) { 783 var attr = arr[1]; 784 if(attr === 'replaceWith') { 785 if(el[0] !== value[0]) { 786 el.replaceWith(value); 787 } 788 } else if(attr === 'img') { 789 if(el.is('img')) { 790 el.attr('src', value); 791 } else { 792 el.replaceWith( '<img src="'+value+'" class="' + el.attr('class') + '" />' ); 793 } 794 } else { 795 el.attr(arr[1], value); 796 } 797 } 798 799 } else { 800 template.find(EVENT_NS + '-'+key).html(value); 801 } 802 }); 803 }, 804 805 _getScrollbarSize: function() { 806 // thx David 807 if(mfp.scrollbarSize === undefined) { 808 var scrollDiv = document.createElement("div"); 809 scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;'; 810 document.body.appendChild(scrollDiv); 811 mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; 812 document.body.removeChild(scrollDiv); 813 } 814 return mfp.scrollbarSize; 815 } 816 817}; /* MagnificPopup core prototype end */ 818 819 820 821 822/** 823 * Public static functions 824 */ 825$.magnificPopup = { 826 instance: null, 827 proto: MagnificPopup.prototype, 828 modules: [], 829 830 open: function(options, index) { 831 _checkInstance(); 832 833 if(!options) { 834 options = {}; 835 } else { 836 options = $.extend(true, {}, options); 837 } 838 839 840 options.isObj = true; 841 options.index = index || 0; 842 return this.instance.open(options); 843 }, 844 845 close: function() { 846 return $.magnificPopup.instance && $.magnificPopup.instance.close(); 847 }, 848 849 registerModule: function(name, module) { 850 if(module.options) { 851 $.magnificPopup.defaults[name] = module.options; 852 } 853 $.extend(this.proto, module.proto); 854 this.modules.push(name); 855 }, 856 857 defaults: { 858 859 // Info about options is in docs: 860 // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options 861 862 disableOn: 0, 863 864 key: null, 865 866 midClick: false, 867 868 mainClass: '', 869 870 preloader: true, 871 872 focus: '', // CSS selector of input to focus after popup is opened 873 874 closeOnContentClick: false, 875 876 closeOnBgClick: true, 877 878 closeBtnInside: true, 879 880 showCloseBtn: true, 881 882 enableEscapeKey: true, 883 884 modal: false, 885 886 alignTop: false, 887 888 removalDelay: 0, 889 890 prependTo: null, 891 892 fixedContentPos: 'auto', 893 894 fixedBgPos: 'auto', 895 896 overflowY: 'auto', 897 898 closeMarkup: '<button title="%title%" type="button" class="mfp-close"></button>', 899 900 tClose: 'Close (Esc)', 901 902 tLoading: 'Loading...' 903 904 } 905}; 906 907 908 909$.fn.magnificPopup = function(options) { 910 _checkInstance(); 911 912 var jqEl = $(this); 913 914 // We call some API method of first param is a string 915 if (typeof options === "string" ) { 916 917 if(options === 'open') { 918 var items, 919 itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup, 920 index = parseInt(arguments[1], 10) || 0; 921 922 if(itemOpts.items) { 923 items = itemOpts.items[index]; 924 } else { 925 items = jqEl; 926 if(itemOpts.delegate) { 927 items = items.find(itemOpts.delegate); 928 } 929 items = items.eq( index ); 930 } 931 mfp._openClick({mfpEl:items}, jqEl, itemOpts); 932 } else { 933 if(mfp.isOpen) 934 mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1)); 935 } 936 937 } else { 938 // clone options obj 939 options = $.extend(true, {}, options); 940 941 /* 942 * As Zepto doesn't support .data() method for objects 943 * and it works only in normal browsers 944 * we assign "options" object directly to the DOM element. FTW! 945 */ 946 if(_isJQ) { 947 jqEl.data('magnificPopup', options); 948 } else { 949 jqEl[0].magnificPopup = options; 950 } 951 952 mfp.addGroup(jqEl, options); 953 954 } 955 return jqEl; 956}; 957 958 959//Quick benchmark 960/* 961var start = performance.now(), 962 i, 963 rounds = 1000; 964for(i = 0; i < rounds; i++) { 965} 966console.log('Test #1:', performance.now() - start); 967start = performance.now(); 968for(i = 0; i < rounds; i++) { 969} 970console.log('Test #2:', performance.now() - start); 971*/ 972 973 974/*>>core*/ 975 976/*>>inline*/ 977 978var INLINE_NS = 'inline', 979 _hiddenClass, 980 _inlinePlaceholder, 981 _lastInlineElement, 982 _putInlineElementsBack = function() { 983 if(_lastInlineElement) { 984 _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach(); 985 _lastInlineElement = null; 986 } 987 }; 988 989$.magnificPopup.registerModule(INLINE_NS, { 990 options: { 991 hiddenClass: 'hide', // will be appended with `mfp-` prefix 992 markup: '', 993 tNotFound: 'Content not found' 994 }, 995 proto: { 996 997 initInline: function() { 998 mfp.types.push(INLINE_NS); 999 1000 _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() { 1001 _putInlineElementsBack(); 1002 }); 1003 }, 1004 1005 getInline: function(item, template) { 1006 1007 _putInlineElementsBack(); 1008 1009 if(item.src) { 1010 var inlineSt = mfp.st.inline, 1011 el = $(item.src); 1012 1013 if(el.length) { 1014 1015 // If target element has parent - we replace it with placeholder and put it back after popup is closed 1016 var parent = el[0].parentNode; 1017 if(parent && parent.tagName) { 1018 if(!_inlinePlaceholder) { 1019 _hiddenClass = inlineSt.hiddenClass; 1020 _inlinePlaceholder = _getEl(_hiddenClass); 1021 _hiddenClass = 'mfp-'+_hiddenClass; 1022 } 1023 // replace target inline element with placeholder 1024 _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass); 1025 } 1026 1027 mfp.updateStatus('ready'); 1028 } else { 1029 mfp.updateStatus('error', inlineSt.tNotFound); 1030 el = $('<div>'); 1031 } 1032 1033 item.inlineElement = el; 1034 return el; 1035 } 1036 1037 mfp.updateStatus('ready'); 1038 mfp._parseMarkup(template, {}, item); 1039 return template; 1040 } 1041 } 1042}); 1043 1044/*>>inline*/ 1045 1046/*>>ajax*/ 1047var AJAX_NS = 'ajax', 1048 _ajaxCur, 1049 _removeAjaxCursor = function() { 1050 if(_ajaxCur) { 1051 _body.removeClass(_ajaxCur); 1052 } 1053 }, 1054 _destroyAjaxRequest = function() { 1055 _removeAjaxCursor(); 1056 if(mfp.req) { 1057 mfp.req.abort(); 1058 } 1059 }; 1060 1061$.magnificPopup.registerModule(AJAX_NS, { 1062 1063 options: { 1064 settings: null, 1065 cursor: 'mfp-ajax-cur', 1066 tError: '<a href="%url%">The content</a> could not be loaded.' 1067 }, 1068 1069 proto: { 1070 initAjax: function() { 1071 mfp.types.push(AJAX_NS); 1072 _ajaxCur = mfp.st.ajax.cursor; 1073 1074 _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest); 1075 _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest); 1076 }, 1077 getAjax: function(item) { 1078 1079 if(_ajaxCur) 1080 _body.addClass(_ajaxCur); 1081 1082 mfp.updateStatus('loading'); 1083 1084 var opts = $.extend({ 1085 url: item.src, 1086 success: function(data, textStatus, jqXHR) { 1087 var temp = { 1088 data:data, 1089 xhr:jqXHR 1090 }; 1091 1092 _mfpTrigger('ParseAjax', temp); 1093 1094 mfp.appendContent( $(temp.data), AJAX_NS ); 1095 1096 item.finished = true; 1097 1098 _removeAjaxCursor(); 1099 1100 mfp._setFocus(); 1101 1102 setTimeout(function() { 1103 mfp.wrap.addClass(READY_CLASS); 1104 }, 16); 1105 1106 mfp.updateStatus('ready'); 1107 1108 _mfpTrigger('AjaxContentAdded'); 1109 }, 1110 error: function() { 1111 _removeAjaxCursor(); 1112 item.finished = item.loadError = true; 1113 mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src)); 1114 } 1115 }, mfp.st.ajax.settings); 1116 1117 mfp.req = $.ajax(opts); 1118 1119 return ''; 1120 } 1121 } 1122}); 1123 1124 1125 1126 1127 1128 1129 1130/*>>ajax*/ 1131 1132/*>>image*/ 1133var _imgInterval, 1134 _getTitle = function(item) { 1135 if(item.data && item.data.title !== undefined) 1136 return item.data.title; 1137 1138 var src = mfp.st.image.titleSrc; 1139 1140 if(src) { 1141 if($.isFunction(src)) { 1142 return src.call(mfp, item); 1143 } else if(item.el) { 1144 return item.el.attr(src) || ''; 1145 } 1146 } 1147 return ''; 1148 }; 1149 1150$.magnificPopup.registerModule('image', { 1151 1152 options: { 1153 markup: '<div class="mfp-figure">'+ 1154 '<div class="mfp-close"></div>'+ 1155 '<figure>'+ 1156 '<div class="mfp-img"></div>'+ 1157 '<figcaption>'+ 1158 '<div class="mfp-bottom-bar">'+ 1159 '<div class="mfp-title"></div>'+ 1160 '<div class="mfp-counter"></div>'+ 1161 '</div>'+ 1162 '</figcaption>'+ 1163 '</figure>'+ 1164 '</div>', 1165 cursor: 'mfp-zoom-out-cur', 1166 titleSrc: 'title', 1167 verticalFit: true, 1168 tError: '<a href="%url%">The image</a> could not be loaded.' 1169 }, 1170 1171 proto: { 1172 initImage: function() { 1173 var imgSt = mfp.st.image, 1174 ns = '.image'; 1175 1176 mfp.types.push('image'); 1177 1178 _mfpOn(OPEN_EVENT+ns, function() { 1179 if(mfp.currItem.type === 'image' && imgSt.cursor) { 1180 _body.addClass(imgSt.cursor); 1181 } 1182 }); 1183 1184 _mfpOn(CLOSE_EVENT+ns, function() { 1185 if(imgSt.cursor) { 1186 _body.removeClass(imgSt.cursor); 1187 } 1188 _window.off('resize' + EVENT_NS); 1189 }); 1190 1191 _mfpOn('Resize'+ns, mfp.resizeImage); 1192 if(mfp.isLowIE) { 1193 _mfpOn('AfterChange', mfp.resizeImage); 1194 } 1195 }, 1196 resizeImage: function() { 1197 var item = mfp.currItem; 1198 if(!item || !item.img) return; 1199 1200 if(mfp.st.image.verticalFit) { 1201 var decr = 0; 1202 // fix box-sizing in ie7/8 1203 if(mfp.isLowIE) { 1204 decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10); 1205 } 1206 item.img.css('max-height', mfp.wH-decr); 1207 } 1208 }, 1209 _onImageHasSize: function(item) { 1210 if(item.img) { 1211 1212 item.hasSize = true; 1213 1214 if(_imgInterval) { 1215 clearInterval(_imgInterval); 1216 } 1217 1218 item.isCheckingImgSize = false; 1219 1220 _mfpTrigger('ImageHasSize', item); 1221 1222 if(item.imgHidden) { 1223 if(mfp.content) 1224 mfp.content.removeClass('mfp-loading'); 1225 1226 item.imgHidden = false; 1227 } 1228 1229 } 1230 }, 1231 1232 /** 1233 * Function that loops until the image has size to display elements that rely on it asap 1234 */ 1235 findImageSize: function(item) { 1236 1237 var counter = 0, 1238 img = item.img[0], 1239 mfpSetInterval = function(delay) { 1240 1241 if(_imgInterval) { 1242 clearInterval(_imgInterval); 1243 } 1244 // decelerating interval that checks for size of an image 1245 _imgInterval = setInterval(function() { 1246 if(img.naturalWidth > 0) { 1247 mfp._onImageHasSize(item); 1248 return; 1249 } 1250 1251 if(counter > 200) { 1252 clearInterval(_imgInterval); 1253 } 1254 1255 counter++; 1256 if(counter === 3) { 1257 mfpSetInterval(10); 1258 } else if(counter === 40) { 1259 mfpSetInterval(50); 1260 } else if(counter === 100) { 1261 mfpSetInterval(500); 1262 } 1263 }, delay); 1264 }; 1265 1266 mfpSetInterval(1); 1267 }, 1268 1269 getImage: function(item, template) { 1270 1271 var guard = 0, 1272 1273 // image load complete handler 1274 onLoadComplete = function() { 1275 if(item) { 1276 if (item.img[0].complete) { 1277 item.img.off('.mfploader'); 1278 1279 if(item === mfp.currItem){ 1280 mfp._onImageHasSize(item); 1281 1282 mfp.updateStatus('ready'); 1283 } 1284 1285 item.hasSize = true; 1286 item.loaded = true; 1287 1288 _mfpTrigger('ImageLoadComplete'); 1289 1290 } 1291 else { 1292 // if image complete check fails 200 times (20 sec), we assume that there was an error. 1293 guard++; 1294 if(guard < 200) { 1295 setTimeout(onLoadComplete,100); 1296 } else { 1297 onLoadError(); 1298 } 1299 } 1300 } 1301 }, 1302 1303 // image error handler 1304 onLoadError = function() { 1305 if(item) { 1306 item.img.off('.mfploader'); 1307 if(item === mfp.currItem){ 1308 mfp._onImageHasSize(item); 1309 mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) ); 1310 } 1311 1312 item.hasSize = true; 1313 item.loaded = true; 1314 item.loadError = true; 1315 } 1316 }, 1317 imgSt = mfp.st.image; 1318 1319 1320 var el = template.find('.mfp-img'); 1321 if(el.length) { 1322 var img = document.createElement('img'); 1323 img.className = 'mfp-img'; 1324 item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError); 1325 img.src = item.src; 1326 1327 // without clone() "error" event is not firing when IMG is replaced by new IMG 1328 // TODO: find a way to avoid such cloning 1329 if(el.is('img')) { 1330 item.img = item.img.clone(); 1331 } 1332 1333 img = item.img[0]; 1334 if(img.naturalWidth > 0) { 1335 item.hasSize = true; 1336 } else if(!img.width) { 1337 item.hasSize = false; 1338 } 1339 } 1340 1341 mfp._parseMarkup(template, { 1342 title: _getTitle(item), 1343 img_replaceWith: item.img 1344 }, item); 1345 1346 mfp.resizeImage(); 1347 1348 if(item.hasSize) { 1349 if(_imgInterval) clearInterval(_imgInterval); 1350 1351 if(item.loadError) { 1352 template.addClass('mfp-loading'); 1353 mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) ); 1354 } else { 1355 template.removeClass('mfp-loading'); 1356 mfp.updateStatus('ready'); 1357 } 1358 return template; 1359 } 1360 1361 mfp.updateStatus('loading'); 1362 item.loading = true; 1363 1364 if(!item.hasSize) { 1365 item.imgHidden = true; 1366 template.addClass('mfp-loading'); 1367 mfp.findImageSize(item); 1368 } 1369 1370 return template; 1371 } 1372 } 1373}); 1374 1375 1376 1377/*>>image*/ 1378 1379/*>>zoom*/ 1380var hasMozTransform, 1381 getHasMozTransform = function() { 1382 if(hasMozTransform === undefined) { 1383 hasMozTransform = document.createElement('p').style.MozTransform !== undefined; 1384 } 1385 return hasMozTransform; 1386 }; 1387 1388$.magnificPopup.registerModule('zoom', { 1389 1390 options: { 1391 enabled: false, 1392 easing: 'ease-in-out', 1393 duration: 300, 1394 opener: function(element) { 1395 return element.is('img') ? element : element.find('img'); 1396 } 1397 }, 1398 1399 proto: { 1400 1401 initZoom: function() { 1402 var zoomSt = mfp.st.zoom, 1403 ns = '.zoom', 1404 image; 1405 1406 if(!zoomSt.enabled || !mfp.supportsTransition) { 1407 return; 1408 } 1409 1410 var duration = zoomSt.duration, 1411 getElToAnimate = function(image) { 1412 var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'), 1413 transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing, 1414 cssObj = { 1415 position: 'fixed', 1416 zIndex: 9999, 1417 left: 0, 1418 top: 0, 1419 '-webkit-backface-visibility': 'hidden' 1420 }, 1421 t = 'transition'; 1422 1423 cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition; 1424 1425 newImg.css(cssObj); 1426 return newImg; 1427 }, 1428 showMainContent = function() { 1429 mfp.content.css('visibility', 'visible'); 1430 }, 1431 openTimeout, 1432 animatedImg; 1433 1434 _mfpOn('BuildControls'+ns, function() { 1435 if(mfp._allowZoom()) { 1436 1437 clearTimeout(openTimeout); 1438 mfp.content.css('visibility', 'hidden'); 1439 1440 // Basically, all code below does is clones existing image, puts in on top of the current one and animated it 1441 1442 image = mfp._getItemToZoom(); 1443 1444 if(!image) { 1445 showMainContent(); 1446 return; 1447 } 1448 1449 animatedImg = getElToAnimate(image); 1450 1451 animatedImg.css( mfp._getOffset() ); 1452 1453 mfp.wrap.append(animatedImg); 1454 1455 openTimeout = setTimeout(function() { 1456 animatedImg.css( mfp._getOffset( true ) ); 1457 openTimeout = setTimeout(function() { 1458 1459 showMainContent(); 1460 1461 setTimeout(function() { 1462 animatedImg.remove(); 1463 image = animatedImg = null; 1464 _mfpTrigger('ZoomAnimationEnded'); 1465 }, 16); // avoid blink when switching images 1466 1467 }, duration); // this timeout equals animation duration 1468 1469 }, 16); // by adding this timeout we avoid short glitch at the beginning of animation 1470 1471 1472 // Lots of timeouts... 1473 } 1474 }); 1475 _mfpOn(BEFORE_CLOSE_EVENT+ns, function() { 1476 if(mfp._allowZoom()) { 1477 1478 clearTimeout(openTimeout); 1479 1480 mfp.st.removalDelay = duration; 1481 1482 if(!image) { 1483 image = mfp._getItemToZoom(); 1484 if(!image) { 1485 return; 1486 } 1487 animatedImg = getElToAnimate(image); 1488 } 1489 1490 1491 animatedImg.css( mfp._getOffset(true) ); 1492 mfp.wrap.append(animatedImg); 1493 mfp.content.css('visibility', 'hidden'); 1494 1495 setTimeout(function() { 1496 animatedImg.css( mfp._getOffset() ); 1497 }, 16); 1498 } 1499 1500 }); 1501 1502 _mfpOn(CLOSE_EVENT+ns, function() { 1503 if(mfp._allowZoom()) { 1504 showMainContent(); 1505 if(animatedImg) { 1506 animatedImg.remove(); 1507 } 1508 image = null; 1509 } 1510 }); 1511 }, 1512 1513 _allowZoom: function() { 1514 return mfp.currItem.type === 'image'; 1515 }, 1516 1517 _getItemToZoom: function() { 1518 if(mfp.currItem.hasSize) { 1519 return mfp.currItem.img; 1520 } else { 1521 return false; 1522 } 1523 }, 1524 1525 // Get element postion relative to viewport 1526 _getOffset: function(isLarge) { 1527 var el; 1528 if(isLarge) { 1529 el = mfp.currItem.img; 1530 } else { 1531 el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem); 1532 } 1533 1534 var offset = el.offset(); 1535 var paddingTop = parseInt(el.css('padding-top'),10); 1536 var paddingBottom = parseInt(el.css('padding-bottom'),10); 1537 offset.top -= ( $(window).scrollTop() - paddingTop ); 1538 1539 1540 /* 1541 1542 Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa. 1543 */ 1544 var obj = { 1545 width: el.width(), 1546 // fix Zepto height+padding issue 1547 height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop 1548 }; 1549 1550 // I hate to do this, but there is no another option 1551 if( getHasMozTransform() ) { 1552 obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)'; 1553 } else { 1554 obj.left = offset.left; 1555 obj.top = offset.top; 1556 } 1557 return obj; 1558 } 1559 1560 } 1561}); 1562 1563 1564 1565/*>>zoom*/ 1566 1567/*>>iframe*/ 1568 1569var IFRAME_NS = 'iframe', 1570 _emptyPage = '//about:blank', 1571 1572 _fixIframeBugs = function(isShowing) { 1573 if(mfp.currTemplate[IFRAME_NS]) { 1574 var el = mfp.currTemplate[IFRAME_NS].find('iframe'); 1575 if(el.length) { 1576 // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug 1577 if(!isShowing) { 1578 el[0].src = _emptyPage; 1579 } 1580 1581 // IE8 black screen bug fix 1582 if(mfp.isIE8) { 1583 el.css('display', isShowing ? 'block' : 'none'); 1584 } 1585 } 1586 } 1587 }; 1588 1589$.magnificPopup.registerModule(IFRAME_NS, { 1590 1591 options: { 1592 markup: '<div class="mfp-iframe-scaler">'+ 1593 '<div class="mfp-close"></div>'+ 1594 '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+ 1595 '</div>', 1596 1597 srcAction: 'iframe_src', 1598 1599 // we don't care and support only one default type of URL by default 1600 patterns: { 1601 youtube: { 1602 index: 'youtube.com', 1603 id: 'v=', 1604 src: '//www.youtube.com/embed/%id%?autoplay=1' 1605 }, 1606 vimeo: { 1607 index: 'vimeo.com/', 1608 id: '/', 1609 src: '//player.vimeo.com/video/%id%?autoplay=1' 1610 }, 1611 gmaps: { 1612 index: '//maps.google.', 1613 src: '%id%&output=embed' 1614 } 1615 } 1616 }, 1617 1618 proto: { 1619 initIframe: function() { 1620 mfp.types.push(IFRAME_NS); 1621 1622 _mfpOn('BeforeChange', function(e, prevType, newType) { 1623 if(prevType !== newType) { 1624 if(prevType === IFRAME_NS) { 1625 _fixIframeBugs(); // iframe if removed 1626 } else if(newType === IFRAME_NS) { 1627 _fixIframeBugs(true); // iframe is showing 1628 } 1629 }// else { 1630 // iframe source is switched, don't do anything 1631 //} 1632 }); 1633 1634 _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() { 1635 _fixIframeBugs(); 1636 }); 1637 }, 1638 1639 getIframe: function(item, template) { 1640 var embedSrc = item.src; 1641 var iframeSt = mfp.st.iframe; 1642 1643 $.each(iframeSt.patterns, function() { 1644 if(embedSrc.indexOf( this.index ) > -1) { 1645 if(this.id) { 1646 if(typeof this.id === 'string') { 1647 embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length); 1648 } else { 1649 embedSrc = this.id.call( this, embedSrc ); 1650 } 1651 } 1652 embedSrc = this.src.replace('%id%', embedSrc ); 1653 return false; // break; 1654 } 1655 }); 1656 1657 var dataObj = {}; 1658 if(iframeSt.srcAction) { 1659 dataObj[iframeSt.srcAction] = embedSrc; 1660 } 1661 mfp._parseMarkup(template, dataObj, item); 1662 1663 mfp.updateStatus('ready'); 1664 1665 return template; 1666 } 1667 } 1668}); 1669 1670 1671 1672/*>>iframe*/ 1673 1674/*>>gallery*/ 1675/** 1676 * Get looped index depending on number of slides 1677 */ 1678var _getLoopedId = function(index) { 1679 var numSlides = mfp.items.length; 1680 if(index > numSlides - 1) { 1681 return index - numSlides; 1682 } else if(index < 0) { 1683 return numSlides + index; 1684 } 1685 return index; 1686 }, 1687 _replaceCurrTotal = function(text, curr, total) { 1688 return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total); 1689 }; 1690 1691$.magnificPopup.registerModule('gallery', { 1692 1693 options: { 1694 enabled: false, 1695 arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>', 1696 preload: [0,2], 1697 navigateByImgClick: true, 1698 arrows: true, 1699 1700 tPrev: 'Previous (Left arrow key)', 1701 tNext: 'Next (Right arrow key)', 1702 tCounter: '%curr% von %total%' 1703 }, 1704 1705 proto: { 1706 initGallery: function() { 1707 1708 var gSt = mfp.st.gallery, 1709 ns = '.mfp-gallery', 1710 supportsFastClick = Boolean($.fn.mfpFastClick); 1711 1712 mfp.direction = true; // true - next, false - prev 1713 1714 if(!gSt || !gSt.enabled ) return false;
1715 1716 _wrapClasses += ' mfp-gallery'; 1717 1718 _mfpOn(OPEN_EVENT+ns, function() { 1719 1720 if(gSt.navigateByImgClick) { 1721 mfp.wrap.on('click'+ns, '.mfp-img', function() { 1722 if(mfp.items.length > 1) { 1723 mfp.next(); 1724 return false; 1725 } 1726 }); 1727 } 1728 1729 _document.on('keydown'+ns, function(e) { 1730 if (e.keyCode === 37) { 1731 mfp.prev(); 1732 } else if (e.keyCode === 39) { 1733 mfp.next(); 1734 } 1735 }); 1736 }); 1737 1738 _mfpOn('UpdateStatus'+ns, function(e, data) { 1739 if(data.text) { 1740 data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length); 1741 } 1742 }); 1743 1744 _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) { 1745 var l = mfp.items.length; 1746 values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : ''; 1747 }); 1748 1749 _mfpOn('BuildControls' + ns, function() { 1750 if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) { 1751 var markup = gSt.arrowMarkup, 1752 arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS), 1753 arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS); 1754 1755 var eName = supportsFastClick ? 'mfpFastClick' : 'click'; 1756 arrowLeft[eName](function() { 1757 mfp.prev(); 1758 }); 1759 arrowRight[eName](function() { 1760 mfp.next(); 1761 }); 1762 1763 // Polyfill for :before and :after (adds elements with classes mfp-a and mfp-b) 1764 if(mfp.isIE7) { 1765 _getEl('b', arrowLeft[0], false, true); 1766 _getEl('a', arrowLeft[0], false, true); 1767 _getEl('b', arrowRight[0], false, true); 1768 _getEl('a', arrowRight[0], false, true); 1769 } 1770 1771 mfp.container.append(arrowLeft.add(arrowRight)); 1772 } 1773 }); 1774 1775 _mfpOn(CHANGE_EVENT+ns, function() { 1776 if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout); 1777 1778 mfp._preloadTimeout = setTimeout(function() { 1779 mfp.preloadNearbyImages(); 1780 mfp._preloadTimeout = null; 1781 }, 16); 1782 }); 1783 1784 1785 _mfpOn(CLOSE_EVENT+ns, function() { 1786 _document.off(ns); 1787 mfp.wrap.off('click'+ns); 1788 1789 if(mfp.arrowLeft && supportsFastClick) { 1790 mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick(); 1791 } 1792 mfp.arrowRight = mfp.arrowLeft = null; 1793 }); 1794 1795 }, 1796 next: function() { 1797 mfp.direction = true; 1798 mfp.index = _getLoopedId(mfp.index + 1); 1799 mfp.updateItemHTML(); 1800 }, 1801 prev: function() { 1802 mfp.direction = false; 1803 mfp.index = _getLoopedId(mfp.index - 1); 1804 mfp.updateItemHTML(); 1805 }, 1806 goTo: function(newIndex) { 1807 mfp.direction = (newIndex >= mfp.index); 1808 mfp.index = newIndex; 1809 mfp.updateItemHTML(); 1810 }, 1811 preloadNearbyImages: function() { 1812 var p = mfp.st.gallery.preload, 1813 preloadBefore = Math.min(p[0], mfp.items.length), 1814 preloadAfter = Math.min(p[1], mfp.items.length), 1815 i; 1816 1817 for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) { 1818 mfp._preloadItem(mfp.index+i); 1819 } 1820 for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) { 1821 mfp._preloadItem(mfp.index-i); 1822 } 1823 }, 1824 _preloadItem: function(index) { 1825 index = _getLoopedId(index); 1826 1827 if(mfp.items[index].preloaded) { 1828 return; 1829 } 1830 1831 var item = mfp.items[index]; 1832 if(!item.parsed) { 1833 item = mfp.parseEl( index ); 1834 } 1835 1836 _mfpTrigger('LazyLoad', item); 1837 1838 if(item.type === 'image') { 1839 item.img = $('<img class="mfp-img" />').on('load.mfploader', function() { 1840 item.hasSize = true; 1841 }).on('error.mfploader', function() { 1842 item.hasSize = true; 1843 item.loadError = true; 1844 _mfpTrigger('LazyLoadError', item); 1845 }).attr('src', item.src); 1846 } 1847 1848 1849 item.preloaded = true; 1850 } 1851 } 1852}); 1853 1854/* 1855Touch Support that might be implemented some day 1856addSwipeGesture: function() { 1857 var startX, 1858 moved, 1859 multipleTouches; 1860 return; 1861 var namespace = '.mfp', 1862 addEventNames = function(pref, down, move, up, cancel) { 1863 mfp._tStart = pref + down + namespace; 1864 mfp._tMove = pref + move + namespace; 1865 mfp._tEnd = pref + up + namespace; 1866 mfp._tCancel = pref + cancel + namespace; 1867 }; 1868 if(window.navigator.msPointerEnabled) { 1869 addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel'); 1870 } else if('ontouchstart' in window) { 1871 addEventNames('touch', 'start', 'move', 'end', 'cancel'); 1872 } else { 1873 return; 1874 } 1875 _window.on(mfp._tStart, function(e) { 1876 var oE = e.originalEvent; 1877 multipleTouches = moved = false;
1878 startX = oE.pageX || oE.changedTouches[0].pageX; 1879 }).on(mfp._tMove, function(e) { 1880 if(e.originalEvent.touches.length > 1) { 1881 multipleTouches = e.originalEvent.touches.length; 1882 } else { 1883 //e.preventDefault(); 1884 moved = true; 1885 } 1886 }).on(mfp._tEnd + ' ' + mfp._tCancel, function(e) { 1887 if(moved && !multipleTouches) { 1888 var oE = e.originalEvent, 1889 diff = startX - (oE.pageX || oE.changedTouches[0].pageX); 1890 if(diff > 20) { 1891 mfp.next(); 1892 } else if(diff < -20) { 1893 mfp.prev(); 1894 } 1895 } 1896 }); 1897}, 1898*/ 1899 1900 1901/*>>gallery*/ 1902 1903/*>>retina*/ 1904 1905var RETINA_NS = 'retina'; 1906 1907$.magnificPopup.registerModule(RETINA_NS, { 1908 options: { 1909 replaceSrc: function(item) { 1910 return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; }); 1911 }, 1912 ratio: 1 // Function or number. Set to 1 to disable. 1913 }, 1914 proto: { 1915 initRetina: function() { 1916 if(window.devicePixelRatio > 1) { 1917 1918 var st = mfp.st.retina, 1919 ratio = st.ratio; 1920 1921 ratio = !isNaN(ratio) ? ratio : ratio(); 1922 1923 if(ratio > 1) { 1924 _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) { 1925 item.img.css({ 1926 'max-width': item.img[0].naturalWidth / ratio, 1927 'width': '100%' 1928 }); 1929 }); 1930 _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) { 1931 item.src = st.replaceSrc(item, ratio); 1932 }); 1933 } 1934 } 1935 1936 } 1937 } 1938}); 1939 1940/*>>retina*/ 1941 1942/*>>fastclick*/ 1943/** 1944 * FastClick event implementation. (removes 300ms delay on touch devices) 1945 * Based on https://developers.google.com/mobile/articles/fast_buttons 1946 * 1947 * You may use it outside the Magnific Popup by calling just: 1948 * 1949 * $('.your-el').mfpFastClick(function() { 1950 * console.log('Clicked!'); 1951 * }); 1952 * 1953 * To unbind: 1954 * $('.your-el').destroyMfpFastClick(); 1955 * 1956 * 1957 * Note that it's a very basic and simple implementation, it blocks ghost click on the same element where it was bound. 1958 * If you need something more advanced, use plugin by FT Labs https://github.com/ftlabs/fastclick 1959 * 1960 */ 1961 1962(function() { 1963 var ghostClickDelay = 1000, 1964 supportsTouch = 'ontouchstart' in window, 1965 unbindTouchMove = function() { 1966 _window.off('touchmove'+ns+' touchend'+ns); 1967 }, 1968 eName = 'mfpFastClick', 1969 ns = '.'+eName; 1970 1971 1972 // As Zepto.js doesn't have an easy way to add custom events (like jQuery), so we implement it in this way 1973 $.fn.mfpFastClick = function(callback) { 1974 1975 return $(this).each(function() { 1976 1977 var elem = $(this), 1978 lock; 1979 1980 if( supportsTouch ) { 1981 1982 var timeout, 1983 startX, 1984 startY, 1985 pointerMoved, 1986 point, 1987 numPointers; 1988 1989 elem.on('touchstart' + ns, function(e) { 1990 pointerMoved = false; 1991 numPointers = 1; 1992 1993 point = e.originalEvent ? e.originalEvent.touches[0] : e.touches[0]; 1994 startX = point.clientX; 1995 startY = point.clientY; 1996 1997 _window.on('touchmove'+ns, function(e) { 1998 point = e.originalEvent ? e.originalEvent.touches : e.touches; 1999 numPointers = point.length; 2000 point = point[0]; 2001 if (Math.abs(point.clientX - startX) > 10 || 2002 Math.abs(point.clientY - startY) > 10) { 2003 pointerMoved = true; 2004 unbindTouchMove(); 2005 } 2006 }).on('touchend'+ns, function(e) { 2007 unbindTouchMove(); 2008 if(pointerMoved || numPointers > 1) { 2009 return; 2010 } 2011 lock = true; 2012 e.preventDefault(); 2013 clearTimeout(timeout); 2014 timeout = setTimeout(function() { 2015 lock = false; 2016 }, ghostClickDelay); 2017 callback(); 2018 }); 2019 }); 2020 2021 } 2022 2023 elem.on('click' + ns, function() { 2024 if(!lock) { 2025 callback(); 2026 } 2027 }); 2028 }); 2029 }; 2030 2031 $.fn.destroyMfpFastClick = function() { 2032 $(this).off('touchstart' + ns + ' click' + ns); 2033 if(supportsTouch) _window.off('touchmove'+ns+' touchend'+ns); 2034 }; 2035})(); 2036 2037/*>>fastclick*/ 2038 _checkInstance(); })(window.jQuery || window.Zepto);
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.