init.js 9.7 KB

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