init.js 11 KB

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