(function(window,undefined){ })(window); (function ($) { // Prepare var History = window.History; // Note: We are using a capital H instead of a lower h if ( !History.enabled ) { // History.js is disabled for this browser. // This is because we can optionally choose to support HTML4 browsers or not. return false; } // Bind to StateChange Event History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate var State = History.getState(); // Note: We are using History.getState() instead of event.state updateContent(History.getState()); }); /* Change our States History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1" History.pushState({state:2}, "State 2", "?state=2"); // logs {state:2}, "State 2", "?state=2" History.replaceState({state:3}, "State 3", "?state=3"); // logs {state:3}, "State 3", "?state=3" History.pushState(null, null, "?state=4"); // logs {}, '', "?state=4" History.back(); // logs {state:3}, "State 3", "?state=3" History.back(); // logs {state:1}, "State 1", "?state=1" History.back(); // logs {}, "Home Page", "?" History.go(2); // logs {state:3}, "State 3", "?state=3" */ if(!( $('body').hasClass('front') || $('body').hasClass('page-strategies') || $('body').hasClass('page-tools') || $('body').hasClass('page-cases') || $('body').hasClass('page-basics') )) { $('body').addClass('loaded'); $('body').addClass('doneloading'); } function replaceLightbox(){ $("html, body").animate({ scrollTop: 0 }, "slow"); } function closeLightbox(){ $('body').removeClass('loaded'); $('body').removeClass('doneloading'); $('#ajaxcontent').html(''); } function goHome(){ var urlPath = '/'; var title = 'Home'; pushLink(urlPath, title); } function ajaxifyLinks(links){ links.click(function(e) { var urlPath = $(this).attr('href'); var title = $(this).text(); pushLink(urlPath, title); return false; // prevents default click action of }); } function pushLink(urlPath, title){ ////console.log(urlPath); ////console.log(title); History.pushState({urlPath: urlPath}, title, urlPath); } function isohope(){ } function replacePaneLink(urlPath, title){ ////console.log(urlPath); ////console.log(title); History.replaceState({urlPath: urlPath}, title, urlPath); switch (urlPath){ case '/basics': ////console.log('background broke 1'); closeLightbox(); clickLogic($('#background.slideme')); break; case '/strategies': // //console.log('strategies broke 1'); closeLightbox(); clickLogic($('#strategies.slideme')); break; case '/tools': ////console.log('tools broke 1'); closeLightbox(); clickLogic($('#tools.slideme')); setTimeout(function(){ $('#toolsviewer').isotope({ itemSelector : '.tool', masonry: { columnWidth: $('#toolsviewer').width() / 8 } }); },2000); break; case '/cases': //console.log('cases broke 1'); closeLightbox(); clickLogic($('#cases.slideme')); setTimeout(function(){ $('#casesviewer').isotope({ itemSelector : '.case', masonry: { columnWidth: $('#casesviewer').width() / 8 } }); },2000); break; } } var openLightbox = function(target, urlBase, selector) { $('#ajaxouterwrapper').show(); $("html, body").animate({ scrollTop: 0 }, 200, function(){ $('body').removeClass('doneloading'); $('body').removeClass('loaded'); $('#ajaxcontent').html(''); $('body').addClass('loaded'); }); $(target).load(urlBase + ' ' + ' #main-content', function(){ $('body').addClass('doneloading'); ajaxifyLinks($('#ajaxcontent a')); }); }; var updateContent = function(State) { var selector = '#' + State.data.urlPath.substring(1); //console.log('in updateContent, url =', State.url); //console.log(selector); switch (selector){ case '#basics': closeLightbox(); //console.log('background broke 2'); break; case '#strategies': closeLightbox(); //console.log('strategies broke 2'); break; case '#tools': closeLightbox(); //console.log('tools broke 2'); break; case '#cases': closeLightbox(); //console.log('cases broke 2'); break; } if(selector.length > 1){ if ($(selector).length) { //content is already in #hidden_content } else { switch (selector){ case '#basics': closeLightbox(); //console.log('background broke 2'); break; case '#strategies': closeLightbox(); //console.log('strategies broke 2'); break; case '#tools': closeLightbox(); //console.log('tools broke 2'); break; case '#cases': closeLightbox(); //console.log('cases broke 2'); break; default: openLightbox('#ajaxcontent', State.url, selector); } } }else{ closeLightbox(); goHome(); } }; function clickLogic(pane){ //console.log('pane attr:' + pane.parent().attr('id')); if(!($(pane).hasClass('openpane'))){ //console.log('openiz'); $('.slideme').removeClass('openpane').removeClass('collapsedpane').addClass('collapsedpane'); $(pane).removeClass('collapsedpane').addClass('openpane'); $('#whatdoyouneedbro').slideUp(); $("html, body").animate({ scrollTop: 0 }, 200); }else{ //console.log('closeme'); $('.slideme').removeClass('openpane').removeClass('collapsedpane'); } } //console.log('oooop'); $(document).ready(function(){ $('.filterterm').click(function(){ $('.activefilter').removeClass('activefilter'); $(this).addClass('activefilter'); //console.log("clicked"); var selector = $(this).attr('data-filter'); //console.log("clicked"+selector); $('#toolsviewer').isotope({ filter: '.' + selector, layoutMode : 'masonry' }); $('#casesviewer').isotope({ filter: '.' + selector, layoutMode : 'masonry' }); }); $('.tool').click(function(){ $('.activetool').removeClass('activetool'); $(this).addClass('activetool'); $('#toolsviewer').isotope('reLayout'); }) $('.bigblock .case').click(function(){ $('.activetool').removeClass('activetool'); $(this).addClass('activetool'); $('#casesviewer').isotope('reLayout'); }) $('#background .paneltitle').click(function(){ replacePaneLink('/basics', 'Basics'); }); $('#strategies .paneltitle').click(function(){ replacePaneLink('/strategies', 'Strategies'); }); $('#tools .paneltitle').click(function(){ replacePaneLink('/tools', 'Tools'); }); $('#tools .smallblock .filterterm').click(function(){ var idd = $(this).attr('data-filter'); replacePaneLink('/tools', 'Tools'); setTimeout(function(){ $('#tools .bigblock .a' +idd).trigger('click'); //console.log('#tools .bigblock .a' +idd); },2000); }); $('#cases .paneltitle').click(function(){ replacePaneLink('/cases', 'Cases'); }); $('#background .plusbutton').click(function(){ replacePaneLink('/basics', 'Basics'); }) $('#strategies .plusbutton').click(function(){ replacePaneLink('/strategies', 'Strategies'); }) $('#tools .plusbutton').click(function(){ replacePaneLink('/tools', 'Tools'); }) $('#cases .plusbutton').click(function(){ replacePaneLink('/cases', 'Cases'); }) $('.page-basics #background .paneltitle').trigger('click'); $('.page-strategies #strategies .paneltitle').trigger('click'); $('.page-tools #tools .paneltitle').trigger('click'); $('.page-cases #cases .paneltitle').trigger('click'); // navigation link handler ajaxifyLinks($('.slideme a')); ajaxifyLinks($('#ajaxcontent a')); $('#closebutton').click(function(){ closeLightbox(); goHome(); }); refreshAnchors(); }); function filterPath(string) { return string .replace(/^\//,'') .replace(/(index|default).[a-zA-Z]{3,4}$/,'') .replace(/\/$/,''); } var locationPath = filterPath(window.location.pathname); var scrollElem = scrollableElement('html', 'body'); function refreshAnchors(){ $('a[href*=#]').each(function() { var thisPath = filterPath(this.pathname) || locationPath; if ( locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,'') ) { var $target = $(this.hash), target = this.hash; if (target && $target.offset()!=null) { var targetOffset = $target.offset().top; //console.log('yes'+targetOffset); $(this).unbind("click"); $(this).click(function(event){ event.preventDefault(); $('.highlightanchor').removeClass('highlightanchor'); $(this).addClass('highlightanchor'); $target.addClass('highlightanchor'); $(this).parent().addClass('highlightanchor'); $target.parent().addClass('highlightanchor'); $('html, body').animate({scrollTop: targetOffset-140}, 400, function() { location.hash = target; }); }); } } }); } // use the first element that is "scrollable" function scrollableElement(els) { for (var i = 0, argLength = arguments.length; i 0) { return el; } else { $scrollElement.scrollTop(1); var isScrollable = $scrollElement.scrollTop()> 0; $scrollElement.scrollTop(0); if (isScrollable) { return el; } } } return []; } })(jQuery);