init.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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: 2777,
  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. $('.posts-front').ScrollTo({
  212. duration: 1000,
  213. easing: 'linear',
  214. callback: function(){
  215. dw_caro_pause();
  216. }
  217. });
  218. closeit();
  219. });
  220. }
  221. }, 10);
  222. });
  223. function dw_caro_pause(){
  224. //$('#caro-lead').fadeOut('slow', function() {
  225. $('#caro-lead').carousel('pause');
  226. //});
  227. }
  228. $('#caro-lead').on('slid.bs.carousel', function() {
  229. $('.carousel-caption').fadeOut(600);
  230. $('#tv').delay(3200).queue(function(playit){
  231. $('#tv').addClass('unblur').removeClass('blur');
  232. var vidout = document.getElementById('tv');
  233. vidout.play();
  234. playit();
  235. });
  236. });
  237. $('.caro-grad').appear();
  238. $('.caro-grad').one('appear', dw_appear);
  239. function dw_appear() {
  240. $('#caro').carousel({
  241. interval: 5555,
  242. wrap: false,
  243. pause: false
  244. });
  245. var anima = new DrawFillSVG({elementId: 'sv'});
  246. anima.replay();
  247. };
  248. $(document).bind('keyup', function(e) {
  249. if(e.which === 39){
  250. //$('#caro-lead').carousel('next');
  251. $('#caro').carousel('next');
  252. }
  253. else if(e.which === 37){
  254. //$('#caro-lead').carousel('prev');
  255. $('#caro').carousel('prev');
  256. }
  257. });
  258. /*============================================
  259. SVG Animate
  260. ==============================================*/
  261. $('#caro').on('slid.bs.carousel', function() {
  262. $('.active .animac').removeClass('hide-svg fade-svg');
  263. var animac = new DrawFillSVG({elementId: 'svg-mac'});
  264. var animac1 = new DrawFillSVG({elementId: 'svg-imac'});
  265. var animac2 = new DrawFillSVG({elementId: 'svg'});
  266. animac.replay();
  267. animac1.replay();
  268. animac2.replay();
  269. });
  270. $('#caro').on('slide.bs.carousel', function() {
  271. $('.active #svg-imac.bg').attr('class', 'svg screen');
  272. $('.active .animac').addClass('fade-svg').delay(1000).queue(function(hideit){
  273. $(this).addClass('hide-svg');
  274. hideit();
  275. });
  276. });
  277. $('#caro').on('slid.bs.carousel', function() {
  278. $('.active #svg-imac.screen').delay(2500).queue(function(screenit){
  279. $(this).attr('class', 'bg');
  280. screenit();
  281. });
  282. });
  283. /*============================================
  284. Comments
  285. ==============================================*/
  286. $('#comments').hide();
  287. $('.toggle-comments').on('touchstart click', function(e) {
  288. e.preventDefault();
  289. $('#comments').toggle('slow', function() {
  290. var anchor = $('.toggle-comments');
  291. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  292. $(anchor).text(anchorText);
  293. });
  294. });
  295. $('#commentform').validate({
  296. rules: {
  297. author: {
  298. required: true,
  299. minlength: 2
  300. },
  301. email: {
  302. required: true,
  303. email: true
  304. },
  305. comment: {
  306. required: true,
  307. minlength: 20
  308. }
  309. },
  310. messages: {
  311. author: 'Please enter in your name.',
  312. email: 'Please enter a valid email address.',
  313. comment: 'Nothing to Say?'
  314. },
  315. errorElement: 'div',
  316. errorPlacement: function(error, element) {
  317. element.before(error);
  318. }
  319. });
  320. /*============================================
  321. SmoothState
  322. ==============================================*/
  323. /*============================================
  324. Calendar
  325. ==============================================*/
  326. $('.calendar').fullCalendar ({
  327. firstDay : 1,
  328. height: 345,
  329. events: [
  330. {
  331. title: 'Project',
  332. start: '2014-09-27',
  333. end: '2014-10-02'
  334. },
  335. {
  336. title: 'Conf',
  337. start: '2014-10-11',
  338. end: '2014-10-13',
  339. borderColor: 'red'
  340. },
  341. {
  342. title: 'off',
  343. start: '2014-10-13',
  344. end: '2014-10-16'
  345. },
  346. {
  347. title: 'Contract',
  348. start: '2014-10-16',
  349. end: '2014-10-31'
  350. },
  351. {
  352. title: 'Contract',
  353. start: '2014-11-03',
  354. end: '2014-11-22'
  355. },
  356. {
  357. title: 'Project',
  358. start: '2014-12-01',
  359. end: '2014-12-06'
  360. },
  361. {
  362. title: 'Project',
  363. start: '2014-12-08',
  364. end: '2014-12-13'
  365. },
  366. {
  367. title: 'Holiday',
  368. start: '2014-12-22',
  369. end: '2015-01-05',
  370. borderColor: 'red'
  371. },
  372. {
  373. title: 'Project',
  374. start: '2015-01-06',
  375. end: '2015-01-25'
  376. },
  377. {
  378. title: 'Project',
  379. start: '2015-02-02',
  380. end: '2015-02-14'
  381. },
  382. {
  383. title: 'Holiday',
  384. start: '2015-02-14',
  385. end: '2015-02-19',
  386. borderColor: 'red'
  387. }
  388. ]
  389. });
  390. });