/* ========================== */ /* ==== helper functions ==== */ isie = false; var isipad = (navigator.useragent.match(/ipad/i) != null); $.fn.isafter = function (sel) { return this.prevall(sel).length !== 0; } $.fn.isbefore = function (sel) { return this.nextall(sel).length !== 0; } function validatedata($attr, $defaultvalue) { if ($attr !== undefined) { return $attr } return $defaultvalue; } function parseboolean(str, $defaultvalue) { if (str == 'true') { return true; } return $defaultvalue; //return /true/i.test(str); } /* ============================================= */ /* ==== google map - asynchronous loading ==== */ function initmap() { "use strict"; jquery(".googlemap").each(function () { var atcenter = ""; var $this = jquery(this); var location = $this.data("location"); var offset = -30; if (validatedata($this.data("offset"))) { offset = $this.data("offset"); } if (validatedata(location)) { var draggable = true; if (($.browser.mobile)||(isipad)) { draggable = false; } $this.gmap3({ marker: { //latlng: [40.616439, -74.035540], address: location, options: { visible: false }, callback: function (marker) { atcenter = marker.getposition(); } }, map: { options: { //maxzoom:11, zoom: 18, maptypeid: google.maps.maptypeid.satellite, // ('roadmap', 'satellite', 'hybrid','terrain'); scrollwheel: false, draggable: draggable, disabledoubleclickzoom: false, //disabledefaultui: true, maptypecontroloptions: { //maptypeids: [google.maps.maptypeid.roadmap, google.maps.maptypeid.hybrid], //style: google.maps.maptypecontrolstyle.horizontal_bar, //position: google.maps.controlposition.right_center maptypeids: [] } }, events: { idle: function () { if (!$this.data('idle')) { $this.gmap3('get').panby(0, offset); $this.data('idle', true); } } } }, overlay: { //latlng: [40.616439, -74.035540], address: location, options: { content: '
', offset: { y: -70, x: -25 } } } //},"autofit" }); // center on resize google.maps.event.adddomlistener(window, "resize", function () { //var userlocation = new google.maps.latlng(53.8018,-1.553); settimeout(function () { $this.gmap3('get').setcenter(atcenter); $this.gmap3('get').panby(0, offset); }, 400); }); // set height $this.css("min-height", $this.data("height") + "px"); } }) } function loadscript() { "use strict"; var script = document.createelement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?key=aizasyact0uqk2gp8l3d8m2mf07cicuwj5cswrs&' + 'callback=initmap'; document.body.appendchild(script); } if ($(".googlemap").length > 0) { window.onload = loadscript; } jquery(document).ready(function () { "use strict"; $ = jquery.noconflict(); /* ===================== */ /* ==== timeline js ==== */ if ($("#timeline-embed").length > 0) { createstoryjs({ width: '100%', height: '600', source: 'js/timeline/source/timeline.json', embed_id: 'timeline-embed', //optional use a different div id for embed start_at_end: false, //optional start at latest date start_at_slide: '2', //optional start at specific slide start_zoom_adjust: '2', //optional tweak the default zoom level hash_bookmark: false, //optional location bar hashes debug: false, //optional debug to console lang: 'en', //optional language maptype: 'hybrid', //optional map style css: 'js/timeline/css/timeline.css', //optional path to css js: 'js/timeline/js/timeline-min.js' //optional path to js }); } /* ============================= */ /* ==== set elements height ==== */ // flexslider $('.flexslider.std-slider').each(function () { var $this = $(this); $this.css('min-height', $this.attr('data-height') + "px"); }) // spacer element $('.spacer').each(function () { var $this = $(this); $this.css('height', $this.attr('data-height') + "px"); }) /* ================================== */ /* ==== set padding for sections ==== */ $(".content-area, .parallaxsection").each(function () { var $this = $(this); var bottomspace = $this.attr("data-btmspace"); var topspace = $this.attr("data-topspace"); var bg = $this.attr("data-bg"); if (validatedata(bottomspace, false)) { $this.css("padding-bottom", bottomspace + "px"); } if (validatedata(topspace, false)) { $this.css("padding-top", topspace + "px"); } if (validatedata(bg, false)) { $this.css('background-image', 'url("' + bg + '")'); } }) if ($(".parallaxsection.height100").length > 0) { $(".parallaxsection.height100").each(function () { var $this = $(this); $("#boxedwrapper, body").css("height", "100%"); var menuheight = 0; if ($this.isafter(".navbar-default")) { menuheight = $(".navbar-default").outerheight(); } if ($(".navbar-default").hasclass("navbar-fixed-top")) { menuheight = 0; } var sliderheight = $this.outerheight() - menuheight; var $slider = $this.find(".flexslider"); $($this, $slider).css("height", sliderheight); }) } /* ========================= */ /* ==== clickable table ==== */ $('.table-responsive tr').click(function () { var $this = $(this); if ($this.attr('data-link') !== undefined) { window.location = $this.attr('data-link'); } }); /* ========================== */ /* ==== scroll to anchor ==== */ $('a.local[href*=#]:not([href=#])').click(function () { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); var menuoffset = 0; if ($(this).hasclass("menuoffset")) { if (!($.browser.mobile)) { menuoffset = parseint($('.navbar-default').height()); } else { } } if (target.length) { $('html,body').animate({ scrolltop: target.offset().top - menuoffset }, 1000, 'swing'); return false; } } }); /* ================== */ /* ==== count to ==== */ if (($().appear) && ($(".timercounter").length > 0)) { $('.timercounter').appear(function () { $('.timerval').each(function () { $(this).countto(); }) }) } /* =============================== */ /* ==== placeholders fallback ==== */ if ($().placeholder) { $("input[placeholder],textarea[placeholder]").placeholder(); } /* ======================================= */ /* === clickable main parent item menu === */ if(isipad) { } else { jquery(".navbar-default li.dropdown > .dropdown-toggle").removeattr("data-toggle data-target"); } $("body").on("click", ".navbar-default .dropdown", function () { var $this = $(this); if($this.hasclass("open")) { $this.find("> .dropdown-toggle").removeattr("data-toggle data-target"); } }); /* ======================== */ /* ==== animation init ==== */ if ($().appear) { if (($.browser.mobile)||(isipad)) { // disable animation on mobile $("body").removeclass("withanimation"); } else { $('.withanimation .animated').appear(function () { var $this = $(this); $this.each(function () { $this.addclass('activate'); $this.addclass($this.data('fx')); }); }, {accx: 50, accy: -150}); } } /* ======================== */ /* === video background === */ // helper function $.fn.isonscreen = function () { var win = $(window); var viewport = { top: win.scrolltop(), left: win.scrollleft() }; viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); var bounds = this.offset(); bounds.right = bounds.left + this.outerwidth(); bounds.bottom = bounds.top + this.outerheight(); return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); }; if (($().ytplayer) && ($(".videosection").length > 0)) { if((isipad)||(($.browser.mobile))) { $("#ct_preloader").fadeout(600); $(".fallbackvideo").fitvids().show(); } else { $(".videosection").ytplayer(); $('.videosection').on("ytpstart", function () { settimeout(function () { $("#ct_preloader").fadeout(300); $(".videosection").find(".flexslider").fadein(1000); }, 1050); }) // if wait long - hide preloader settimeout(function () { $("#ct_preloader").fadeout(300); }, 9000); // chrome parallax section fix if ($('.videosection.parallaxeffect').isonscreen()) { $('.videosection.parallaxeffect .innervideo').css("position", "fixed"); } else { $('.videosection.parallaxeffect .innervideo').css("position", "absolute"); } $(window).on('scroll', function () { if ($('.videosection.parallaxeffect').isonscreen()) { $('.videosection.parallaxeffect .innervideo').css("position", "fixed"); } else { $('.videosection.parallaxeffect .innervideo').css("position", "absolute"); } }); $('.videosection.parallaxeffect').each(function () { var $this = $(this); $this.siblings(":not([data-bg], .navbar-default, #themeswitcher)").css({ "position": "relative", "z-index": "1" }) }) } } /* ======================= */ /* ==== tooltips init ==== */ $("[data-toggle='tooltip']").tooltip(); if($("#timeline-embed").length > 0){ $("[data-toggle='tooltip']").on('shown.bs.tooltip', function () { $(this).tooltip('destroy') }) } /* ======================= */ /* ==== to top button ==== */ $('#totop').click(function () { $("body,html").animate({scrolltop: 0}, 600); return false; }); $(window).scroll(function () { if ($(this).scrolltop() != 0) { $("#totop").fadein(300); } else { $("#totop").fadeout(250); } }); /* ======================== */ /* ==== magnific popup ==== */ if ($().magnificpopup) { $(".popup-iframe").magnificpopup({ disableon: 700, type: 'iframe', mainclass: 'mfp-fade', removaldelay: 160, preloader: false, fixedcontentpos: false }); $('.imgpopup').magnificpopup({ type: 'image', closeoncontentclick: true, closebtninside: false, fixedcontentpos: false, mainclass: 'mfp-fade', // class to remove default margin from left and right side image: { verticalfit: true } }); } /* ========================= */ /* ==== load svg images ==== */ if ($(".octagon").length > 0) { $(".octagon .svg-load").load("images/octagon1.svg"); } /* ============================ */ /* ==== show header search ==== */ $("#showheadersearch").click(function () { var $this = $(this); var $searchform = $this.parent().find(".header-search"); $searchform.fadetoggle(250, function () { if (($searchform).is(":visible")) { $this.find(".fa-search").removeclass("fa-search").addclass("fa-times"); if (!isie) { $searchform.find("[type=text]").focus(); } } else { $this.find(".fa-times").removeclass("fa-times").addclass("fa-search"); } }); return false; }) /* =========================== */ /* ==== show map on click ==== */ $(".showmap").click(function () { var $this = $(this); var $parent = $this.closest(".content-layer"); var $form = $parent.find(".placeover"); $parent.find(".bg-layer, .placeover").fadetoggle(250, function () { if (($form).is(":visible")) { $this.text($this.attr("data-old")); } else { $this.attr("data-old", $this.text()); $this.text($this.attr("data-text")); } }); return false; }) /* ==================================== */ /* ==== fitvids - responsive video ==== */ if (($().fitvids) && ($(".responsivevideo").length > 0)) { $(".responsivevideo").fitvids(); } /* ==================== */ /* === progress bar === */ if (($().appear) && ($(".progress").length > 0)) { jquery('.progress').appear(function () { var $this = jquery(this); $this.each(function () { var $innerbar = $this.find(".progress-bar"); var percentage = $innerbar.attr("data-percentage"); $innerbar.addclass("animating").css("width", percentage + "%"); $innerbar.on('transitionend webkittransitionend otransitionend otransitionend mstransitionend', function () { $this.find(".pro-level").fadein(600); }); }); }, {accy: -100}); } /* ================== */ /* ==== isotope ==== */ if (($.isotope) && ($('#blog-list.withmasonry').length > 0)) { jquery(window).load(function () { // blog masonry var $blogcontainer = $('#blog-list.withmasonry'), // object that will keep track of options isotopeoptions = {}, // defaults, used if not explicitly set in hash defaultoptions = { itemselector: '.blog-item', layoutmode: 'sloppymasonry', resizable: false, // disable normal resizing // set columnwidth to a percentage of container width masonry: { } }; $(window).smartresize(function () { $blogcontainer.isotope({ // update columnwidth to a percentage of container width masonry: { } }); }); // set up isotope $blogcontainer.isotope(defaultoptions, function () { // fix for height dynamic content settimeout(function () { $blogcontainer.isotope('relayout'); }, 1000); }); }); } if (($.isotope) && ($('#gallerycontainer').length > 0)) { // gallery isotope jquery(window).load(function () { var $container = jquery('#gallerycontainer'), // object that will keep track of options isotopeoptions = {}, // defaults, used if not explicitly set in hash defaultoptions = { filter: '*', itemselector: '.galleryitem', sortby: 'original-order', layoutmode: 'sloppymasonry', sortascending: true, resizable: false, // disable normal resizing // set columnwidth to a percentage of container width masonry: { } }; $(window).smartresize(function () { $container.isotope({ // update columnwidth to a percentage of container width masonry: { } }); }); // set up isotope $container.isotope(defaultoptions); var $optionsets = jquery('#galleryfilters'), isoptionlinkclicked = false; // switches selected class on buttons function changeselectedlink($elem) { // remove selected class on previous item $elem.parents('.option-set').find('.btn-primary').removeclass('btn-primary'); // set selected class on new item $elem.addclass('btn-primary'); } var hashchanged = false; jquery(window).bind('hashchange', function (event) { // get options object from hash var hashoptions = window.location.hash ? jquery.deparam.fragment(window.location.hash, true) : {}, // do not animate first call aniengine = hashchanged ? 'best-available' : 'none', // apply defaults where no option was specified options = jquery.extend({}, defaultoptions, hashoptions, { animationengine: aniengine }); // apply options from hash $container.isotope(options); // save options isotopeoptions = hashoptions; // if option link was not clicked // then we'll need to update selected links if (!isoptionlinkclicked) { // iterate over options var hrefobj, hrefvalue, $selectedlink; for (var key in options) { hrefobj = {}; hrefobj[ key ] = options[ key ]; // convert object into parameter string // i.e. { filter: '.inner-transition' } -> 'filter=.inner-transition' hrefvalue = jquery.param(hrefobj); // get matching link $selectedlink = $optionsets.find('a[href="#' + hrefvalue + '"]'); changeselectedlink($selectedlink); } } isoptionlinkclicked = false; hashchanged = true; })// trigger hashchange to capture any hash data on init .trigger('hashchange'); }); } $(window).load(function () { /* ==================== */ /* ==== flexslider ==== */ if (($().flexslider) && ($(".flexslider").length > 0)) { $('.flexslider.std-slider').each(function () { var $this = $(this); // initialize $this.find(".slides > li").each(function () { var $slide_item = $(this); var bg = validatedata($slide_item.attr('data-bg'), false); if (bg) { $slide_item.css('background-image', 'url("' + bg + '")'); } $slide_item.css('min-height', $this.attr('data-height') + "px"); // hide slider content due to fade animation /* $slide_item.find(".inner").hide(); $slide_item.find(".inner [data-fx]").each(function () { $(this).removeclass("animated"); }) */ }) var loop = validatedata(parseboolean($this.attr("data-loop")), false); var smooth = validatedata(parseboolean($this.attr("data-smooth")), false); var slideshow = validatedata(parseboolean($this.attr("data-slideshow")), false); var speed = validatedata(parseint($this.attr('data-speed')), 7000); var animspeed = validatedata(parseint($this.attr("data-animspeed")), 600); var controls = validatedata(parseboolean($this.attr('data-controls')), false); var dircontrols = validatedata(parseboolean($this.attr('data-dircontrols')), false); $this.flexslider({ animation: "fade", //string: select your animation type, "fade" or "slide" animationloop: loop, //boolean: should the animation loop? if false, directionnav will received "disable" classes at either end smoothheight: smooth, //{new} boolean: allow height of the slider to animate smoothly in horizontal mode slideshow: slideshow, //boolean: animate slider automatically slideshowspeed: speed, //integer: set the speed of the slideshow cycling, in milliseconds animationspeed: animspeed, //integer: set the speed of animations, in milliseconds // primary controls controlnav: controls, //boolean: create navigation for paging control of each clide? note: leave true for manualcontrols usage directionnav: dircontrols, //boolean: create navigation for previous/next navigation? (true/false) touch:false, pauseonhover: true, //boolean: pause the slideshow when hovering over slider, then resume when no longer hovering prevtext: " ", //string: set the text for the "previous" directionnav item nexttext: " ", usecss: false, // callback api start: function () { //$this.removeclass("loading-slider"); settimeout(function () { $this.find(".slides > li.flex-active-slide .inner [data-fx]").each(function () { var $content = $(this); $content.addclass($content.data('fx')).addclass("activate"); }) }, 650); }, before: function () { $this.find(".slides > li .inner [data-fx]").each(function () { var $content = $(this); $content.removeclass($content.data('fx')).removeclass("activate"); }) }, //callback: function(slider) - fires asynchronously with each slider animation after: function () { settimeout(function () { $this.find(".slides > li.flex-active-slide .inner [data-fx]").each(function () { var $content = $(this); $content.addclass($content.data('fx')).addclass("activate"); }) }, 150); }, //callback: function(slider) - fires after each slider animation completes end: function () { }, //callback: function(slider) - fires when the slider reaches the last slide (asynchronous) added: function () { }, //{new} callback: function(slider) - fires after a slide is added removed: function () { } //{new} callback: function(slider) - fires after a slide is removed }); }); $('.flexslider.carousel-slider').each(function () { var $this = $(this); var slideshow = validatedata(parseboolean($this.attr("data-slideshow")), false); var speed = validatedata(parseint($this.attr('data-speed')), 7000); var animspeed = validatedata(parseint($this.attr("data-animspeed")), 600); var loop = validatedata(parseboolean($this.attr("data-loop")), false); var min = validatedata(parseint($this.attr('data-min')), 1); var max = validatedata(parseint($this.attr("data-max")), 3); var move = validatedata(parseint($this.attr("data-move")), 0); var controls = validatedata(parseboolean($this.attr('data-controls')), false); var dircontrols = validatedata(parseboolean($this.attr('data-dircontrols')), false); $this.flexslider({ animation: "slide", slideshow: slideshow, slideshowspeed: speed, animationspeed: animspeed, animationloop: loop, itemwidth: 370, itemmargin: 30, minitems: min, maxitems: max, move: move, controlnav: controls, directionnav: dircontrols }); }); } /* =========================== */ /* === big arrow animation === */ function animatearrow() { settimeout(function () { $(".bigarrow i").css('opacity', 1).stop(true, true).animate({ opacity: 0, top: "15px" }, { queue: false, duration: 350, complete: function () { $(".bigarrow i").css("top", "-15px").stop(true, true).delay(200).animate({ opacity: 1, top: 0 }, { queue: false, duration: 450, complete: function () { animatearrow(); }}) }}) }, 1800); } animatearrow(); }); /* / window load */ /* =================== */ /* ==== one pager ==== */ var $logoimage = ''; var oldsrc = ''; function swapmenu(mode) { var animduration = 50; if(isipad) { animduration = 0; } if (mode == "init") { $logoimage = $(".navbar-brand img"); oldsrc = $logoimage.attr('src'); } if ((mode == "standardmenu")&&(!($.browser.mobile))) { $onepagernav.removeclass("navbar-transparent"); if (!($logoimage.hasclass("swaped"))) { $logoimage.fadeout(animduration, function () { $logoimage.attr('src', $logoimage.parent().attr("data-logo")); $logoimage.fadein(animduration).addclass("swaped"); }); } } if ((mode == "fixedmenu")&&(!($.browser.mobile))) { $onepagernav.addclass("navbar-transparent"); $logoimage.attr('src', oldsrc); $logoimage.removeclass("swaped"); } } var onepagernavclass = "navbar-fixed-top"; var $onepagernav = $("."+onepagernavclass); if (($onepagernav.length > 0)) { var scrolloffset = 0; var navheightspecial = 0; navheightspecial = parseint($('.navbar-default').height()); if (!($.browser.mobile)) { // ipad landscape if ($(window).width()<800) { navheightspecial = parseint($('.navbar-default').height()); } } else { $(".navbar-fixed-top").removeclass(onepagernavclass).removeclass("navbar-transparent").addclass("navbar-static-top"); $logoimage = $(".navbar-brand img"); $logoimage.fadeout(50, function () { $logoimage.attr('src', $logoimage.parent().attr("data-logo")); $logoimage.fadein(50).addclass("swaped"); }); scrolloffset = parseint($('.navbar-default').height()); } $('.nav.navbar-nav li a').click(function () { // if mobile and menu open - hide it after click var $togglebtn = $(".navbar-toggle") if (!($togglebtn.hasclass("collapsed")) && ($togglebtn.is(":visible"))) { $(".navbar-toggle").trigger("click"); } var $this = $(this); var content = $this.attr('href'); var myurl = content.match(/^#([^\/]+)$/i); if ($(content).length > 0) { if (myurl) { if ($.browser.mobile) { navheightspecial = parseint($('.navbar-default').height()); } var goposition = $(content).offset().top + scrolloffset - navheightspecial; $('html,body').stop().animate({ scrolltop: goposition}, 1000, 'easeinoutexpo', function () { $this.closest("li").addclass("active"); }); } else { window.location = content; } return false; } }); $(window).on('scroll', function () { var menuel, mainmenu = $onepagernav, mainmenuheight = mainmenu.outerheight() + 5; var menuelements = mainmenu.find('a'); var scrollelements = menuelements.map(function () { var content = $(this).attr("href"); var myurl = content.match(/^#([^\/]+)$/i); if (myurl) { var item = $($(this).attr("href")); if (item.length) { return item; } } }); var fromtop = $(window).scrolltop() + mainmenuheight; var currentel = scrollelements.map(function () { if ($(this).offset().top < fromtop) { return this; } }); currentel = currentel[currentel.length - 1]; var id = currentel && currentel.length ? currentel[0].id : ""; if (menuel !== id) { menuelements.parent().removeclass("active").end().filter("[href=#" + id + "]").parent().addclass("active"); } var scroll = $(window).scrolltop(); if (scroll > 0) { swapmenu("standardmenu"); } else { swapmenu("fixedmenu"); } }); swapmenu("init"); var scroll = $(window).scrolltop(); if ((scroll > 0)&&(!isipad)) { swapmenu("standardmenu"); } // ipad hack to swap menus document.addeventlistener("touchmove", scrollstart, false); } function scrollstart() { swapmenu("standardmenu"); } /* ================================ */ /* === ajax portfolio one pager === */ $("body").on("click", ".getajaxitem", function () { var $this = $(this); var $galdetails = $("#galleryajaxdetails"); if ($galdetails.length <= 0) { return true; } var url = $this.attr("href") + " #ajaxcontent"; var $navbar = $('.navbar-fixed-top'); var navheight = 0; if ($navbar.length > 0) { navheight = parseint($navbar.height()); } if (($galdetails).is(":visible")) { $galdetails.animate({opacity: 0}, 400, function () { $galdetails.load(url, function () { $galdetails.delay(300).animate({opacity: 1}, 400, function () { $('html,body').animate({ scrolltop: $galdetails.offset().top - navheight }, 600, 'swing'); }); }); }); } else { $galdetails.slideup(300, function () { $galdetails.load(url, function () { $galdetails.delay(300).slidedown(700, function () { $('html,body').animate({ scrolltop: $galdetails.offset().top - navheight }, 600, 'swing'); }); }); }); } return false; }) $("body").on("click", ".closeajaxportfolio", function () { var $galdetails = $("#galleryajaxdetails"); var $navbar = $('.navbar-fixed-top'); var navheight = 0; if ($navbar.length > 0) { navheight = parseint($navbar.height()); } $galdetails.slideup(300, function () { $('html,body').animate({ scrolltop: $("#portfolio").offset().top - navheight }, 600, 'swing'); }); return false; }); $(document).ajaxstart(function () { $("#ct_preloader").addclass("ajax-inprogress").show(); }); $(document).ajaxstop(function () { settimeout(function () { $("#ct_preloader").removeclass("ajax-inprogress").hide(); }, 300); // init js after ajax stop $("#galleryajaxdetails .content-area").each(function () { var $this = $(this); var bottomspace = $this.attr("data-btmspace"); var topspace = $this.attr("data-topspace"); if (validatedata(bottomspace, false)) { $this.css("padding-bottom", bottomspace + "px"); } if (validatedata(topspace, false)) { $this.css("padding-top", topspace + "px"); } }) $("[data-toggle='tooltip']").tooltip(); }); }); /* / document ready */