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