init.js 8.8 KB

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