0byt3m1n1
Path:
/
home
/
kassiope
/
OLD
/
assets
/
js
/
[
Home
]
File: main.js
/*------------------------------------------ Contact form ------------------------------------------*/ $(document).ready(function () { $("#contactForm").submit(function(e){ e.preventDefault(); var postData = $(this).serializeArray(), formURL = $(this).attr("action"), $cfResponse = $('#contactFormResponse'), $cfsubmit = $("#cfsubmit"), cfsubmitText = $cfsubmit.text(); $cfsubmit.text("Sending..."); $.ajax( { url : formURL, type: "POST", data : postData, success:function(data) { $cfResponse.html(data); $cfsubmit.text(cfsubmitText); }, error: function(data) { alert("Error occurd! Please try again"); } }); return false; }); }); /*------------------------------------------ Fun-facts counter ------------------------------------------*/ (function () { if(!$('#funfacts').html()) return; var inview = new Waypoint.Inview({ element: $('#funfacts')[0], enter: function (direction) { $('.count.number').each(function () { $(this).prop('Counter', 0).animate({ Counter: $(this).text() }, { duration: 3000, easing: 'swing', step: function (now) { $(this).text(Math.ceil(now)); } }); }); this.destroy(); } }); })(); /*------------------------------------------ Google Map ------------------------------------------*/ (function(){ if($("#map").length == 0 || !google) return; // When the window has finished loading create our google map below google.maps.event.addDomListener(window, 'load', init); function init() { // Basic options for a simple Google Map // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions var mapOptions = { // How zoomed in you want the map to start at (always required) zoom: 11, scrollwheel: false, // The latitude and longitude to center the map (always required) center: new google.maps.LatLng(43.3561969, 5.4740174), // New York // How you would like to style the map. // This is where you would paste any style found on Snazzy Maps. styles: [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]}] }; // Get the HTML DOM element that will contain your map // We are using a div with id="map" seen below in the <body> var mapElement = document.getElementById('map'); // Create the Google Map using our element and options defined above var map = new google.maps.Map(mapElement, mapOptions); // Let's also add a marker while we're at it var marker = new google.maps.Marker({ position: new google.maps.LatLng(43.3561969, 5.4740174), map: map, title: 'Kassiopé' }); } })(); /*------------------------------------------ Gridjs ------------------------------------------*/ /* * debouncedresize: special jQuery event that happens once after a window resize * * latest version and complete README available on Github: * https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js * * Copyright 2011 @louis_remi * Licensed under the MIT license. */ var $event = $.event, $special, resizeTimeout; $special = $event.special.debouncedresize = { setup: function() { $( this ).on( "resize", $special.handler ); }, teardown: function() { $( this ).off( "resize", $special.handler ); }, handler: function( event, execAsap ) { // Save the context var context = this, args = arguments, dispatch = function() { // set correct event type event.type = "debouncedresize"; $event.dispatch.apply( context, args ); }; if ( resizeTimeout ) { clearTimeout( resizeTimeout ); } execAsap ? dispatch() : resizeTimeout = setTimeout( dispatch, $special.threshold ); }, threshold: 250 }; // ======================= imagesLoaded Plugin =============================== // https://github.com/desandro/imagesloaded // $('#my-container').imagesLoaded(myFunction) // execute a callback when all images have loaded. // needed because .load() doesn't work on cached images // callback function gets image collection as argument // this is the container // original: MIT license. Paul Irish. 2010. // contributors: Oren Solomianik, David DeSandro, Yiannis Chatzikonstantinou // blank image data-uri bypasses webkit log warning (thx doug jones) var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; $.fn.imagesLoaded = function( callback ) { var $this = this, deferred = $.isFunction($.Deferred) ? $.Deferred() : 0, hasNotify = $.isFunction(deferred.notify), $images = $this.find('img').add( $this.filter('img') ), loaded = [], proper = [], broken = []; // Register deferred callbacks if ($.isPlainObject(callback)) { $.each(callback, function (key, value) { if (key === 'callback') { callback = value; } else if (deferred) { deferred[key](value); } }); } function doneLoading() { var $proper = $(proper), $broken = $(broken); if ( deferred ) { if ( broken.length ) { deferred.reject( $images, $proper, $broken ); } else { deferred.resolve( $images ); } } if ( $.isFunction( callback ) ) { callback.call( $this, $images, $proper, $broken ); } } function imgLoaded( img, isBroken ) { // don't proceed if BLANK image, or image is already loaded if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) { return; } // store element in loaded images array loaded.push( img ); // keep track of broken and properly loaded images if ( isBroken ) { broken.push( img ); } else { proper.push( img ); } // cache image and its state for future calls $.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } ); // trigger deferred progress method if present if ( hasNotify ) { deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] ); } // call doneLoading and clean listeners if all images are loaded if ( $images.length === loaded.length ){ setTimeout( doneLoading ); $images.unbind( '.imagesLoaded' ); } } // if no images, trigger immediately if ( !$images.length ) { doneLoading(); } else { $images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){ // trigger imgLoaded imgLoaded( event.target, event.type === 'error' ); }).each( function( i, el ) { var src = el.src; // find out if this image has been already checked for status // if it was, and src has not changed, call imgLoaded on it var cached = $.data( el, 'imagesLoaded' ); if ( cached && cached.src === src ) { imgLoaded( el, cached.isBroken ); return; } // if complete is true and browser supports natural sizes, try // to check for image status manually if ( el.complete && el.naturalWidth !== undefined ) { imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 ); return; } // cached images don't fire load sometimes, so we reset src, but only when // dealing with IE, or image is complete (loaded) and failed manual check // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f if ( el.readyState || el.complete ) { el.src = BLANK; el.src = src; } }); } return deferred ? deferred.promise( $this ) : $this; }; var Grid = (function() { // list of items var $grid = $( '#og-grid' ), // the items $items = $grid.children( 'li' ), // current expanded item's index current = -1, // position (top) of the expanded item // used to know if the preview will expand in a different row previewPos = -1, // extra amount of pixels to scroll the window scrollExtra = 0, // extra margin when expanded (between preview overlay and the next items) marginExpanded = 10, $window = $( window ), winsize, $body = $( 'html, body' ), // transitionend events transEndEventNames = { 'WebkitTransition' : 'webkitTransitionEnd', 'MozTransition' : 'transitionend', 'OTransition' : 'oTransitionEnd', 'msTransition' : 'MSTransitionEnd', 'transition' : 'transitionend' }, transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ], // support for csstransitions support = Modernizr.csstransitions, // default settings settings = { minHeight : 500, speed : 350, easing : 'ease' }; function init( config ) { // the settings.. settings = $.extend( true, {}, settings, config ); // preload all images $grid.imagesLoaded( function() { // save item´s size and offset saveItemInfo( true ); // get window´s size getWinSize(); // initialize some events initEvents(); } ); } // add more items to the grid. // the new items need to appended to the grid. // after that call Grid.addItems(theItems); function addItems( $newitems ) { $items = $items.add( $newitems ); $newitems.each( function() { var $item = $( this ); $item.data( { offsetTop : $item.offset().top, height : $item.height() } ); } ); initItemsEvents( $newitems ); } // saves the item´s offset top and height (if saveheight is true) function saveItemInfo( saveheight ) { $items.each( function() { var $item = $( this ); $item.data( 'offsetTop', $item.offset().top ); if( saveheight ) { $item.data( 'height', $item.height() ); } } ); } function initEvents() { // when clicking an item, show the preview with the item´s info and large image. // close the item if already expanded. // also close if clicking on the item´s cross initItemsEvents( $items ); // on window resize get the window´s size again // reset some values.. $window.on( 'debouncedresize', function() { scrollExtra = 0; previewPos = -1; // save item´s offset saveItemInfo(); getWinSize(); var preview = $.data( this, 'preview' ); if( typeof preview != 'undefined' ) { hidePreview(); } } ); } function initItemsEvents( $items ) { $items.on( 'click', 'span.og-close', function() { hidePreview(); return false; } ).children( 'a' ).on( 'click', function(e) { var $item = $( this ).parent(); // check if item already opened current === $item.index() ? hidePreview() : showPreview( $item ); return false; } ); } function getWinSize() { winsize = { width : $window.width(), height : $window.height() }; } function showPreview( $item ) { var preview = $.data( this, 'preview' ), // item´s offset top position = $item.data( 'offsetTop' ); scrollExtra = 0; // if a preview exists and previewPos is different (different row) from item´s top then close it if( typeof preview != 'undefined' ) { // not in the same row if( previewPos !== position ) { // if position > previewPos then we need to take te current preview´s height in consideration when scrolling the window if( position > previewPos ) { scrollExtra = preview.height; } hidePreview(); } // same row else { preview.update( $item ); return false; } } // update previewPos previewPos = position; // initialize new preview for the clicked item preview = $.data( this, 'preview', new Preview( $item ) ); // expand preview overlay preview.open(); } function hidePreview() { current = -1; var preview = $.data( this, 'preview' ); preview.close(); $.removeData( this, 'preview' ); } // the preview obj / overlay function Preview( $item ) { this.$item = $item; this.expandedIdx = this.$item.index(); this.create(); this.update(); } Preview.prototype = { create : function() { // create Preview structure: this.$title = $( '<h3></h3>' ); this.$description = $( '<p></p>' ); this.$href = $( '<a class="btn btn-default" href="#">Visit website</a>' ); this.$details = $( '<div class="og-details"></div>' ).append( this.$title, this.$description, this.$href ); this.$loading = $( '<div class="og-loading"></div>' ); this.$fullimage = $( '<div class="og-fullimg"></div>' ).append( this.$loading ); this.$closePreview = $( '<span class="og-close"></span>' ); this.$previewInner = $( '<div class="og-expander-inner"></div>' ).append( this.$closePreview, this.$fullimage, this.$details ); this.$previewEl = $( '<div class="og-expander"></div>' ).append( this.$previewInner ); // append preview element to the item this.$item.append( this.getEl() ); // set the transitions for the preview and the item if( support ) { this.setTransition(); } }, update : function( $item ) { if( $item ) { this.$item = $item; } // if already expanded remove class "og-expanded" from current item and add it to new item if( current !== -1 ) { var $currentItem = $items.eq( current ); $currentItem.removeClass( 'og-expanded' ); this.$item.addClass( 'og-expanded' ); // position the preview correctly this.positionPreview(); } // update current value current = this.$item.index(); // update preview´s content var $itemEl = this.$item.children( 'a' ), eldata = { href : $itemEl.attr( 'href' ), largesrc : $itemEl.data( 'largesrc' ), title : $itemEl.data( 'title' ), description : $itemEl.data( 'description' ) }; this.$title.html( eldata.title ); this.$description.html( eldata.description ); this.$href.attr( 'href', eldata.href ); var self = this; // remove the current image in the preview if( typeof self.$largeImg != 'undefined' ) { self.$largeImg.remove(); } // preload large image and add it to the preview // for smaller screens we don´t display the large image (the media query will hide the fullimage wrapper) if( self.$fullimage.is( ':visible' ) ) { this.$loading.show(); $( '<img/>' ).load( function() { var $img = $( this ); if( $img.attr( 'src' ) === self.$item.children('a').data( 'largesrc' ) ) { self.$loading.hide(); self.$fullimage.find( 'img' ).remove(); self.$largeImg = $img.fadeIn( 350 ); self.$fullimage.append( self.$largeImg ); } } ).attr( 'src', eldata.largesrc ); } }, open : function() { setTimeout( $.proxy( function() { // set the height for the preview and the item this.setHeights(); // scroll to position the preview in the right place this.positionPreview(); }, this ), 25 ); }, close : function() { var self = this, onEndFn = function() { if( support ) { $( this ).off( transEndEventName ); } self.$item.removeClass( 'og-expanded').css('height',''); self.$previewEl.remove(); }; setTimeout( $.proxy( function() { if( typeof this.$largeImg !== 'undefined' ) { this.$largeImg.fadeOut( 'fast' ); } this.$previewEl.css( 'height', 0 ); // the current expanded item (might be different from this.$item) var $expandedItem = $items.eq( this.expandedIdx ); $expandedItem.css( 'height', $expandedItem.data( 'height' ) ).on( transEndEventName, onEndFn ); if( !support ) { onEndFn.call(); } }, this ), 25 ); return false; }, calcHeight : function() { var heightPreview = winsize.height - this.$item.data( 'height' ) - marginExpanded, itemHeight = winsize.height; if( heightPreview < settings.minHeight ) { heightPreview = settings.minHeight; itemHeight = settings.minHeight + this.$item.data( 'height' ) + marginExpanded; } this.height = heightPreview; this.itemHeight = itemHeight; }, setHeights : function() { var self = this, onEndFn = function() { if( support ) { self.$item.off( transEndEventName ); } self.$item.addClass( 'og-expanded' ); }; this.calcHeight(); this.$previewEl.css( 'height', this.height ); this.$item.css( 'height', this.itemHeight ).on( transEndEventName, onEndFn ); if( !support ) { onEndFn.call(); } }, positionPreview : function() { // scroll page // case 1 : preview height + item height fits in window´s height // case 2 : preview height + item height does not fit in window´s height and preview height is smaller than window´s height // case 3 : preview height + item height does not fit in window´s height and preview height is bigger than window´s height var position = this.$item.data( 'offsetTop' ), previewOffsetT = this.$previewEl.offset().top - scrollExtra, scrollVal = this.height + this.$item.data( 'height' ) + marginExpanded <= winsize.height ? position : this.height < winsize.height ? previewOffsetT - ( winsize.height - this.height ) : previewOffsetT; $body.animate( { scrollTop : scrollVal }, settings.speed ); }, setTransition : function() { this.$previewEl.css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); this.$item.css( 'transition', 'height ' + settings.speed + 'ms ' + settings.easing ); }, getEl : function() { return this.$previewEl; } } return { init : init, addItems : addItems }; })(); /*------------------------------------------ Hover Dir ------------------------------------------*/ /** * jquery.hoverdir.js v1.1.0 * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2012, Codrops * http://www.codrops.com */ ;( function( $, window, undefined ) { 'use strict'; $.HoverDir = function( options, element ) { this.$el = $( element ); this._init( options ); }; // the options $.HoverDir.defaults = { speed : 300, easing : 'ease', hoverDelay : 0, inverse : false }; $.HoverDir.prototype = { _init : function( options ) { // options this.options = $.extend( true, {}, $.HoverDir.defaults, options ); // transition properties this.transitionProp = 'all ' + this.options.speed + 'ms ' + this.options.easing; // support for CSS transitions this.support = Modernizr.csstransitions; // load the events this._loadEvents(); }, _loadEvents : function() { var self = this; this.$el.on( 'mouseenter.hoverdir, mouseleave.hoverdir', function( event ) { var $el = $( this ), $hoverElem = $el.find( 'div' ), direction = self._getDir( $el, { x : event.pageX, y : event.pageY } ), styleCSS = self._getStyle( direction ); if( event.type === 'mouseenter' ) { $hoverElem.hide().css( styleCSS.from ); clearTimeout( self.tmhover ); self.tmhover = setTimeout( function() { $hoverElem.show( 0, function() { var $el = $( this ); if( self.support ) { $el.css( 'transition', self.transitionProp ); } self._applyAnimation( $el, styleCSS.to, self.options.speed ); } ); }, self.options.hoverDelay ); } else { if( self.support ) { $hoverElem.css( 'transition', self.transitionProp ); } clearTimeout( self.tmhover ); self._applyAnimation( $hoverElem, styleCSS.from, self.options.speed ); } } ); }, // credits : http://stackoverflow.com/a/3647634 _getDir : function( $el, coordinates ) { // the width and height of the current div var w = $el.width(), h = $el.height(), // calculate the x and y to get an angle to the center of the div from that x and y. // gets the x value relative to the center of the DIV and "normalize" it x = ( coordinates.x - $el.offset().left - ( w/2 )) * ( w > h ? ( h/w ) : 1 ), y = ( coordinates.y - $el.offset().top - ( h/2 )) * ( h > w ? ( w/h ) : 1 ), // the angle and the direction from where the mouse came in/went out clockwise (TRBL=0123); // first calculate the angle of the point, // add 180 deg to get rid of the negative values // divide by 90 to get the quadrant // add 3 and do a modulo by 4 to shift the quadrants to a proper clockwise TRBL (top/right/bottom/left) **/ direction = Math.round( ( ( ( Math.atan2(y, x) * (180 / Math.PI) ) + 180 ) / 90 ) + 3 ) % 4; return direction; }, _getStyle : function( direction ) { var fromStyle, toStyle, slideFromTop = { left : '0px', top : '-100%' }, slideFromBottom = { left : '0px', top : '100%' }, slideFromLeft = { left : '-100%', top : '0px' }, slideFromRight = { left : '100%', top : '0px' }, slideTop = { top : '0px' }, slideLeft = { left : '0px' }; switch( direction ) { case 0: // from top fromStyle = !this.options.inverse ? slideFromTop : slideFromBottom; toStyle = slideTop; break; case 1: // from right fromStyle = !this.options.inverse ? slideFromRight : slideFromLeft; toStyle = slideLeft; break; case 2: // from bottom fromStyle = !this.options.inverse ? slideFromBottom : slideFromTop; toStyle = slideTop; break; case 3: // from left fromStyle = !this.options.inverse ? slideFromLeft : slideFromRight; toStyle = slideLeft; break; }; return { from : fromStyle, to : toStyle }; }, // apply a transition or fallback to jquery animate based on Modernizr.csstransitions support _applyAnimation : function( el, styleCSS, speed ) { $.fn.applyStyle = this.support ? $.fn.css : $.fn.animate; el.stop().applyStyle( styleCSS, $.extend( true, [], { duration : speed + 'ms' } ) ); }, }; var logError = function( message ) { if ( window.console ) { window.console.error( message ); } }; $.fn.hoverdir = function( options ) { var instance = $.data( this, 'hoverdir' ); if ( typeof options === 'string' ) { var args = Array.prototype.slice.call( arguments, 1 ); this.each(function() { if ( !instance ) { logError( "cannot call methods on hoverdir prior to initialization; " + "attempted to call method '" + options + "'" ); return; } if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) { logError( "no such method '" + options + "' for hoverdir instance" ); return; } instance[ options ].apply( instance, args ); }); } else { this.each(function() { if ( instance ) { instance._init(); } else { instance = $.data( this, 'hoverdir', new $.HoverDir( options, this ) ); } }); } return instance; }; } )( jQuery, window ); /*------------------------------------------ Placeholder support for ie9 ------------------------------------------*/ /*! http://mths.be/placeholder v2.1.2 by @mathias */ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD define(['jquery'], factory); } else if (typeof module === 'object' && module.exports) { factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { // Opera Mini v7 doesn't support placeholder although its DOM seems to indicate so var isOperaMini = Object.prototype.toString.call(window.operamini) === '[object OperaMini]'; var isInputSupported = 'placeholder' in document.createElement('input') && !isOperaMini; var isTextareaSupported = 'placeholder' in document.createElement('textarea') && !isOperaMini; var valHooks = $.valHooks; var propHooks = $.propHooks; var hooks; var placeholder; var settings = {}; if (isInputSupported && isTextareaSupported) { placeholder = $.fn.placeholder = function () { return this; }; placeholder.input = true; placeholder.textarea = true; } else { placeholder = $.fn.placeholder = function (options) { var defaults = {customClass: 'placeholder'}; settings = $.extend({}, defaults, options); return this.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') .not('.' + settings.customClass) .bind({ 'focus.placeholder': clearPlaceholder, 'blur.placeholder': setPlaceholder }) .data('placeholder-enabled', true) .trigger('blur.placeholder'); }; placeholder.input = isInputSupported; placeholder.textarea = isTextareaSupported; hooks = { 'get': function (element) { var $element = $(element); var $passwordInput = $element.data('placeholder-password'); if ($passwordInput) { return $passwordInput[0].value; } return $element.data('placeholder-enabled') && $element.hasClass(settings.customClass) ? '' : element.value; }, 'set': function (element, value) { var $element = $(element); var $replacement; var $passwordInput; if (value !== '') { $replacement = $element.data('placeholder-textinput'); $passwordInput = $element.data('placeholder-password'); if ($replacement) { clearPlaceholder.call($replacement[0], true, value) || (element.value = value); $replacement[0].value = value; } else if ($passwordInput) { clearPlaceholder.call(element, true, value) || ($passwordInput[0].value = value); element.value = value; } } if (!$element.data('placeholder-enabled')) { element.value = value; return $element; } if (value === '') { element.value = value; // Setting the placeholder causes problems if the element continues to have focus. if (element != safeActiveElement()) { // We can't use `triggerHandler` here because of dummy text/password inputs :( setPlaceholder.call(element); } } else { if ($element.hasClass(settings.customClass)) { clearPlaceholder.call(element); } element.value = value; } // `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363 return $element; } }; if (!isInputSupported) { valHooks.input = hooks; propHooks.value = hooks; } if (!isTextareaSupported) { valHooks.textarea = hooks; propHooks.value = hooks; } $(function () { // Look for forms $(document).delegate('form', 'submit.placeholder', function () { // Clear the placeholder values so they don't get submitted var $inputs = $('.' + settings.customClass, this).each(function () { clearPlaceholder.call(this, true, ''); }); setTimeout(function () { $inputs.each(setPlaceholder); }, 10); }); }); // Clear placeholder values upon page reload $(window).bind('beforeunload.placeholder', function () { $('.' + settings.customClass).each(function () { this.value = ''; }); }); } function args(elem) { // Return an object of element attributes var newAttrs = {}; var rinlinejQuery = /^jQuery\d+$/; $.each(elem.attributes, function (i, attr) { if (attr.specified && !rinlinejQuery.test(attr.name)) { newAttrs[attr.name] = attr.value; } }); return newAttrs; } function clearPlaceholder(event, value) { var input = this; var $input = $(input); if (input.value === $input.attr('placeholder') && $input.hasClass(settings.customClass)) { input.value = ''; $input.removeClass(settings.customClass); if ($input.data('placeholder-password')) { $input = $input.hide().nextAll('input[type="password"]:first').show().attr('id', $input.removeAttr('id').data('placeholder-id')); // If `clearPlaceholder` was called from `$.valHooks.input.set` if (event === true) { $input[0].value = value; return value; } $input.focus(); } else { input == safeActiveElement() && input.select(); } } } function setPlaceholder(event) { var $replacement; var input = this; var $input = $(input); var id = input.id; // If the placeholder is activated, triggering blur event (`$input.trigger('blur')`) should do nothing. if (event && event.type === 'blur') { if ($input.hasClass(settings.customClass)) { return; } if (input.type === 'password') { $replacement = $input.prevAll('input[type="text"]:first'); if ($replacement.length > 0 && $replacement.is(':visible')) { return; } } } if (input.value === '') { if (input.type === 'password') { if (!$input.data('placeholder-textinput')) { try { $replacement = $input.clone().prop({'type': 'text'}); } catch (e) { $replacement = $('<input>').attr($.extend(args(this), {'type': 'text'})); } $replacement .removeAttr('name') .data({ 'placeholder-enabled': true, 'placeholder-password': $input, 'placeholder-id': id }) .bind('focus.placeholder', clearPlaceholder); $input .data({ 'placeholder-textinput': $replacement, 'placeholder-id': id }) .before($replacement); } input.value = ''; $input = $input.removeAttr('id').hide().prevAll('input[type="text"]:first').attr('id', $input.data('placeholder-id')).show(); } else { var $passwordInput = $input.data('placeholder-password'); if ($passwordInput) { $passwordInput[0].value = ''; $input.attr('id', $input.data('placeholder-id')).show().nextAll('input[type="password"]:last').hide().removeAttr('id'); } } $input.addClass(settings.customClass); $input[0].value = $input.attr('placeholder'); } else { $input.removeClass(settings.customClass); } } function safeActiveElement() { // Avoid IE9 `document.activeElement` of death try { return document.activeElement; } catch (exception) { } } })); /*------------------------------------------ Logo Slider ------------------------------------------*/ $(document).ready(function () { //Client Carousel $("#client-carousel").owlCarousel({ items: 6, itemsDesktopSmall: 4, itemsTablet: 4, itemsMobile: 2, autoPlay: true }); }); /*------------------------------------------ IE DETECTION ------------------------------------------*/ (function(){ /** * detect IE * returns version of IE or false, if browser is not Internet Explorer */ function detectIE() { var ua = window.navigator.userAgent; var msie = ua.indexOf('MSIE '); if (msie > 0) { // IE 10 or older => return version number return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); } var trident = ua.indexOf('Trident/'); if (trident > 0) { // IE 11 => return version number var rv = ua.indexOf('rv:'); return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); } var edge = ua.indexOf('Edge/'); if (edge > 0) { // IE 12 => return version number return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } // other browser return false; } if(detectIE()){ $('body').addClass("ie"); } })(); /*------------------------------------------ 02. Parallax Fade Animation in Header ------------------------------------------*/ (function(){ //Animation function function fadeIntro(scrollTopp) { var homeSection = $("#header"); if (homeSection.length > 0) { var homeSHeight = homeSection.height(); var topScroll = $(document).scrollTop(); if ((homeSection.hasClass('home-parallax')) && ($(scrollTopp).scrollTop() <= homeSHeight)) { homeSection.css('top', (topScroll * 0.55)); } if (homeSection.hasClass('home-fade') && ($(scrollTopp).scrollTop() <= homeSHeight)) { var caption = $('.intro'); var overlay = $("#header .color-overlay"); overlay.css('opacity', (0.3 + topScroll/homeSection.height() * 1)); caption.css('opacity', (1 - topScroll/homeSection.height() * 1)); } } } //Calling the function on scroll $(window).scroll(function(e) { e.preventDefault(); fadeIntro(this); }); })(); /*------------------------------------------ 03. FixedTop Navigation ------------------------------------------*/ (function(){ var $nav = $('#fixedTopNav'); function navbarAnimation() { if ($(window).scrollTop() > 0) { $nav.addClass('navbar-solid'); return; } $nav.removeClass('navbar-solid'); $(".navbar-nav > li > a").blur(); } navbarAnimation(); $(window).scroll(function() { navbarAnimation(); }); })(); /*------------------------------------------ 04. On-page navigation smooth scroll ------------------------------------------*/ $(document).ready(function(){ $('.main-navigation a[href*=#]:not([href=#]), .onPageNav').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) +']'); if (target.length) { $(".navbar-collapse.collapse.in").removeClass("in"); $('html,body').animate({ scrollTop: target.offset().top - 55 }, 1000, function(){ }); return false; } } }); //fixed bootstrap scroll spy $('#main-nav-collapse').on('activate.bs.scrollspy', function () { $(".navbar-nav > li[class='active'] > a").focus(); }); }); /*------------------------------------------ 11. Preloader ------------------------------------------*/ $(window).load(function () { imagesLoaded('body', function () { $(".page-loader div").fadeOut(); $(".page-loader").delay(200).fadeOut("slow"); }); }); var navbar = $('.main-navigation'), width = Math.max($(window).width(), window.innerWidth), mobileTest; if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { mobileTest = true; } /* ---------------------------------------------- /* * Navbar submenu /* ---------------------------------------------- */ function navbarSubmenu(width) { if (width > 767) { $('.main-navigation .navbar-nav > li.dropdown').hover(function() { var MenuLeftOffset = $('.dropdown-menu', $(this)).offset().left; var Menu1LevelWidth = $('.dropdown-menu', $(this)).width(); if (width - MenuLeftOffset < Menu1LevelWidth * 2) { $(this).children('.dropdown-menu').addClass('leftauto'); } else { $(this).children('.dropdown-menu').removeClass('leftauto'); } if ($('.dropdown', $(this)).length > 0) { var Menu2LevelWidth = $('.dropdown-menu', $(this)).width(); if (width - MenuLeftOffset - Menu1LevelWidth < Menu2LevelWidth) { $(this).children('.dropdown-menu').addClass('left-side'); } else { $(this).children('.dropdown-menu').removeClass('left-side'); } } }); } } /* ---------------------------------------------- /* * Navbar hover dropdown on desctop /* ---------------------------------------------- */ function hoverDropdown(width, mobileTest) { if ((width > 767) && (mobileTest !== true)) { $('.main-navigation .navbar-nav > li.dropdown, .main-navigation li.dropdown > ul > li.dropdown').removeClass('open'); var delay = 0; var setTimeoutConst; $('.main-navigation .navbar-nav > li.dropdown, .main-navigation li.dropdown > ul > li.dropdown').hover(function() { var $this = $(this); setTimeoutConst = setTimeout(function() { $this.addClass('open'); $this.find('.dropdown-toggle').addClass('disabled'); }, delay); }, function() { clearTimeout(setTimeoutConst); $(this).removeClass('open'); $(this).find('.dropdown-toggle').removeClass('disabled'); }); } else { $('.main-navigation .navbar-nav > li.dropdown, .main-navigation li.dropdown > ul > li.dropdown').unbind('mouseenter mouseleave'); $('.main-navigation [data-toggle=dropdown]').not('.binded').addClass('binded').on('click', function(event) { event.preventDefault(); event.stopPropagation(); $(this).parent().siblings().removeClass('open'); $(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeClass('open'); $(this).parent().toggleClass('open'); }); } } /* ---------------------------------------------- /* * Navbar collapse on click /* ---------------------------------------------- */ $(document).on('click','.navbar-collapse.in',function(e) { if( $(e.target).is('a') && $(e.target).attr('class') != 'dropdown-toggle' ) { $(this).collapse('hide'); } }); navbarSubmenu(width); hoverDropdown(width, mobileTest); $(window).resize(function() { var width = Math.max($(window).width(), window.innerWidth); hoverDropdown(width, mobileTest); }); /* Scroll to top */ $(window).scroll(function() { var $toTop = $('#totop'); if ($(this).scrollTop() > 100) { $toTop.fadeIn(); } else { $toTop.fadeOut(); } }); $("a[href='#totop']").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); /* FlexSlider */ $(window).load(function() { $('.flexslider').flexslider({ animation: "fade", easing: "swing", controlNav: false }); }); /* text rotator */ $(".rotate").textrotator({ animation: "fade", // You can pick the way it animates when rotating through words. Options are dissolve (default), fade, flip, flipUp, flipCube, flipCubeUp and spin. separator: ",", // If you don't want commas to be the separator, you can define a new separator (|, &, * etc.) by yourself using this field. speed: 2000 // How many milliseconds until the next word show. }); (function(){ /* ---------------------------------------------- /* * Youtube video background /* ---------------------------------------------- */ $(function(){ $("#videoBackground").mb_YTPlayer(); }); $('#video-play').click(function(event) { event.preventDefault(); if ($(this).hasClass('fa-play')) { $('#videoBackground').playYTP(); } else { $('#videoBackground').pauseYTP(); } $(this).toggleClass('fa-play fa-pause'); return false; }); $('#video-volume').click(function(event) { event.preventDefault(); $('#videoBackground').YTPToggleVolume(); $(this).toggleClass('fa-volume-off fa-volume-up'); return false; }); })(); //initialize gallery images (function(){ Grid.init(); })(); (function(){ /* checking if comments in page exists */ if($("#disqus_thread").length == 0) return; /* discus */ /* * * CONFIGURATION VARIABLES * * */ var disqus_shortname = 'reigntemplate'; /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); })(); /* Lightbox gallery */ $(window).load(function () { imagesLoaded('body', function () { $(".lightbox-gallery").magnificPopup({ delegate: 'a', gallery:{ enabled:true }, type:'image', zoom: { enabled: true, duration: 300, // don't foget to change the duration also in CSS opener: function(element) { return element.find('img'); } } }); }); }); /*------------------------------------------ Portfolio isotope and hover ------------------------------------------*/ $(window).load(function() { // Initialize Isotope var $container = $('.isotope').isotope({ itemSelector: 'li', //percentPosition: true }); // Bind filter button click $('#filters').on( 'click', 'button', function(){ var filterValue = $( this ).attr('data-filter'); $container.isotope({ filter: filterValue }); }); // change is-checked class on buttons $('.button-group').each( function( i, buttonGroup ){ var $buttonGroup = $( buttonGroup ); $buttonGroup.on( 'click', 'button', function(){ $buttonGroup.find('.is-checked').removeClass('is-checked'); $( this ).addClass('is-checked'); }); }); //Hover Direction $(function() { $('#da-thumbs').find('> li').each(function () { $(this).hoverdir({ hoverDelay : 75 }); }); }); }); /*------------------------------------------ Expertise Progressbar animation ------------------------------------------*/ (function () { if($(".progressbars").length == 0) return; $(".progressbars").each(function(){ var $this = $(this); var inview = new Waypoint.Inview({ element: $this, enter: function (direction) { $this.find(".progress-bar").each(function () { $(this).css('width', $(this).attr("aria-valuenow") + '%'); }); } }); }); })(); /*------------------------------------------ Smooth Scroll ------------------------------------------*/ // SmoothScroll v0.9.9 // Licensed under the terms of the MIT license. // People involved // - Balazs Galambosi: maintainer (CHANGELOG.txt) // - Patrick Brunner (patrickb1991@gmail.com) // - Michael Herf: ssc_pulse Algorithm function ssc_init() { if (!document.body) return; var e = document.body; var t = document.documentElement; var n = window.innerHeight; var r = e.scrollHeight; ssc_root = document.compatMode.indexOf("CSS") >= 0 ? t : e; ssc_activeElement = e; ssc_initdone = true; if (top != self) { ssc_frame = true } else if (r > n && (e.offsetHeight <= n || t.offsetHeight <= n)) { ssc_root.style.height = "auto"; if (ssc_root.offsetHeight <= n) { var i = document.createElement("div"); i.style.clear = "both"; e.appendChild(i) } } if (!ssc_fixedback) { e.style.backgroundAttachment = "scroll"; t.style.backgroundAttachment = "scroll" } if (ssc_keyboardsupport) { ssc_addEvent("keydown", ssc_keydown) } } function ssc_scrollArray(e, t, n, r) { r || (r = 1e3); ssc_directionCheck(t, n); ssc_que.push({ x: t, y: n, lastX: t < 0 ? .99 : -.99, lastY: n < 0 ? .99 : -.99, start: +(new Date) }); if (ssc_pending) { return } var i = function () { var s = +(new Date); var o = 0; var u = 0; for (var a = 0; a < ssc_que.length; a++) { var f = ssc_que[a]; var l = s - f.start; var c = l >= ssc_animtime; var h = c ? 1 : l / ssc_animtime; if (ssc_pulseAlgorithm) { h = ssc_pulse(h) } var p = f.x * h - f.lastX >> 0; var d = f.y * h - f.lastY >> 0; o += p; u += d; f.lastX += p; f.lastY += d; if (c) { ssc_que.splice(a, 1); a-- } } if (t) { var v = e.scrollLeft; e.scrollLeft += o; if (o && e.scrollLeft === v) { t = 0 } } if (n) { var m = e.scrollTop; e.scrollTop += u; if (u && e.scrollTop === m) { n = 0 } } if (!t && !n) { ssc_que = [] } if (ssc_que.length) { setTimeout(i, r / ssc_framerate + 1) } else { ssc_pending = false } }; setTimeout(i, 0); ssc_pending = true } function ssc_wheel(e) { if (!ssc_initdone) { ssc_init() } var t = e.target; var n = ssc_overflowingAncestor(t); if (!n || e.defaultPrevented || ssc_isNodeName(ssc_activeElement, "embed") || ssc_isNodeName(t, "embed") && /\.pdf/i.test(t.src)) { return true } var r = e.wheelDeltaX || 0; var i = e.wheelDeltaY || 0; if (!r && !i) { i = e.wheelDelta || 0 } if (Math.abs(r) > 1.2) { r *= ssc_stepsize / 120 } if (Math.abs(i) > 1.2) { i *= ssc_stepsize / 120 } ssc_scrollArray(n, -r, -i); e.preventDefault() } function ssc_keydown(e) { var t = e.target; var n = e.ctrlKey || e.altKey || e.metaKey; if (/input|textarea|embed/i.test(t.nodeName) || t.isContentEditable || e.defaultPrevented || n) { return true } if (ssc_isNodeName(t, "button") && e.keyCode === ssc_key.spacebar) { return true } var r, i = 0, s = 0; var o = ssc_overflowingAncestor(ssc_activeElement); var u = o.clientHeight; if (o == document.body) { u = window.innerHeight } switch (e.keyCode) { case ssc_key.up: s = -ssc_arrowscroll; break; case ssc_key.down: s = ssc_arrowscroll; break; case ssc_key.spacebar: r = e.shiftKey ? 1 : -1; s = -r * u * .9; break; case ssc_key.pageup: s = -u * .9; break; case ssc_key.pagedown: s = u * .9; break; case ssc_key.home: s = -o.scrollTop; break; case ssc_key.end: var a = o.scrollHeight - o.scrollTop - u; s = a > 0 ? a + 10 : 0; break; case ssc_key.left: i = -ssc_arrowscroll; break; case ssc_key.right: i = ssc_arrowscroll; break; default: return true } ssc_scrollArray(o, i, s); e.preventDefault() } function ssc_mousedown(e) { ssc_activeElement = e.target } function ssc_setCache(e, t) { for (var n = e.length; n--;) ssc_cache[ssc_uniqueID(e[n])] = t; return t } function ssc_overflowingAncestor(e) { var t = []; var n = ssc_root.scrollHeight; do { var r = ssc_cache[ssc_uniqueID(e)]; if (r) { return ssc_setCache(t, r) } t.push(e); if (n === e.scrollHeight) { if (!ssc_frame || ssc_root.clientHeight + 10 < n) { return ssc_setCache(t, document.body) } } else if (e.clientHeight + 10 < e.scrollHeight) { overflow = getComputedStyle(e, "").getPropertyValue("overflow"); if (overflow === "scroll" || overflow === "auto") { return ssc_setCache(t, e) } } } while (e = e.parentNode) } function ssc_addEvent(e, t, n) { window.addEventListener(e, t, n || false) } function ssc_removeEvent(e, t, n) { window.removeEventListener(e, t, n || false) } function ssc_isNodeName(e, t) { return e.nodeName.toLowerCase() === t.toLowerCase() } function ssc_directionCheck(e, t) { e = e > 0 ? 1 : -1; t = t > 0 ? 1 : -1; if (ssc_direction.x !== e || ssc_direction.y !== t) { ssc_direction.x = e; ssc_direction.y = t; ssc_que = [] } } function ssc_pulse_(e) { var t, n, r; e = e * ssc_pulseScale; if (e < 1) { t = e - (1 - Math.exp(-e)) } else { n = Math.exp(-1); e -= 1; r = 1 - Math.exp(-e); t = n + r * (1 - n) } return t * ssc_pulseNormalize } function ssc_pulse(e) { if (e >= 1) return 1; if (e <= 0) return 0; if (ssc_pulseNormalize == 1) { ssc_pulseNormalize /= ssc_pulse_(1) } return ssc_pulse_(e) } var ssc_framerate = 150; var ssc_animtime = 500; var ssc_stepsize = 150; var ssc_pulseAlgorithm = true; var ssc_pulseScale = 6; var ssc_pulseNormalize = 1; var ssc_keyboardsupport = true; var ssc_arrowscroll = 50; var ssc_frame = false; var ssc_direction = { x: 0, y: 0 }; var ssc_initdone = false; var ssc_fixedback = true; var ssc_root = document.documentElement; var ssc_activeElement; var ssc_key = { left: 37, up: 38, right: 39, down: 40, spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36 }; var ssc_que = []; var ssc_pending = false; var ssc_cache = {}; setInterval(function () { ssc_cache = {} }, 10 * 1e3); var ssc_uniqueID = function () { var e = 0; return function (t) { return t.ssc_uniqueID || (t.ssc_uniqueID = e++) } }(); var ischrome = /chrome/.test(navigator.userAgent.toLowerCase()); if (ischrome) { ssc_addEvent("mousedown", ssc_mousedown); ssc_addEvent("mousewheel", ssc_wheel); ssc_addEvent("load", ssc_init) } /*------------------------------------------ Subscribe form ajax ------------------------------------------*/ $('#subscription-form').submit(function(e) { e.preventDefault(); var $form = $('#subscription-form'); var submit = $('#subscribe-button'); var ajaxResponse = $('#subscription-response'); var email = $('#subscriber-email').val(); $.ajax({ type: 'POST', url: 'php/subscribe.php', dataType: 'json', data: { email: email }, cache: false, beforeSend: function(result) { submit.val("Joining..."); }, success: function(result) { if(result.sendstatus == 1) { ajaxResponse.html(result.message); $form.fadeOut(500); } else { ajaxResponse.html(result.message); submit.val("Join"); } } }); }); /*------------------------------------------ Testimonial carousel ------------------------------------------*/ (function () { var $testimonialCarousel = $("#testimonials-carousel"), $reviews = $(".review"), $clientFace = $("#clientFace"); $testimonialCarousel.owlCarousel({ singleItem: true, autoPlay: true, pagination: false, autoHeight: true, beforeMove: function(parm){ var owl = $testimonialCarousel.data('owlCarousel'); var image = $reviews[owl.currentItem]; image = $(image).data('client-image'); //console.log(image); $clientFace.css('background-image', 'url('+image+')'); } }); $('.carosel-wrapper .prev').click(function(e){ e.preventDefault(); $testimonialCarousel.trigger('owl.prev'); }); $('.carosel-wrapper .next').click(function(e){ e.preventDefault(); $testimonialCarousel.trigger('owl.next'); }); })(); /*------------------------------------------ Video Player ------------------------------------------*/ /* * @author Rob W (http://stackoverflow.com/a/7513356/938089 * @description Executes function on a framed YouTube video (see previous link) * For a full list of possible functions, see: * http://code.google.com/apis/youtube/js_api_reference.html * @param String frame_id The id of (the div containing) the frame * @param String func Desired function to call, eg. "playVideo" * @param Array args (optional) List of arguments to pass to function func*/ function callPlayer(frame_id, func, args) { if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id; var iframe = document.getElementById(frame_id); if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') { iframe = iframe.getElementsByTagName('iframe')[0]; } if (iframe) { // Frame exists, iframe.contentWindow.postMessage(JSON.stringify({ "event": "command", "func": func, "args": args || [], "id": frame_id }), "*"); } } $("#playVideo").click(function(e){ e.preventDefault(); callPlayer("ytPlayer","playVideo"); $("#video").hide(); $("#video-container").fadeIn(); });