init.js 10 KB

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