1(function($) { 2 'use strict'; 3 function mk_animated_cols() { 4 function equalheight (container){ 5 var currentTallest = 0, 6 currentRowStart = 0, 7 rowDivs = new Array(), 8 $el, 9 topPosition = 0; 10 $(container).each(function() { 11 12 $el = $(this); 13 $($el).height('auto'); 14 topPosition = $el.position().top; 15 16 if (currentRowStart != topPosition) { 17 for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { 18 rowDivs[currentDiv].height(currentTallest); 19 } 20 rowDivs.length = 0; // empty the array 21 currentRowStart = topPosition; 22 currentTallest = $el.height(); 23 rowDivs.push($el); 24 } else { 25 rowDivs.push($el); 26 currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest); 27 } 28 for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) { 29 rowDivs[currentDiv].height(currentTallest); 30 } 31 32 }); 33 34 // console.log('recalc' + container + ' ' + currentTallest); 35 36 return currentTallest; 37 } 38 39 40 function prepareCols(el) { 41 var $this = el.parent().parent().find('.mk-animated-columns'); 42 43 var iconHeight = equalheight('.vc_row .animated-column-icon, .animated-column-holder .mk-svg-icon'), 44 titleHeight = equalheight('.vc_row .animated-column-title'), 45 descHeight = equalheight('.vc_row .animated-column-desc'), 46 btnHeight = $this.find('.animated-column-btn').innerHeight(); 47 48 if ($this.hasClass('full-style')) { 49 $this.find('.animated-column-item').each(function() { 50 var $this = $(this), 51 contentHeight = (iconHeight + 30) + (titleHeight + 10) + (descHeight + 70) + 34; 52 /* 53 * Fix AM-2418. 54 * 55 * Column height setting of VC Animated Column doesn't work when Animated Column 56 * content is higher than the setting. So, check column height setting first. 57 * - If the column height setting < Animated Column height, update the column 58 * height based on column height setting. 59 */ 60 var $columnHeight = contentHeight * 1.5 + 50; 61 var $minHeight = parseInt( $this.css( 'min-height' ), 10 ); 62 if ( ! isNaN( $minHeight ) ) { 63 if ( $minHeight < $columnHeight ) { 64 $columnHeight = $minHeight; 65 } 66 } 67 68 $this.height( $columnHeight ); 69 70 var $box_height = $this.outerHeight(true), 71 $icon_height = $this.find('.animated-column-icon, .animated-column-holder .mk-svg-icon').height(); 72 73 $this.find('.animated-column-holder').css({ 74 'paddingTop': $box_height / 2 - $icon_height 75 }); 76 77 78 $this.animate({opacity:1}, 300); 79 }); 80 } else { 81 $this.find('.animated-column-item').each(function() { 82 var $this = $(this), 83 halfHeight = $this.height() / 2, 84 halfIconHeight = $this.find('.animated-column-icon, .animated-column-holder .mk-svg-icon').height()/2, 85 halfTitleHeight = $this.find('.animated-column-simple-title').height()/2; 86 87 $this.find('.animated-column-holder').css({ 88 'paddingTop': halfHeight - halfIconHeight 89 }); 90 91 $this.find('.animated-column-title').css({ 92 'paddingTop': halfHeight - halfTitleHeight 93 }); 94 95 $this.animate({ 96 opacity:1 97 }, 300); 98 99 }); 100 } 101 } 102 103 $('.mk-animated-columns').each(function() { 104 var that = this; 105 MK.core.loadDependencies([ MK.core.path.plugins + 'tweenmax.js' ], function() { 106 var $this = $(that), 107 $parent = $this.parent().parent(), 108 $columns = $parent.find('.column_container'), 109 index = $columns.index($this.parent()); 110 // really bad that we cannot read it before bootstrap - needs full shortcode refactor 111 112 if($this.hasClass('full-style')) { 113 $this.find('.animated-column-item').hover( 114 function() { 115 TweenLite.to($(this).find(".animated-column-holder"), 0.5, { 116 top: '-15%', 117 ease: Back.easeOut 118 }); 119 TweenLite.to($(this).find(".animated-column-desc"), 0.5, { 120 top: '50%', 121 ease: Expo.easeOut 122 }, 0.4); 123 TweenLite.to($(this).find(".animated-column-btn"), 0.3, { 124 top: '50%', 125 ease: Expo.easeOut 126 }, 0.6); 127 }, 128 function() { 129 130 TweenLite.to($(this).find(".animated-column-holder"), 0.5, { 131 top: '0%', 132 ease: Back.easeOut, easeParams:[3] 133 }); 134 TweenLite.to($(this).find(".animated-column-desc"), 0.5, { 135 top: '100%', 136 ease: Back.easeOut 137 }, 0.4); 138 TweenLite.to($(this).find(".animated-column-btn"), 0.5, { 139 top: '100%', 140 ease: Back.easeOut 141 }, 0.2); 142 }); 143 } 144 145 if($this.hasClass('simple-style')) { 146 $this.find('.animated-column-item').hover( 147 function() { 148 TweenLite.to($(this).find(".animated-column-holder"), 0.7, { 149 top: '100%', 150 ease: Expo.easeOut 151 }); 152 TweenLite.to($(this).find(".animated-column-title"), 0.7, { 153 top: '0%', 154 ease: Back.easeOut 155 }, 0.2); 156 }, 157 function() { 158 TweenLite.to($(this).find(".animated-column-holder"), 0.7, { 159 top: '0%', 160 ease: Expo.easeOut 161 }); 162 TweenLite.to($(this).find(".animated-column-title"), 0.7, { 163 top: '-100%', 164 ease: Back.easeOut 165 }, 0.2); 166 }); 167 } 168 169 if($columns.length === index + 1) { 170 prepareCols($this); 171 $(window).on("resize", function() { 172 setTimeout(prepareCols($this), 1000); 173 }); 174 } 175 176 MK.utils.eventManager.subscribe('iconsInsert', function() { 177 prepareCols($this); 178 }); 179 }); 180 181 }); 182 } 183 184 $(window).on('load vc_reload', mk_animated_cols); 185 186}(jQuery)); 187 188(function($) { 189 'use strict'; 190 191 var _toBuild = []; 192 MK.api = window.MK.api || {}; 193 194 MK.component.AdvancedGMaps = function(el) { 195 var $this = $(el), 196 container = document.getElementById( 'mk-theme-container' ), 197 data = $this.data( 'advancedgmaps-config' ), 198 apikey = data.options.apikey ? ('key='+data.options.apikey+'&') : false, 199 map = null, 200 bounds = null, 201 infoWindow = null, 202 position = null; 203 204 var build = function() { 205 data.options.scrollwheel = false;
206 data.options.mapTypeId = google.maps.MapTypeId[data.options.mapTypeId]; 207 data.options.styles = data.style; 208 209 bounds = new google.maps.LatLngBounds(); 210 map = new google.maps.Map(el, data.options); 211 infoWindow = new google.maps.InfoWindow(); 212 213 map.setOptions({ 214 panControl : data.options.panControl, 215 draggable: data.options.draggable, 216 zoomControl: data.options.zoomControl, 217 mapTypeControl: data.options.scaleControl, 218 scaleControl: data.options.mapTypeControl, 219 }); 220 221 var marker, i; 222 223 map.setTilt(45); 224 225 for (i = 0; i < data.places.length; i++) { 226 if(data.places[i].latitude && data.places[i].longitude) { 227 position = new google.maps.LatLng(data.places[i].latitude, data.places[i].longitude); 228 229 bounds.extend(position); 230 231 marker = new google.maps.Marker({ 232 position: position, 233 map: map, 234 title: data.places[i].address, 235 icon: (data.places[i].marker) ? data.places[i].marker : data.icon 236 }); 237 238 239 google.maps.event.addListener(marker, 'click', (function(marker, i) { 240 return function() { 241 if(data.places[i].address && data.places[i].address.length > 1) { 242 infoWindow.setContent('<div class="info_content"><p>'+ data.places[i].address +'</p></div>'); 243 infoWindow.open(map, marker); 244 } else { 245 infoWindow.setContent(''); 246 infoWindow.close(); 247 } 248 }; 249 })(marker, i)); 250 251 /** 252 * If there is only one marker, map.fitBounds will zoom-in too much. 253 * Only run map.fitBounds if the markers are more than 1. Use setCenter 254 * instead if the the marker is only 1. 255 */ 256 if ( i > 0 ) { 257 map.fitBounds( bounds ); 258 } else { 259 // Set latitude and longtitude as float. 260 var latLang = { 261 lat: parseFloat( data.places[i].latitude ), 262 lng: parseFloat( data.places[i].longitude ) 263 }; 264 map.setCenter( latLang ); 265 // Need to setZoom here as we didn't trigger bounds_changed event. 266 map.setZoom( data.options.zoom ); 267 } 268 } 269 } 270 271 var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) { 272 this.setZoom(data.options.zoom); 273 google.maps.event.removeListener(boundsListener); 274 }); 275 276 277 var update = function() { 278 google.maps.event.trigger(map, "resize"); 279 map.setCenter(position); 280 }; 281 update(); 282 283 284 var bindEvents = function() { 285 $( window ).on( 'resize', update ); 286 window.addResizeListener( container, update ); 287 }; 288 bindEvents(); 289 }; 290 291 292 var initAll = function() { 293 for( var i = 0, l = _toBuild.length; i < l; i++ ) { 294 _toBuild[i](); 295 } 296 }; 297 298 MK.api.advancedgmaps = MK.api.advancedgmaps || function() { 299 initAll(); 300 }; 301 302 return { 303 init : function() { 304 _toBuild.push( build ); 305 MK.core.loadDependencies(['https://maps.googleapis.com/maps/api/js?'+apikey+'callback=MK.api.advancedgmaps']); 306 } 307 }; 308 309 }; 310 311})(jQuery); 312(function($) { 313 'use strict'; 314 315 var core = MK.core, 316 path = MK.core.path; 317 318 MK.component.BannerBuilder = function( el ) { 319 var init = function(){ 320 var $this = $(el), 321 data = $this.data( 'bannerbuilder-config' ); 322 323 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.flexslider.js' ], function() { 324 $this.flexslider({ 325 selector: '.mk-banner-slides > .mk-banner-slide', 326 animation: data.animation, 327 smoothHeight: false, 328 direction:'horizontal', 329 slideshow: true, 330 slideshowSpeed: data.slideshowSpeed, 331 animationSpeed: data.animationSpeed, 332 pauseOnHover: true, 333 directionNav: data.directionNav, 334 controlNav: false, 335 initDelay: 2000,
336 prevText: '', 337 nextText: '', 338 pauseText: '', 339 playText: '' 340 }); 341 }); 342 }; 343 344 return { 345 init : init 346 }; 347 }; 348 349})(jQuery); 350 351 352 353 354 355 356 357 358(function($) { 359 'use strict'; 360 361 var zIndex = 0; 362 363 $('.mk-newspaper-wrapper').on('click', '.blog-loop-comments', function (event) { 364 event.preventDefault(); 365 366 var $this = $(event.currentTarget); 367 var $parent = $this.parents('.mk-blog-newspaper-item'); 368 369 $parent.css('z-index', ++zIndex); 370 $this.parents('.newspaper-item-footer').find('.newspaper-social-share').slideUp(200).end().find('.newspaper-comments-list').slideDown(200); 371 setTimeout( function() { 372 MK.utils.eventManager.publish('item-expanded'); 373 }, 300); 374 }); 375 376 $('.mk-newspaper-wrapper').on('click', '.newspaper-item-share', function (event) { 377 event.preventDefault(); 378 379 var $this = $(event.currentTarget); 380 var $parent = $this.parents('.mk-blog-newspaper-item'); 381 382 $parent.css('z-index', ++zIndex); 383 $this.parents('.newspaper-item-footer').find('.newspaper-comments-list').slideUp(200).end().find('.newspaper-social-share').slideDown(200); 384 setTimeout( function() { 385 MK.utils.eventManager.publish('item-expanded'); 386 }, 300); 387 }); 388 389 var init = function init() { 390 391 // setTimeout Trick to make the VC Front Editor to load the images as well 392 setTimeout( function() { 393 394 // Get All Related Layers 395 var $blog = $('.mk-blog-container'); 396 var $imgs = $blog.find('img[data-mk-image-src-set]'); 397 398 if ( $blog.hasClass('mk-blog-container-lazyload') && $imgs.length ) { 399 400 // Load Images if the user scrolls to them 401 $(window).on('scroll.mk_blog_lazyload', MK.utils.throttle(500, function(){ 402 $imgs.each(function(index, elem) { 403 if ( MK.utils.isElementInViewport(elem) ) { 404 MK.component.ResponsiveImageSetter.init( $(elem) ); 405 $imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 406 } 407 }); 408 })); 409 410 $(window).trigger('scroll.mk_blog_lazyload'); 411 $(window).trigger('resize') 412 413 // Handle the resize 414 MK.component.ResponsiveImageSetter.onResize($imgs); 415 416 } else { 417 418 MK.component.ResponsiveImageSetter.init($imgs); 419 MK.component.ResponsiveImageSetter.onResize($imgs); 420 421 } 422 423 }, 50); 424 425 // If in VC Editor Page, Trigger Resize after 2 second (AM-2490) 426 // This is to fix the Pagination Overlapping issue on first initial blog insert as it takes VC about 1 second to change the Blog Layout on initial stage 427 if ( $('body').hasClass('vc_editor') ) { 428 setTimeout( function() { 429 $(window).trigger('resize'); 430 }, 2000) 431 } 432 433 $('.featured-image').on('click', function (event) { 434 var $this = $(event.currentTarget); 435 436 if ( 437 $this.parents('.mk-jupiter-blog').length === 0 || 438 $this.parents( '.mk-blog-spotlight-item' ).length !== 0 439 ) { 440 return; 441 } 442 443 window.location.href = $this.find('.post-type-badge').attr('href'); 444 }) 445 } 446 447 init(); 448 449 // VC Front-End Editor 450 $(window).on('vc_reload mk-image-loaded', init); 451 452}(jQuery)); 453 454(function($) { 455 'use strict'; 456 457 var core = MK.core, 458 path = core.path; 459 460 MK.component.Chart = function(el) { 461 var init = function() { 462 MK.core.loadDependencies([MK.core.path.plugins + 'jquery.easyPieChart.js'], function() { 463 $('.mk-chart__chart').each(function() { 464 var $this = $(this), 465 $parent_width = $(this).parent().width(), 466 $chart_size = parseInt($this.attr('data-barSize')); 467 468 if ($parent_width < $chart_size) { 469 $chart_size = $parent_width; 470 $this.css('line-height', $chart_size); 471 $this.find('i').css({ 472 'line-height': $chart_size + 'px' 473 }); 474 $this.css({ 475 'line-height': $chart_size + 'px' 476 }); 477 } 478 479 var build = function() { 480 $this.easyPieChart({ 481 animate: 1300, 482 lineCap: 'butt', 483 lineWidth: $this.attr('data-lineWidth'), 484 size: $chart_size, 485 barColor: $this.attr('data-barColor'), 486 trackColor: $this.attr('data-trackColor'), 487 scaleColor: 'transparent', 488 onStep: function(value) {
489 this.$el.find('.chart-percent span').text(Math.ceil(value)); 490 } 491 }); 492 }; 493 494 // refactored only :in-viewport logic. rest is to-do 495 MK.utils.scrollSpy(this, { 496 position: 'bottom', 497 after: build 498 }); 499 }); 500 }); 501 }; 502 503 return { 504 init: init 505 }; 506 }; 507 508})(jQuery); 509 510(function($) { 511 'use strict'; 512 // Update countdown style in VC FEE - AM-2684. 513 $(window).on('vc_reload', function() { 514 $('.mk-event-countdown-ul').each(function() { 515 if ($(this).width() < 750) { 516 $(this).addClass('mk-event-countdown-ul-block'); 517 } else { 518 $(this).removeClass('mk-event-countdown-ul-block'); 519 } 520 }); 521 }); 522})(jQuery); 523(function($) { 524 "use strict"; 525 526 $('.mk-clients.column-style').each(function() { 527 var $group = $(this), 528 $listItems = $group.find('li'), 529 listItemsCount = $listItems.length, 530 listStyle = $group.find('ul').attr('style') || '', 531 fullRowColumnsCount = $group.find('ul:first-of-type li').length; 532 533 function recreateGrid() { 534 var i; 535 536 $listItems.unwrap(); 537 538 if (window.matchMedia('(max-width: 550px)').matches && fullRowColumnsCount >= 1) { 539 for (i = 0; i < listItemsCount; i += 1) { 540 $listItems.slice(i, i + 1) 541 .wrapAll('<ul class="mk-clients-fixed-list" style="' + listStyle + '"></ul>'); 542 } 543 } else if (window.matchMedia('(max-width: 767px)').matches && fullRowColumnsCount >= 2) { 544 for (i = 0; i < listItemsCount; i += 2) { 545 $listItems.slice(i, i + 2) 546 .wrapAll('<ul class="mk-clients-fixed-list" style="' + listStyle + '"></ul>'); 547 } 548 } else if (window.matchMedia('(max-width: 960px)').matches && fullRowColumnsCount >= 3) { 549 for (i = 0; i < listItemsCount; i += 3) { 550 $listItems.slice(i, i + 3) 551 .wrapAll('<ul class="mk-clients-fixed-list" style="' + listStyle + '"></ul>'); 552 } 553 } else { 554 for (i = 0; i < listItemsCount; i += fullRowColumnsCount) { 555 $listItems.slice(i, i + fullRowColumnsCount) 556 .wrapAll('<ul style="' + listStyle + '"></ul>'); 557 } 558 } 559 } 560 561 recreateGrid(); 562 $(window).on('resize', recreateGrid); 563 564 }); 565 566}(jQuery)); 567(function($) { 568 'use strict'; 569 570 $('.mk-edge-slider').find('video').each(function() { 571 this.pause(); 572 this.currentTime = 0; 573 }); 574 575 MK.component.EdgeSlider = function( el ) { 576 var self = this, 577 $this = $( el ), 578 $window = $(window), 579 $wrapper = $this.parent(), 580 config = $this.data( 'edgeslider-config' ), 581 $nav = $( config.nav ), 582 $prev = $nav.find( '.mk-edge-prev' ), 583 $prevTitle = $prev.find( '.nav-item-caption' ), 584 $prevBg = $prev.find('.edge-nav-bg'), 585 $next = $nav.find( '.mk-edge-next' ), 586 $nextTitle = $next.find( '.nav-item-caption' ), 587 $nextBg = $next.find('.edge-nav-bg'), 588 $navBtns = $nav.find( 'a' ), 589 $pagination = $( '.swiper-pagination' ), 590 $skipBtn = $( '.edge-skip-slider' ), 591 $opacityLayer = $this.find('.edge-slide-content'), 592 $videos = $this.find('video'), 593 currentSkin = null, 594 currentPoint = null, 595 winH = null, 596 opacity = null, 597 offset = null; 598 599 var callbacks = { 600 onInitialize : function( slides ) { 601 self.$slides = $( slides ); 602 603 self.slideContents = $.map( self.$slides, function( slide ) { 604 var $slide = $( slide ), 605 title = $slide.find('.edge-slide-content .edge-title').first().text(), 606 skin = $slide.attr("data-header-skin"), 607 image = $slide.find('.mk-section-image').attr('data-thumb') || 608 $slide.find('.mk-video-section-touch').attr('data-thumb'), 609 bgColor = $slide.find('.mk-section-image').css('background-color'); 610 611 612 return { 613 skin: skin, 614 title: title, 615 image: image, 616 bgColor: bgColor 617 }; 618 }); 619 620 // Set position fixed here rather than css to avoid flash of strangely styled slides befor plugin init 621 if(MK.utils.isSmoothScroll) $this.css('position', 'fixed'); 622 623 setNavigationContent( 1, self.$slides.length - 1 ); 624 setSkin( 0 ); 625 // stopVideos(); 626 playVideo(0); 627 628 setTimeout( function() { 629 $( '.edge-slider-loading' ).fadeOut( '100' ); 630 }, 1000 ); 631 }, 632 633 onBeforeSlide : function( id ) { 634 635 }, 636 637 onAfterSlide : function( id ) { 638 setNavigationContent( nextFrom(id), prevFrom(id) ); 639 setSkin( id ); 640 stopVideos(); // stop all others if needed 641 playVideo( id ); 642 } 643 }; 644 645 646 var nextFrom = function nextFrom(id) { 647 return ( id + 1 === self.$slides.length ) ? 0 : id + 1; 648 }; 649 650 651 var prevFrom = function prevFrom(id) { 652 return ( id - 1 === -1 ) ? self.$slides.length - 1 : id - 1; 653 }; 654 655 656 var setNavigationContent = function( nextId, prevId ) { 657 if(self.slideContents[ prevId ]) { 658 $prevTitle.text( self.slideContents[ prevId ].title ); 659 $prevBg.css( 'background', 660 self.slideContents[ prevId ].image !== 'none' ? 661 'url(' + self.slideContents[ prevId ].image + ')' : 662 self.slideContents[ prevId ].bgColor ); 663 } 664 665 if(self.slideContents[ nextId ]) { 666 $nextTitle.text( self.slideContents[ nextId ].title ); 667 $nextBg.css( 'background', 668 self.slideContents[ nextId ].image !== 'none' ? 669 'url(' + self.slideContents[ nextId ].image + ')' : 670 self.slideContents[ nextId ].bgColor ); 671 } 672 }; 673 674 675 var setSkin = function setSkin( id ) { 676 currentSkin = self.slideContents[ id ].skin; 677 678 $navBtns.attr('data-skin', currentSkin); 679 $pagination.attr('data-skin', currentSkin); 680 $skipBtn.attr('data-skin', currentSkin); 681 682 if( self.config.firstEl ) { 683 MK.utils.eventManager.publish( 'firstElSkinChange', currentSkin ); 684 } 685 }; 686 687 688 var stopVideos = function stopVideos() { 689 $videos.each(function() { 690 this.pause(); 691 this.currentTime = 0; 692 }); 693 }; 694 695 696 var playVideo = function playVideo(id) { 697 var video = self.$slides.eq(id).find('video').get(0); 698 if(video) { 699 video.play(); 700 console.log('play video in slide nr ' + id); 701 } 702 703 }; 704 705 706 var onResize = function onResize() { 707 var height = $wrapper.height(); 708 $this.height( height ); 709 710 var width = $wrapper.width(); 711 $this.width( width ); 712 713 winH = $window.height(); 714 offset = $this.offset().top; 715 716 if(!MK.utils.isSmoothScroll) return; 717 if(MK.utils.isResponsiveMenuState()) { 718 // Reset our parallax layers position and styles when we're in responsive mode 719 $this.css({
720 '-webkit-transform': 'translateZ(0)', 721 '-moz-transform': 'translateZ(0)', 722 '-ms-transform': 'translateZ(0)', 723 '-o-transform': 'translateZ(0)', 724 'transform': 'translateZ(0)', 725 'position': 'absolute' 726 }); 727 $opacityLayer.css({ 728 'opacity': 1 729 }); 730 } else { 731 // or proceed with scroll logic when we assume desktop screen 732 onScroll(); 733 } 734 }; 735 736 var onScroll = function onScroll() { 737 currentPoint = - MK.val.scroll(); 738 739 if( offset + currentPoint <= 0 ) { 740 opacity = 1 + ((offset + currentPoint) / winH) * 2; 741 opacity = Math.min(opacity, 1); 742 opacity = Math.max(opacity, 0); 743 744 $opacityLayer.css({ 745 opacity: opacity 746 }); 747 } 748 749 $this.css({ 750 '-webkit-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 751 '-moz-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 752 '-ms-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 753 '-o-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 754 'transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 755 'position': 'fixed' 756 }); 757 }; 758 759 onResize(); 760 $window.on('load', onResize); 761 $window.on('resize', onResize); 762 window.addResizeListener( $wrapper.get(0), onResize ); 763 764 if(MK.utils.isSmoothScroll) { 765 onScroll(); 766 $window.on('scroll', function() { 767 if(MK.utils.isResponsiveMenuState()) return; 768 window.requestAnimationFrame(onScroll); 769 }); 770 } 771 772 this.el = el; 773 this.config = $.extend( config, callbacks ); 774 this.slideContents = null; // cache slide contents 775 776 // Let mk_slider know it's EdgeSlider 777 this.config.edgeSlider = true; 778 }; 779 780 MK.component.EdgeSlider.prototype = { 781 init : function() { 782 // Inherit from Slider. add prototypes if needed 783 var slider = new MK.ui.Slider( this.el, this.config ); 784 slider.init(); 785 } 786 }; 787 788})(jQuery); 789 790(function($) { 791 'use strict'; 792 793 var core = MK.core, 794 path = MK.core.path; 795 796 // TODO: Repair after Rifat. He repeated The same code twice - other same code is in photoalbum (why by the way?!). 797 // Split it into two separate components when you see reusage 798 MK.component.Category = function( el ) { 799 var init = function(){ 800 core.loadDependencies([ path.plugins + 'pixastic.js' ], function() { 801 blurImage($('.blur-image-effect .mk-loop-item .item-holder ')); 802 }); 803 804 core.loadDependencies([ path.plugins + 'minigrid.js' ], masonry); 805 }; 806 807 var blurImage = function($item) { 808 return $item.each(function() { 809 var $_this = $(this); 810 811 var img = $_this.find('.item-thumbnail'); 812 813 img.clone().addClass("blur-effect item-blur-thumbnail").removeClass('item-thumbnail').prependTo(this); 814 815 var blur_this = $(".blur-effect", this); 816 blur_this.each(function(index, element){ 817 if (img[index].complete === true) { 818 Pixastic.process(blur_this[index], "blurfast", {amount:0.5}); 819 } 820 else { 821 blur_this.load(function () { 822 Pixastic.process(blur_this[index], "blurfast", {amount:0.5}); 823 }); 824 } 825 }); 826 }); 827 }; 828
829 // TODO: find other shortcodes like this design and make it as a component 830 var masonry = function() { 831 if(!$('.js-masonry').length) return; 832 833 function grid() { 834 minigrid({ 835 container: '.js-masonry', 836 item: '.js-masonry-item', 837 gutter: 0 838 }); 839 } 840 841 grid(); 842 $(window).on('resize', grid); 843 }; 844 845 return { 846 init : init 847 }; 848 }; 849 850})(jQuery); 851 852 853 854 855 856 857 858 859/* Flickr Feeds */ 860/* -------------------------------------------------------------------- */ 861(function ($) { 862 'use strict'; 863function mk_flickr_feeds() { 864 865 $('.mk-flickr-feeds').each(function() { 866 var $this = $(this), 867 apiKey = $this.attr('data-key'), 868 userId = $this.attr('data-userid'), 869 perPage = $this.attr('data-count'), 870 column = $this.attr('data-column'); 871 872 if ( ! $( '.mk-flickr-feeds' ).is( ':empty' ) ) { 873 return; 874 } 875 876 jQuery.getJSON('https://api.flickr.com/services/rest/?format=json&method=' + 'flickr.photos.search&api_key=' + apiKey + '&user_id=' + userId + '&&per_page=' + perPage + '&jsoncallback=?', function(data) { 877 878 jQuery.each(data.photos.photo, function(i, rPhoto) { 879 var basePhotoURL = 'http://farm' + rPhoto.farm + '.static.flickr.com/' + rPhoto.server + '/' + rPhoto.id + '_' + rPhoto.secret; 880 881 var thumbPhotoURL = basePhotoURL + '_q.jpg'; 882 var mediumPhotoURL = basePhotoURL + '.jpg'; 883 884 var photoStringStart = '<a '; 885 var photoStringEnd = 'title="' + rPhoto.title + '" rel="flickr-feeds" class="mk-lightbox flickr-item jupiter-donut-colitem" href="' + mediumPhotoURL + '"><img src="' + thumbPhotoURL + '" alt="' + rPhoto.title + '"/></a>;'; 886 var photoString = (i < perPage) ? photoStringStart + photoStringEnd : photoStringStart + photoStringEnd; 887 888 jQuery(photoString).appendTo($this); 889 }); 890 }); 891 }); 892 893} 894 mk_flickr_feeds(); 895 $( window ).on( 'vc_reload', mk_flickr_feeds ); 896})(jQuery); 897 898(function ($) { 899 'use strict'; 900 901var init = function init() { 902 $('.mk-faq-wrapper').each( function() { 903 var $this = $(this); 904 var $filter = $this.find('.filter-faq'); 905 var $filterItem = $filter.find('a'); 906 var $faq = $this.find('.mk-faq-container > div'); 907 var currentFilter = ''; 908 909 $filterItem.on('click', function(e) { 910 var $this = $(this); 911 912 currentFilter = $this.data('filter'); 913 $filterItem.removeClass('current'); 914 $this.addClass('current'); 915 916 filterItems( currentFilter ); 917 918 e.preventDefault(); 919 }); 920 921 function filterItems( cat ) { 922 if( cat === '' ) { 923 $faq.slideDown(200).removeClass('hidden'); 924 return; 925 } 926 $faq.not( '.' + cat ).slideUp(200).addClass('hidden'); 927 $faq.filter( '.' + cat ).slideDown(200).removeClass('hidden'); 928 } 929 }); 930} 931init(); 932$(window).on('vc_reload', init); 933 934}( jQuery )); 935jQuery(function($) { 936 937 'use strict'; 938 939 // Get All Related Layers 940 var init = function init() { 941 var $gallery = $('.mk-gallery'); 942 var $imgs = $gallery.find('img[data-mk-image-src-set]'); 943 944 if ( $gallery.hasClass('mk-gallery-lazyload') && $imgs.length ) { 945 946 // Load Images if the user scrolls to them 947 $(window).on('scroll.mk_gallery_lazyload', MK.utils.throttle(500, function(){ 948 $imgs.each(function(index, elem) { 949 if ( MK.utils.isElementInViewport(elem) ) { 950 MK.component.ResponsiveImageSetter.init( $(elem) ); 951 $imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 952 } 953 }); 954 })); 955 956 $(window).trigger('scroll.mk_gallery_lazyload'); 957 958 // Handle the resize 959 MK.component.ResponsiveImageSetter.onResize($imgs); 960 961 } else { 962 963 MK.component.ResponsiveImageSetter.init($imgs); 964 MK.component.ResponsiveImageSetter.onResize($imgs); 965 966 } 967 } 968 969 init(); 970 $(window).on('vc_reload mk-image-loaded', init); 971 972}); 973 974 975 976jQuery(function($) { 977 978 'use strict'; 979 980 // Get All Related Layers
981 var init = function init() { 982 var $image = $('.mk-image'); 983 var $imgs = $image.find('img[data-mk-image-src-set]'); 984 985 if ( $image.hasClass('mk-image-lazyload') && $imgs.length ) { 986 987 // Load Images if the user scrolls to them 988 $(window).on('scroll.mk_image_lazyload', MK.utils.throttle(500, function(){ 989 $imgs.each(function(index, elem) { 990 if ( MK.utils.isElementInViewport(elem) ) { 991 MK.component.ResponsiveImageSetter.init( $(elem) ); 992 $imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 993 } 994 }); 995 })); 996 997 $(window).trigger('scroll.mk_image_lazyload'); 998 999 // Handle the resize 1000 MK.component.ResponsiveImageSetter.onResize($imgs); 1001 1002 } else { 1003 1004 MK.component.ResponsiveImageSetter.init($imgs); 1005 MK.component.ResponsiveImageSetter.onResize($imgs); 1006 1007 } 1008 } 1009 1010 init(); 1011 $(window).on('vc_reload mk-image-loaded', init); 1012 1013}); 1014 1015 1016 1017(function($) { 1018 'use strict'; 1019 1020 function mk_page_title_parallax() { 1021 if (!MK.utils.isMobile()) { 1022 1023 $('.mk-effect-wrapper').each(function() { 1024 var $this = $(this), 1025 progressVal, 1026 currentPoint, 1027 ticking = false, 1028 scrollY = MK.val.scroll(), 1029 $window = $(window), 1030 windowHeight = $(window).height(), 1031 parentHeight = $this.outerHeight(), 1032 startPoint = 0, 1033 endPoint = $this.offset().top + parentHeight, 1034 effectLayer = $this.find('.mk-effect-bg-layer'), 1035 gradientLayer = effectLayer.find('.mk-effect-gradient-layer'), 1036 cntLayer = $this.find('.mk-page-title-box-content'), 1037 animation = effectLayer.attr('data-effect'), 1038 top = $this.offset().top, 1039 height = $this.outerHeight(); 1040 1041 var parallaxSpeed = 0.7, 1042 zoomFactor = 1.3; 1043 1044 var parallaxTopGap = function() { 1045 var gap = top * parallaxSpeed; 1046 1047 effectLayer.css({ 1048 height : height + gap + 'px', 1049 top : (-gap) + 'px' 1050 }); 1051 }; 1052 1053 1054 if (animation == ("parallax" || "parallaxZoomOut") ) { 1055 parallaxTopGap(); 1056 } 1057 1058 var animationSet = function() { 1059 scrollY = MK.val.scroll(); 1060 1061 if (animation == "parallax") { 1062 currentPoint = (startPoint + scrollY) * parallaxSpeed; 1063 effectLayer.get(0).style.transform = 'translateY(' + currentPoint + 'px)'; 1064 } 1065 1066 if (animation == "parallaxZoomOut") { 1067 console.log(effectLayer); 1068 currentPoint = (startPoint + scrollY) * parallaxSpeed; 1069 progressVal = (1 / (endPoint - startPoint) * (scrollY - startPoint)); 1070 var zoomCalc = zoomFactor - ((zoomFactor - 1) * progressVal); 1071 1072 effectLayer.get(0).style.transform = 'translateY(' + currentPoint + 'px) scale(' + zoomCalc + ')'; 1073 } 1074 1075 if (animation == "gradient") { 1076 progressVal = (1 / (endPoint - startPoint) * (scrollY - startPoint)); 1077 gradientLayer.css({ 1078 opacity: progressVal * 2 1079 }); 1080 } 1081 1082 if (animation != "gradient") { 1083 progressVal = (1 / (endPoint - startPoint) * (scrollY - startPoint)); 1084 cntLayer.css({ 1085 opacity: 1 - (progressVal * 4) 1086 }); 1087 } 1088 1089 // Stop ticking 1090 ticking = false; 1091 }; 1092 animationSet(); 1093 1094 // This will limit the calculation of the background position to 1095 // 60fps as well as blocking it from running multiple times at once 1096 var requestTick = function() { 1097 if (!ticking) { 1098 window.requestAnimationFrame(animationSet); 1099 ticking = true; 1100 } 1101 }; 1102 1103 $window.off('scroll', requestTick); 1104 $window.on('scroll', requestTick); 1105 1106 }); 1107 } 1108 } 1109 1110 1111 var $window = $(window); 1112 var debounceResize = null; 1113 1114 $window.on('load', mk_page_title_parallax); 1115 $window.on("resize", function() { 1116 if( debounceResize !== null ) { clearTimeout( debounceResize ); } 1117 debounceResize = setTimeout( mk_page_title_parallax, 300 ); 1118 }); 1119 1120}(jQuery)); 1121 1122(function($) { 1123 'use strict'; 1124 1125 /* Page Section Intro Effects */ 1126 /* -------------------------------------------------------------------- */ 1127 1128 function mk_section_intro_effects() { 1129 if (!MK.utils.isMobile()) { 1130 if (!$.exists('.mk-page-section.intro-true')) return; 1131 1132 $('.mk-page-section.intro-true').each(function() { 1133 var that = this; 1134 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.sectiontrans.js', MK.core.path.plugins + 'tweenmax.js' ], function() { 1135 var $this = $(that), 1136 $pageCnt = $this.parent().nextAll('div'), 1137 windowHeight = $(window).height(), 1138 effectName = $this.attr('data-intro-effect'), 1139 $header = $('.mk-header'); 1140 1141 var effect = { 1142 fade: new TimelineLite({paused: true}) 1143 .set($pageCnt, { opacity: 0, y: windowHeight * 0.3 }) 1144 .to($this, 1, { opacity: 0, ease:Power2.easeInOut }) 1145 .to($pageCnt, 1, { opacity: 1, y: 0, ease:Power2.easeInOut}, "-=.7") 1146 .set($this, { zIndex: '-1'}), 1147 1148 zoom_out: new TimelineLite({paused: true}) 1149 .set($pageCnt, { opacity: 0, y: windowHeight * 0.3}) 1150 .to($this, 1.5, { opacity: .8, scale: 0.8, y: -windowHeight - 100, ease:Strong.easeInOut }) 1151 .to($pageCnt, 1.5, { opacity: 1, y: 0, ease:Strong.easeInOut}, "-=1.3"), 1152 1153 shuffle: new TimelineLite({paused: true}) 1154 .to($this, 1.5, { y: -windowHeight/2, ease:Strong.easeInOut }) 1155 .to($pageCnt.first(), 1.5, { paddingTop: windowHeight/2, ease:Strong.easeInOut }, "-=1.3") 1156 }; 1157 1158 console.log($pageCnt); 1159 1160 1161 $this.sectiontrans({ 1162 effect: effectName 1163 }); 1164 1165 if($this.hasClass('shuffled')) { 1166 TweenLite.set($this, { y: -windowHeight/2 }); 1167 TweenLite.set($this.nextAll('div').first(), { paddingTop: windowHeight/2 }); 1168 } 1169 1170 $('body').on('page_intro', function() { 1171 MK.utils.scroll.disable(); 1172 $(this).data('intro', true); 1173 effect[effectName].play(); 1174 setTimeout(function() { 1175 $header.addClass('pre-sticky'); 1176 $header.addClass('a-sticky'); 1177 $('.mk-header-padding-wrapper').addClass('enable-padding'); 1178 $('body').data('intro', false); 1179 if(effectName === 'shuffle') $this.addClass('shuffled'); 1180 }, 1000); 1181
1182 setTimeout(MK.utils.scroll.enable, 1500); 1183 }); 1184 1185 $('body').on('page_outro', function() { 1186 MK.utils.scroll.disable(); 1187 $(this).data('intro', true); 1188 effect[effectName].reverse(); 1189 setTimeout(function() { 1190 $header.removeClass('pre-sticky'); 1191 $header.removeClass('a-sticky'); 1192 $('.mk-header-padding-wrapper').removeClass('enable-padding'); 1193 $('body').data('intro', false); 1194 if($this.hasClass('shuffled')) $this.removeClass('shuffled'); 1195 }, 1000); 1196 1197 setTimeout(MK.utils.scroll.enable, 1500); 1198 }); 1199 }); 1200 }); 1201 1202 } else { 1203 $('.mk-page-section.intro-true').each(function() { 1204 $(this).attr('data-intro-effect', ''); 1205 }); 1206 } 1207 } 1208 1209 mk_section_intro_effects(); 1210 1211 var debounceResize = null; 1212 $(window).on("resize", function() { 1213 if( debounceResize !== null ) { clearTimeout( debounceResize ); } 1214 debounceResize = setTimeout( mk_section_intro_effects, 300 ); 1215 }); 1216 1217 /* Page Section Adaptive Height */ 1218 /* -------------------------------------------------------------------- */ 1219 1220 function mk_section_adaptive_height() { 1221 $( ".mk-page-section.mk-adaptive-height" ).each( function() { 1222 var imageHeight = $( this ).find( ".mk-adaptive-image" ).height(); 1223 $( this ).css( "height", imageHeight ); 1224 }); 1225 } 1226 1227 $( window ).on( "load resize", mk_section_adaptive_height ); 1228 1229 1230 /* Page Section Image Loader */ 1231 /* -------------------------------------------------------------------- */ 1232 1233 // Get All Related Layers 1234 var init = function init() { 1235 var $allLayers = $('.mk-page-section .background-layer').filter(function(index) { 1236 var isLazyLoad = $(this).attr('data-mk-lazyload') === 'true'; 1237 if ( !isLazyLoad ) { 1238 MK.component.BackgroundImageSetter.init( $(this) ); 1239 } 1240 return isLazyLoad; 1241 });; 1242 1243 // Load BG Images if the user scroll to them 1244 if ( $allLayers.length ) { 1245 1246 $(window).on('scroll.mk_page_section_lazyload', MK.utils.throttle(500, function(){ 1247 $allLayers.each(function(index, elem) { 1248 if ( MK.utils.isElementInViewport(elem) ) { 1249 MK.component.BackgroundImageSetter.init( $(elem) ); 1250 $allLayers = $allLayers.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 1251 } 1252 }); 1253 })); 1254 1255 // First init 1256 $(window).trigger('scroll.mk_page_section_lazyload'); 1257 1258 // Handle the resize 1259 MK.component.BackgroundImageSetter.onResize($allLayers); 1260 1261 } 1262 } 1263 init(); 1264 1265 $(window).on('vc_reload', init); 1266 1267 /* Page Section Layout */ 1268 /* -------------------------------------------------------------------- */ 1269 1270 function mk_section_half_layout() { 1271 $(".mk-page-section.half_boxed").each(function() { 1272 var $section = $(this); 1273 if ($(window).width() > jupiterDonutVars.gridWidth) { 1274 var margin = ($(window).width() - jupiterDonutVars.gridWidth) / 2; 1275 var $section_inner = $section.find('.mk-half-layout-inner'); 1276 if($section.hasClass('half_left_layout')){ 1277 $section_inner.css({ 1278 marginRight: margin + 'px' 1279 }); 1280 } 1281 if($section.hasClass('half_right_layout')){ 1282 $section_inner.css({ 1283 marginLeft: margin + 'px' 1284 }); 1285 } 1286 } 1287 }); 1288 } 1289 1290 $(window).on("load resize", mk_section_half_layout); 1291 1292 /* Page Section - Fluid Width Equal Height Columns */ 1293 /* -------------------------------------------------------------------- */ 1294 function mk_reset_section_fluid_width_equal_height_columns() { 1295 var $colWrappers = '', maxWidth = 850; 1296 1297 $colWrappers = $('.page-section-content.fluid-width-equal-height-columns'); 1298 1299 $colWrappers.each(function() { 1300 var $colWrapper = '', colHeight = 0; 1301 $colWrapper = $(this); 1302 $colWrapper.find('.wpb_column.column_container').each(function() { 1303 var $col = $(this), size = $(this).children('div').length; 1304 if (size > 0) { 1305 $col.removeAttr("style"); 1306 $col.children('div').each(function() { 1307 var $this = $( this ); 1308 /** 1309 * Fix Advanced Google Maps (AGM) issue on page section. 1310 * 1311 * Problem: AGM set the height as inline CSS property (style attribute). 1312 * In this case, the style attribute will be removed before checking the 1313 * elements height in each of the column. That's why AGM container will 1314 * loose the height and the map can't be displayed properly (only 1px) 1315 * because it overlap other row in the page. We need to check if current 1316 * element is AGM or not before removing style attribute of the element. 1317 */ 1318 if ( ! $this.hasClass( 'mk-advanced-gmaps' ) ) { 1319 $this.removeAttr( 'style' ); 1320 } 1321 }); 1322 } 1323 }); 1324 }); 1325 } 1326 1327 function mk_section_fluid_width_equal_height_columns() { 1328 mk_reset_section_fluid_width_equal_height_columns(); 1329 1330 var $colWrappers = '', maxWidth = 850, $pageSection = $('.page-section-content'); 1331 1332 if ( ! $pageSection.hasClass('.fluid-width-equal-height-columns') ) { 1333 $pageSection.find('.wpb_column.column_container').removeAttr( 'style' ); 1334 $pageSection.find('.wpb_column.column_container .vc_element').removeAttr( 'style' ); 1335 } 1336 1337 $colWrappers = $('.page-section-content.fluid-width-equal-height-columns'); 1338 1339 $colWrappers.each(function() { 1340 var $colWrapper = '', colHeight = 0; 1341 $colWrapper = $(this); 1342 1343 if ($colWrapper.length > 0) { 1344 /* Get the minimum height of the wrapper */ 1345 colHeight = $colWrappers.outerHeight(true); 1346 $colWrapper.find('.wpb_column.column_container').each(function() { 1347 var $col = $(this); 1348 if ($col.length > 0) { 1349 colHeight = ($col.outerHeight(true) > colHeight) ? $col.outerHeight(true) : colHeight; 1350 } 1351 }); 1352 } 1353 1354 if (colHeight > 0) { 1355 $colWrapper.find('.wpb_column.column_container').each(function() { 1356 var $col = $(this), size = $(this).children('div').length; 1357 if (size > 0) { 1358 colHeight = ($(window).width() < maxWidth) ? 'initial' : colHe
1358ight; 1359 $col.css("height", colHeight); 1360 if ($colWrapper.hasClass('vertical-align-center')) { 1361 $col.children('div').each(function() { 1362 var elHeight = ($(window).width() < maxWidth) ? 'initial' : (colHeight/size); 1363 /** 1364 * Fix Advanced Google Maps (AGM) issue on page section. 1365 */ 1366 if ( ! $(this).hasClass( 'mk-advanced-gmaps' ) ) { 1367 $(this).css("height", elHeight); 1368 } 1369 }); 1370 } 1371 } 1372 }); 1373 } 1374 }); 1375 } 1376 $(window).on('load vc_reload', function() { 1377 setTimeout(function() { 1378 /* 1379 Somehow the values are not correctly updated for the screens 1380 and we need to put setTimeout to fix the issue. 1381 */ 1382 mk_section_fluid_width_equal_height_columns(); 1383 }, 500); 1384 }); 1385 1386 var debounceResize = null; 1387 $(window).on("resize", function() { 1388 if( debounceResize !== null ) { clearTimeout( debounceResize ); } 1389 debounceResize = setTimeout( mk_section_fluid_width_equal_height_columns(), 500 ); 1390 }); 1391 1392}(jQuery)); 1393 1394jQuery(document).ready(function( $ ) { 1395 1396 // Continue only on Safari. 1397 if ( typeof window.safari === 'undefined' ) { 1398 return; 1399 } 1400 1401 // Fore redraw for Safari. This is a hack. 1402 function mkRedraw() { 1403 $('.mk-photo-roller').hide().show(0); 1404 } 1405 1406 mkRedraw(); 1407 1408 $( window ).resize( function() { 1409 mkRedraw() 1410 } ); 1411 1412}); 1413(function($) { 1414 'use strict'; 1415 var utils = MK.utils, 1416 core = MK.core, 1417 path = MK.core.path; 1418 MK.component.PhotoAlbum = function(el) { 1419 this.album = el; 1420 this.initialOpen = false; 1421 }; 1422 MK.component.PhotoAlbum.prototype = { 1423 dom: { 1424 gallery: '.slick-slider-wrapper', 1425 title: '.slick-title', 1426 galleryContainer: '.slick-slides', 1427 closeBtn: '.slick-close-icon', 1428 thumbList: '.slick-dots', 1429 thumbs: '.slick-dots li', 1430 imagesData: 'photoalbum-images', 1431 titleData: 'photoalbum-title', 1432 idData: 'photoalbum-id', 1433 urlData: 'photoalbum-url', 1434 activeClass: 'is-active' 1435 }, 1436 tpl: { 1437 gallery: '#tpl-photo-album', 1438 slide: '<div class="slick-slide"></div>' 1439 }, 1440 init: function() { 1441 this.cacheElements(); 1442 this.bindEvents(); 1443 this.openByLink(); 1444 }, 1445 cacheElements: function() { 1446 this.$album = $(this.album); 1447 this.imagesSrc = this.$album.data(this.dom.imagesData); 1448 this.albumLength = this.imagesSrc.length; 1449 this.title = this.$album.data(this.dom.titleData); 1450 this.id = this.$album.data(this.dom.idData); 1451 this.url = this.$album.data(this.dom.urlData); 1452 this.images = []; // stores dom objects to insert into gallery instance 1453 }, 1454 bindEvents: function() { 1455 this.$album.not('[data-photoalbum-images="[null]"]').on('click', this.albumClick.bind(this)); 1456 $(document).on('click', this.dom.closeBtn, this.closeClick.bind(this)); 1457 $(window).on('resize', this.thumbsVisibility.bind(this)); 1458 $(window).on('resize', this.makeArrows.bind(this)); 1459 }, 1460 albumClick: function(e) { 1461 e.preventDefault(); 1462 this.open(); 1463 MK.ui.loader.add(this.album); 1464 }, 1465 closeClick: function(e) { 1466 e.preventDefault(); 1467 // Because one close btn rules them all 1468 if (this.slider) { 1469 this.removeGallery(); 1470 this.slider.exitFullScreen(); 1471 } 1472 }, 1473 thumbsVisibility: function() { 1474 if (!this.thumbsWidth) return; 1475 if (window.matchMedia('(max-width:' + (this.thumbsWidth + 260) + 'px)').matches) this.hideThumbs(); // 260 is 2 * 120 - right corner buttons width + scrollbar 1476 else this.showThumbs(); 1477 }, 1478 hideThumbs: function() { 1479 if (!this.$thumbList) return; 1480 this.$thumbList.hide(); 1481 }, 1482 showThumbs: function() { 1483 if (!this.$thumbList) return; 1484 this.$thumbList.show(); 1485 }, 1486 open: function() { 1487 var self = this; 1488 core.loadDependencies([path.plugins + 'slick.js'], function() { 1489 self.createGallery(); 1490 self.loadImages(); 1491 }); 1492 }, 1493 createGallery: function() { 1494 // only one per page 1495 if (!$(this.dom.gallery).length) { 1496 var tpl = $(this.tpl.gallery).eq(0).html(); 1497 $('body').append(tpl); 1498 } 1499 // and cache obj 1500 this.$gallery = $(this.dom.gallery); 1501 this.$closeBtn = $(this.dom.closeBtn); 1502 }, 1503 createSlideshow: function() { 1504 var self = this; 1505 this.slider = new MK.ui.FullScreenGallery(this.dom.galleryContainer, { 1506 id: this.id, 1507 url: this.url 1508 }); 1509 this.slider.init(); 1510 $(window).trigger('resize'); 1511 this.makeArrows(); 1512 this.$thumbList = $(this.dom.thumbList); 1513 this.$thumbs = $(this.dom.thumbs); 1514 this.thumbsWidth = (this.$thumbs.length) * 95; 1515 this.thumbsVisibility(); 1516 setTimeout(function() { 1517 MK.ui.loader.remove(self.album); 1518 }, 100); 1519 MK.utils.eventManager.publish('photoAlbum-open'); 1520 }, 1521 makeArrows: function() { 1522 if (this.arrowsTimeout) clearTimeout(this.arrowsTimeout); 1523 this.arrowsTimeout = setTimeout(function() { 1524 var $prev = $('.slick-prev').find('svg'); 1525 var $next = $('.slick-next').find('svg'); 1526 $prev.wrap('<div class="slick-nav-holder"></div>'); 1527 $next.wrap('<div class="slick-nav-holder"></div>'); 1528 if (matchMedia("(max-width: 1024px)").matches) { 1529 $prev.attr({ 1530 width: 12, 1531 height: 22 1532 }).find('polyline').attr('points', '12,0 0,11 12,22'); 1533 $next.attr({ 1534 width: 12, 1535 height: 22 1536 }).find('polyline').attr('points', '0,0 12,11 0,22'); 1537 } else { 1538 $prev.attr({ 1539 width: 33, 1540 height: 65 1541 }).find('polyline').attr('points', '0.5,0.5 32.5,32.5 0.5,64.5'); 1542 $next.attr({ 1543 width: 33, 1544 height: 65 1545 }).find('polyline').attr('points', '0.5,0.5 32.5,32.5 0.5,64.5'); 1546 } 1547 }, 0); 1548 }, 1549 loadImages: function() { 1550 var self = this, 1551 n = 0; 1552 // cache images on first load. 1553 if (!this.images.length) {
1554 this.imagesSrc.forEach(function(src) { 1555 if (src === null) return; // protect from nulls 1556 var img = new Image(); 1557 img.onload = function() { 1558 self.onLoad(n += 1); 1559 }; 1560 img.src = src; 1561 self.images.push(img); 1562 }); 1563 } else { 1564 this.onLoad(this.albumLength); 1565 } 1566 }, 1567 onLoad: function(n) { 1568 if (n === this.albumLength) { 1569 this.insertImages(); 1570 this.showGallery(); 1571 this.createSlideshow(); 1572 } 1573 }, 1574 insertImages: function() { 1575 var $galleryContainer = this.$gallery.find(this.dom.galleryContainer), 1576 $title = $(this.dom.title), 1577 slide = this.tpl.slide; 1578 // clear first 1579 $galleryContainer.html(''); 1580 $title.html(this.title); 1581 this.images.forEach(function(img) { 1582 var $slide = $(slide); 1583 $slide.html(img); 1584 $galleryContainer.prepend($slide); 1585 }); 1586 }, 1587 showGallery: function() { 1588 var self = this; 1589 this.$gallery.addClass(this.dom.activeClass); 1590 utils.scroll.disable(); 1591 }, 1592 removeGallery: function() { 1593 var self = this; 1594 this.$gallery.removeClass(this.dom.activeClass); 1595 setTimeout(function() { 1596 self.$gallery.remove(); 1597 }, 300); 1598 utils.scroll.enable(); 1599 }, 1600 openByLink: function() { 1601 var loc = window.location, 1602 hash = loc.hash, 1603 id; 1604 if (hash.length && hash.substring(1).length) { 1605 id = hash.substring(1); 1606 id = id.replace('!loading', ''); 1607 if (id == this.id && !this.initialOpen) { 1608 this.initialOpen = true; 1609 this.open(); 1610 } 1611 } 1612 } 1613 }; 1614 // Barts note; Rifat duplication and coupling here. Remove it when have time 1615 MK.component.PhotoAlbumBlur = function(el) { 1616 var init = function() { 1617 core.loadDependencies([path.plugins + 'pixastic.js'], function() { 1618 blurImage($('.mk-album-item figure')); 1619 }); 1620 }; 1621 var blurImage = function($item) { 1622 return $item.each(function() { 1623 var $_this = $(this); 1624 var img = $_this.find('.album-cover-image'); 1625 img.clone().addClass("blur-effect item-blur-thumbnail").removeClass('album-cover-image').prependTo(this); 1626 var blur_this = $(".blur-effect", this); 1627 blur_this.each(function(index, element) { 1628 if (img[index].complete === true) { 1629 Pixastic.process(blur_this[index], "blurfast", { 1630 amount: 0.5 1631 }); 1632 } else { 1633 blur_this.load(function() { 1634 Pixastic.process(blur_this[index], "blurfast", { 1635 amount: 0.5 1636 }); 1637 }); 1638 } 1639 }); 1640 }); 1641 }; 1642 return { 1643 init: init 1644 }; 1645 }; 1646})(jQuery); 1647 1648jQuery(document).ready(function($) { 1649 'use strict'; 1650 /** 1651 * Get dynamic width of items for passing in `flexslider()`. 1652 * @param string style Style of the carousel, classic/modern 1653 * @param integer showItems Number of items to show 1654 * @param integer id ID of the carousel 1655 * @return interger The width for items 1656 */ 1657 function get_item_width(style, showItems, id) { 1658 var item_width; 1659 if (style == "classic") { 1660 item_width = 275; 1661 items_to_show = 4; 1662 } else { 1663 var screen_width = $('#portfolio-carousel-' + id).width(), 1664 items_to_show = showItems; 1665 if (screen_width >= 1100) { 1666 item_width = screen_width / items_to_show; 1667 } else if (screen_width <= 1200 && screen_width >= 800) { 1668 item_width = screen_width / 3; 1669 } else if (screen_width <= 800 && screen_width >= 540) { 1670 item_width = screen_width / 2; 1671 } else { 1672 item_width = screen_width; 1673 } 1674 } 1675 return item_width; 1676 } 1677 jQuery(window).on("load vc_reload", function() { 1678 MK.core.loadDependencies([MK.core.path.plugins + 'jquery.flexslider.js'], function() { 1679 1680 $('.portfolio-carousel .mk-flexslider').each(function() { 1681 var $this = $(this); 1682 var $pauseOnHover = $this.attr('data-pauseOnHover') == "true" ? true : false;
1683 var $slideshow = $this.attr('data-slideshow') == "true" ? true : false; 1684 1685 $this.flexslider({ 1686 selector: ".mk-flex-slides > li", 1687 animation: "slide", 1688 slideshowSpeed: parseInt($this.attr('data-slideshowSpeed')), 1689 animationSpeed: parseInt($this.attr('data-animationSpeed')), 1690 pauseOnHover: $pauseOnHover, 1691 controlNav: false, 1692 smoothHeight: false, 1693 useCSS: false, 1694 directionNav: $this.data('directionNav'), 1695 prevText: "", 1696 nextText: "", 1697 itemWidth: get_item_width($this.data('style'), $this.data('showItems'), $this.data('id')), 1698 itemMargin: 0, 1699 maxItems: ($this.data('style') === 'modern') ? $this.data('showItems') : 4, 1700 minItems: 1, 1701 move: 1, 1702 slideshow: $slideshow, 1703 }); 1704 }); // End each(). 1705 }); // End loadDependencies(). 1706 }); // End on(). 1707}); 1708 1709jQuery(function($) { 1710 1711 'use strict'; 1712 1713 // Get All Related Layers 1714 var init = function init() { 1715 var $portfolio = $('.portfolio-grid'); 1716 var $imgs = $portfolio.find('img[data-mk-image-src-set]'); 1717 1718 if ( $portfolio.hasClass('portfolio-grid-lazyload') && $imgs.length ) { 1719 1720 // Load Images if the user scrolls to them 1721 $(window).on('scroll.mk_portfolio_lazyload', MK.utils.throttle(500, function(){ 1722 $imgs.each(function(index, elem) { 1723 if ( MK.utils.isElementInViewport(elem) ) { 1724 MK.component.ResponsiveImageSetter.init( $(elem) ); 1725 $imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 1726 } 1727 }); 1728 })); 1729 1730 $(window).trigger('scroll.mk_portfolio_lazyload'); 1731 1732 // Handle the resize 1733 MK.component.ResponsiveImageSetter.onResize($imgs); 1734 1735 } else { 1736 1737 MK.component.ResponsiveImageSetter.init($imgs); 1738 MK.component.ResponsiveImageSetter.onResize($imgs); 1739 1740 } 1741 } 1742 1743 init(); 1744 $(window).on('vc_reload mk-image-loaded', function(){ 1745 init(); 1746 1747 $('.mk-portfolio-container').each(function(){ 1748 var id = $(this).attr('id'); 1749 var el = '#' + id + '.mk-portfolio-container.js-el'; 1750 1751 if($(this).data('mk-component') == 'Grid') { 1752 // Disable VC frontend component init for portfolio. 1753 $(el).data('init-Grid', true); 1754 1755 // Init Grid component on shortcode render. 1756 var component = new MK.component[ 'Grid' ]( el ); 1757 component.init(); 1758 } 1759 }); 1760 1761 }); 1762 1763}); 1764 1765 1766 1767(function($) { 1768 if (window.addEventListener) { 1769 window.addEventListener('load', handleLoad, false); 1770 } 1771 else if (window.attachEvent) { 1772 window.attachEvent('onload', handleLoad); 1773 } 1774 1775 function handleLoad() { 1776 $('.mk-slideshow-box').each(run); 1777 } 1778 1779 function run() { 1780 var $slider = $(this); 1781 1782 var $slides = $slider.find('.mk-slideshow-box-item'); 1783 var $transition_time = $slider.data('transitionspeed'); 1784 var $time_between_slides = $slider.data('slideshowspeed'); 1785 1786 $slider.find('.mk-slideshow-box-content').children('p').filter(function() { 1787 if ( $.trim($(this).text()) == '' ) { 1788 return true; 1789 } 1790 }).remove(); 1791 1792 // set active classes 1793 $slides.first().addClass('active').fadeIn($transition_time, function(){ 1794 setTimeout(autoScroll, $time_between_slides); 1795 }); 1796 1797 // auto scroll 1798 function autoScroll(){ 1799 var $i = $slider.find('.active').index(); 1800 $slides.eq($i).removeClass('active').fadeOut($transition_time); 1801 if ($slides.length == $i + 1) $i = -1; // loop to start 1802 $slides.eq($i + 1).addClass('active').fadeIn($transition_time, function() { 1803 setTimeout(autoScroll, $time_between_slides); 1804 }); 1805 } 1806 1807 /** 1808 * Need to set the height manually as min-height property doesn't work with display 1809 * table and table-cell in Firefox and Safari. We use Javascript to set them only 1810 * for Firefox and Safari to avoid any problem with Chrome users. The problem is only 1811 * happen when the window screen size bigger than 850px. 1812 */ 1813 var browserName = MK.utils.browser.name; 1814 if ( browserName === 'Firefox' || browserName === 'Safari' ) { 1815 var currentWidth = parseInt( $( window ).width() ); 1816 if ( currentWidth >= 850 ) { 1817 var height = $slider.css( 'min-height' ); 1818 if ( typeof height !== 'undefined' ) { 1819 $slider.find( '.mk-slideshow-box-items' ).height( parseInt( height ) ); 1820 } 1821 } else { 1822 $slider.find( '.mk-slideshow-box-items' ).removeAttr( 'style' ); 1823 } 1824 } 1825 } 1826 $(window).on('vc_reload', function(){ 1827 handleLoad(); 1828 }); 1829 1830 // Handle resize event only for Safari and Firefox. 1831 window.addEventListener( 'resize', function(){ 1832 var browserName = MK.utils.browser.name; 1833 if ( browserName === 'Firefox' || browserName === 'Safari' ) { 1834 handleLoad(); 1835 } 1836 }, true); 1837}(jQuery)); 1838 1839(function($) { 1840 'use strict'; 1841 1842 $(".mk-subscribe").each(function() { 1843 var $this = $(this); 1844 1845 $this.find('.mk-subscribe--form').submit(function(e){ 1846 $this.addClass('form-in-progress'); 1847 e.preventDefault(); 1848 $.ajax({ 1849 url: MK.core.path.ajaxUrl, 1850 type: "POST", 1851 data: { 1852 action: "mk_ajax_subscribe", 1853 email: $this.find(".mk-subscribe--email").val(), 1854 list_id: $this.find(".mk-subscribe--list-id").val(), 1855 optin: $this.find(".mk-subscribe--optin").val() 1856 }, 1857 success: function (response) { 1858 console.log(response) 1859 $this.removeClass('form-in-progress'); 1860 var data = $.parseJSON(response), 1861 $messaage_box = $this.find(".mk-subscribe--message"); 1862 1863 $messaage_box.html(data.message); 1864 1865 if(data.action_status == true) { 1866 $messaage_box.addClass('success'); 1867 } else { 1868 $messaage_box.addClass('error'); 1869 } 1870 1871 $this.find(".mk-subscribe--email").val(''); 1872 1873 } 1874 }); 1875 }); 1876 }); 1877 1878}(jQuery)); 1879 1880(function( $ ) { 1881 'use strict'; 1882 1883 // If we want to get access to API of already initilised component we run a regular new conctructor. 1884 // When instance is discovered in cache object then we return exisiting instance. 1885 // 1886 // TODO move it to core functions and run logic on init
1887 // var init = function init() { 1888 var _instancesCollection = {}; 1889 1890 var MK = window.MK || {}; 1891 window.MK = MK; 1892 MK.component = window.MK.component || {}; 1893 1894 MK.component.SwipeSlideshow = function( el ) { 1895 var $this = $( el ); 1896 var id = $this.parent().attr('id'); 1897 1898 this.el = el; 1899 this.id = id; 1900 this.config = $this.data( 'swipeslideshow-config' ); 1901 if( this.config ) this.config.hasPagination = false; 1902 }; 1903 1904 MK.component.SwipeSlideshow.prototype = { 1905 init : function() { 1906 var slider = new MK.ui.Slider( this.el, this.config ); 1907 slider.init(); 1908 1909 _instancesCollection[ this.id ] = slider; 1910 } 1911 }; 1912 1913 1914 // Additional nav 1915 // Mostly for thumbs in woocommerce 1916 MK.component.SwipeSlideshowExtraNav = function( el ) { 1917 this.el = el; 1918 }; 1919 1920 MK.component.SwipeSlideshowExtraNav.prototype = { 1921 init : function init() { 1922 this.cacheElements(); 1923 this.bindEvents(); 1924 }, 1925 1926 cacheElements : function cacheElements() { 1927 var $this = $( this.el ); 1928 1929 this.sliderId = $this.data( 'gallery' ); 1930 this.slider = _instancesCollection[this.sliderId]; 1931 this.$thumbs = $( '#' + this.sliderId ).find( '.thumbnails a'); 1932 }, 1933 1934 bindEvents : function bindEvents() { 1935 this.$thumbs.on( 'click', this.clickThumb.bind( this ) ); 1936 }, 1937 1938 clickThumb : function clickThumb( e ) { 1939 e.preventDefault(); 1940 var $this = $( e.currentTarget ), 1941 id = $this.index(); 1942 1943 this.slider.goTo( id ); 1944 } 1945 }; 1946 1947 1948 // Mostly for switcher in woocommerce 1949 MK.utils.eventManager.subscribe('gallery-update', function(e, config) { 1950 if(typeof _instancesCollection[config.id] === 'undefined') return; 1951 _instancesCollection[config.id].reset(); 1952 }); 1953 1954 function init() { 1955 // Lazy load. 1956 // Get All Related Layers 1957 var $swiper = $('.mk-slider'); 1958 1959 if ( ! $swiper.hasClass('mk-slideshow') && ! $swiper.hasClass('mk-swipe-slideshow') ) { 1960 return; 1961 } 1962 1963 var $imgs = $swiper.find('img[data-mk-image-src-set]'); 1964 1965 if ( $swiper.hasClass('mk-swipe-slideshow-lazyload') && $imgs.length ) { 1966 1967 // Load Images if the user scrolls to them 1968 $(window).on('scroll.mk_swipe_slideshow_lazyload', MK.utils.throttle(500, function(){ 1969 $imgs.each(function(index, elem) { 1970 if ( MK.utils.isElementInViewport(elem) ) { 1971 MK.component.ResponsiveImageSetter.init( $(elem) ); 1972 $imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each() 1973 } 1974 }); 1975 })); 1976 1977 $(window).trigger('scroll.mk_swipe_slideshow_lazyload'); 1978 1979 // Handle the resize 1980 MK.component.ResponsiveImageSetter.onResize($imgs); 1981 1982 } else { 1983 1984 MK.component.ResponsiveImageSetter.init($imgs); 1985 MK.component.ResponsiveImageSetter.onResize($imgs); 1986 1987 } 1988 1989 /* Why we need to reinitialize it? it causes double sliding effect 1990 $( '.mk-swiper-container' ).each( function() { 1991 new MK.component.SwipeSlideshow( this ).init(); 1992 } ); 1993 */ 1994 1995 } 1996 1997 init(); 1998 $(window).on('vc_reload mk-image-loaded', init); 1999 2000})( jQuery ); 2001 2002(function($) { 2003 'use strict'; 2004 2005 var core = MK.core, 2006 path = core.path; 2007 2008 MK.component.Tooltip = function(el) { 2009 var init = function() { 2010 $('.mk-tooltip').each(function() { 2011 $(this).find('.mk-tooltip--link').hover(function() { 2012 $(this).siblings('.mk-tooltip--text').stop(true).animate({ 2013 'opacity': 1 2014 }, 400); 2015 2016 }, function() { 2017 $(this).siblings('.mk-tooltip--text').stop(true).animate({ 2018 'opacity': 0 2019 }, 400); 2020 }); 2021 }); 2022 }; 2023 2024 return { 2025 init: init 2026 }; 2027 }; 2028 2029})(jQuery); 2030 2031(function( $ ) { 2032 'use strict'; 2033 2034 /** 2035 * Fix issue with WC Recent Carousel classic style when SC is active. 2036 * At the first load of shortcode, the height is not correct, only cover the image 2037 * without product detail. This script only set the min-height. 2038 */ 2039 function mkWcCarouselSwiperHeight() { 2040 var mkWCRecentCarousel = $( '.mk-woocommerce-carousel.classic-style' ); 2041 mkWCRecentCarousel.each( function() { 2042 var maxHeight = 0; 2043 var height = $( this ).height(); 2044 var childs = $( this ).find( '.item' ); 2045 childs.each( function(){ 2046 if ( $( this ).height() > maxHeight ) { 2047 maxHeight = $( this ).height(); 2048 } 2049 } ); 2050 var swiperContainers = $( this ).find( '.mk-swiper-container' ); 2051 swiperContainers[0].style.setProperty( 'min-height', maxHeight + 'px', 'important' ); 2052 } ); 2053 } 2054 2055 mkWcCarouselSwiperHeight(); 2056 2057}
2057)( jQuery ); 2058(function ($) { 2059 'use strict'; 2060 2061 function dynamicHeight() { 2062 var $this = $( this ); 2063 2064 $this.height( 'auto' ); 2065 2066 if( window.matchMedia( '(max-width: 767px)' ).matches ) { 2067 return; 2068 } 2069 2070 $this.height( $this.height() ); 2071 } 2072 2073 var $window = $( window ); 2074 var container = document.getElementById( 'mk-theme-container' ); 2075 2076 function equalColumns() { 2077 $( '.equal-columns' ).each( function() { 2078 dynamicHeight.bind( this ); 2079 $window.on( 'load', dynamicHeight.bind( this ) ); 2080 $window.on( 'resize', dynamicHeight.bind( this ) ); 2081 $window.on( 'mk-image-loaded', dynamicHeight.bind( this ) ); 2082 window.addResizeListener( container, dynamicHeight.bind( this ) ); 2083 }); 2084 } 2085 2086 equalColumns(); 2087 2088 $window.on( 'vc_reload' , function() { 2089 equalColumns(); 2090 }); 2091 2092}( jQuery )); 2093 2094(function($) { 2095 'use strict'; 2096 2097 function mk_video_play() { 2098 2099 var lightboxMargin = 60; 2100 2101 // Play self hosted video 2102 function playSelfHosted($video, isLightbox) { 2103 if (isLightbox === undefined || typeof isLightbox === 'undefined') { 2104 isLightbox = false; 2105 } 2106 2107 if (isLightbox) { 2108 2109 var content = $video.parent().html(); 2110 2111 playLightbox({ 2112 content: '<div class="fancybox-video">' + $(content).attr('autoplay', 'autoplay').wrap('<div></div>').parent().html() + '</div>', 2113 }); 2114 2115 } else { 2116 playTagVideo($video); 2117 } 2118 } 2119 2120 // Play social hosted video 2121 function playSocialHosted($iframe, isLightbox) { 2122 2123 if (isLightbox === undefined || typeof isLightbox === 'undefined') { 2124 isLightbox = false; 2125 } 2126 2127 if (isLightbox) { 2128 2129 playLightbox({ 2130 type: 'iframe', 2131 src: $iframe.attr('src'), 2132 }); 2133 2134 } else { 2135 2136 var videoData = getSocialVideoData($iframe.attr('src')); 2137 2138 switch (videoData.source) { 2139 case 'youtube': 2140 playTagIframeYoutube(videoData.videoId, $iframe); 2141 break; 2142 case 'vimeo': 2143 playTagIframeVimeo(videoData.videoId, $iframe); 2144 break; 2145 default: 2146 playTagIframe($iframe); 2147 break; 2148 } 2149 } 2150 } 2151 2152 // Play video in lightbox 2153 function playLightbox(args) { 2154 var options = { 2155 autoSize: 0, 2156 width: getVideoboxWidth(), 2157 height: getVideoHeight(), 2158 }; 2159 $.extend(options, args); 2160 $.fancybox.open(options); 2161 } 2162 2163 function playTagVideo($video) { 2164 $video.get(0).play(); 2165 $video.closest('.video-container').find('.video-thumbnail').fadeOut('slow'); 2166 } 2167 2168 function playTagIframe($iframe, videoId) { 2169 var video_loop = ''; 2170 if (videoId !== undefined && typeof videoId !== 'undefined') { 2171 video_loop = '&playlist=' + videoId; 2172 } 2173 2174 var src = $iframe.attr('src'); 2175 var separator = (src.indexOf('?') === -1) ? '?' : '&'; 2176 src += separator + 'autoplay=1'; 2177 separator = (src.indexOf('?') === -1) ? '?' : '&'; 2178 video_loop = separator + 'loop=1' + video_loop; 2179 video_loop = ( $iframe.closest('.video-container').data('loop') == '1' ) ? video_loop : ''; 2180 src += video_loop; 2181 $iframe.attr('src', src).closest('.video-container').find('.video-thumbnail').fadeOut(3000); 2182 } 2183 2184 function playTagIframeYoutube(videoId, $iframe) { 2185 2186 // Credit: https://goo.gl/ku3NgH 2187 if ( document.getElementById('mk_iframe_api') === null ) { 2188 var tag = document.createElement('script'); 2189 tag.src = "https://www.youtube.com/iframe_api"; 2190 tag.id = "mk_iframe_api"; 2191 var firstScriptTag = document.getElementsByTagName('script')[0]; 2192 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 2193 } else { 2194 runPlayer(); 2195 } 2196 2197 window.onYouTubeIframeAPIReady = function () { 2198 runPlayer(); 2199 }; 2200 2201 function runPlayer(){ 2202 var player, 2203 isPlayed = false; 2204 2205 player = new YT.Player('video-player-' + $iframe.data('id'), { 2206 videoId: videoId, 2207 rel: false, 2208 events: { 2209 onReady: function(e) { 2210 e.target.playVideo(); 2211 }, 2212 onStateChange: function(e) { 2213 let $playerWrapper = $('#video-player-' + $iframe.data('id')) 2214 2215 if (e.data === 1 && !isPlayed) { 2216 $playerWrapper.closest('.video-container').find('.video-thumbnail').fadeOut('slow'); 2217 isPlayed = true; 2218 } 2219 2220 if ($playerWrapper.closest('.video-container').data('loop') && e.data === YT.PlayerState.ENDED) { 2221 e.target.playVideo(); 2222 } 2223 }, 2224 onError: function(e) { 2225 playTagIframe($iframe, videoId); 2226 } 2227 } 2228 }); 2229 } 2230 } 2231 2232 function playTagIframeVimeo(videoId, $iframe) { 2233 // Embed async the vimeo API script 2234 $.getScript('//player.vimeo.com/api/player.js', function(data, textStatus, jqxhr) { 2235 if (jqxhr.status === 200) { 2236 2237 var player, 2238 isPlayed = false;
2239 2240 player = new Vimeo.Player('video-player-' + $iframe.data('id'), { 2241 id: videoId 2242 }); 2243 2244 player.play().then(function() { 2245 if (!isPlayed) { 2246 $iframe.closest('.video-container').find('.video-thumbnail').fadeOut('slow'); 2247 isPlayed = true; 2248 } 2249 }).catch(function(error) { 2250 playTagIframe($iframe); 2251 }); 2252 2253 if ($iframe.closest('.video-container').data('loop')) { 2254 player.setLoop(true).then(function(loop) { 2255 // Enable loop 2256 }).catch(function(error) { 2257 playTagIframe($iframe); 2258 }); 2259 } 2260 2261 } else { 2262 playTagIframe($iframe); 2263 } 2264 }); 2265 } 2266 2267 // Get Social Provider Video Data 2268 function getSocialVideoData(url) { 2269 2270 // Get Youtube video data 2271 var youtubeRegex = /(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i; 2272 var youtubeMatch = url.match(youtubeRegex); 2273 if (youtubeMatch && youtubeMatch != null) { 2274 return { 2275 source: 'youtube', 2276 videoId: youtubeMatch[3] 2277 }; 2278 } 2279 2280 // Get Vimeo video data 2281 var vimeoRegex = /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/i; 2282 var vimeoMatch = url.match(vimeoRegex); 2283 if (vimeoMatch && vimeoMatch != null) { 2284 return { 2285 source: 'vimeo', 2286 videoId: vimeoMatch[1] 2287 }; 2288 } 2289 2290 return { 2291 source: false, 2292 videoId: false 2293 }; 2294 } 2295 2296 // Get lightbox width 2297 function getVideoboxWidth() { 2298 var $width, 2299 wWidth = $(window).width(), 2300 wHeight = $(window).height(); 2301 2302 if (wHeight >= wWidth) { 2303 2304 $width = wWidth - (lightboxMargin * 2); 2305 2306 } else { 2307 2308 var wHeightMax = (wHeight * 90) / 100; 2309 2310 if (wWidth > 1280) { 2311 var $width = (wHeightMax / 5768) * 10000; 2312 } else { 2313 var $width = (wHeightMax / 6120) * 10000; 2314 } 2315 2316 } 2317 2318 return Math.round($width) + 'px'; 2319 } 2320 2321 // Get lightbox height 2322 function getVideoHeight() { 2323 2324 var $height, 2325 wWidth = $(window).width(), 2326 wHeight = $(window).height(); 2327 2328 if (wHeight >= wWidth) { 2329 $height = ((wWidth - (lightboxMargin * 2)) * 5670) / 10000; 2330 } else { 2331 $height = ((wHeight * 90) / 100) + (lightboxMargin * 2); 2332 } 2333 return Math.round($height) + 'px'; 2334 } 2335 2336 $('.video-container').each(function() { 2337 2338 var $videoContainer = $(this); 2339 var playSource = $videoContainer.data('source'); 2340 var playTarget = $videoContainer.data('target'); 2341 var $iframe = $videoContainer.find('iframe'); 2342 var $video = $videoContainer.find('video'); 2343 2344 if ($videoContainer.data('autoplay')) { 2345 switch (playSource) { 2346 case 'social_hosted': 2347 playSocialHosted($iframe); 2348 break; 2349 case 'self_hosted': 2350 playSelfHosted($video); 2351 break; 2352 } 2353 } else { 2354 var $playIcon = $videoContainer.find('.mk-svg-icon'); 2355 $playIcon.bind('click', function(e) { 2356 e.preventDefault(); 2357 var isLightbox = (playTarget == 'lightbox') ? true : false; 2358 if (!isLightbox) { 2359 $playIcon.hide().next('.preloader-preview-area').show(); 2360 } 2361 switch (playSource) { 2362 case 'social_hosted': 2363 playSocialHosted($iframe, isLightbox); 2364 break; 2365 case 'self_hosted': 2366 playSelfHosted($video, isLightbox); 2367 break; 2368 } 2369 }); 2370 } 2371 }); 2372 } 2373 $(window).on('load vc_reload', mk_video_play); 2374 2375 // Resize icon size for responsive layout 2376 function mk_video_resize_play_icon() { 2377 $('.video-thumbnail-overlay').each(function() { 2378 var $thumbnailOverlay = $(this); 2379 var thumbnailWidth = $thumbnailOverlay.width(); 2380 var $svg = $thumbnailOverlay.find('svg'); 2381 if (typeof $svg.data('width') === 'undefined') { 2382 $svg.attr('data-width', $svg.width()); 2383 } 2384 if (typeof $svg.data('height') === 'undefined') { 2385 $svg.attr('data-height', $svg.height()); 2386 } 2387 if (($svg.data('width') * 4) > thumbnailWidth) { 2388 $svg.css({ 2389 width: Math.round((parseInt(thumbnailWidth) / 4)) + 'px', 2390 height: Math.round((parseInt(thumbnailWidth) / 4) * $svg.data('height') / $svg.data('width')) + 'px' 2391 }); 2392 } else { 2393 $svg.css({ 2394 width: $svg.data('width') + 'px', 2395 height: $svg.data('height') + 'px' 2396 }); 2397 } 2398 }); 2399 } 2400 $(window).on('load resize orientationChange vc_reload', mk_video_resize_play_icon); 2401}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.