;(function () {
'use strict';
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
var fullHeight = function() {
if ( !isMobile.any() ) {
$('.js-fullheight').css('height', $(window).height());
$(window).resize(function(){
$('.js-fullheight').css('height', $(window).height());
});
}
};
var sliderMain = function() {
$('#dsn-hero .flexslider').flexslider({
animation: "fade",
slideshowSpeed: 5000,
directionNav: true,
start: function(){
setTimeout(function(){
$('.slider-text').removeClass('animated fadeInUp');
$('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
}, 500);
},
before: function(){
setTimeout(function(){
$('.slider-text').removeClass('animated fadeInUp');
$('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
}, 500);
}
});
$('#dsn-hero .flexslider .slides > li').css('height', $(window).height());
$(window).resize(function(){
$('#dsn-hero .flexslider .slides > li').css('height', $(window).height());
});
};
var centerBlock = function() {
$('.dsn-section-with-image .dsn-box').css('margin-top', -($('.dsn-section-with-image .dsn-box').outerHeight()/2));
$(window).resize(function(){
$('.dsn-section-with-image .dsn-box').css('margin-top', -($('.dsn-section-with-image .dsn-box').outerHeight()/2));
});
};
var responseHeight = function() {
setTimeout(function(){
$('.js-responsive > .v-align').css('height', $('.js-responsive > img').height());
}, 1);
$(window).resize(function(){
setTimeout(function(){
$('.js-responsive > .v-align').css('height', $('.js-responsive > img').height());
}, 1);
})
};
var mobileMenuOutsideClick = function() {
$(document).click(function (e) {
var container = $("#dsn-offcanvas, .js-dsn-nav-toggle");
if (!container.is(e.target) && container.has(e.target).length === 0) {
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('offcanvas-visible');
$('.js-dsn-nav-toggle').removeClass('active');
}
}
});
};
var offcanvasMenu = function() {
$('body').prepend('
');
$('#dsn-offcanvas').prepend('');
$('body').prepend('');
$('#dsn-offcanvas').append($('#dsn-header nav').clone());
};
var burgerMenu = function() {
$('body').on('click', '.js-dsn-nav-toggle', function(event){
var $this = $(this);
$('body').toggleClass('dsn-overflow offcanvas-visible');
$this.toggleClass('active');
event.preventDefault();
});
$(window).resize(function() {
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('offcanvas-visible');
$('.js-dsn-nav-toggle').removeClass('active');
}
});
$(window).scroll(function(){
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('offcanvas-visible');
$('.js-dsn-nav-toggle').removeClass('active');
}
});
};
var toggleBtnColor = function() {
if ( $('#dsn-hero').length > 0 ) {
$('#dsn-hero').waypoint( function( direction ) {
if( direction === 'down' ) {
$('.dsn-nav-toggle').addClass('dark');
}
} , { offset: - $('#dsn-hero').height() } );
$('#dsn-hero').waypoint( function( direction ) {
if( direction === 'up' ) {
$('.dsn-nav-toggle').removeClass('dark');
}
} , {
offset: function() { return -$(this.element).height() + 0; }
} );
}
};
var contentWayPoint = function() {
var i = 0;
$('.animate-box').waypoint( function( direction ) {
if( direction === 'down' && !$(this.element).hasClass('animated') ) {
i++;
$(this.element).addClass('item-animate');
setTimeout(function(){
$('body .animate-box.item-animate').each(function(k){
var el = $(this);
setTimeout( function () {
var effect = el.data('animate-effect');
if ( effect === 'fadeIn') {
el.addClass('fadeIn animated');
} else if ( effect === 'fadeInLeft') {
el.addClass('fadeInLeft animated');
} else if ( effect === 'fadeInRight') {
el.addClass('fadeInRight animated');
} else {
el.addClass('fadeInUp animated');
}
el.removeClass('item-animate');
}, k * 200, 'easeInOutExpo' );
});
}, 100);
}
} , { offset: '85%' } );
};
// postweb 170403 추가
// MagnificPopup
var magnifPopup = function() {
$('.image-popup').magnificPopup({
type: 'image',
removalDelay: 300,
mainClass: 'mfp-with-zoom',
gallery:{
enabled:true
},
zoom: {
enabled: true, // By default it's false, so don't forget to enable it
duration: 300, // duration of the effect, in milliseconds
easing: 'ease-in-out', // CSS transition easing function
// The "opener" function should return the element from which popup will be zoomed in
// and to which popup will be scaled down
// By defailt it looks for an image tag:
opener: function(openerElement) {
// openerElement is the element on which popup was initialized, in this case its tag
// you don't need to add "opener" option if this code matches your needs, it's defailt one.
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
};
$(function(){
fullHeight();
sliderMain();
centerBlock();
responseHeight()
mobileMenuOutsideClick();
offcanvasMenu();
burgerMenu();
toggleBtnColor();
contentWayPoint();
magnifPopup(); // 170403 추가
});
}());