init.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. new WOW().init();
  2. jQuery(document).ready(function($) {
  3. $(window).bind('load', function() {
  4. $('#loader').fadeOut(700);
  5. });
  6. /*============================================
  7. Welcome Cookies
  8. ==============================================*/
  9. $(function dw_set_cookie() {
  10. var COOKIE = 'windhamdavid-cookie';
  11. var dwcookie = $.cookie(COOKIE);
  12. if (dwcookie == null) {
  13. $.cookie(COOKIE, 'yum-cookies', { expires: 7, path: '/'});
  14. $('.terminal-welcome').modal('show');
  15. $('.welcome').typed({
  16. 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. \nWhat is your name?^200\n'],
  17. typeSpeed: 30,
  18. backSpeed: 50,
  19. startDelay: 0,
  20. backDelay: 0,
  21. loop: false,
  22. loopCount: false,
  23. attr: null,
  24. callback: function(){
  25. dw_terminal();
  26. }
  27. });
  28. $('.first-slide').css('visibility','hidden');
  29. }
  30. else {
  31. $('.terminal').modal('show');
  32. if (localStorage.getItem('person') === null) {
  33. var person = 'anonymous person';
  34. }
  35. else {
  36. var person = localStorage.getItem('person');
  37. }
  38. $('.welcome-back-text').typed({
  39. strings: ['...', 'Welcome back ' +person],
  40. typeSpeed: 30,
  41. backSpeed: 50,
  42. startDelay: 0,
  43. backDelay: 0,
  44. loop: false,
  45. loopCount: false,
  46. attr: null,
  47. callback: function(){
  48. dw_terminal();
  49. }
  50. });
  51. $('.first-slide').css('visibility','hidden');
  52. $('.terminal').on('hidden.bs.modal', function () {
  53. dw_caro();
  54. $('.first-slide').css('visibility','visible');
  55. });
  56. }
  57. });
  58. function dw_shift() {
  59. $('.terminal-welcome').modal('hide');
  60. $('.terminal-welcome').on('hidden.bs.modal', function () {
  61. dw_caro();
  62. $('.first-slide').css('visibility','visible');
  63. });
  64. }
  65. /*============================================
  66. Terminal
  67. ==============================================*/
  68. (function ($){
  69. $.fn.cli = function(handler, prompt, effect){
  70. if (!prompt) prompt = '<span class="u">you</span><span class="at">@</span><span class="mee">david</span>&nbsp;&gt;&nbsp;';
  71. if (!effect) effect = $.fn.text;
  72. return this.each(function(){
  73. var self = $(this);
  74. function newline(){
  75. self.
  76. append('<p class=input><span class=prompt>'+prompt+'</span><span style=outline:none contenteditable></span></p>');
  77. try {
  78. $('[contenteditable]', self)[0].focus();
  79. }catch(e){
  80. }
  81. }
  82. newline();
  83. self.on('keydown', '[contenteditable]', function(evt){
  84. if (evt.keyCode === 13){
  85. $(this).removeAttr('contenteditable');
  86. effect.call($('<p class=response>').appendTo(self),handler(this.textContent || this.innerText));
  87. newline();
  88. return false;
  89. }
  90. });
  91. });
  92. };
  93. })(jQuery);
  94. function dw_terminal(){
  95. function type(text){
  96. var span = $('<span>').appendTo(this).after('<span id="blinker" style="background:green">&nbsp;&nbsp;</span>');
  97. var style = $('<style>p.input {visibility: hidden} p.input.old {visibility: visible}</style>').appendTo('head');
  98. $('p.input').addClass('old');
  99. var progress = 0;
  100. var timer = setInterval (function(){
  101. span.text(text.substr(0, progress++));
  102. if (progress > text.length){
  103. $('#blinker').remove();
  104. style.remove();
  105. $('[contenteditable]')[0].focus();
  106. clearInterval(timer);
  107. }
  108. },100);
  109. }
  110. $('.thermo-intro').cli(function(text){
  111. if (text.length > 1) {
  112. localStorage.setItem('person', text),
  113. dw_shift();
  114. };
  115. return '';
  116. }, null, type);
  117. $('.thermo').cli(function(text){
  118. if (/exit/i.test(text)) {
  119. $('.terminal').modal('hide');
  120. }
  121. if (/help/i.test(text)) return "I need somebody. Type 'exit' to close";
  122. if (/hello/i.test(text)) return "Hello to you!";
  123. if (/what/i.test(text)) return "This is a website silly human";
  124. if (/and/i.test(text)) return "and what?";
  125. if (/who/i.test(text)) return "David A. Windham";
  126. if (/when/i.test(text)) return "Yesterday";
  127. if (/how/i.test(text)) return "JavaScript is a dynamic computer programming language";
  128. if (/why/i.test(text)) return "For fun";
  129. if (/you/i.test(text)) return "your mama";
  130. if (/cd ../i.test(text)) return "Oh, I see";
  131. if (/thermonuclear/i.test(text)) return "Wouldn't you prefer a nice game of chess?";
  132. if (text.length < 3) return "type 'exit' to close";
  133. return 'command not found: '+text;
  134. }, null, type);
  135. $('p.input').on('touchstart click', function(e) {
  136. e.preventDefault();
  137. $('[contenteditable]')[0].focus();
  138. });
  139. }
  140. /*============================================
  141. Navigation
  142. ==============================================*/
  143. $('.nav-toggle').on('touchstart click', function(e) {
  144. e.preventDefault();
  145. $( this ).toggleClass( 'active' );
  146. });
  147. $('#nav').affix({
  148. //offset: {top: $('.intro').height()-$('.navbar').height()}
  149. });
  150. $('.about').affix({
  151. top: 0,
  152. bottom: 0
  153. });
  154. $(function dw_hidenav() {
  155. var headerHeight = $('.navbar').height();
  156. $(window).on('scroll', { previousTop: 0 },
  157. function() {
  158. var currentTop = $(window).scrollTop();
  159. if (currentTop < this.previousTop) {
  160. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  161. $('.navbar').addClass('visible');
  162. $('.site-title a').removeClass('light');
  163. } else {
  164. $('.navbar').removeClass('visible fixed');
  165. $('.site-title a').addClass('light');
  166. }
  167. }
  168. else {
  169. $('.navbar').removeClass('visible');
  170. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  171. }
  172. this.previousTop = currentTop;
  173. }
  174. );
  175. });
  176. /*============================================
  177. Carousel
  178. ==============================================*/
  179. function dw_caro(){
  180. $('#caro-lead').carousel({
  181. interval: 5777,
  182. wrap: true,
  183. pause: false
  184. });
  185. var vidout = document.getElementById('tv');
  186. vidout.play();
  187. $('.posts-front').show();
  188. }
  189. $('#caro-lead').on('slide.bs.carousel', function(event) {
  190. $('.carousel-caption').fadeIn(600);
  191. var consta = $(event.target);
  192. setTimeout(function() {
  193. if (consta.find('.item.active').data('id') === 1) {
  194. $('#tv').removeClass('unblur').addClass('blur');
  195. var anistars = new DrawFillSVG({elementId: 'sites'});
  196. anistars.replay();
  197. $('#tv').delay(100).queue(function(pauseit){
  198. var vidin = document.getElementById('tv');
  199. vidin.pause();
  200. pauseit();
  201. });
  202. }
  203. if (consta.find('.item.active').data('id') === 2) {
  204. $('#tv').removeClass('unblur').addClass('blur');
  205. var anibrain = new DrawFillSVG({elementId: 'brain'});
  206. anibrain.replay();
  207. $('#tv').delay(100).queue(function(pauseit){
  208. var vidin = document.getElementById('tv');
  209. vidin.pause();
  210. pauseit();
  211. });
  212. }
  213. if (consta.find('.item.active').data('id') === 3) {
  214. $('.leader').delay(100).queue(function(closeit){
  215. dw_caro_hide();
  216. closeit();
  217. });
  218. }
  219. }, 10);
  220. });
  221. function dw_caro_hide(){
  222. $('.leader').fadeTo(500,0, function() {
  223. $('.leader').slideUp(800);
  224. $('.leader').delay(1000).queue(function(scrollit){
  225. $('.posts-front').ScrollTo({
  226. duration: 1000,
  227. easing: 'linear',
  228. });
  229. });
  230. $('#caro-lead').carousel('pause');
  231. })
  232. }
  233. $('#caro-lead').on('slid.bs.carousel', function() {
  234. $('.carousel-caption').fadeOut(600);
  235. $('#tv').delay(3200).queue(function(playit){
  236. $('#tv').addClass('unblur').removeClass('blur');
  237. var vidout = document.getElementById('tv');
  238. vidout.play();
  239. playit();
  240. });
  241. });
  242. $('.caro-grad').appear();
  243. $('.caro-grad').one('appear', dw_appear);
  244. function dw_appear() {
  245. $('#caro').carousel({
  246. interval: 5555,
  247. wrap: false,
  248. pause: false
  249. });
  250. var anima = new DrawFillSVG({elementId: 'sv'});
  251. anima.replay();
  252. };
  253. $(document).bind('keyup', function(e) {
  254. if(e.which === 39){
  255. //$('#caro-lead').carousel('next');
  256. $('#caro').carousel('next');
  257. }
  258. else if(e.which === 37){
  259. //$('#caro-lead').carousel('prev');
  260. $('#caro').carousel('prev');
  261. }
  262. });
  263. /*============================================
  264. SVG Animate
  265. ==============================================*/
  266. $('#caro').on('slid.bs.carousel', function() {
  267. $('.active .animac').removeClass('hide-svg fade-svg');
  268. var animac = new DrawFillSVG({elementId: 'svg-mac'});
  269. var animac1 = new DrawFillSVG({elementId: 'svg-imac'});
  270. var animac2 = new DrawFillSVG({elementId: 'svg'});
  271. animac.replay();
  272. animac1.replay();
  273. animac2.replay();
  274. });
  275. $('#caro').on('slide.bs.carousel', function() {
  276. $('.active #svg-imac.bg').attr('class', 'svg screen');
  277. $('.active .animac').addClass('fade-svg').delay(1000).queue(function(hideit){
  278. $(this).addClass('hide-svg');
  279. hideit();
  280. });
  281. });
  282. $('#caro').on('slid.bs.carousel', function() {
  283. $('.active #svg-imac.screen').delay(2500).queue(function(screenit){
  284. $(this).attr('class', 'bg');
  285. screenit();
  286. });
  287. });
  288. /*============================================
  289. Comments
  290. ==============================================*/
  291. $('#comments').hide();
  292. $('.toggle-comments').on('touchstart click', function(e) {
  293. e.preventDefault();
  294. $('#comments').toggle('slow', function() {
  295. var anchor = $('.toggle-comments');
  296. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  297. $(anchor).text(anchorText);
  298. });
  299. });
  300. $('#commentform').validate({
  301. rules: {
  302. author: {
  303. required: true,
  304. minlength: 2
  305. },
  306. email: {
  307. required: true,
  308. email: true
  309. },
  310. comment: {
  311. required: true,
  312. minlength: 20
  313. }
  314. },
  315. messages: {
  316. author: 'Please enter in your name.',
  317. email: 'Please enter a valid email address.',
  318. comment: 'Nothing to Say?'
  319. },
  320. errorElement: 'div',
  321. errorPlacement: function(error, element) {
  322. element.before(error);
  323. }
  324. });
  325. /*============================================
  326. SmoothState
  327. ==============================================*/
  328. /*============================================
  329. Calendar
  330. ==============================================*/
  331. $('.calendar').fullCalendar ({
  332. firstDay : 1,
  333. height: 345,
  334. events: [
  335. {
  336. title: 'Project',
  337. start: '2014-09-27',
  338. end: '2014-10-02'
  339. },
  340. {
  341. title: 'Conf',
  342. start: '2014-10-11',
  343. end: '2014-10-13',
  344. borderColor: 'red'
  345. },
  346. {
  347. title: 'off',
  348. start: '2014-10-13',
  349. end: '2014-10-16'
  350. },
  351. {
  352. title: 'Contract',
  353. start: '2014-10-16',
  354. end: '2014-10-31'
  355. },
  356. {
  357. title: 'Contract',
  358. start: '2014-11-03',
  359. end: '2014-11-22'
  360. },
  361. {
  362. title: 'Project',
  363. start: '2014-12-01',
  364. end: '2014-12-06'
  365. },
  366. {
  367. title: 'Project',
  368. start: '2014-12-08',
  369. end: '2014-12-13'
  370. },
  371. {
  372. title: 'Holiday',
  373. start: '2014-12-22',
  374. end: '2015-01-05',
  375. borderColor: 'red'
  376. },
  377. {
  378. title: 'Project',
  379. start: '2015-01-06',
  380. end: '2015-01-25'
  381. },
  382. {
  383. title: 'Project',
  384. start: '2015-02-02',
  385. end: '2015-02-14'
  386. },
  387. {
  388. title: 'Holiday',
  389. start: '2015-02-14',
  390. end: '2015-02-19',
  391. borderColor: 'red'
  392. }
  393. ]
  394. });
  395. });