init.js 8.2 KB

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