clean up javascript code
authorThomas Park <thomas@thomaspark.me>
Fri, 28 Dec 2012 04:07:25 +0000 (23:07 -0500)
committerThomas Park <thomas@thomaspark.me>
Fri, 28 Dec 2012 04:07:25 +0000 (23:07 -0500)
js/application.js

index 670947c..cd7cf0c 100755 (executable)
@@ -1,29 +1,29 @@
-!function ($) {
+(function ($) {
 
-  $(function(){
+       $(function(){
 
-    // fix sub nav on scroll
-    var $win = $(window)
-      , $nav = $('.subnav')
-         , navHeight = $('.navbar').first().height()
-      , navTop = $('.subnav').length && $('.subnav').offset().top - navHeight
-      , isFixed = 0
+               // fix sub nav on scroll
+               var $win = $(window),
+                               $nav = $('.subnav'),
+                               navHeight = $('.navbar').first().height(),
+                               navTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
+                               isFixed = 0;
 
-    processScroll()
+               processScroll();
 
-    $win.on('scroll', processScroll)
+               $win.on('scroll', processScroll);
 
-    function processScroll() {
-      var i, scrollTop = $win.scrollTop()
-      if (scrollTop >= navTop && !isFixed) {
-        isFixed = 1
-        $nav.addClass('subnav-fixed')
-      } else if (scrollTop <= navTop && isFixed) {
-        isFixed = 0
-        $nav.removeClass('subnav-fixed')
-      }
-    }
+               function processScroll() {
+                       var i, scrollTop = $win.scrollTop();
+                       if (scrollTop >= navTop && !isFixed) {
+                               isFixed = 1;
+                               $nav.addClass('subnav-fixed');
+                       } else if (scrollTop <= navTop && isFixed) {
+                               isFixed = 0;
+                               $nav.removeClass('subnav-fixed');
+                       }
+               }
 
-  })
+       });
 
-}(window.jQuery)
\ No newline at end of file
+})(window.jQuery);
\ No newline at end of file