init.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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 (/exit/i.test(text)) {
  114. $('.terminal').modal('hide');
  115. }
  116. if (/help/i.test(text)) return "I need somebody. Type 'exit' to close";
  117. if (/hello/i.test(text)) return "Hello to you!";
  118. if (/what/i.test(text)) return "This is a website silly human";
  119. if (/and/i.test(text)) return "and what?";
  120. if (/who/i.test(text)) return "David A. Windham";
  121. if (/when/i.test(text)) return "Yesterday";
  122. if (/how/i.test(text)) return "JavaScript is a dynamic computer programming language";
  123. if (/why/i.test(text)) return "For fun";
  124. if (/you/i.test(text)) return "your mama";
  125. if (/cd ../i.test(text)) return "Oh, I see";
  126. if (/thermonuclear/i.test(text)) return "Wouldn't you prefer a nice game of chess?";
  127. if (text.length < 3) return "type 'exit' to close";
  128. return 'command not found: '+text;
  129. }, null, type);
  130. $('p.input').on('touchstart click', function(e) {
  131. e.preventDefault();
  132. $('[contenteditable]')[0].focus();
  133. });
  134. }
  135. /*============================================
  136. Navigation
  137. ==============================================*/
  138. $('.nav-toggle').on('touchstart click', function(e) {
  139. e.preventDefault();
  140. $( this ).toggleClass( 'active' );
  141. });
  142. $('#nav').affix({
  143. offset: {top: $('.intro').height()-$('.navbar').height()}
  144. });
  145. $(function dw_hidenav() {
  146. var headerHeight = $('.navbar').height();
  147. $(window).on('scroll', { previousTop: 0 },
  148. function() {
  149. var currentTop = $(window).scrollTop();
  150. if (currentTop < this.previousTop) {
  151. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  152. $('.navbar').addClass('visible');
  153. } else {
  154. $('.navbar').removeClass('visible fixed');
  155. }
  156. }
  157. else {
  158. $('.navbar').removeClass('visible');
  159. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  160. }
  161. this.previousTop = currentTop;
  162. }
  163. );
  164. });
  165. /*============================================
  166. Carousel
  167. ==============================================*/
  168. $('.carousel').carousel({
  169. interval: false
  170. });
  171. $('#caro-lead').on('slide.bs.carousel', function() {
  172. $('.carousel-caption').fadeIn(600);
  173. //$('#tv').removeClass('invert');
  174. });
  175. $('#caro-lead').on('slid.bs.carousel', function() {
  176. $('.carousel-caption').fadeOut(600);
  177. //$('#tv').addClass('invert');
  178. });
  179. $('.caro').carousel({
  180. interval: 9000
  181. });
  182. $(document).bind('keyup', function(e) {
  183. if(e.which === 39){
  184. //$('#caro-lead').carousel('next');
  185. $('#caro').carousel('next');
  186. }
  187. else if(e.which === 37){
  188. //$('#caro-lead').carousel('prev');
  189. $('#caro').carousel('prev');
  190. }
  191. });
  192. /*============================================
  193. SVG Animate
  194. ==============================================*/
  195. (function() {
  196. var myAnimation = new DrawFillSVG({elementId: 'sv'});
  197. })();
  198. $('#caro').on('slid.bs.carousel', function() {
  199. $('.active .animac').removeClass('hide-svg fade-svg');
  200. var animac = new DrawFillSVG({elementId: 'svg-mac'});
  201. var animac1 = new DrawFillSVG({elementId: 'svg-imac'});
  202. var animac2 = new DrawFillSVG({elementId: 'svg'});
  203. animac.replay();
  204. animac1.replay();
  205. animac2.replay();
  206. });
  207. $('#caro').on('slide.bs.carousel', function() {
  208. $('.active #svg-imac.bg').attr('class', 'svg screen');
  209. $('.active .animac').addClass('fade-svg').delay(1000).queue(function(hideit){
  210. $(this).addClass('hide-svg');
  211. hideit();
  212. });
  213. });
  214. $('#caro').on('slid.bs.carousel', function() {
  215. $('.active #svg-imac.screen').delay(2500).queue(function(screenit){
  216. $(this).attr('class', 'bg');
  217. screenit();
  218. });
  219. });
  220. /*============================================
  221. Comments
  222. ==============================================*/
  223. $('#comments').hide();
  224. $('.toggle-comments').on('touchstart click', function(e) {
  225. e.preventDefault();
  226. $('#comments').toggle('slow', function() {
  227. var anchor = $('.toggle-comments');
  228. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  229. $(anchor).text(anchorText);
  230. });
  231. });
  232. $('#commentform').validate({
  233. rules: {
  234. author: {
  235. required: true,
  236. minlength: 2
  237. },
  238. email: {
  239. required: true,
  240. email: true
  241. },
  242. comment: {
  243. required: true,
  244. minlength: 20
  245. }
  246. },
  247. messages: {
  248. author: 'Please enter in your name.',
  249. email: 'Please enter a valid email address.',
  250. comment: 'Nothing to Say?'
  251. },
  252. errorElement: 'div',
  253. errorPlacement: function(error, element) {
  254. element.before(error);
  255. }
  256. });
  257. /*============================================
  258. SmoothState
  259. ==============================================*/
  260. /*============================================
  261. Calendar
  262. ==============================================*/
  263. $('.calendar').fullCalendar ({
  264. firstDay : 1,
  265. height: 345,
  266. events: [
  267. {
  268. title: 'Project',
  269. start: '2014-09-27',
  270. end: '2014-10-02'
  271. },
  272. {
  273. title: 'Conf',
  274. start: '2014-10-11',
  275. end: '2014-10-13',
  276. borderColor: 'red'
  277. },
  278. {
  279. title: 'off',
  280. start: '2014-10-13',
  281. end: '2014-10-16'
  282. },
  283. {
  284. title: 'Contract',
  285. start: '2014-10-16',
  286. end: '2014-10-31'
  287. },
  288. {
  289. title: 'Contract',
  290. start: '2014-11-03',
  291. end: '2014-11-22'
  292. },
  293. {
  294. title: 'Project',
  295. start: '2014-12-01',
  296. end: '2014-12-06'
  297. },
  298. {
  299. title: 'Project',
  300. start: '2014-12-08',
  301. end: '2014-12-13'
  302. },
  303. {
  304. title: 'Holiday',
  305. start: '2014-12-22',
  306. end: '2015-01-05',
  307. borderColor: 'red'
  308. },
  309. {
  310. title: 'Project',
  311. start: '2015-01-06',
  312. end: '2015-01-25'
  313. },
  314. {
  315. title: 'Project',
  316. start: '2015-02-02',
  317. end: '2015-02-14'
  318. },
  319. {
  320. title: 'Holiday',
  321. start: '2015-02-14',
  322. end: '2015-02-19',
  323. borderColor: 'red'
  324. }
  325. ]
  326. });
  327. });