new WOW().init(); jQuery(document).ready(function($) { $(window).bind('load', function() { $('#loader').fadeOut(70); }); /*============================================ Welcome Cookies ==============================================*/ $(function dw_set_cookie() { var COOKIE = 'windhamdavid-cookie'; var dwcookie = $.cookie(COOKIE); if (dwcookie == null) { $.cookie(COOKIE, 'yum-cookies', { expires: 7, path: '/'}); $('.welcome').typed({ strings: ['Hey,', 'Hello,\n^10Welcome to ^10my domain ^10...^10', 'Hello, \nWelcome to my little corner of the internet. \n^10It is nice to ', 'Hello, \nWelcome to my little corner of the internet. \nIt is very nice to have you here!^10\n'], typeSpeed: -40, backSpeed: -70, startDelay: 0, backDelay: 0, loop: false, loopCount: false, attr: null, callback: function(){ dw_shift(); } }); } else { $('.intro').collapse('hide'); $('.terminal').modal('show'); $('.welcome-back-text').typed({ strings: ['Hello...', 'Welcome back'], typeSpeed: 10, backSpeed: 70, startDelay: 0, backDelay: 0, loop: false, loopCount: false, attr: null, callback: function(){ dw_terminal(); dw_collapse(); } }); } }); function dw_shift() { var collapseh = $('.intro').height(); $('.leader').ScrollTo({ offset: -(collapseh), duration: 1500, easing: 'linear', callback: function(){ dw_collapse(); } }); $('.intro').slideToggle({ duration: 1000, easing: 'linear' }); } function dw_collapse() { $('.welcome-back-text').addClass('.welcome-back-text:after'); //$('.intro').collapse('hide'); //$('.terminal').modal('hide'); } /*============================================ Terminal ==============================================*/ (function ($){ $.fn.cli = function(handler, prompt, effect){ if (!prompt) prompt = 'you@david > '; if (!effect) effect = $.fn.text; return this.each(function(){ var self = $(this); function newline(){ self. append('
'+prompt+'
'); try { $('[contenteditable]', self)[0].focus(); }catch(e){ } } newline(); self.on('keydown', '[contenteditable]', function(evt){ if (evt.keyCode === 13){ $(this).removeAttr('contenteditable'); // IE needs special handling which jQuery provides effect.call($('').appendTo(self),handler(this.textContent || this.innerText)); newline(); return false; } }); }); }; })(jQuery); function dw_terminal(){ function type(text){ var span = $('').appendTo(this).after(' '); var style = $('').appendTo('head'); $('p.input').addClass('old'); var progress = 0; var timer = setInterval (function(){ span.text(text.substr(0, progress++)); if (progress > text.length){ $('#blinker').remove(); style.remove(); $('[contenteditable]')[0].focus(); clearInterval(timer); } },100); } $('.thermo').cli(function(text){ if (/exit/i.test(text)) { $('.terminal').modal('hide'); } if (/help/i.test(text)) return "I need somebody. Type 'exit' to close"; if (/hello/i.test(text)) return "Hello to you!"; if (/what/i.test(text)) return "This is a website silly human"; if (/and/i.test(text)) return "and what?"; if (/who/i.test(text)) return "David A. Windham"; if (/when/i.test(text)) return "Yesterday"; if (/how/i.test(text)) return "JavaScript is a dynamic computer programming language"; if (/why/i.test(text)) return "For fun"; if (/you/i.test(text)) return "your mama"; if (/cd ../i.test(text)) return "Oh, I see"; if (/thermonuclear/i.test(text)) return "Wouldn't you prefer a nice game of chess?"; if (text.length < 3) return "type 'exit' to close"; return 'command not found: '+text; }, null, type); $('p.input').on('touchstart click', function(e) { e.preventDefault(); $('[contenteditable]')[0].focus(); }); } /*============================================ Navigation ==============================================*/ $('.nav-toggle').on('touchstart click', function(e) { e.preventDefault(); $( this ).toggleClass( 'active' ); }); $('#nav').affix({ offset: {top: $('.intro').height()-$('.navbar').height()} }); $(function dw_hidenav() { var headerHeight = $('.navbar').height(); $(window).on('scroll', { previousTop: 0 }, function() { var currentTop = $(window).scrollTop(); if (currentTop < this.previousTop) { if (currentTop > 0 && $('.navbar').hasClass('fixed')) { $('.navbar').addClass('visible'); } else { $('.navbar').removeClass('visible fixed'); } } else { $('.navbar').removeClass('visible'); if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed'); } this.previousTop = currentTop; } ); }); /*============================================ Carousel ==============================================*/ $('.carousel').carousel({ interval: false }); $('#caro-lead').on('slide.bs.carousel', function() { $('.carousel-caption').fadeIn(600); //$('#tv').removeClass('invert'); }); $('#caro-lead').on('slid.bs.carousel', function() { $('.carousel-caption').fadeOut(600); //$('#tv').addClass('invert'); }); $('.caro').carousel({ interval: 9000 }); $(document).bind('keyup', function(e) { if(e.which === 39){ //$('#caro-lead').carousel('next'); $('#caro').carousel('next'); } else if(e.which === 37){ //$('#caro-lead').carousel('prev'); $('#caro').carousel('prev'); } }); /*============================================ SVG Animate ==============================================*/ (function() { var myAnimation = new DrawFillSVG({elementId: 'sv'}); })(); $('#caro').on('slid.bs.carousel', function() { $('.active .animac').removeClass('hide-svg fade-svg'); var animac = new DrawFillSVG({elementId: 'svg-mac'}); var animac1 = new DrawFillSVG({elementId: 'svg-imac'}); var animac2 = new DrawFillSVG({elementId: 'svg'}); animac.replay(); animac1.replay(); animac2.replay(); }); $('#caro').on('slide.bs.carousel', function() { $('.active #svg-imac.bg').attr('class', 'svg screen'); $('.active .animac').addClass('fade-svg').delay(1000).queue(function(hideit){ $(this).addClass('hide-svg'); hideit(); }); }); $('#caro').on('slid.bs.carousel', function() { $('.active #svg-imac.screen').delay(2500).queue(function(screenit){ $(this).attr('class', 'bg'); screenit(); }); }); /*============================================ Comments ==============================================*/ $('#comments').hide(); $('.toggle-comments').on('touchstart click', function(e) { e.preventDefault(); $('#comments').toggle('slow', function() { var anchor = $('.toggle-comments'); var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments'; $(anchor).text(anchorText); }); }); $('#commentform').validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 20 } }, messages: { author: 'Please enter in your name.', email: 'Please enter a valid email address.', comment: 'Nothing to Say?' }, errorElement: 'div', errorPlacement: function(error, element) { element.before(error); } }); /*============================================ SmoothState ==============================================*/ /*============================================ Calendar ==============================================*/ $('.calendar').fullCalendar ({ firstDay : 1, height: 345, events: [ { title: 'Project', start: '2014-09-27', end: '2014-10-02' }, { title: 'Conf', start: '2014-10-11', end: '2014-10-13', borderColor: 'red' }, { title: 'off', start: '2014-10-13', end: '2014-10-16' }, { title: 'Contract', start: '2014-10-16', end: '2014-10-31' }, { title: 'Contract', start: '2014-11-03', end: '2014-11-22' }, { title: 'Project', start: '2014-12-01', end: '2014-12-06' }, { title: 'Project', start: '2014-12-08', end: '2014-12-13' }, { title: 'Holiday', start: '2014-12-22', end: '2015-01-05', borderColor: 'red' }, { title: 'Project', start: '2015-01-06', end: '2015-01-25' }, { title: 'Project', start: '2015-02-02', end: '2015-02-14' }, { title: 'Holiday', start: '2015-02-14', end: '2015-02-19', borderColor: 'red' } ] }); });