/**
* FRONT END SCRIPTS
*
* Scripts that will be loaded in front.
*
*/
jQuery(function ($) {
// check if elements animation is enabled and init animations
if (CMA.elementsAnimation && !cma_is_touch_device()) {
jQuery('.animated').css('opacity', '0');
$('.triggerAnimation').waypoint(function () {
var animation = $(this).attr('data-animate');
$(this).css('opacity', '');
$(this).addClass("animated " + animation);
},
{
offset: CMA.elementsAnimationOffset + '%',
triggerOnce: true
}
);
}
// check if parallax effect is enabled and init
if (CMA.sectionParallax && !cma_is_touch_device()) {
$.stellar({
horizontalOffset: 0,
horizontalScrolling: false
});
}
// function to check is user is on touch device
function cma_is_touch_device() {
if (typeof (Modernizr) != "undefined")
return Modernizr.touch;
else
return 'ontouchstart' in window || 'onmsgesturechange' in window;
}
function equalHeight() {
$('.page-content.image-background *[class^="col-md-"].empty').each(function () {
var $grid = $(this);
var $section = $(this).closest('.page-content');
if ($section.css('background-size') == '50%') {
$section.data('backgroundSize', $section.css('background-size'));
$section.data('paddingTop', $section.css('padding-top'));
var img = new Image();
img.src = $(this).closest('.page-content').css('background-image').replace(/url\(|\)$/ig, "");
$(window).on("resize", function () {
if ($(window).width() < 991) {
$section.css('padding-top', '0');
$grid.height($section.width() * img.height / img.width);
} else {
$section.css('padding-top', $section.data('paddingTop'));
$grid.height(0);
}
});
}
});
}
$(document).ready(equalHeight);
function cmaColumnBackgroundImageHeight() {
$('.page-content .row-equal-height *[class^="col-md-"].empty.image-background').each(function () {
var $grid = $(this);
if ($(window).width() < 991) {
var img = new Image();
img.src = $grid.css('background-image').replace(/url\(|\)$/ig, "");
$grid.height($(window).width() * img.height / img.width).css('backgroundSize', 'cover').closest('.row').addClass('equal-stop');
} else {
$grid.css('height', 'auto').css('backgroundSize', 'auto').closest('.row').removeClass('equal-stop');
}
});
}
$(window).resize(cmaColumnBackgroundImageHeight);
$(document).ready(cmaColumnBackgroundImageHeight);
});
|