/*== Copyright (c) Kopa Theme Premium Wordpress Theme ==*/ /** * 1. top Menu 2. Main Menu 3. Search box 4. Accordion 5. Toggle 6. Owl Carousel 7. Validate Form 8. Breadking News 9. 10. Scroll to top 11. Masonry 12. Bootstrap Slider 13. Accordion Slider 14. Enquire 15. Fix css ie8 16. Match height *----------------------------------------------------------------- **/ "use strict"; jQuery(document).ready(function(){ var ad_mag_lite_variable = { "contact": { "address": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", "marker": "/url image" }, "i18n": { "VIEW": "View", "VIEWS": "Views", "validate": { "form": { "SUBMIT": "Submit", "SENDING": "Sending..." }, "name": { "REQUIRED": "Please enter your name", "MINLENGTH": "At least {0} characters required" }, "email": { "REQUIRED": "Please enter your email", "EMAIL": "Please enter a valid email" }, "url": { "REQUIRED": "Please enter your url", "URL": "Please enter a valid url" }, "message": { "REQUIRED": "Please enter a message", "MINLENGTH": "At least {0} characters required" } }, "tweets": { "failed": "Sorry, twitter is currently unavailable for this user.", "loading": "Loading tweets..." } }, "url": { "template_directory_uri":"" } }; var map; /* ========================================================= 1. top Menu ============================================================ */ Modernizr.load([ { load: ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/superfish.min.js', complete: function () { //Main menu jQuery('.top-menu').superfish({ }); } } ]); /* ========================================================= 2. Main Menu ============================================================ */ Modernizr.load([ { load: ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/superfish.min.js', complete: function () { var r_ul = jQuery('.kopa-main-nav .sf-menu'); r_ul.superfish({ speed: "fast", delay: "100" }); } } ]); /* ============================================ 3. Mobile-menu =============================================== */ Modernizr.load([{ load: [ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.navgoco.min.js'], complete: function () { jQuery(".top-menu-mobile").navgoco({ accordion: true }); jQuery(".top-nav-mobile > .pull").click(function () { jQuery(this).closest(".top-nav-mobile").find(".top-menu-mobile").slideToggle("slow"); }); jQuery(".main-nav-mobile > .pull").click(function () { jQuery(this).closest(".main-nav-mobile").find(".main-menu-mobile").slideToggle("slow"); }); jQuery(".main-menu-mobile").navgoco({ accordion: true }); jQuery(".main-menu-mobile").find(".sf-mega").removeClass("sf-mega").addClass("sf-mega-mobile"); jQuery(".main-menu-mobile").find(".sf-mega-section").removeClass("sf-mega-section").addClass("sf-mega-section-mobile"); jQuery(".caret").removeClass("caret"); jQuery(".bottom-nav-mobile > .pull").click(function () { jQuery(this).closest(".bottom-nav-mobile").find(".main-menu-mobile").slideToggle("slow"); }); } }]); /* ========================================================= 4. Accordion ============================================================ */ var panel_titles = jQuery('.kopa-accordion .panel-title a'); panel_titles.addClass("collapsed"); jQuery('.panel-heading.active').find(panel_titles).removeClass("collapsed"); panel_titles.click(function(){ jQuery(this).closest('.kopa-accordion').find('.panel-heading').removeClass('active'); var pn_heading = jQuery(this).parents('.panel-heading'); if (jQuery(this).hasClass('collapsed')) { pn_heading.addClass('active'); } else { pn_heading.removeClass('active'); } }); /* ========================================================= 5. Toggle ============================================================ */ jQuery('.kopa-toggle .panel-group .collapse').collapse({ toggle: false }); var panel_titles_2 = jQuery('.kopa-toggle .panel-title a'); panel_titles_2.click(function(){ var parent = jQuery(this).closest('.panel-heading'); if (parent.hasClass('active')) { parent.removeClass('active'); } else { parent.addClass('active'); } }); /* ========================================================= 6. Owl Carousel ============================================================ */ Modernizr.load([{ load: [ ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/owl.carousel.min.js'], complete: function () { var owl1 = jQuery(".owl-carousel-1"); owl1.owlCarousel({ items: 4, pagination: true, slideSpeed: 600, navigationText: false, navigation: false, beforeInit: function(){ owl1.find(".item:even").addClass("bgb"); } }); var owl2 = jQuery(".owl-carousel-2"); owl2.owlCarousel({ items: 3, itemsDesktop: [1160,3], itemsDesktopSmall : [979,2], itemsTabletSmall: [639,1], pagination: false, slideSpeed: 600, navigationText: false, navigation: true }); owl2.find(".owl-controls").addClass("style1"); var owl3 = jQuery(".owl-carousel-3"); owl3.owlCarousel({ items: 2, itemsDesktop: [1160,2], pagination: false, slideSpeed: 600, navigationText: false, navigation: true }); owl3.find(".owl-controls").addClass("style1"); var owl4 = jQuery(".owl-carousel-4"); owl4.owlCarousel({ items: 4, pagination: false, slideSpeed: 600, navigationText: false, navigation: true }); owl4.find(".owl-controls").addClass("style1"); var owl5 = jQuery(".owl-carousel-5"); owl5.owlCarousel({ items: 3, itemsDesktop: [1160,3], itemsDesktopSmall : [979,2], itemsTabletSmall: [639,1], pagination: false, slideSpeed: 600, navigationText: false, navigation: true }); owl5.find(".owl-controls").addClass("style2"); var owl6 = jQuery(".owl-carousel-6"); owl6.owlCarousel({ items: 3, itemsDesktop: [1160,3], itemsTablet: [799,3], itemsTabletSmall: [639,2], pagination: false, slideSpeed: 600, autoPlay: true, stopOnHover: true, navigationText: false, navigation: true }); var owl7 = jQuery(".owl-carousel-7"); owl7.owlCarousel({ singleItem: true, pagination: true, slideSpeed: 600, navigationText: false, navigation: true }); owl7.find(".owl-controls").addClass("style3"); } }]); /* ========================================================= 7. Validate Form ============================================================ */ if (jQuery('.contact-form').length > 0) { Modernizr.load([ { load:[ ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.form.min.js', ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.validate.min.js'], complete: function () { jQuery('.contact-form').validate({ // Add requirements to each of the fields rules: { name: { required: true, minlength: 8 }, email: { required: true, email: true }, message: { required: true, minlength: 10 } }, // Specify what error messages to display // when the user does something horrid messages: { name: { required: "Please enter your name.", minlength: jQuery.format("At least {0} characters required.") }, email: { required: "Please enter your email.", email: "Please enter a valid email." }, message: { required: "Please enter a message.", minlength: jQuery.format("At least {0} characters required.") } }, // Use Ajax to send everything to processForm.php submitHandler: function (form) { jQuery(".contact-form .input-submit").attr("value", ad_mag_lite_custom_front_localization.validate.form.sending); jQuery(form).ajaxSubmit({ success: function (data) { jQuery("#response").html(data); jQuery(".contact-form .input-submit").attr("value", ad_mag_lite_custom_front_localization.validate.form.submit); } }); return false; } }); } } ]); }; /*-- comment form --*/ if (jQuery('#comments-form').length > 0) { Modernizr.load([ { load:[ ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.form.min.js', ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.validate.min.js'], complete: function () { jQuery('#comments-form').validate({ // Add requirements to each of the fields rules: { author: { required: true, minlength: 8 }, email: { required: true, email: true }, comment: { required: true, minlength: 15 } }, // Specify what error messages to display // when the user does something horrid messages: { author: { required: "Please enter your name.", minlength: jQuery.format("At least {0} characters required.") }, email: { required: "Please enter your email.", email: "Please enter a valid email." }, comment: { required: "Please enter a message.", minlength: jQuery.format("At least {0} characters required.") } } }); } } ]); }; /* ========================================================= 8. Breadking News ============================================================ */ Modernizr.load([ { load: [ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/jquery.ticker.js',ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/site.js'], complete: function () { jQuery('#js-news').ticker({ titleText: 'Breaking' }); } } ]); /* ========================================================= 10. Scroll to top ============================================================ */ jQuery('.scrollup').click(function(){ $("html, body").animate({ scrollTop: 0 }, 600); return false; }); /* ========================================================= 11. Masonry ============================================================ */ Modernizr.load([{ load: [ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/masonry.pkgd.min.js', ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/imagesloaded.js'], complete: function () { var jQuerymasonry1 = jQuery('.kopa-masonry-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry1, function () { jQuerymasonry1.masonry({ columnWidth: 1, itemSelector: '.ms-item1' }); jQuerymasonry1.masonry('bindResize') }); var jQuerymasonry2 = jQuery('.kopa-masonry-2-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry2, function () { jQuerymasonry2.masonry({ columnWidth: 1, itemSelector: '.ms-item2' }); jQuerymasonry2.masonry('bindResize') }); var jQuerymasonry3 = jQuery('.kopa-masonry-3-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry3, function () { jQuerymasonry3.masonry({ columnWidth: 1, itemSelector: '.ms-item3' }); jQuerymasonry3.masonry('bindResize') }); var jQuerymasonry4 = jQuery('.kopa-masonry-4-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry4, function () { jQuerymasonry4.masonry({ columnWidth: 1, itemSelector: '.ms-item4' }); jQuerymasonry4.masonry('bindResize') }); var jQuerymasonry5 = jQuery('.kopa-masonry-5-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry5, function () { jQuerymasonry5.masonry({ columnWidth: 1, itemSelector: '.ms-item5' }); jQuerymasonry5.masonry('bindResize') }); var jQuerymasonry6 = jQuery('.kopa-masonry-6-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry6, function () { jQuerymasonry6.masonry({ columnWidth: 1, itemSelector: '.ms-item6' }); jQuerymasonry6.masonry('bindResize') }); var jQuerymasonry7 = jQuery('.kopa-masonry-7-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry7, function () { jQuerymasonry7.masonry({ columnWidth: 1, itemSelector: '.ms-item7' }); jQuerymasonry7.masonry('bindResize') }); var jQuerymasonry8 = jQuery('.kopa-masonry-8-widget').find('.kopa-masonry-wrap'); imagesLoaded(jQuerymasonry8, function () { jQuerymasonry8.masonry({ columnWidth: 1, itemSelector: '.ms-item8' }); jQuerymasonry8.masonry('bindResize') }); } }]); /* ============================================ 12. Bootstrap Slider =============================================== */ if (jQuery('.kopa-slider-ip').length > 0) { Modernizr.load([{ load: [ad_mag_lite_custom_front_localization.url.template_directory_uri + '/js/bootstrap-slider.min.js'], complete: function () { jQuery('.kopa-slider-ip').slider({ tooltip: "show" }) .on('slideStop', function(){ var value = jQuery('.tooltip-inner').text(); jQuery.ajax({ type: 'POST', url: ad_mag_lite_front_variable.ajax.url, dataType: 'json', async: true, data: { action: 'kopa_ajax_set_user_rate', wpnonce: jQuery('#kopa_set_user_rate_wpnonce').val(), post_id: ad_mag_lite_front_variable.template.post_id, rate_value: value/10 }, success: function(data) { jQuery('.kopa-slider').html(' You rated ( '+value+'% ) '); var star_count = Math.floor(data.new_result*5/10); var stars_html = ""; for(var i=0; i < star_count; i++){ stars_html += '