/**
* ismobile
* responsivemenu
* headerfixed
* ajaxcontactform
* alertbox
* topsearch
* ajaxsubscribe
* videopopup
* effectdiv
* detectviewport
* counter
* blancediv
* flatfilterprice
* countdown
* fullscreen
* blogcarousel
* blogcarousellist
* googlemap
* flatflextestimonial
* flattestimonials
* flatcarousel
* flataccordion
* tabs
* swclick
* gotop
* retinalogos
* parallax
* removepreloader
*/
;(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 responsivemenu = function() {
var menutype = 'desktop';
$(window).on('load resize', function() {
var currmenutype = 'desktop';
if ( matchmedia( 'only screen and (max-width: 991px)' ).matches ) {
currmenutype = 'mobile';
}
if ( currmenutype !== menutype ) {
menutype = currmenutype;
if ( currmenutype === 'mobile' ) {
var $mobilemenu = $('#mainnav').attr('id', 'mainnav-mobi').hide();
var haschildmenu = $('#mainnav-mobi').find('li:has(ul)');
$('#header').after($mobilemenu);
haschildmenu.children('ul').hide();
haschildmenu.children('a').after('');
$('.btn-menu').removeclass('active');
} else {
var $desktopmenu = $('#mainnav-mobi').attr('id', 'mainnav').removeattr('style');
$desktopmenu.find('.submenu').removeattr('style');
$('#header').find('.nav-wrap').append($desktopmenu);
$('.btn-submenu').remove();
}
}
});
$('.btn-menu').on('click', function() {
$('#mainnav-mobi').slidetoggle(300);
$(this).toggleclass('active');
});
$(document).on('click', '#mainnav-mobi li .btn-submenu', function(e) {
$(this).toggleclass('active').next('ul').slidetoggle(300);
e.stopimmediatepropagation()
});
};
var headerfixed = function() {
if ( $('body').hasclass('header_sticky') ) {
var nav = $('#header');
if ( nav.size() !== 0 ) {
var offsettop = $('#header').offset().top,
headerheight = $('#header').height(),
injectspace = $('
', { height: headerheight }).insertafter(nav);
injectspace.hide();
$(window).on('load scroll', function(){
if ( $(window).scrolltop() > offsettop ) {
if ( $('#header').hasclass('header-classic') ) {
injectspace.show();
}
$('#header').addclass('downscrolled');
} else {
$('#header').removeclass('header-small downscrolled');
injectspace.hide();
}
})
}
}
};
var topsearch = function () {
$(document).on('click', function(e) {
var clickid = e.target.id;
if ( ( clickid !== 'input-search' ) ) {
$('.top-search').removeclass('show');
}
});
$('.show-search').on('click', function(event){
event.stoppropagation();
});
$('.search-form').on('click', function(event){
event.stoppropagation();
});
$('.show-search').on('click', function (event) {
if(!$('.top-search').hasclass( "show" )) {
$('.top-search').addclass('show');
event.preventdefault();
}
else
$('.top-search').removeclass('show');
event.preventdefault();
if( !$('.show-search' ).hasclass( "active" ) )
$( '.show-search' ).addclass( 'active' );
else
$( '.show-search' ).removeclass( 'active' );
});
};
var ajaxcontactform = function() {
$('#contactform').each(function() {
$(this).validate({
submithandler: function( form ) {
var $form = $(form),
str = $form.serialize(),
loading = $('', { 'class': 'loading' });
$.ajax({
type: "post",
url: $form.attr('action'),
data: str,
beforesend: function () {
$form.find('.form-submit').append(loading);
},
success: function( msg ) {
var result, cls;
if ( msg === 'success' ) {result = 'message sent successfully to email administrator. ( you can change the email management a very easy way to get the message of customers in the user manual )'; cls = 'msg-success'; } else {result = 'error sending email.'; cls = 'msg-error'; } $form.prepend(
$('', {
'class': 'flat-alert ' + cls,
'text' : result
}).append(
$('')
)
);
$form.find(':input').not('.submit').val('');
},
complete: function (xhr, status, error_thrown) {
$form.find('.loading').remove();
}
});
}
});
}); // each contactform
};
var alertbox = function() {
$(document).on('click', '.close', function(e) {
$(this).closest('.flat-alert').remove();
e.preventdefault();
})
};
var ajaxsubscribe = {
obj: {
subscribeemail : $('#subscribe-email'),
subscribebutton : $('#subscribe-button'),
subscribemsg : $('#subscribe-msg'),
subscribecontent : $("#subscribe-content"),
datamailchimp : $('#subscribe-form').attr('data-mailchimp'),
success_message : 'thank you for joining our mailing list! please check your email for a confirmation link.
',
failure_message : 'error! there was a problem processing your submission.
',
noticeerror : '{msg}
',
noticeinfo : '{msg}
',
basicaction : 'mail/subscribe.php',
mailchimpaction : 'mail/subscribe-mailchimp.php'
},
eventload: function() {
var objuse = ajaxsubscribe.obj;
$(objuse.subscribebutton).on('click', function() {
if ( window.ajaxcalling ) return;
var ismailchimp = objuse.datamailchimp === 'true';
if ( ismailchimp ) {
ajaxsubscribe.ajaxcall(objuse.mailchimpaction);
} else {
ajaxsubscribe.ajaxcall(objuse.basicaction);
}
});
},
ajaxcall: function (action) {
window.ajaxcalling = true;
var objuse = ajaxsubscribe.obj;
var messagediv = objuse.subscribemsg.html('').hide();
$.ajax({
url: action,
type: 'post',
datatype: 'json',
data: {
subscribeemail: objuse.subscribeemail.val()
},
success: function (responsedata, textstatus, jqxhr) {
if ( responsedata.status ) {
objuse.subscribecontent.fadeout(500, function () {
messagediv.html(objuse.success_message).fadein(500);
});
} else {
switch (responsedata.msg) {
case "email-required":
messagediv.html(objuse.noticeerror.replace('{msg}','error! email is required.'));
break;
case "email-err":
messagediv.html(objuse.noticeerror.replace('{msg}','error! email invalid.'));
break;
case "duplicate":
messagediv.html(objuse.noticeerror.replace('{msg}','error! email is duplicate.'));
break;
case "filewrite":
messagediv.html(objuse.noticeinfo.replace('{msg}','error! mail list file is open.'));
break;
case "undefined":
messagediv.html(objuse.noticeinfo.replace('{msg}','error! undefined error.'));
break;
case "api-error":
objuse.subscribecontent.fadeout(500, function () {
messagediv.html(objuse.failure_message);
});
}
messagediv.fadein(500);
}
},
error: function (jqxhr, textstatus, errorthrown) {
alert('connection error');
},
complete: function (data) {
window.ajaxcalling = false;
}
});
}
};
var videopopup = function() {
$(".fancybox").on("click", function(){
$.fancybox({
href: this.href,
type: $(this).data("type")
}); // fancybox
return false
}); // on
};
var effectdiv = function() {
$(function() {
$(' #data-effect > li ').each( function() { $(this).hoverdir(); } );
});
};
var animation = function() {
$('.effect-animation').each( function() {
var $this = $(this),
animateclass = $this.data('animation'),
animatedelay = $this.data('animation-delay'),
animateoffset = $this.data('animation-offset');
$this.css({
'-webkit-animation-delay': animatedelay,
'-moz-animation-delay': animatedelay,
'animation-delay': animatedelay
});
$this.waypoint(function() {
$this.addclass('animated ' + animateclass);
},{
triggeronce: true,
offset: animateoffset
});
});
};
var detectviewport = function() {
$('[data-waypoint-active="yes"]').waypoint(function() {
$(this).trigger('on-appear');
}, { offset: '90%', triggeronce: true });
$(window).on('load', function() {
settimeout(function() {
$.waypoints('refresh');
});
});
};
var counter = function() {
$('.flat-counter').on('on-appear', function() {
$(this).find('.numb-count').each(function() {
var to = parseint( ($(this).attr('data-to')),10 ), speed = parseint( ($(this).attr('data-speed')),10 );
if ( $().countto ) {
$(this).countto({
to: to,
speed: speed
});
}
});
});
};
var blancediv = function() {
$(window).load(function() {
if ( matchmedia( 'only screen and (min-width: 1199px)' ).matches ) {
if ( $('section').hasclass('blancejqurey') ) {
$('.wrap-blance').each(function() {
var h = document.getelementbyid("blance1").offsetheight;
document.getelementbyid("blance2").style.height = h + "px";
});
};
if ( $('section').hasclass('blancejqurey2') ) {
$('.wrap-blance').each(function() {
var h = document.getelementbyid("blance-s1").offsetheight;
document.getelementbyid("blance-s2").style.height = h + "px";
});
};
}
});
};
var flatfilterprice = function() {
if( $().slider ) {
$( ".price_slider" ).slider({
range: true,
min: 607,
max: 1140,
values: [ 610, 980 ],
slide: function( event, ui ) {
$( ".price_label > input " ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
}
});
$( ".price_label > input " ).val( "$" + $( ".price_slider" ).slider( "values", 0 ) +
" - $" + $( ".price_slider" ).slider( "values", 1 ) );
$( ".ui-slider-handle").append("");
}
};
var countdown = function() {
var before = '',
text = '
';
if ($().countdown) {
$(".countdown").countdown('2018/12/25', function(event) {
$(this).html(event.strftime(before + '%d' + text + 'day
' + before + '%h' + text + 'hours' + before + '%m' + text + 'mins' + before + '%s' + text + 'secs'));
});
}
};
var fullscreen = function() {
if ( $('section').hasclass('full-page') ) {
function setdimensions(){
var windowsheight = $(window).height();
$('.full-page').css('height', windowsheight + 'px');
}
setdimensions();
$(window).resize(function() {
setdimensions();
});
}
};
var blogcarousel = function() {
$('.blog-carosuel-wrap').each(function(){
if ( $().owlcarousel ) {
$(this).find('.blog-shortcode').owlcarousel({
loop: true,
margin: 30,
nav: false,
dots: false,
auto:true,
responsive:{
0:{
items: 1
},
480:{
items: 2
},
767:{
items: 2
},
991:{
items: 3
},
1200:{
items: 3
}
}
});
}
});
};
var blogcarousellist = function() {
$('.blog-carosuel-wrap2').each(function(){
if ( $().owlcarousel ) {
$(this).find('.blog-shortcode').owlcarousel({
loop: true,
margin: 30,
nav: false,
dots: false,
auto:true,
responsive:{
0:{
items: 1
},
480:{
items: 2
},
767:{
items: 2
},
991:{
items: 2
},
1200:{
items: 2
}
}
});
}
});
};
var googlemap = function() {
// gmap defaults
if ( $().gmap3 ){
var data = json.parse('[{"address":"baria sreet, newyork city","content":""}]');
var data2 = json.parse('[{"address":"harvard yard, cambridge, massachusetts, hoa kỳ","content":""}]');
$('.maps').gmap3({
map:{
options:{
center:[40.6777899, -73.9981382],
maptypeid: 'consuloan',
maptypecontroloptions: {
maptypeids: ['consuloan', google.maps.maptypeid.satellite, google.maps.maptypeid.hybrid]},
zoom: 16,
},
navigationcontrol: true,
scrollwheel: false,
streetviewcontrol: true
}
});
$('.maps2').gmap3({
map:{
options:{
center:[42.3738858, -71.1164816],
maptypeid: 'consuloan',
maptypecontroloptions: {
maptypeids: ['consuloan', google.maps.maptypeid.satellite, google.maps.maptypeid.hybrid]},
zoom: 16,
},
navigationcontrol: false,
scrollwheel: false,
streetviewcontrol: false
}
});
}
// json loop
$.each(data, function(key, val) {
$('.maps').gmap3({
marker:{
values:[{
address:val.address,
options:{icon: "images/maps/1.png"},
events: {
mouseover: function() {
$(this).gmap3({
overlay:{
address:val.address,
options:{
content: "40 baria sreet,
newyork city, us
",
offset:{
y:34,
x:-186
}
}
}
});
},
mouseout: function(){
$('.infobox').each(function() {
$(this).remove();
});
}
}
}]
},
styledmaptype:{
id: "consuloan",
options:{
name: "consuloan maps"
},
styles:[
{
"featuretype": "landscape",
"elementtype": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featuretype": "transit",
"elementtype": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featuretype": "poi",
"elementtype": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featuretype": "water",
"elementtype": "labels",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featuretype": "road",
"elementtype": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"stylers": [
{
"hue": "#00aaff"
},
{
"saturation": -100
},
{
"gamma": 2.15
},
{
"lightness": 12
}
]
},
{
"featuretype": "road",
"elementtype": "labels.text.fill",
"stylers": [
{
"visibility": "on"
},
{
"lightness": 24
}
]
},
{
"featuretype": "road",
"elementtype": "geometry",
"stylers": [
{
"lightness": 57
}
]
}
]
}
});
});
// json loop
$.each(data2, function(key, val) {
$('.maps2').gmap3({
marker:{
values:[{
address:val.address,
options:{icon: "images/maps/2.png"},
events: {
mouseover: function() {
$(this).gmap3({
overlay:{
address:val.address,
options:{
content: "40 baria sreet, newyork
city, us
",
offset:{
y:26,
x:-137
}
}
}
});
},
mouseout: function(){
$('.infobox').each(function() {
$(this).remove();
});
}
}
}]
},
styledmaptype:{
id: "consuloan",
options:{
name: "consuloan maps"
},
styles:[
{
"featuretype": "administrative",
"elementtype": "all",
"stylers": [
{
"visibility": "on"
},
{
"saturation": -100
},
{
"lightness": 20
}
]
},
{
"featuretype": "road",
"elementtype": "all",
"stylers": [
{
"visibility": "on"
},
{
"saturation": -100
},
{
"lightness": 40
}
]
},
{
"featuretype": "water",
"elementtype": "all",
"stylers": [
{
"visibility": "on"
},
{
"saturation": -10
},
{
"lightness": 30
}
]
},
{
"featuretype": "landscape.man_made",
"elementtype": "all",
"stylers": [
{
"visibility": "simplified"
},
{
"saturation": -60
},
{
"lightness": 10
}
]
},
{
"featuretype": "landscape.natural",
"elementtype": "all",
"stylers": [
{
"visibility": "simplified"
},
{
"saturation": -60
},
{
"lightness": 60
}
]
},
{
"featuretype": "poi",
"elementtype": "all",
"stylers": [
{
"visibility": "off"
},
{
"saturation": -100
},
{
"lightness": 60
}
]
},
{
"featuretype": "transit",
"elementtype": "all",
"stylers": [
{
"visibility": "off"
},
{
"saturation": -100
},
{
"lightness": 60
}
]
}
]
}
});
});
// function clear markers
function gmap_clear_markers() {
$('.infobox').each(function() {
var args = {duration: 600};
$(this).slidetoggle(args).remove();
});
}
};
var flatflextestimonial= function() {
$('.wrap-testimonial').each(function(){
$(this).children('#testimonial-carousel').flexslider({
animation: "slide",
controlnav: false,
controldot: false,
animationloop: true,
slideshow: false,
itemwidth: 194,
drag: true,
itemmargin: 0,
directionnav: false,
asnavfor: $(this).children('#testimonial-slider'),
});
$(this).children('#testimonial-slider').flexslider({
animation: "slide",
controlnav: false,
animationloop: false,
slideshow: false,
directionnav: false,
sync: $(this).children('#testimonial-carousel'),
});
});
}
var flattestimonials = function() {
$('.flat-row').each(function() {
if ( $().owlcarousel ) {
$(this).find('.flat-testimonials').owlcarousel({
loop: true,
margin: 0,
nav: $('.flat-testimonials').data('nav'),
dots: $('.flat-testimonials').data('dots'),
autoplay: $('.flat-testimonials').data('auto'),
responsive:{
0:{
items: 1
},
480:{
items: 1
},
767:{
items: 1
},
991:{
items: 1
},
1200: {
items: $('.flat-testimonials').data('item')
}
}
});
}
if ( $().owlcarousel ) {
$(this).find('.flat-testimonials2').owlcarousel({
loop: true,
margin: 30,
nav: $('.flat-testimonials2').data('nav'),
dots: $('.flat-testimonials2').data('dots'),
autoplay: $('.flat-testimonials2').data('auto'),
responsive:{
0:{
items: 1
},
480:{
items: 1
},
767:{
items: 1
},
991:{
items: 2
},
1200: {
items: $('.flat-testimonials2').data('item')
}
}
});
}
});
};
var flatcarousel = function() {
$('.flat-row').each(function() {
if ( $().owlcarousel ) {
$(this).find('.flat-carousel').owlcarousel({
loop: true,
margin: 0,
nav: $('.flat-carousel').data('nav'),
dots: $('.flat-carousel').data('dots'),
autoplay: $('.flat-carousel').data('auto'),
responsive:{
0:{
items: 1
},
320: {
items: 1
},
480:{
items: 2
},
767:{
items: 2
},
991:{
items: 3
},
1200: {
items: $('.flat-carousel').data('item')
}
}
});
}
});
};
var flatclient = function() {
$('.flat-row').each(function() {
if ( $().owlcarousel ) {
$(this).find('.flat-client').owlcarousel({
loop: true,
margin: 0,
nav: $('.flat-client').data('nav'),
dots: $('.flat-client').data('dots'),
autoplay: $('.flat-client').data('auto'),
responsive:{
0:{
items: 1
},
320: {
items: 2
},
480:{
items: 3
},
767:{
items: 3
},
991:{
items: 4
},
1200: {
items: $('.flat-client').data('item')
}
}
});
}
});
};
var flataccordion = function() {
var args = {duration: 600};
$('.flat-toggle .toggle-title.active').siblings('.toggle-content').show();
$('.flat-toggle.enable .toggle-title').on('click', function() {
$(this).closest('.flat-toggle').find('.toggle-content').slidetoggle(args);
$(this).toggleclass('active');
}); // toggle
$('.flat-accordion .toggle-title').on('click', function () {
if( !$(this).is('.active') ) {
$(this).closest('.flat-accordion').find('.toggle-title.active').toggleclass('active').next().slidetoggle(args);
$(this).toggleclass('active');
$(this).next().slidetoggle(args);
} else {
$(this).toggleclass('active');
$(this).next().slidetoggle(args);
}
}); // accordion
};
var tabs = function() {
$('.flat-tabs').each(function() {
$(this).children('.content-tab').children().hide();
$(this).children('.content-tab').children().first().show();
$(this).find('.menu-tab').children('li').on('click', function(e) {
var liactive = $(this).index(),
contentactive = $(this).siblings().removeclass('active').parents('.flat-tabs').children('.content-tab').children().eq(liactive);
contentactive.addclass('active').fadein('slow');
contentactive.siblings().removeclass('active');
$(this).addclass('active').parents('.flat-tabs').children('.content-tab').children().eq(liactive).siblings().hide();
e.preventdefault();
});
});
};
var swclick = function () {
function activelayout () {
$(".switcher-container" ).on( "click", "a.sw-light", function() {
$(this).toggleclass( "active" );
$('body').addclass('home-boxed');
$('body').css({'background': '#f6f6f6' });
$('.sw-pattern.pattern').css ({ "top": "100%", "opacity": 1, "z-index": "10"});
}).on( "click", "a.sw-dark", function() {
$('.sw-pattern.pattern').css ({ "top": "98%", "opacity": 0, "z-index": "-1"});
$(this).removeclass('active').addclass('active');
$('body').removeclass('home-boxed');
$('body').css({'background': '#fff' });
return false;
})
}
function activepattern () {
$('.sw-pattern').on('click', function () {
$('.sw-pattern.pattern a').removeclass('current');
$(this).addclass('current');
$('body').css({'background': 'url("' + $(this).data('image') + '")', 'background-size' : '30px 30px', 'background-repeat': 'repeat' });
return false
})
}
activelayout();
activepattern();
};
var gotop = function() {
$(window).scroll(function() {
if ( $(this).scrolltop() > 800 ) {
$('.go-top').addclass('show');
} else {
$('.go-top').removeclass('show');
}
});
$('.go-top').on('click', function() {
$("html, body").animate({ scrolltop: 0 }, 1000 , 'easeinoutexpo');
return false;
});
};
var retinalogos = function() {
var retina = window.devicepixelratio > 1 ? true : false;
if(retina) {
$('.header .logo').find('img').attr({src:'images/logo_402x.png',width:'217',height:'35'});
}
if(retina) {
$('.footer .logo').find('img').attr({src:'images/logofooter_402x.png',width:'217',height:'35'});
}
};
var parallax = function() {
if ( $().parallax && ismobile.any() === null ) {
$('.parallax1').parallax("50%", -0.6);
$('.parallax2').parallax("50%", 0.5);
$('.parallax3').parallax("50%", 0.5);
$('.parallax4').parallax("50%", -0.6);
$('.parallax5').parallax("50%", -0.6);
$('.parallax6').parallax("50%", 0.5);
$('.parallax7').parallax("50%", -0.5);
}
};
var removepreloader = function() {
$(window).on("load", function () {
$(".loader").fadeout();
$("#loading-overlay").delay(300).fadeout('slow',function(){
$(this).remove();
});
});
};
// dom ready
$(function() {
if ( matchmedia( 'only screen and (min-width: 991px)' ).matches ) {
headerfixed();
}
responsivemenu();
topsearch();
ajaxsubscribe.eventload();
ajaxcontactform();
detectviewport();
flattestimonials();
flatflextestimonial();
videopopup();
flataccordion();
tabs();
flatcarousel();
flatclient();
effectdiv();
counter();
blancediv();
animation();
countdown();
fullscreen();
googlemap();
blogcarousel();
blogcarousellist();
flatfilterprice();
swclick();
gotop();
alertbox();
parallax();
retinalogos();
removepreloader();
});
})(jquery);