underoos 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. data/Gemfile +5 -0
  2. data/Gemfile.lock +21 -7
  3. data/README.md +85 -10
  4. data/Rakefile +36 -1
  5. data/app/assets/javascripts/docs.js +6 -0
  6. data/app/assets/javascripts/styleguide.coffee +162 -0
  7. data/app/assets/javascripts/underoos.js +0 -1
  8. data/app/assets/stylesheets/base/_base.sass +14 -0
  9. data/app/assets/stylesheets/base/_buttons.sass +68 -0
  10. data/app/assets/stylesheets/base/_forms.sass +313 -24
  11. data/app/assets/stylesheets/base/_helpers.sass +27 -13
  12. data/app/assets/stylesheets/base/_normalize.sass +17 -9
  13. data/app/assets/stylesheets/base/_scaffold.sass +85 -0
  14. data/app/assets/stylesheets/base/_tables.sass +77 -0
  15. data/app/assets/stylesheets/base/_transitions.sass +10 -2
  16. data/app/assets/stylesheets/base/_typography.sass +183 -21
  17. data/app/assets/stylesheets/components/_accordions.sass +38 -0
  18. data/app/assets/stylesheets/components/_breadcrumbs.sass +19 -5
  19. data/app/assets/stylesheets/components/_button-groups.sass +43 -0
  20. data/app/assets/stylesheets/components/_carets.sass +13 -2
  21. data/app/assets/stylesheets/components/_carousels.sass +32 -0
  22. data/app/assets/stylesheets/components/_close.sass +15 -2
  23. data/app/assets/stylesheets/components/_components.sass +28 -0
  24. data/app/assets/stylesheets/components/_decals.sass +14 -0
  25. data/app/assets/stylesheets/components/_dropdowns.sass +88 -4
  26. data/app/assets/stylesheets/components/_media.sass +36 -0
  27. data/app/assets/stylesheets/components/_modals.sass +29 -0
  28. data/app/assets/stylesheets/components/_nav-lists.sass +20 -0
  29. data/app/assets/stylesheets/components/_navbars.sass +64 -3
  30. data/app/assets/stylesheets/components/_notifications.sass +112 -16
  31. data/app/assets/stylesheets/components/_paddles.sass +26 -0
  32. data/app/assets/stylesheets/components/_pagination.sass +23 -3
  33. data/app/assets/stylesheets/components/_pills.sass +80 -0
  34. data/app/assets/stylesheets/components/_popovers.sass +28 -0
  35. data/app/assets/stylesheets/components/_progress-bars.sass +33 -1
  36. data/app/assets/stylesheets/components/_tabs.sass +79 -0
  37. data/app/assets/stylesheets/components/_tooltips.sass +26 -0
  38. data/app/assets/stylesheets/components/_wells.sass +9 -0
  39. data/app/assets/stylesheets/layouts/_containers.sass +12 -0
  40. data/app/assets/stylesheets/layouts/_layouts.sass +5 -0
  41. data/app/assets/stylesheets/layouts/_print.sass +5 -1
  42. data/app/assets/stylesheets/layouts/_queries.sass +18 -15
  43. data/app/assets/stylesheets/layouts/_upgrades.sass +51 -40
  44. data/app/assets/stylesheets/mixins/_arrows.sass +13 -1
  45. data/app/assets/stylesheets/mixins/_clearfixins.sass +18 -4
  46. data/app/assets/stylesheets/mixins/_coloring.sass +10 -1
  47. data/app/assets/stylesheets/mixins/_columns.sass +16 -3
  48. data/app/assets/stylesheets/mixins/_conversions.sass +18 -6
  49. data/app/assets/stylesheets/mixins/_font-size.sass +16 -1
  50. data/app/assets/stylesheets/mixins/_image-tools.sass +12 -1
  51. data/app/assets/stylesheets/mixins/_inline-block.sass +21 -0
  52. data/app/assets/stylesheets/mixins/_ir.sass +14 -1
  53. data/app/assets/stylesheets/mixins/_mixins.sass +6 -0
  54. data/app/assets/stylesheets/mixins/_responsive.sass +16 -0
  55. data/app/assets/stylesheets/mixins/_sticky-footer.sass +52 -0
  56. data/app/assets/stylesheets/mixins/_tab-focus.sass +8 -1
  57. data/app/assets/stylesheets/mixins/_timing-equations.sass +34 -1
  58. data/app/assets/stylesheets/mixins/_visibility.sass +18 -5
  59. data/app/assets/stylesheets/polyfills/_box-shadow.sass +10 -0
  60. data/app/assets/stylesheets/polyfills/_box-sizing.sass +10 -1
  61. data/app/assets/stylesheets/polyfills/_functions.sass +14 -1
  62. data/app/assets/stylesheets/polyfills/_opacity.sass +10 -1
  63. data/app/assets/stylesheets/polyfills/_polyfills.sass +9 -2
  64. data/app/assets/stylesheets/polyfills/_transition.sass +10 -0
  65. data/app/assets/stylesheets/polyfills/_user-select.sass +10 -0
  66. data/app/assets/stylesheets/settings/_config.sass +26 -0
  67. data/app/assets/stylesheets/settings/_settings.sass +7 -0
  68. data/app/assets/stylesheets/settings/_theme.sass +189 -0
  69. data/app/assets/stylesheets/{styleguide.sass → underoos-docs.sass} +20 -116
  70. data/app/assets/stylesheets/underoos.sass +5 -16
  71. data/config.ru +1 -3
  72. data/features/generator.feature +13 -4
  73. data/lib/generators/underoos/assets_generator.rb +4 -2
  74. data/lib/underoos/version.rb +1 -1
  75. data/public/images.html +157 -0
  76. data/public/index.html +149 -0
  77. data/public/sherpa.css +306 -0
  78. data/public/styles.html +5374 -0
  79. data/script/javascripts +0 -1
  80. data/sherpa/config.yml +96 -0
  81. data/sherpa/layouts/images.mustache +17 -0
  82. data/sherpa/layouts/layout.mustache +77 -0
  83. data/sherpa/layouts/overview.mustache +19 -0
  84. data/sherpa/layouts/raw.mustache +25 -0
  85. data/sherpa/layouts/section.mustache +67 -0
  86. data/underoos.gemspec +0 -2
  87. data/vendor/assets/javascripts/bootstrap-alert.js +28 -32
  88. data/vendor/assets/javascripts/bootstrap-button.js +29 -33
  89. data/vendor/assets/javascripts/bootstrap-collapse.js +45 -26
  90. data/vendor/assets/javascripts/bootstrap-dropdown.js +18 -10
  91. data/vendor/assets/javascripts/bootstrap-modal.js +25 -17
  92. data/vendor/assets/javascripts/bootstrap-popover.js +13 -10
  93. data/vendor/assets/javascripts/bootstrap-tab.js +12 -7
  94. data/vendor/assets/javascripts/bootstrap-tooltip.js +40 -35
  95. data/vendor/assets/javascripts/bootstrap-transition.js +30 -20
  96. data/vendor/assets/javascripts/bootstrap-typeahead.js +24 -10
  97. data/vendor/assets/javascripts/sherpa.coffee +78 -0
  98. metadata +34 -75
  99. data/app/assets/javascripts/styleguide.js +0 -132
  100. data/app/assets/stylesheets/base/_elements.sass +0 -61
  101. data/app/assets/stylesheets/polyfills/_inline-block.sass +0 -8
  102. data/app/assets/stylesheets/themes/_default.sass +0 -119
  103. data/app/controllers/underoos/styleguides_controller.rb +0 -79
  104. data/app/views/shared/_upgrades.html.haml +0 -12
  105. data/app/views/underoos/styleguides/_assets.haml +0 -42
  106. data/app/views/underoos/styleguides/_components.haml +0 -42
  107. data/app/views/underoos/styleguides/_elements.haml +0 -242
  108. data/app/views/underoos/styleguides/_forms.haml +0 -305
  109. data/app/views/underoos/styleguides/_layouts.haml +0 -76
  110. data/app/views/underoos/styleguides/_palettes.haml +0 -18
  111. data/app/views/underoos/styleguides/_resources.haml +0 -27
  112. data/app/views/underoos/styleguides/_tables.haml +0 -124
  113. data/app/views/underoos/styleguides/_typography.haml +0 -284
  114. data/app/views/underoos/styleguides/_utilities.haml +0 -270
  115. data/app/views/underoos/styleguides/components/_accordions.haml +0 -83
  116. data/app/views/underoos/styleguides/components/_breadcrumbs.haml +0 -42
  117. data/app/views/underoos/styleguides/components/_button-groups.haml +0 -162
  118. data/app/views/underoos/styleguides/components/_carets.haml +0 -28
  119. data/app/views/underoos/styleguides/components/_close.haml +0 -20
  120. data/app/views/underoos/styleguides/components/_decals.haml +0 -40
  121. data/app/views/underoos/styleguides/components/_dropdowns.haml +0 -189
  122. data/app/views/underoos/styleguides/components/_media.haml +0 -78
  123. data/app/views/underoos/styleguides/components/_modals.haml +0 -42
  124. data/app/views/underoos/styleguides/components/_nav-lists.haml +0 -52
  125. data/app/views/underoos/styleguides/components/_navbars.haml +0 -144
  126. data/app/views/underoos/styleguides/components/_navs-showcase.haml +0 -27
  127. data/app/views/underoos/styleguides/components/_notifications.haml +0 -169
  128. data/app/views/underoos/styleguides/components/_paddles.haml +0 -68
  129. data/app/views/underoos/styleguides/components/_pagination.haml +0 -64
  130. data/app/views/underoos/styleguides/components/_popovers.haml +0 -33
  131. data/app/views/underoos/styleguides/components/_progress-bars.haml +0 -72
  132. data/app/views/underoos/styleguides/components/_tabs-pills.haml +0 -241
  133. data/app/views/underoos/styleguides/components/_tooltips.haml +0 -37
  134. data/app/views/underoos/styleguides/components/_wells.haml +0 -29
  135. data/app/views/underoos/styleguides/index.html.haml +0 -259
  136. data/app/views/underoos/styleguides/partials/_form-template.haml +0 -171
  137. data/app/views/underoos/styleguides/partials/_table-data.haml +0 -33
  138. data/app/views/underoos/styleguides/partials/_transitions.haml +0 -136
  139. data/config/routes.rb +0 -3
  140. data/vendor/assets/javascripts/bootstrap-scrollspy.js +0 -125
@@ -1,171 +0,0 @@
1
-
2
- %fieldset
3
- %legend=legend
4
- %ol
5
- -# Text Input
6
- %li(class="#{state} #{disabled}" id="#{uid}test_text_input")
7
- %label.label(for="#{uid}test_text") Text Input<abbr title="required">*</abbr>
8
- - if disabled == "disabled"
9
- %input.input-medium(id="#{uid}test_text" type="text" name="test[text]" placeholder="text input" disabled)
10
- - else
11
- %input.input-medium(id="#{uid}test_text" type="text" name="test[text]" placeholder="text input")
12
- %p.hint This is a hint for the text element!
13
-
14
- -# Block Checkboxes
15
- %li.boolean(class="#{state} #{disabled}")
16
- %label(for="#{uid}test_check1" name="test[check1]")
17
- - if disabled == "disabled"
18
- %input(id="#{uid}test_check1" name="test[check1]" type="checkbox" checked="checked" value="0" disabled)
19
- - else
20
- %input(id="#{uid}test_check1" name="test[check1]" type="checkbox" checked="checked" value="0")
21
- Checkboxes for multiple selections
22
- %li.boolean(class="#{state} #{disabled}")
23
- %label(for="#{uid}test_check2" name="test[check2]")
24
- - if disabled == "disabled"
25
- %input(id="#{uid}test_check2" name="test[check2]" type="checkbox" value="1" disabled)
26
- - else
27
- %input(id="#{uid}test_check2" name="test[check2]" type="checkbox" value="1")
28
- Go ahead and select this one too
29
-
30
- -# Block Radio Group
31
- %li
32
- %ol.choices-group
33
- %li.choice(class="#{state} #{disabled}")
34
- %label(for="#{uid}test_radio1")
35
- - if disabled == "disabled"
36
- %input(id="#{uid}test_radio1" name="test[radio]" type="radio" value="true" disabled)
37
- - else
38
- %input(id="#{uid}test_radio1" name="test[radio]" type="radio" value="true")
39
- Yes, to radio buttons
40
- %li.choice(class="#{state} #{disabled}")
41
- %label(for="#{uid}test_radio2")
42
- - if disabled == "disabled"
43
- %input(id="#{uid}test_radio2" name="test[radio]" type="radio" value="false" disabled)
44
- - else
45
- %input(id="#{uid}test_radio2" name="test[radio]" type="radio" value="false")
46
- No, to radio buttons
47
-
48
- -# Inline Checkboxes
49
- %li.boolean.inline(class="#{state} #{disabled}")
50
- %label(for="#{uid}test_check3" name="test[check3]")
51
- - if disabled == "disabled"
52
- %input(id="#{uid}test_check3" name="test[check3]" type="checkbox" checked="checked" value="0" disabled)
53
- - else
54
- %input(id="#{uid}test_check3" name="test[check3]" type="checkbox" checked="checked" value="0")
55
- Checkbox inline 1
56
- %li.boolean.inline(class="#{state} #{disabled}")
57
- %label(for="#{uid}test_check4" name="test[check4]")
58
- - if disabled == "disabled"
59
- %input(id="#{uid}test_check4" name="test[check4]" type="checkbox" value="1" disabled)
60
- - else
61
- %input(id="#{uid}test_check4" name="test[check4]" type="checkbox" value="1")
62
- Checkbox inline 2
63
-
64
- -# Inline Radio Group
65
- %li
66
- %ol.choices-group
67
- %li.choice.inline(class="#{state} #{disabled}")
68
- %label(for="#{uid}test_radio3")
69
- - if disabled == "disabled"
70
- %input(id="#{uid}test_radio3" name="test[radio]" type="radio" value="true" disabled)
71
- - else
72
- %input(id="#{uid}test_radio3" name="test[radio]" type="radio" value="true")
73
- Yes, radio inline
74
- %li.choice.inline(class="#{state} #{disabled}")
75
- %label(for="#{uid}test_radio4")
76
- - if disabled == "disabled"
77
- %input(id="#{uid}test_radio4" name="test[radio]" type="radio" value="false" disabled)
78
- - else
79
- %input(id="#{uid}test_radio4" name="test[radio]" type="radio" value="false")
80
- No, radio inline
81
-
82
- -# Select
83
- %li(id="#{uid}test_select_input" class="#{state} #{disabled}")
84
- %label.label(for="#{uid}test_select") Select
85
- - if disabled == "disabled"
86
- %select.input-medium(id="#{uid}test_select" name="test[select]" disabled)
87
- %optgroup(label="Colorado")
88
- %option(value="denver" selected="selected") Denver
89
- %option(value="boulder") Boulder
90
- %optgroup(label="California")
91
- %option(value="los angeles") Los Angeles
92
- %option(value="san francisco") San Francisco
93
- - else
94
- %select.input-medium(id="#{uid}test_select" name="test[select]")
95
- %optgroup(label="Colorado")
96
- %option(value="denver" selected="selected") Denver
97
- %option(value="boulder") Boulder
98
- %optgroup(label="California")
99
- %option(value="los angeles") Los Angeles
100
- %option(value="san francisco") San Francisco
101
-
102
- -# Multi Select
103
- %li(id="#{uid}test_multi_input" class="#{state} #{disabled}")
104
- %label.label(for="#{uid}test_multi") Multi
105
- - if disabled == "disabled"
106
- %select.input-medium(id="#{uid}test_multi" name="test[multi]" multiple disabled)
107
- %option(value="1") One
108
- %option(value="2" selected="selected") Two
109
- %option(value="3") Three
110
- %option(value="4") Four
111
- %option(value="5") Five
112
- - else
113
- %select.input-medium(id="#{uid}test_multi" name="test[multi]" multiple)
114
- %option(value="1") One
115
- %option(value="2" selected="selected") Two
116
- %option(value="3") Three
117
- %option(value="4") Four
118
- %option(value="5") Five
119
-
120
- -# Text Area
121
- %li(id="#{uid}test_textarea_textarea.optional" class="#{state} #{disabled}")
122
- %label.label(for="#{uid}test_textarea") Text Area
123
- - if disabled == "disabled"
124
- %textarea.input-medium(id="#{uid}test_textarea" name="test[textarea]" placeholder="Enter some text..." rows="2" disabled)
125
- - else
126
- %textarea.input-medium(id="#{uid}test_textarea" name="test[textarea]" placeholder="Enter some text..." rows="2")
127
-
128
- -# Uneditable Text Input
129
- %li(class="#{state} #{disabled}" id="#{uid}test_uneditable")
130
- %label.label(for="#{uid}test_uneditable") Uneditable Input
131
- - if disabled == "disabled"
132
- %span.input-medium.uneditable(id="#{uid}test_uneditable" class="disabled") Hammer time
133
- - else
134
- %span.input-medium.uneditable(id="#{uid}test_uneditable") Hammer time
135
- %p.hint Can't touch this!
136
-
137
- -# File Browser
138
- %li.commit.button(class="#{state} #{disabled}")
139
- %label.label(for="#{uid}test_file") File Browser
140
- - if disabled == "disabled"
141
- %input.file(id="#{uid}test_file" name="file" type="file" value="file" disabled)
142
- - else
143
- %input.file(id="#{uid}test_file" name="file" type="file" value="file")
144
-
145
- -# Action Group
146
- %li
147
- %ol.form-actions(class="#{dark}")
148
- %li.commit.button(class="#{state} #{disabled}")
149
- - if disabled == "disabled"
150
- %input.submit.btn(name="submit" type="submit" value="Submit" disabled)
151
- - else
152
- %input.submit.btn(name="submit" type="submit" value="Submit")
153
-
154
- %li.commit.button(class="#{state} #{disabled}")
155
- - if disabled == "disabled"
156
- %input.reset.btn(name="reset" type="reset" value="Reset" disabled)
157
- - else
158
- %input.reset.btn(name="reset" type="reset" value="Reset")
159
-
160
- %li.commit.button(class="#{state} #{disabled}")
161
- - if disabled == "disabled"
162
- %input.button.btn(name="button" type="button" value="Button" disabled)
163
- - else
164
- %input.button.btn(name="button" type="button" value="Button")
165
-
166
- %li.commit.button(class="#{state} #{disabled}")
167
- - if disabled == "disabled"
168
- %input.image(name="image" type="image" src="http://placehold.it/68x28&text=IMG" value="Image" disabled)
169
- - else
170
- %input.image(name="image" type="image" src="http://placehold.it/68x28&text=IMG" value="Image")
171
-
@@ -1,33 +0,0 @@
1
-
2
- %caption Table Caption
3
- %thead
4
- %tr
5
- %th
6
- %a(href="#") #
7
- %th Table Header
8
- %th
9
- %a.ascending(href="#") Ascending <span class="caret"></span>
10
- %th
11
- %a.descending(href="#") Descending <span class="caret north"></span>
12
- %tfoot
13
- %tr
14
- %td(colspan="4") The table footer appears at the bottom of the table. Set the <code>colspan</code> attribute to span the width of the table.
15
- %tbody
16
- %tr
17
- %td 1
18
- %td Table Data
19
- %td One
20
- %td Three
21
- %tr
22
- %td 2
23
- %td
24
- %a(href="#") Click me!
25
- %td Two
26
- %td Two
27
- %tr
28
- %td 3
29
- %td
30
- %a(href="#") Click me!
31
- %td Three
32
- %td One
33
-
@@ -1,136 +0,0 @@
1
-
2
- %section.sg-tranny-demo
3
- %table.box.vborder.banded.thead-decorate
4
- %thead
5
- %tr
6
- %th Property
7
- %th Example
8
- %tbody
9
- %tr
10
- %td.prop
11
- %code default (linear)
12
- %td
13
- .sg-swatch
14
- %tr
15
- %td.prop
16
- %code $ease-in-quad
17
- %td
18
- .sg-swatch.ease-in-quad
19
- %tr
20
- %td.prop
21
- %code $ease-in-cubic
22
- %td
23
- .sg-swatch.ease-in-cubic
24
- %tr
25
- %td.prop
26
- %code $ease-in-quart
27
- %td
28
- .sg-swatch.ease-in-quart
29
- %tr
30
- %td.prop
31
- %code $ease-in-quint
32
- %td
33
- .sg-swatch.ease-in-quint
34
- %tr
35
- %td.prop
36
- %code $ease-in-sine
37
- %td
38
- .sg-swatch.ease-in-sine
39
- %tr
40
- %td.prop
41
- %code $ease-in-expo
42
- %td
43
- .sg-swatch.ease-in-expo
44
- %tr
45
- %td.prop
46
- %code $ease-in-circ
47
- %td
48
- .sg-swatch.ease-in-circ
49
- %tr
50
- %td.prop
51
- %code $ease-in-back
52
- %td
53
- .sg-swatch.ease-in-back
54
-
55
- %tr
56
- %td.prop
57
- %code $ease-out-quad
58
- %td
59
- .sg-swatch.ease-out-quad
60
- %tr
61
- %td.prop
62
- %code $ease-out-cubic
63
- %td
64
- .sg-swatch.ease-out-cubic
65
- %tr
66
- %td.prop
67
- %code $ease-out-quart
68
- %td
69
- .sg-swatch.ease-out-quart
70
- %tr
71
- %td.prop
72
- %code $ease-out-quint
73
- %td
74
- .sg-swatch.ease-out-quint
75
- %tr
76
- %td.prop
77
- %code $ease-out-sine
78
- %td
79
- .sg-swatch.ease-out-sine
80
- %tr
81
- %td.prop
82
- %code $ease-out-expo
83
- %td
84
- .sg-swatch.ease-out-expo
85
- %tr
86
- %td.prop
87
- %code $ease-out-circ
88
- %td
89
- .sg-swatch.ease-out-circ
90
- %tr
91
- %td.prop
92
- %code $ease-out-back
93
- %td
94
- .sg-swatch.ease-out-back
95
-
96
- %tr
97
- %td.prop
98
- %code $ease-in-out-quad
99
- %td
100
- .sg-swatch.ease-in-out-quad
101
- %tr
102
- %td.prop
103
- %code $ease-in-out-cubic
104
- %td
105
- .sg-swatch.ease-in-out-cubic
106
- %tr
107
- %td.prop
108
- %code $ease-in-out-quart
109
- %td
110
- .sg-swatch.ease-in-out-quart
111
- %tr
112
- %td.prop
113
- %code $ease-in-out-quint
114
- %td
115
- .sg-swatch.ease-in-out-quint
116
- %tr
117
- %td.prop
118
- %code $ease-in-out-sine
119
- %td
120
- .sg-swatch.ease-in-out-sine
121
- %tr
122
- %td.prop
123
- %code $ease-in-out-expo
124
- %td
125
- .sg-swatch.ease-in-out-expo
126
- %tr
127
- %td.prop
128
- %code $ease-in-out-circ
129
- %td
130
- .sg-swatch.ease-in-out-circ
131
- %tr
132
- %td.prop
133
- %code $ease-in-out-back
134
- %td
135
- .sg-swatch.ease-in-out-back
136
-
@@ -1,3 +0,0 @@
1
- Underoos::Engine.routes.draw do
2
- match "/" => "styleguides#index"
3
- end
@@ -1,125 +0,0 @@
1
- /* =============================================================
2
- * bootstrap-scrollspy.js v2.0.2
3
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
4
- * =============================================================
5
- * Copyright 2012 Twitter, Inc.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- * ============================================================== */
19
-
20
- !function ( $ ) {
21
-
22
- "use strict"
23
-
24
- /* SCROLLSPY CLASS DEFINITION
25
- * ========================== */
26
-
27
- function ScrollSpy( element, options) {
28
- var process = $.proxy(this.process, this)
29
- , $element = $(element).is('body') ? $(window) : $(element)
30
- , href
31
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
32
- this.$scrollElement = $element.on('scroll.scroll.data-api', process)
33
- this.selector = (this.options.target
34
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
35
- || '') + ' .nav li > a'
36
- this.$body = $('body').on('click.scroll.data-api', this.selector, process)
37
- this.refresh()
38
- this.process()
39
- }
40
-
41
- ScrollSpy.prototype = {
42
-
43
- constructor: ScrollSpy
44
-
45
- , refresh: function () {
46
- this.targets = this.$body
47
- .find(this.selector)
48
- .map(function () {
49
- var href = $(this).attr('href')
50
- return /^#\w/.test(href) && $(href).length ? href : null
51
- })
52
-
53
- this.offsets = $.map(this.targets, function (id) {
54
- return $(id).position().top
55
- })
56
- }
57
-
58
- , process: function () {
59
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
60
- , offsets = this.offsets
61
- , targets = this.targets
62
- , activeTarget = this.activeTarget
63
- , i
64
-
65
- for (i = offsets.length; i--;) {
66
- activeTarget != targets[i]
67
- && scrollTop >= offsets[i]
68
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
69
- && this.activate( targets[i] )
70
- }
71
- }
72
-
73
- , activate: function (target) {
74
- var active
75
-
76
- this.activeTarget = target
77
-
78
- this.$body
79
- .find(this.selector).parent('.active')
80
- .removeClass('active')
81
-
82
- active = this.$body
83
- .find(this.selector + '[href="' + target + '"]')
84
- .parent('li')
85
- .addClass('active')
86
-
87
- if ( active.parent('.dropdown-menu') ) {
88
- active.closest('li.dropdown').addClass('active')
89
- }
90
- }
91
-
92
- }
93
-
94
-
95
- /* SCROLLSPY PLUGIN DEFINITION
96
- * =========================== */
97
-
98
- $.fn.scrollspy = function ( option ) {
99
- return this.each(function () {
100
- var $this = $(this)
101
- , data = $this.data('scrollspy')
102
- , options = typeof option == 'object' && option
103
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
104
- if (typeof option == 'string') data[option]()
105
- })
106
- }
107
-
108
- $.fn.scrollspy.Constructor = ScrollSpy
109
-
110
- $.fn.scrollspy.defaults = {
111
- offset: 10
112
- }
113
-
114
-
115
- /* SCROLLSPY DATA-API
116
- * ================== */
117
-
118
- $(function () {
119
- $('[data-spy="scroll"]').each(function () {
120
- var $spy = $(this)
121
- $spy.scrollspy($spy.data())
122
- })
123
- })
124
-
125
- }( window.jQuery );