init.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. $(function dw_hidenav() {
  151. var headerHeight = $('.navbar').height();
  152. $(window).on('scroll', { previousTop: 0 },
  153. function() {
  154. var currentTop = $(window).scrollTop();
  155. if (currentTop < this.previousTop) {
  156. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  157. $('.navbar').addClass('visible');
  158. $('.site-title a').removeClass('light');
  159. } else {
  160. $('.navbar').removeClass('visible fixed');
  161. $('.site-title a').addClass('light');
  162. }
  163. }
  164. else {
  165. $('.navbar').removeClass('visible');
  166. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  167. }
  168. this.previousTop = currentTop;
  169. }
  170. );
  171. });
  172. /*============================================
  173. Carousel
  174. ==============================================*/
  175. function dw_caro(){
  176. $('#caro-lead').carousel({
  177. interval: 5777,
  178. wrap: true,
  179. pause: false
  180. });
  181. var vidout = document.getElementById('tv');
  182. vidout.play();
  183. $('.posts-front').show();
  184. }
  185. $('#caro-lead').on('slide.bs.carousel', function(event) {
  186. $('.carousel-caption').fadeIn(600);
  187. var consta = $(event.target);
  188. setTimeout(function() {
  189. if (consta.find('.item.active').data('id') === 1) {
  190. $('#tv').removeClass('unblur').addClass('blur');
  191. var anistars = new DrawFillSVG({elementId: 'sites'});
  192. anistars.replay();
  193. $('#tv').delay(100).queue(function(pauseit){
  194. var vidin = document.getElementById('tv');
  195. vidin.pause();
  196. pauseit();
  197. });
  198. }
  199. if (consta.find('.item.active').data('id') === 2) {
  200. $('#tv').removeClass('unblur').addClass('blur');
  201. var anibrain = new DrawFillSVG({elementId: 'brain'});
  202. anibrain.replay();
  203. $('#tv').delay(100).queue(function(pauseit){
  204. var vidin = document.getElementById('tv');
  205. vidin.pause();
  206. pauseit();
  207. });
  208. }
  209. if (consta.find('.item.active').data('id') === 3) {
  210. $('.leader').delay(100).queue(function(closeit){
  211. dw_caro_hide();
  212. closeit();
  213. });
  214. }
  215. }, 10);
  216. });
  217. function dw_caro_hide(){
  218. $('.leader').fadeTo(500,0, function() {
  219. $('.leader').slideUp(800);
  220. $('.leader').delay(1000).queue(function(scrollit){
  221. $('.posts-front').ScrollTo({
  222. duration: 1000,
  223. easing: 'linear',
  224. });
  225. });
  226. $('#caro-lead').carousel('pause');
  227. })
  228. }
  229. $('#caro-lead').on('slid.bs.carousel', function() {
  230. $('.carousel-caption').fadeOut(600);
  231. $('#tv').delay(3200).queue(function(playit){
  232. $('#tv').addClass('unblur').removeClass('blur');
  233. var vidout = document.getElementById('tv');
  234. vidout.play();
  235. playit();
  236. });
  237. });
  238. $('.caro-grad').appear();
  239. $('.caro-grad').one('appear', dw_appear);
  240. function dw_appear() {
  241. $('#caro').carousel({
  242. interval: 5555,
  243. wrap: false,
  244. pause: false
  245. });
  246. var anima = new DrawFillSVG({elementId: 'sv'});
  247. anima.replay();
  248. };
  249. $(document).bind('keyup', function(e) {
  250. if(e.which === 39){
  251. //$('#caro-lead').carousel('next');
  252. $('#caro').carousel('next');
  253. }
  254. else if(e.which === 37){
  255. //$('#caro-lead').carousel('prev');
  256. $('#caro').carousel('prev');
  257. }
  258. });
  259. /*============================================
  260. SVG Animate
  261. ==============================================*/
  262. $('#caro').on('slid.bs.carousel', function() {
  263. $('.active .animac').removeClass('hide-svg fade-svg');
  264. var animac = new DrawFillSVG({elementId: 'svg-mac'});
  265. var animac1 = new DrawFillSVG({elementId: 'svg-imac'});
  266. var animac2 = new DrawFillSVG({elementId: 'svg'});
  267. animac.replay();
  268. animac1.replay();
  269. animac2.replay();
  270. });
  271. $('#caro').on('slide.bs.carousel', function() {
  272. $('.active #svg-imac.bg').attr('class', 'svg screen');
  273. $('.active .animac').addClass('fade-svg').delay(1000).queue(function(hideit){
  274. $(this).addClass('hide-svg');
  275. hideit();
  276. });
  277. });
  278. $('#caro').on('slid.bs.carousel', function() {
  279. $('.active #svg-imac.screen').delay(2500).queue(function(screenit){
  280. $(this).attr('class', 'bg');
  281. screenit();
  282. });
  283. });
  284. /*============================================
  285. Comments
  286. ==============================================*/
  287. $('#comments').hide();
  288. $('.toggle-comments').on('touchstart click', function(e) {
  289. e.preventDefault();
  290. $('#comments').toggle('slow', function() {
  291. var anchor = $('.toggle-comments');
  292. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  293. $(anchor).text(anchorText);
  294. });
  295. });
  296. $('#commentform').validate({
  297. rules: {
  298. author: {
  299. required: true,
  300. minlength: 2
  301. },
  302. email: {
  303. required: true,
  304. email: true
  305. },
  306. comment: {
  307. required: true,
  308. minlength: 3
  309. }
  310. },
  311. messages: {
  312. author: 'Please enter in your name.',
  313. email: 'Please enter a valid email address.',
  314. comment: 'Nothing to Say?'
  315. },
  316. errorElement: 'div',
  317. errorPlacement: function(error, element) {
  318. element.before(error);
  319. }
  320. });
  321. /*============================================
  322. SmoothState
  323. ==============================================*/
  324. /*============================================
  325. Calendar
  326. ==============================================*/
  327. $('.calendar').fullCalendar ({
  328. firstDay : 1,
  329. height: 345,
  330. events: [
  331. {
  332. title: 'Project',
  333. start: '2014-09-27',
  334. end: '2014-10-02'
  335. },
  336. {
  337. title: 'Conf',
  338. start: '2014-10-11',
  339. end: '2014-10-13',
  340. borderColor: 'red'
  341. },
  342. {
  343. title: 'off',
  344. start: '2014-10-13',
  345. end: '2014-10-16'
  346. },
  347. {
  348. title: 'Contract',
  349. start: '2014-10-16',
  350. end: '2014-10-31'
  351. },
  352. {
  353. title: 'Contract',
  354. start: '2014-11-03',
  355. end: '2014-11-22'
  356. },
  357. {
  358. title: 'Project',
  359. start: '2014-12-01',
  360. end: '2014-12-06'
  361. },
  362. {
  363. title: 'Project',
  364. start: '2014-12-08',
  365. end: '2014-12-13'
  366. },
  367. {
  368. title: 'Holiday',
  369. start: '2014-12-22',
  370. end: '2015-01-05',
  371. borderColor: 'red'
  372. },
  373. {
  374. title: 'Project',
  375. start: '2015-01-06',
  376. end: '2015-01-25'
  377. },
  378. {
  379. title: 'Project',
  380. start: '2015-02-02',
  381. end: '2015-02-14'
  382. },
  383. {
  384. title: 'Holiday',
  385. start: '2015-02-14',
  386. end: '2015-02-19',
  387. borderColor: 'red'
  388. }
  389. ]
  390. });
  391. });