Skip to content
This repository
Browse code

allow the :target parameter in nav menu tabs

  • Loading branch information...
commit 802a6bbe468e531cbcfc8bbbed9c1954cd12e352 1 parent 9ff6d40
Mike North authored June 24, 2012
2  Gemfile.lock
@@ -18,7 +18,7 @@ GIT
18 18
 PATH
19 19
   remote: .
20 20
   specs:
21  
-    spurs (0.0.5.alpha.2)
  21
+    spurs (0.0.5.alpha.3)
22 22
       haml (>= 3.1)
23 23
       rails (~> 3.2)
24 24
       twitter-bootstrap-rails (~> 2.0)
3  app/assets/javascripts/spurs/beyond_bootstrap/all.js
... ...
@@ -1 +1,2 @@
1  
-//= require ./responsive-tables
  1
+//= require ./responsive-tables
  2
+//= require ./sticky-subnav
24  app/assets/javascripts/spurs/beyond_bootstrap/sticky-subnav.js.coffee
... ...
@@ -0,0 +1,24 @@
  1
+not ($) ->
  2
+  $ ->
  3
+    processScroll = ->
  4
+      i = undefined
  5
+      scrollTop = $win.scrollTop()
  6
+      if scrollTop >= navTop and not isFixed
  7
+        isFixed = 1
  8
+        $nav.addClass "subnav-fixed"
  9
+      else if scrollTop <= navTop and isFixed
  10
+        isFixed = 0
  11
+        $nav.removeClass "subnav-fixed"
  12
+    $win = $(window)
  13
+    $nav = $(".subnav")
  14
+    navTop = $(".subnav").length and $(".subnav").offset().top - 40
  15
+    isFixed = 0
  16
+    processScroll()
  17
+    $nav.on "click", ->
  18
+      unless isFixed
  19
+        setTimeout (->
  20
+          $win.scrollTop $win.scrollTop() - 47
  21
+        ), 10
  22
+
  23
+    $win.on "scroll", processScroll
  24
+(window.jQuery)
3  lib/spurs/nav/builder.rb
@@ -108,6 +108,9 @@ def tab_tag(name, content_inside_a, content_inside_li=nil, options={ })
108 108
           if opts[:method] then
109 109
             a_opts[:method] = opts[:method]
110 110
           end
  111
+          if opts[:target] then
  112
+            a_opts[:target] = opts[:target]
  113
+          end
111 114
         end
112 115
         if opts[:onclick]
113 116
           a_opts[:onclick] = opts[:onclick]
2  lib/spurs/version.rb
... ...
@@ -1,3 +1,3 @@
1 1
 module Spurs
2  
-  VERSION = "0.0.5.alpha.2"
  2
+  VERSION = "0.0.5.alpha.3"
3 3
 end

0 notes on commit 802a6bb

Please sign in to comment.
Something went wrong with that request. Please try again.