/js/functions.js
JavaScript | 436 lines | 332 code | 62 blank | 42 comment | 31 complexity | 024a0e399010d6ce2fb69d9af9661e58 MD5 | raw file
- /* -------------------------------------- */
- // Page Loader
- /* -------------------------------------- */
- jQuery(window).on("load", function () {
- "use strict";
- jQuery(".loader").fadeOut(800);
-
- jQuery(".rev_slider_wrapper").css({"left": "0"});
-
- });
-
-
-
- jQuery(function ($) {
- "use strict";
-
- /* -------------------------------------- */
- // Pretty Social
- /* -------------------------------------- */
- $('.prettySocial').prettySocial();
-
-
-
- /* -------------------------------------- */
- // magnificPopup Initialize popup as usual
- /* -------------------------------------- */
- $('.cloud-zoom').magnificPopup({
- type: 'image',
- mainClass: 'product-img-zoomin',
- gallery: { enabled: true },
- zoom: {
- enabled: true, // By default it's false, so don't forget to enable it
- duration: 400, // duration of the effect, in milliseconds
- easing: 'ease-in-out', // CSS transition easing function
- opener: function(openerElement) {
- return openerElement.is('img') ? openerElement : openerElement.find('img');
- }
- }
- });
-
-
- /* -------------------------------------- */
- // Scroll To Top
- /* -------------------------------------- */
- var amountScrolled = 700;
- var backBtn = $("a.scrollToTop");
- $(window).on("scroll", function () {
- if ($(window).scrollTop() > amountScrolled) {
- backBtn.fadeIn("slow");
- } else {
- backBtn.fadeOut("slow");
- }
- });
- backBtn.on("click", function () {
- $("html, body").animate({
- scrollTop: 0
- }, 700);
- return false;
- });
-
-
- // Push Menus
- var $menuRight = $(".pushmenu-right");
- var $toggleright = $("#menu_bars.right");
- if ($("#menu_bars").length) {
- $("body").addClass("pushmenu-push");
- $toggleright.on("click", function () {
- $(this).toggleClass("active");
- $(".pushmenu-push").toggleClass("pushmenu-push-toleft");
- $menuRight.toggleClass("pushmenu-open");
- return false;
- });
- }
-
- //push DropDowns
- var side_drop = $('.push_nav .dropdown');
- side_drop.on('show.bs.dropdown', function (e) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideDown();
- });
- side_drop.on('hide.bs.dropdown', function (e) {
- $(this).find('.dropdown-menu').first().stop(true, true).slideUp();
- });
-
- // ************ Accordions
- $(".items > li:first-child .sub-items").fadeIn();
- $(".items > li:first-child >").addClass("expanded");
- $(".items > li > a").on('click', function (e) {
- e.preventDefault();
- var $this = $(this);
- if ($this.hasClass("expanded")) {
- $this.removeClass("expanded");
- } else {
- $(".items a.expanded").removeClass("expanded");
- $this.addClass("expanded");
- $(".sub-items").filter(":visible").slideUp("normal");
- }
- $this.parent().children("ul").stop(true, true).slideToggle("normal");
- });
-
- // ************ Search On Click
-
- $(".search_btn").on("click", function (event) {
- event.preventDefault();
- $("#xsearch").addClass("open");
- $("#xsearch > form > input[type='search']").focus();
- });
-
- $("#xsearch, #xsearch button.close").on("click keyup", function (event) {
- if (event.target == this || event.target.className == "close" || event.keyCode == 27) {
- $(this).removeClass("open");
- }
- });
-
- /*Equal Heights*/
- if($(".equalheight").length){
- $(".equalheight").matchHeight({ property: 'height' });
- }
-
-
- // ************ tabbed content
- $(".tab_content").hide();
- $(".tab_content:first").show();
- /* tab mode */
- $("ul.tabs li").on('click', function () {
- $(".tab_content").hide();
- var activeTab = $(this).attr("rel");
- $("#" + activeTab).fadeIn();
- $("ul.tabs li").removeClass("active");
- $(this).addClass("active");
- $(".tab_drawer_heading").removeClass("d_active");
- $(".tab_drawer_heading[rel^='" + activeTab + "']").addClass("d_active");
-
- });
- /*drawer mode on Mobile Version*/
- $(".tab_drawer_heading").on("click", function () {
- $(".tab_content").hide();
- var d_activeTab = $(this).attr("rel");
- $("#" + d_activeTab).fadeIn(1200);
- $(".tab_drawer_heading").removeClass("d_active");
- $(this).addClass("d_active");
- $("ul.tabs li").removeClass("active");
- $("ul.tabs li[rel^='" + d_activeTab + "']").addClass("active");
- });
-
- //contact form
- $("#btn_submit").on("click", function () {
- //get input field values
- var user_name = $('input[name=name]').val();
- var user_email = $('input[name=email]').val();
- var user_website = $('input[name=website]').val();
- var user_message = $('textarea[name=message]').val();
- var post_data, output;
- //simple validation at client's end
- var proceed = true;
- if (user_name == "") {
- proceed = false;
- }
- if (user_email == "") {
- proceed = false;
- }
- if (user_message == "") {
- proceed = false;
- }
-
- //everything looks good! proceed...
- if (proceed) {
- //alert(proceed);
- //data to be sent to server
- post_data = {
- 'userName': user_name,
- 'userEmail': user_email,
- 'userWebsite': user_website,
- 'userMessage': user_message
- };
-
- //Ajax post data to server
- $.post('contact_me.php', post_data, function (response) {
-
- //load json data from server and output message
- if (response.type == 'error') {
- output = '<div class="alert-danger" style="padding:10px; margin-bottom:10px;">' + response.text + '</div>';
- } else {
- output = '<div class="alert-success" style="padding:10px; margin-bottom:10px;">' + response.text + '</div>';
-
- //reset values in all input fields
- $('.form-inline input').val('');
- $('.form-inline textarea').val('');
- $('#btn_submit').val('Submit');
- }
-
- $("#result").hide().html(output).slideDown();
- }, 'json');
-
- }
- });
-
-
- //reset previously set border colors and hide all message on .keyup()
- $(".form-inline input, .form-inline textarea").keyup(function () {
- $("#result").slideUp();
- });
-
- // ************ Fun Facts
- $(".number-counters").appear(function () {
- $(".number-counters [data-to]").each(function () {
- var e = $(this).attr("data-to");
- $(this).delay(6e3).countTo({
- from: 1,
- to: e,
- speed: 3500,
- refreshInterval: 50
- })
- })
- });
-
- // ************Owl Carousel
- $("#news_slider").owlCarousel({
- autoPlay: false,
- items: 3,
- pagination: false,
- stopOnHover: true,
- navigationText: ["<i class='icon-chevron-thin-left'></i>", "<i class=' icon-chevron-thin-right'></i>"],
- navigation: true,
- itemsDesktop: [1199, 2],
- itemsDesktopSmall: [979, 2],
- itemsMobile: [479, 1],
-
- });
-
- $("#expert_slider").owlCarousel({
- autoPlay: true,
- items: 4,
- pagination: false,
- stopOnHover: true,
- navigationText: ["<i class='icon-chevron-thin-left'></i>", "<i class=' icon-chevron-thin-right'></i>"],
- navigation: true,
- itemsDesktop: [1199, 2],
- itemsDesktopSmall: [979, 2],
- itemsMobile: [479, 1],
-
- });
-
-
- //Fading testimonial content
- $("#review_slider, #text_rotator").owlCarousel({
- autoPlay: 3000,
- navigation: false,
- slideSpeed: 300,
- singleItem: true,
- transitionStyle: "fade"
- });
-
- // ============= Revolution Slider =============
-
- //Full Screen
- var revapi = $("#rev_slider_full").revolution({
- sliderType: "standard",
- sliderLayout: "fullscreen",
- scrollbarDrag: "true",
- delay: 9000,
- spinner: "off",
- navigation: {
- arrows: {
- enable: true
- },
- mouseScrollNavigation: "off",
- keyboardNavigation: "off",
- touch: {
- touchenabled: "on",
- swipe_threshold: 75,
- swipe_min_touches: 1,
- swipe_direction: "horizontal",
- drag_block_vertical: false
- }
-
- },
- parallax: {
- type: "mouse",
- origo: "slidercenter",
- speed: 9000,
- levels: [2, 3, 4, 5, 6, 7, 12, 16, 10, 50],
- },
- responsiveLevels: [4096, 1024, 778, 480],
- gridwidth: [1170, 960, 750, 480],
- gridheight: [670, 600, 500, 390],
- });
-
-
- var revVideo = $("#rev_slider_video").revolution({
- sliderType: "standard",
- sliderLayout: "fullscreen",
- scrollbarDrag: "true",
- delay: 9000,
- spinner: "off",
- navigation: {
- arrows: {
- enable: false
- },
- mouseScrollNavigation: "off",
- keyboardNavigation: "off",
- touch: {
- touchenabled: "on",
- swipe_threshold: 75,
- swipe_min_touches: 1,
- swipe_direction: "horizontal",
- drag_block_vertical: false
- }
-
- },
- parallax: {
- type: "mouse",
- origo: "slidercenter",
- speed: 9000,
- levels: [2, 3, 4, 5, 6, 7, 12, 16, 10, 50],
- },
- responsiveLevels: [4096, 1024, 778, 480],
- gridwidth: [1170, 960, 767, 480],
- gridheight: [600, 550, 450, 320],
- });
-
-
- // ============= Parallax=============
- $(".page_header").parallax("50%", 0.3);
- $("#parallax").parallax("50%", 0.2);
- $("#counter").parallax("50%", -0.02);
-
- // ======= Cubeportfolio ======
-
- //Project Filter
- $("#projects").cubeportfolio({
- filters: "#project-filter",
- layoutMode: 'grid',
- defaultFilter: '*',
- animationType: 'slideDelay',
- gapHorizontal: 20,
- gapVertical: 20,
- gridAdjustment: 'responsive',
- displayTypeSpeed: 100,
- });
-
- //testimonial
- $('#js-grid-masonry').cubeportfolio({
- layoutMode: 'grid',
- gapHorizontal: 50,
- gapVertical: 20,
- gridAdjustment: 'responsive',
- mediaQueries: [{
- width: 1500,
- cols: 4
- }, {
- width: 1100,
- cols: 4
- }, {
- width: 800,
- cols: 3
- }, {
- width: 480,
- cols: 2
- }, {
- width: 320,
- cols: 1
- }],
-
- });
-
- // +++++ WOW Transitions
- if ($(window).width() > 767) {
- new WOW().init();
- }
-
- //Contact Map
- if ($("#map").length) {
- var map;
- map = new GMaps({
- el: '#map',
- lat: 51.507309,
- lng: -0.127448
- });
- map.drawOverlay({
- lat: map.getCenter().lat(),
- lng: map.getCenter().lng(),
- layer: 'overlayLayer',
- content: '<div class="overlay_map"><i class="icon-location-pin"></i></div>',
- verticalAlign: 'top',
- horizontalAlign: 'center'
- });
-
- }
-
- //Custom Code
- jQuery('.page-numbers').addClass('pagination').removeClass('page-numbers');
- jQuery('.pagination li a').removeClass('pagination');
- jQuery('.pagination li span').removeClass('pagination');
- jQuery('.pagination li span').removeClass('current');
-
- jQuery('#icon-submit').on('click', function(){
- jQuery('#bizness-sidebar-search').submit();
- });
-
- function isEmpty(obj) {
- for(var prop in obj) {
- if(obj.hasOwnProperty(prop))
- return false;
- }
-
- return true;
- }
-
- var regExp = /\(([^)]+)\)/;
- jQuery('.widget_archive ul li').each(function(){
- var total_post = regExp.exec(jQuery(this).text());
- if(isEmpty(total_post)) {
- jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p></a></li>");
- } else {
- jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p><span>"+total_post[1]+"</span></a></li>");
- }
- });
-
- var regExp = /\(([^)]+)\)/;
- jQuery('.widget_layered_nav ul li').each(function(){
- var total_post = regExp.exec(jQuery(this).text());
- if(isEmpty(total_post)) {
- jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p></a></li>");
- } else {
- jQuery(this).replaceWith("<li><a href='"+jQuery('a', jQuery(this)).attr('href')+"'><p>"+jQuery('a', jQuery(this)).text()+"</p><span>"+total_post[1]+"</span></a></li>");
- }
- });
-
- var get_megamenu = jQuery(".megamenu-fw").length;
- if( get_megamenu > 0 ){
- jQuery(".megamenu-fw .dropdown-menu").addClass("megamenu-content");
- jQuery('.megamenu-fw .dropdown-menu').attr('role', 'menu');
- }
-
- });
-