(function($) {
'use strict';
var _toBuild = [];
MK.api = window.MK.api || {};
MK.component.AdvancedGMaps = function(el) {
var $this = $(el),
container = document.getElementById( 'mk-theme-container' ),
data = $this.data( 'advancedgmaps-config' ),
apikey = data.options.apikey ? ('key='+data.options.apikey+'&') : false,
map = null,
bounds = null,
infoWindow = null,
position = null;
var build = function() {
data.options.scrollwheel = false;
data.options.mapTypeId = google.maps.MapTypeId[data.options.mapTypeId];
data.options.styles = data.style;
bounds = new google.maps.LatLngBounds();
map = new google.maps.Map(el, data.options);
infoWindow = new google.maps.InfoWindow();
map.setOptions({
panControl : data.options.panControl,
draggable: data.options.draggable,
zoomControl: data.options.zoomControl,
mapTypeControl: data.options.scaleControl,
scaleControl: data.options.mapTypeControl,
});
var marker, i;
map.setTilt(45);
for (i = 0; i < data.places.length; i++) {
if(data.places[i].latitude && data.places[i].longitude) {
position = new google.maps.LatLng(data.places[i].latitude, data.places[i].longitude);
bounds.extend(position);
marker = new google.maps.Marker({
position: position,
map: map,
title: data.places[i].address,
icon: (data.places[i].marker) ? data.places[i].marker : data.icon
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
if(data.places[i].address && data.places[i].address.length > 1) {
infoWindow.setContent('
'+ data.places[i].address +'
');
infoWindow.open(map, marker);
} else {
infoWindow.setContent('');
infoWindow.close();
}
};
})(marker, i));
/**
* If there is only one marker, map.fitBounds will zoom-in too much.
* Only run map.fitBounds if the markers are more than 1. Use setCenter
* instead if the the marker is only 1.
*/
if ( i > 0 ) {
map.fitBounds( bounds );
} else {
// Set latitude and longtitude as float.
var latLang = {
lat: parseFloat( data.places[i].latitude ),
lng: parseFloat( data.places[i].longitude )
};
map.setCenter( latLang );
// Need to setZoom here as we didn't trigger bounds_changed event.
map.setZoom( data.options.zoom );
}
}
}
var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) {
this.setZoom(data.options.zoom);
google.maps.event.removeListener(boundsListener);
});
var update = function() {
google.maps.event.trigger(map, "resize");
map.setCenter(position);
};
update();
var bindEvents = function() {
$( window ).on( 'resize', update );
window.addResizeListener( container, update );
};
bindEvents();
};
var initAll = function() {
for( var i = 0, l = _toBuild.length; i < l; i++ ) {
_toBuild[i]();
}
};
MK.api.advancedgmaps = MK.api.advancedgmaps || function() {
initAll();
};
return {
init : function() {
_toBuild.push( build );
MK.core.loadDependencies(['https://maps.googleapis.com/maps/api/js?'+apikey+'callback=MK.api.advancedgmaps']);
}
};
};
})(jQuery);
(function($) {
'use strict';
function mk_animated_cols() {
function equalheight (container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function() {
$el = $(this);
$($el).height('auto');
topPosition = $el.position().top;
if (currentRowStart != topPosition) {
for (var currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPosition;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
// console.log('recalc' + container + ' ' + currentTallest);
return currentTallest;
}
function prepareCols(el) {
var $this = el.parent().parent().find('.mk-animated-columns');
var iconHeight = equalheight('.vc_row .animated-column-icon, .animated-column-holder .mk-svg-icon'),
titleHeight = equalheight('.vc_row .animated-column-title'),
descHeight = equalheight('.vc_row .animated-column-desc'),
btnHeight = $this.find('.animated-column-btn').innerHeight();
if ($this.hasClass('full-style')) {
$this.find('.animated-column-item').each(function() {
var $this = $(this),
contentHeight = (iconHeight + 30) + (titleHeight + 10) + (descHeight + 70) + 34;
/*
* Fix AM-2418.
*
* Column height setting of VC Animated Column doesn't work when Animated Column
* content is higher than the setting. So, check column height setting first.
* - If the column height setting < Animated Column height, update the column
* height based on column height setting.
*/
var $columnHeight = contentHeight * 1.5 + 50;
var $minHeight = parseInt( $this.css( 'min-height' ), 10 );
if ( ! isNaN( $minHeight ) ) {
if ( $minHeight < $columnHeight ) {
$columnHeight = $minHeight;
}
}
$this.height( $columnHeight );
var $box_height = $this.outerHeight(true),
$icon_height = $this.find('.animated-column-icon, .animated-column-holder .mk-svg-icon').height();
$this.find('.animated-column-holder').css({
'paddingTop': $box_height / 2 - $icon_height
});
$this.animate({opacity:1}, 300);
});
} else {
$this.find('.animated-column-item').each(function() {
var $this = $(this),
halfHeight = $this.height() / 2,
halfIconHeight = $this.find('.animated-column-icon, .animated-column-holder .mk-svg-icon').height()/2,
halfTitleHeight = $this.find('.animated-column-simple-title').height()/2;
$this.find('.animated-column-holder').css({
'paddingTop': halfHeight - halfIconHeight
});
$this.find('.animated-column-title').css({
'paddingTop': halfHeight - halfTitleHeight
});
$this.animate({
opacity:1
}, 300);
});
}
}
$('.mk-animated-columns').each(function() {
var that = this;
MK.core.loadDependencies([ MK.core.path.plugins + 'tweenmax.js' ], function() {
var $this = $(that),
$parent = $this.parent().parent(),
$columns = $parent.find('.column_container'),
index = $columns.index($this.parent());
// really bad that we cannot read it before bootstrap - needs full shortcode refactor
if($this.hasClass('full-style')) {
$this.find('.animated-column-item').hover(
function() {
TweenLite.to($(this).find(".animated-column-holder"), 0.5, {
top: '-15%',
ease: Back.easeOut
});
TweenLite.to($(this).find(".animated-column-desc"), 0.5, {
top: '50%',
ease: Expo.easeOut
}, 0.4);
TweenLite.to($(this).find(".animated-column-btn"), 0.3, {
top: '50%',
ease: Expo.easeOut
}, 0.6);
},
function() {
TweenLite.to($(this).find(".animated-column-holder"), 0.5, {
top: '0%',
ease: Back.easeOut, easeParams:[3]
});
TweenLite.to($(this).find(".animated-column-desc"), 0.5, {
top: '100%',
ease: Back.easeOut
}, 0.4);
TweenLite.to($(this).find(".animated-column-btn"), 0.5, {
top: '100%',
ease: Back.easeOut
}, 0.2);
});
}
if($this.hasClass('simple-style')) {
$this.find('.animated-column-item').hover(
function() {
TweenLite.to($(this).find(".animated-column-holder"), 0.7, {
top: '100%',
ease: Expo.easeOut
});
TweenLite.to($(this).find(".animated-column-title"), 0.7, {
top: '0%',
ease: Back.easeOut
}, 0.2);
},
function() {
TweenLite.to($(this).find(".animated-column-holder"), 0.7, {
top: '0%',
ease: Expo.easeOut
});
TweenLite.to($(this).find(".animated-column-title"), 0.7, {
top: '-100%',
ease: Back.easeOut
}, 0.2);
});
}
if($columns.length === index + 1) {
prepareCols($this);
$(window).on("resize", function() {
setTimeout(prepareCols($this), 1000);
});
}
MK.utils.eventManager.subscribe('iconsInsert', function() {
prepareCols($this);
});
});
});
}
$(window).on('load vc_reload', mk_animated_cols);
}(jQuery));
(function($) {
'use strict';
var core = MK.core,
path = MK.core.path;
MK.component.BannerBuilder = function( el ) {
var init = function(){
var $this = $(el),
data = $this.data( 'bannerbuilder-config' );
MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.flexslider.js' ], function() {
$this.flexslider({
selector: '.mk-banner-slides > .mk-banner-slide',
animation: data.animation,
smoothHeight: false,
direction:'horizontal',
slideshow: true,
slideshowSpeed: data.slideshowSpeed,
animationSpeed: data.animationSpeed,
pauseOnHover: true,
directionNav: data.directionNav,
controlNav: false,
initDelay: 2000,
prevText: '',
nextText: '',
pauseText: '',
playText: ''
});
});
};
return {
init : init
};
};
})(jQuery);
(function($) {
'use strict';
var zIndex = 0;
$('.mk-newspaper-wrapper').on('click', '.blog-loop-comments', function (event) {
event.preventDefault();
var $this = $(event.currentTarget);
var $parent = $this.parents('.mk-blog-newspaper-item');
$parent.css('z-index', ++zIndex);
$this.parents('.newspaper-item-footer').find('.newspaper-social-share').slideUp(200).end().find('.newspaper-comments-list').slideDown(200);
setTimeout( function() {
MK.utils.eventManager.publish('item-expanded');
}, 300);
});
$('.mk-newspaper-wrapper').on('click', '.newspaper-item-share', function (event) {
event.preventDefault();
var $this = $(event.currentTarget);
var $parent = $this.parents('.mk-blog-newspaper-item');
$parent.css('z-index', ++zIndex);
$this.parents('.newspaper-item-footer').find('.newspaper-comments-list').slideUp(200).end().find('.newspaper-social-share').slideDown(200);
setTimeout( function() {
MK.utils.eventManager.publish('item-expanded');
}, 300);
});
var init = function init() {
// setTimeout Trick to make the VC Front Editor to load the images as well
setTimeout( function() {
// Get All Related Layers
var $blog = $('.mk-blog-container');
var $imgs = $blog.find('img[data-mk-image-src-set]');
if ( $blog.hasClass('mk-blog-container-lazyload') && $imgs.length ) {
// Load Images if the user scrolls to them
$(window).on('scroll.mk_blog_lazyload', MK.utils.throttle(500, function(){
$imgs.each(function(index, elem) {
if ( MK.utils.isElementInViewport(elem) ) {
MK.component.ResponsiveImageSetter.init( $(elem) );
$imgs = $imgs.not( $(elem) ); // Remove element from the list when loaded to reduce the amount of iteration in each()
}
});
}));
$(window).trigger('scroll.mk_blog_lazyload');
$(window).trigger('resize')
// Handle the resize
MK.component.ResponsiveImageSetter.onResize($imgs);
} else {
MK.component.ResponsiveImageSetter.init($imgs);
MK.component.ResponsiveImageSetter.onResize($imgs);
}
}, 50);
// If in VC Editor Page, Trigger Resize after 2 second (AM-2490)
// 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
if ( $('body').hasClass('vc_editor') ) {
setTimeout( function() {
$(window).trigger('resize');
}, 2000)
}
}
init();
// VC Front-End Editor
$(window).on('vc_reload mk-image-loaded', init);
}(jQuery));
(function($) {
'use strict';
var core = MK.core,
path = MK.core.path;
// TODO: Repair after Rifat. He repeated The same code twice - other same code is in photoalbum (why by the way?!).
// Split it into two separate components when you see reusage
MK.component.Category = function( el ) {
var init = function(){
core.loadDependencies([ path.plugins + 'pixastic.js' ], function() {
blurImage($('.blur-image-effect .mk-loop-item .item-holder '));
});
core.loadDependencies([ path.plugins + 'minigrid.js' ], masonry);
};
var blurImage = function($item) {
return $item.each(function() {
var $_this = $(this);
var img = $_this.find('.item-thumbnail');
img.clone().addClass("blur-effect item-blur-thumbnail").removeClass('item-thumbnail').prependTo(this);
var blur_this = $(".blur-effect", this);
blur_this.each(function(index, element){
if (img[index].complete === true) {
Pixastic.process(blur_this[index], "blurfast", {amount:0.5});
}
else {
blur_this.load(function () {
Pixastic.process(blur_this[index], "blurfast", {amount:0.5});
});
}
});
});
};
// TODO: find other shortcodes like this design and make it as a component
var masonry = function() {
if(!$('.js-masonry').length) return;
function grid() {
minigrid({
container: '.js-masonry',
item: '.js-masonry-item',
gutter: 0
});
}
grid();
$(window).on('resize', grid);
};
return {
init : init
};
};
})(jQuery);
(function($) {
'use strict';
var core = MK.core,
path = core.path;
MK.component.Chart = function(el) {
var init = function() {
MK.core.loadDependencies([MK.core.path.plugins + 'jquery.easyPieChart.js'], function() {
$('.mk-chart__chart').each(function() {
var $this = $(this),
$parent_width = $(this).parent().width(),
$chart_size = parseInt($this.attr('data-barSize'));
if ($parent_width < $chart_size) {
$chart_size = $parent_width;
$this.css('line-height', $chart_size);
$this.find('i').css({
'line-height': $chart_size + 'px'
});
$this.css({
'line-height': $chart_size + 'px'
});
}
var build = function() {
$this.easyPieChart({
animate: 1300,
lineCap: 'butt',
lineWidth: $this.attr('data-lineWidth'),
size: $chart_size,
barColor: $this.attr('data-barColor'),
trackColor: $this.attr('data-trackColor'),
scaleColor: 'transparent',
onStep: function(value) {
this.$el.find('.chart-percent span').text(Math.ceil(value));
}
});
};
// refactored only :in-viewport logic. rest is to-do
MK.utils.scrollSpy(this, {
position: 'bottom',
after: build
});
});
});
};
return {
init: init
};
};
})(jQuery);
(function($) {
"use strict";
$('.mk-clients.column-style').each(function() {
var $group = $(this),
$listItems = $group.find('li'),
listItemsCount = $listItems.length,
listStyle = $group.find('ul').attr('style') || '',
fullRowColumnsCount = $group.find('ul:first-of-type li').length;
function recreateGrid() {
var i;
$listItems.unwrap();
if (window.matchMedia('(max-width: 550px)').matches && fullRowColumnsCount >= 1) {
for (i = 0; i < listItemsCount; i += 1) {
$listItems.slice(i, i + 1)
.wrapAll('