/** * Replace jQuery's $.fn.ready() function with a mod exec * * Sites that make heavy use of the $(document).ready function * are generally incompatable with asynchrounous content. The * the $.fn.ready function only runs once. This script replaces * the ready function with a module execution controller that * let's us register functions and execute all of the functions * as we need them. This is useful after HTML gets injected on the * page and we want to rebind functionally to the new content. * * @author Miguel Ángel Pérez reachme@miguel-perez.com * @note Should be placed directly after jQuery on the page * */ ;(function($){ var $doc = $(document); /** create mod exec controller */ $.readyFn = { list: [], register: function(fn) { $.readyFn.list.push(fn); }, execute: function() { for (var i = 0; i < $.readyFn.list.length; i++) { try { $.readyFn.list[i].apply(document, [$]); } catch (e) { throw e; } }; } }; /** run all functions */ $doc.ready(function(){ $.readyFn.execute(); }); /** register function */ $.fn.ready = function(fn) { $.readyFn.register(fn); }; })(jQuery); //Masonry jQuery(document).ready(function($){ var $container = $('.masonry').imagesLoaded( function() { //var $container = $('.masonry'); $container.imagesLoaded(function(){ $container.masonry({ // options //columnWidth: '.grid-sizer', itemSelector: '.grid-item', percentPosition: true, //columnWidth: 200 }); }); }); $('#cssmenu').prepend(''); $('#cssmenu #menu-button').on('click', function(){ var menu = $(this).next('ul'); if (menu.hasClass('open')) { menu.removeClass('open'); } else { menu.addClass('open'); } }); function addBlacklistClass() { $( 'a' ).each( function() { if ( this.href.indexOf('/wp-admin/') !== -1 || this.href.indexOf('/wp-login.php') !== -1 ) { $( this ).addClass( 'wp-link' ); } }); } function addMenu() { $('#menu-icon').click(function(){ //this is for the burger menu $(this).toggleClass('open'); //this toggles the height var theHeight = $(window).height(); if($('#menu-wrapper').hasClass('show')) { $('#menu-wrapper').animate({height:0},500).removeClass('show'); } else { $('#menu-wrapper').animate({height:theHeight,display:"block"},500).addClass('show'); } }); } $( function() { addBlacklistClass(); addMenu(); var settings = { anchors: 'a', blacklist: '.wp-link, .wp-link a', onStart: { duration: 280, // ms render: function ( $container ) { $container.addClass( 'slide-out' ); } }, onAfter: function( $container ) { addBlacklistClass(); addMenu(); $.readyFn.execute(); $container.removeClass( 'slide-out' ); var $hash = $( window.location.hash ); if ( $hash.length !== 0 ) { var offsetTop = $hash.offset().top; $( 'body, html' ).animate( { scrollTop: ( offsetTop - 60 ), }, { duration: 280 } ); } } }; $( '#page' ).smoothState( settings ); } ); });