(function($) {
"use strict";
//hide loading box (preloader)
function handlepreloader() {
if($('.preloader').length){
$('.preloader').delay(200).fadeout(500);
}
}
//update header style and scroll to top
function headerstyle() {
if($('.main-header').length){
var windowpos = $(window).scrolltop();
var siteheader = $('.main-header');
var sticky_header = $('.main-header .sticky-header');
var scrolllink = $('.scroll-to-top');
if (windowpos > 200) {
siteheader.addclass('fixed-header');
sticky_header.addclass("animated slideindown");
scrolllink.fadein(300);
} else {
siteheader.removeclass('fixed-header');
sticky_header.removeclass("animated slideindown");
scrolllink.fadeout(300);
}
}
}
headerstyle();
//submenu dropdown toggle
if($('.main-header li.dropdown ul').length){
$('.main-header li.dropdown').append('
');
//dropdown button
$('.main-header li.dropdown .dropdown-btn').on('click', function() {
$(this).prev('ul').slidetoggle(500);
});
//megamenu toggle
$('.main-header .main-menu li.dropdown .dropdown-btn').on('click', function() {
$(this).prev('.mega-menu').slidetoggle(500);
});
//disable dropdown parent link
$('.main-header .navigation li.dropdown > a,.hidden-bar .side-menu li.dropdown > a').on('click', function(e) {
e.preventdefault();
});
}
//banner carousel
if ($('.banner-carousel').length) {
$('.banner-carousel').owlcarousel({
animateout: 'fadeout',
animatein: 'fadein',
loop:true,
margin:30,
nav:true,
smartspeed: 15000,
mousedrag:false,
touchdrag:false,
autoheight: true,
autoplay: true,
autoplaytimeout:10000,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
},
}
});
}
//recent property carousel
if ($('.recent-property-carousel').length) {
$('.recent-property-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 700,
autoplay: false,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
768:{
items:2
},
1024:{
items:3
}
}
});
}
//single item carousel
if ($('.single-item-carousel').length) {
$('.single-item-carousel').owlcarousel({
loop:true,
margin:0,
nav:true,
smartspeed: 700,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
}
}
});
}
//property carousel
if ($('.property-carousel').length) {
$('.property-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 1000,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
1024:{
items:1
}
}
});
}
//popular places carousel
if ($('.popular-places-carousel').length) {
$('.popular-places-carousel').owlcarousel({
loop:true,
margin:20,
nav:true,
smartspeed: 1000,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:2
},
800:{
items:3
},
1200:{
items:4
},
1800:{
items:5
}
}
});
}
//testimonial carousel
if ($('.testimonial-carousel').length) {
$('.testimonial-carousel').owlcarousel({
loop:true,
margin:30,
nav:false,
smartspeed: 700,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
992:{
items:2
},
1024:{
items:2
}
}
});
}
//testimonial carousel
if ($('.testimonial-carousel-two').length) {
$('.testimonial-carousel-two').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 700,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
800:{
items:1
},
1024:{
items:1
}
}
});
}
//agents carousel
if ($('.agents-carousel').length) {
$('.agents-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 700,
autoplay: false,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
768:{
items:2
},
1024:{
items:3
}
}
});
}
//agents property carousel
if ($('.agent-property-carousel').length) {
$('.agent-property-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 700,
autoplay: false,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:1
},
768:{
items:2
},
1024:{
items:3
}
}
});
}
//sponsors carousel
if ($('.sponsors-carousel').length) {
$('.sponsors-carousel').owlcarousel({
loop:true,
margin:30,
nav:true,
smartspeed: 700,
autoplay: true,
navtext: [ '', '' ],
responsive:{
0:{
items:1
},
600:{
items:2
},
768:{
items:3
},
1024:{
items:4
}
}
});
}
// product carousel slider
if ($('.property-detail .image-carousel').length && $('.property-detail .thumbs-carousel').length) {
var $sync1 = $(".property-detail .image-carousel"),
$sync2 = $(".property-detail .thumbs-carousel"),
flag = false,
duration = 500;
$sync1
.owlcarousel({
loop:false,
items: 1,
margin: 0,
nav: false,
navtext: [ '', '' ],
dots: false,
autoplay: true,
autoplaytimeout: 5000
})
.on('changed.owl.carousel', function (e) {
if (!flag) {
flag = false;
$sync2.trigger('to.owl.carousel', [e.item.index, duration, true]);
flag = false;
}
});
$sync2
.owlcarousel({
loop:false,
margin: 10,
items: 1,
nav: true,
navtext: [ '', '' ],
dots: false,
center: false,
autoplay: true,
autoplaytimeout: 5000,
responsive: {
0:{
items:2,
autowidth: false
},
400:{
items:2,
autowidth: false
},
600:{
items:3,
autowidth: false
},
800:{
items:5,
autowidth: false
},
1024:{
items:4,
autowidth: false
}
},
})
.on('click', '.owl-item', function () {
$sync1.trigger('to.owl.carousel', [$(this).index(), duration, true]);
})
.on('changed.owl.carousel', function (e) {
if (!flag) {
flag = true;
$sync1.trigger('to.owl.carousel', [e.item.index, duration, true]);
flag = false;
}
});
}
//sortable masonary with filters
function enablemasonry() {
if($('.sortable-masonry').length){
var window = $(window);
// needed variables
var $container=$('.sortable-masonry .items-container');
var $filter=$('.filter-btns');
$container.isotope({
filter:'*',
masonry: {
columnwidth : '.masonry-item.small-column'
},
animationoptions:{
duration:500,
easing:'linear'
}
});
// isotope filter
$filter.find('li').on('click', function(){
var selector = $(this).attr('data-filter');
try {
$container.isotope({
filter : selector,
animationoptions: {
duration: 500,
easing : 'linear',
queue : false
}
});
} catch(err) {
}
return false;
});
window.on('resize', function(){
var selector = $filter.find('li.active').attr('data-filter');
$container.isotope({
filter : selector,
animationoptions: {
duration: 500,
easing : 'linear',
queue : false
}
});
});
var filteritema = $('.filter-btns li');
filteritema.on('click', function(){
var $this = $(this);
if ( !$this.hasclass('active')) {
filteritema.removeclass('active');
$this.addclass('active');
}
});
}
}
enablemasonry();
//default masonary
function defaultmasonry() {
if($('.masonry-items-container').length){
var window = $(window);
// needed variables
var $container=$('.masonry-items-container');
$container.isotope({
itemselector: '.masonry-item',
masonry: {
columnwidth :1
},
animationoptions:{
duration:500,
easing:'linear'
}
});
window.on('resize', function(){
$container.isotope({
itemselector: '.masonry-item',
animationoptions: {
duration: 500,
easing : 'linear',
queue : false
}
});
});
}
}
defaultmasonry();
//price range slider
if($('.price-range-slider').length){
$( ".price-range-slider" ).slider({
range: true,
min: 0,
max: 10000,
values: [ 1000, 8000 ],
slide: function( event, ui ) {
$( "input.price-amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "input.price-amount" ).val( $( ".price-range-slider" ).slider( "values", 0 ) + " - $" + $( ".price-range-slider" ).slider( "values", 1 ) );
}
//price range slider
if($('.area-range-slider').length){
$( ".area-range-slider" ).slider({
range: true,
min: 0,
max: 1000,
values: [ 100, 900 ],
slide: function( event, ui ) {
$( "input.property-amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
}
});
$( "input.property-amount" ).val( $( ".area-range-slider" ).slider( "values", 0 ) + " - " + $( ".area-range-slider" ).slider( "values", 1 ) );
}
//custom seclect box
if($('.custom-select-box').length){
$('.custom-select-box').selectmenu().selectmenu('menuwidget').addclass('overflow');
}
//gallery filters
if($('.filter-list').length){
$('.filter-list').mixitup({});
}
//fact counter + text count
if($('.count-box').length){
$('.count-box').appear(function(){
var $t = $(this),
n = $t.find(".count-text").attr("data-stop"),
r = parseint($t.find(".count-text").attr("data-speed"), 10);
if (!$t.hasclass("counted")) {
$t.addclass("counted");
$({
countnum: $t.find(".count-text").text()
}).animate({
countnum: n
}, {
duration: r,
easing: "linear",
step: function() {
$t.find(".count-text").text(math.floor(this.countnum));
},
complete: function() {
$t.find(".count-text").text(this.countnum);
}
});
}
},{accy: 0});
}
//progress bar
if($('.progress-line').length){
$('.progress-line').appear(function(){
var el = $(this);
var percent = el.data('width');
$(el).css('width',percent+'%');
},{accy: 0});
}
//tabs box
if($('.tabs-box').length){
$('.tabs-box .tab-buttons .tab-btn').on('click', function(e) {
e.preventdefault();
var target = $($(this).attr('data-tab'));
if ($(target).is(':visible')){
return false;
}else{
target.parents('.tabs-box').find('.tab-buttons').find('.tab-btn').removeclass('active-btn');
$(this).addclass('active-btn');
target.parents('.tabs-box').find('.tabs-content').find('.tab').fadeout(0);
target.parents('.tabs-box').find('.tabs-content').find('.tab').removeclass('active-tab');
$(target).fadein(300);
$(target).addclass('active-tab');
}
});
}
//accordion box
if($('.accordion-box').length){
$(".accordion-box").on('click', '.acc-btn', function() {
var outerbox = $(this).parents('.accordion-box');
var target = $(this).parents('.accordion');
if($(this).hasclass('active')!==true){
$(outerbox).find('.accordion .acc-btn').removeclass('active ');
}
if ($(this).next('.acc-content').is(':visible')){
return false;
}else{
$(this).addclass('active');
$(outerbox).children('.accordion').removeclass('active-block animated fadeinup');
$(outerbox).find('.accordion').children('.acc-content').slideup(300);
target.addclass('active-block animated fadeinup');
$(this).next('.acc-content').slidedown(300);
}
});
}
//event countdown timer
if($('.time-countdown').length){
$('.time-countdown').each(function() {
var $this = $(this), finaldate = $(this).data('countdown');
$this.countdown(finaldate, function(event) {
var $this = $(this).html(event.strftime('' + '%ddays
' + '%hhours
' + '%mmints
' + '%ssec
'));
});
});
}
//lightbox / fancybox
if($('.lightbox-image').length) {
$('.lightbox-image').fancybox({
openeffect : 'fade',
closeeffect : 'fade',
helpers : {
media : {}
}
});
}
//contact form validation
if($('#contact-form').length){
$('#contact-form').validate({
rules: {
username: {
required: true
},
email: {
required: true,
email: true
},
subject: {
required: true
},
message: {
required: true
}
}
});
}
// scroll to a specific div
if($('.scroll-to-target').length){
$(".scroll-to-target").on('click', function() {
var target = $(this).attr('data-target');
// animate
$('html, body').animate({
scrolltop: $(target).offset().top
}, 1500);
});
}
// elements animation
if($('.wow').length){
var wow = new wow(
{
boxclass: 'wow', // animated element css class (default is wow)
animateclass: 'animated', // animation css class (default is animated)
offset: 0, // distance to the element when triggering the animation (default is 0)
mobile: false, // trigger animations on mobile devices (default is true)
live: true // act on asynchronously loaded content (default is true)
}
);
wow.init();
}
function fullheight(){
$('.full-height').css("height", $(window).height());
}
fullheight()
/* ==========================================================================
when document is resize, do
========================================================================== */
$(window).on('resize', function() {
fullheight();
});
/* ==========================================================================
when document is scrollig, do
========================================================================== */
$(window).on('scroll', function() {
headerstyle();
});
/* ==========================================================================
when document is loading, do
========================================================================== */
$(window).on('load', function() {
handlepreloader();
enablemasonry();
defaultmasonry();
});
})(window.jquery);