inkstream 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/_config.yml +131 -0
- data/_includes/button.html +4 -0
- data/_includes/icon.html +1 -0
- data/_includes/nav-default.html +23 -0
- data/_includes/nav-header.html +25 -0
- data/_includes/post-list.html +59 -0
- data/_includes/post-meta.html +0 -0
- data/_includes/post-pagination.html +29 -0
- data/_includes/promo-section.html +12 -0
- data/_includes/site-before-end.html +1 -0
- data/_includes/site-before-start.html +1 -0
- data/_includes/site-favicons.html +12 -0
- data/_includes/site-fonts.html +13 -0
- data/_includes/site-footer-default.html +17 -0
- data/_includes/site-footer.html +23 -0
- data/_includes/site-header.html +66 -0
- data/_includes/site-styles.html +6 -0
- data/_layouts/blog.html +24 -0
- data/_layouts/default.html +62 -0
- data/_layouts/page.html +35 -0
- data/_layouts/post.html +201 -0
- data/assets/css/styles.css +11167 -0
- data/assets/favicon/android-chrome-192x192.png +0 -0
- data/assets/favicon/android-chrome-512x512.png +0 -0
- data/assets/favicon/apple-touch-icon.png +0 -0
- data/assets/favicon/browserconfig.xml +9 -0
- data/assets/favicon/favicon-16x16.png +0 -0
- data/assets/favicon/favicon-32x32.png +0 -0
- data/assets/favicon/favicon.ico +0 -0
- data/assets/favicon/favicon.svg +1 -0
- data/assets/favicon/mstile-150x150.png +0 -0
- data/assets/favicon/safari-pinned-tab.svg +88 -0
- data/assets/favicon/site.webmanifest +19 -0
- data/assets/images/about-me.jpg +0 -0
- data/assets/images/posts/default-post-img.jpg +0 -0
- data/assets/images/posts/text-syntax.jpg +0 -0
- data/assets/images/posts/welcome.jpg +0 -0
- data/assets/images/profile.png +0 -0
- data/assets/images/promo-banner.jpg +0 -0
- data/assets/js/blog.js +9 -0
- data/assets/js/demo/style-switcher.js +45 -0
- data/assets/logo/logo.jpg +0 -0
- data/assets/logo/logo.svg +1 -0
- data/assets/plugins/bootstrap/js/bootstrap.min.js +7 -0
- data/assets/plugins/jquery-3.3.1.min.js +2 -0
- data/assets/plugins/popper.min.js +5 -0
- data/assets/resume/resume.pdf +0 -0
- data/assets/scss/bootstrap/js/dist/alert.js +199 -0
- data/assets/scss/bootstrap/js/dist/alert.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/button.js +187 -0
- data/assets/scss/bootstrap/js/dist/button.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/carousel.js +668 -0
- data/assets/scss/bootstrap/js/dist/carousel.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/collapse.js +428 -0
- data/assets/scss/bootstrap/js/dist/collapse.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/dropdown.js +595 -0
- data/assets/scss/bootstrap/js/dist/dropdown.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/index.js +23 -0
- data/assets/scss/bootstrap/js/dist/index.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/modal.js +650 -0
- data/assets/scss/bootstrap/js/dist/modal.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/popover.js +261 -0
- data/assets/scss/bootstrap/js/dist/popover.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/scrollspy.js +375 -0
- data/assets/scss/bootstrap/js/dist/scrollspy.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/tab.js +269 -0
- data/assets/scss/bootstrap/js/dist/tab.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/toast.js +283 -0
- data/assets/scss/bootstrap/js/dist/toast.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/tooltip.js +760 -0
- data/assets/scss/bootstrap/js/dist/tooltip.js.map +1 -0
- data/assets/scss/bootstrap/js/dist/util.js +172 -0
- data/assets/scss/bootstrap/js/dist/util.js.map +1 -0
- data/assets/scss/bootstrap/js/src/alert.js +179 -0
- data/assets/scss/bootstrap/js/src/button.js +171 -0
- data/assets/scss/bootstrap/js/src/carousel.js +606 -0
- data/assets/scss/bootstrap/js/src/collapse.js +402 -0
- data/assets/scss/bootstrap/js/src/dropdown.js +545 -0
- data/assets/scss/bootstrap/js/src/index.js +52 -0
- data/assets/scss/bootstrap/js/src/modal.js +594 -0
- data/assets/scss/bootstrap/js/src/popover.js +184 -0
- data/assets/scss/bootstrap/js/src/scrollspy.js +326 -0
- data/assets/scss/bootstrap/js/src/tab.js +260 -0
- data/assets/scss/bootstrap/js/src/toast.js +227 -0
- data/assets/scss/bootstrap/js/src/tooltip.js +752 -0
- data/assets/scss/bootstrap/js/src/util.js +177 -0
- data/assets/scss/bootstrap/js/tests/README.md +69 -0
- data/assets/scss/bootstrap/js/tests/browsers.js +82 -0
- data/assets/scss/bootstrap/js/tests/index.html +133 -0
- data/assets/scss/bootstrap/js/tests/integration/bundle.js +8 -0
- data/assets/scss/bootstrap/js/tests/integration/index.html +66 -0
- data/assets/scss/bootstrap/js/tests/integration/rollup.bundle.js +20 -0
- data/assets/scss/bootstrap/js/tests/karma.conf.js +143 -0
- data/assets/scss/bootstrap/js/tests/unit/.eslintrc.json +40 -0
- data/assets/scss/bootstrap/js/tests/unit/alert.js +123 -0
- data/assets/scss/bootstrap/js/tests/unit/button.js +222 -0
- data/assets/scss/bootstrap/js/tests/unit/carousel.js +1333 -0
- data/assets/scss/bootstrap/js/tests/unit/collapse.js +892 -0
- data/assets/scss/bootstrap/js/tests/unit/dropdown.js +1419 -0
- data/assets/scss/bootstrap/js/tests/unit/modal.js +815 -0
- data/assets/scss/bootstrap/js/tests/unit/popover.js +471 -0
- data/assets/scss/bootstrap/js/tests/unit/scrollspy.js +728 -0
- data/assets/scss/bootstrap/js/tests/unit/tab.js +518 -0
- data/assets/scss/bootstrap/js/tests/unit/toast.js +259 -0
- data/assets/scss/bootstrap/js/tests/unit/tooltip.js +1109 -0
- data/assets/scss/bootstrap/js/tests/unit/util.js +163 -0
- data/assets/scss/bootstrap/js/tests/visual/alert.html +58 -0
- data/assets/scss/bootstrap/js/tests/visual/button.html +51 -0
- data/assets/scss/bootstrap/js/tests/visual/carousel.html +66 -0
- data/assets/scss/bootstrap/js/tests/visual/collapse.html +78 -0
- data/assets/scss/bootstrap/js/tests/visual/dropdown.html +212 -0
- data/assets/scss/bootstrap/js/tests/visual/modal.html +268 -0
- data/assets/scss/bootstrap/js/tests/visual/popover.html +46 -0
- data/assets/scss/bootstrap/js/tests/visual/scrollspy.html +95 -0
- data/assets/scss/bootstrap/js/tests/visual/tab.html +234 -0
- data/assets/scss/bootstrap/js/tests/visual/toast.html +72 -0
- data/assets/scss/bootstrap/js/tests/visual/tooltip.html +106 -0
- data/assets/scss/bootstrap/scss/_alert.scss +51 -0
- data/assets/scss/bootstrap/scss/_badge.scss +54 -0
- data/assets/scss/bootstrap/scss/_breadcrumb.scss +41 -0
- data/assets/scss/bootstrap/scss/_button-group.scss +163 -0
- data/assets/scss/bootstrap/scss/_buttons.scss +137 -0
- data/assets/scss/bootstrap/scss/_card.scss +289 -0
- data/assets/scss/bootstrap/scss/_carousel.scss +197 -0
- data/assets/scss/bootstrap/scss/_close.scss +41 -0
- data/assets/scss/bootstrap/scss/_code.scss +48 -0
- data/assets/scss/bootstrap/scss/_custom-forms.scss +507 -0
- data/assets/scss/bootstrap/scss/_dropdown.scss +191 -0
- data/assets/scss/bootstrap/scss/_forms.scss +330 -0
- data/assets/scss/bootstrap/scss/_functions.scss +86 -0
- data/assets/scss/bootstrap/scss/_grid.scss +52 -0
- data/assets/scss/bootstrap/scss/_images.scss +42 -0
- data/assets/scss/bootstrap/scss/_input-group.scss +193 -0
- data/assets/scss/bootstrap/scss/_jumbotron.scss +17 -0
- data/assets/scss/bootstrap/scss/_list-group.scss +149 -0
- data/assets/scss/bootstrap/scss/_media.scss +8 -0
- data/assets/scss/bootstrap/scss/_mixins.scss +47 -0
- data/assets/scss/bootstrap/scss/_modal.scss +229 -0
- data/assets/scss/bootstrap/scss/_nav.scss +120 -0
- data/assets/scss/bootstrap/scss/_navbar.scss +294 -0
- data/assets/scss/bootstrap/scss/_pagination.scss +73 -0
- data/assets/scss/bootstrap/scss/_popover.scss +171 -0
- data/assets/scss/bootstrap/scss/_print.scss +141 -0
- data/assets/scss/bootstrap/scss/_progress.scss +43 -0
- data/assets/scss/bootstrap/scss/_reboot.scss +483 -0
- data/assets/scss/bootstrap/scss/_root.scss +19 -0
- data/assets/scss/bootstrap/scss/_spinners.scss +55 -0
- data/assets/scss/bootstrap/scss/_tables.scss +185 -0
- data/assets/scss/bootstrap/scss/_toasts.scss +44 -0
- data/assets/scss/bootstrap/scss/_tooltip.scss +115 -0
- data/assets/scss/bootstrap/scss/_transitions.scss +20 -0
- data/assets/scss/bootstrap/scss/_type.scss +125 -0
- data/assets/scss/bootstrap/scss/_utilities.scss +17 -0
- data/assets/scss/bootstrap/scss/_variables.scss +1123 -0
- data/assets/scss/bootstrap/scss/bootstrap-grid.scss +29 -0
- data/assets/scss/bootstrap/scss/bootstrap-reboot.scss +12 -0
- data/assets/scss/bootstrap/scss/bootstrap.scss +44 -0
- data/assets/scss/bootstrap/scss/mixins/_alert.scss +13 -0
- data/assets/scss/bootstrap/scss/mixins/_background-variant.scss +21 -0
- data/assets/scss/bootstrap/scss/mixins/_badge.scss +17 -0
- data/assets/scss/bootstrap/scss/mixins/_border-radius.scss +63 -0
- data/assets/scss/bootstrap/scss/mixins/_box-shadow.scss +20 -0
- data/assets/scss/bootstrap/scss/mixins/_breakpoints.scss +123 -0
- data/assets/scss/bootstrap/scss/mixins/_buttons.scss +107 -0
- data/assets/scss/bootstrap/scss/mixins/_caret.scss +62 -0
- data/assets/scss/bootstrap/scss/mixins/_clearfix.scss +7 -0
- data/assets/scss/bootstrap/scss/mixins/_deprecate.scss +10 -0
- data/assets/scss/bootstrap/scss/mixins/_float.scss +14 -0
- data/assets/scss/bootstrap/scss/mixins/_forms.scss +192 -0
- data/assets/scss/bootstrap/scss/mixins/_gradients.scss +45 -0
- data/assets/scss/bootstrap/scss/mixins/_grid-framework.scss +66 -0
- data/assets/scss/bootstrap/scss/mixins/_grid.scss +51 -0
- data/assets/scss/bootstrap/scss/mixins/_hover.scss +37 -0
- data/assets/scss/bootstrap/scss/mixins/_image.scss +36 -0
- data/assets/scss/bootstrap/scss/mixins/_list-group.scss +21 -0
- data/assets/scss/bootstrap/scss/mixins/_lists.scss +7 -0
- data/assets/scss/bootstrap/scss/mixins/_nav-divider.scss +10 -0
- data/assets/scss/bootstrap/scss/mixins/_pagination.scss +22 -0
- data/assets/scss/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/assets/scss/bootstrap/scss/mixins/_resize.scss +6 -0
- data/assets/scss/bootstrap/scss/mixins/_screen-reader.scss +33 -0
- data/assets/scss/bootstrap/scss/mixins/_size.scss +7 -0
- data/assets/scss/bootstrap/scss/mixins/_table-row.scss +39 -0
- data/assets/scss/bootstrap/scss/mixins/_text-emphasis.scss +16 -0
- data/assets/scss/bootstrap/scss/mixins/_text-hide.scss +11 -0
- data/assets/scss/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/assets/scss/bootstrap/scss/mixins/_transition.scss +16 -0
- data/assets/scss/bootstrap/scss/mixins/_visibility.scss +8 -0
- data/assets/scss/bootstrap/scss/utilities/_align.scss +8 -0
- data/assets/scss/bootstrap/scss/utilities/_background.scss +19 -0
- data/assets/scss/bootstrap/scss/utilities/_borders.scss +75 -0
- data/assets/scss/bootstrap/scss/utilities/_clearfix.scss +3 -0
- data/assets/scss/bootstrap/scss/utilities/_display.scss +26 -0
- data/assets/scss/bootstrap/scss/utilities/_embed.scss +39 -0
- data/assets/scss/bootstrap/scss/utilities/_flex.scss +51 -0
- data/assets/scss/bootstrap/scss/utilities/_float.scss +11 -0
- data/assets/scss/bootstrap/scss/utilities/_overflow.scss +5 -0
- data/assets/scss/bootstrap/scss/utilities/_position.scss +32 -0
- data/assets/scss/bootstrap/scss/utilities/_screenreaders.scss +11 -0
- data/assets/scss/bootstrap/scss/utilities/_shadows.scss +6 -0
- data/assets/scss/bootstrap/scss/utilities/_sizing.scss +20 -0
- data/assets/scss/bootstrap/scss/utilities/_spacing.scss +73 -0
- data/assets/scss/bootstrap/scss/utilities/_stretched-link.scss +19 -0
- data/assets/scss/bootstrap/scss/utilities/_text.scss +72 -0
- data/assets/scss/bootstrap/scss/utilities/_visibility.scss +13 -0
- data/assets/scss/bootstrap/scss/vendor/_rfs.scss +212 -0
- data/assets/scss/theme/_about.scss +28 -0
- data/assets/scss/theme/_base.scss +207 -0
- data/assets/scss/theme/_blog.scss +140 -0
- data/assets/scss/theme/_demo.scss +153 -0
- data/assets/scss/theme/_mixins.scss +34 -0
- data/assets/scss/theme/_responsive.scss +88 -0
- data/assets/scss/theme/styles.scss +14 -0
- data/assets/scss/theme-8.scss +41 -0
- data/assets/styles.scss +6 -0
- metadata +221 -4
@@ -0,0 +1,728 @@
|
|
1
|
+
$(function () {
|
2
|
+
'use strict'
|
3
|
+
|
4
|
+
QUnit.module('scrollspy plugin')
|
5
|
+
|
6
|
+
QUnit.test('should be defined on jquery object', function (assert) {
|
7
|
+
assert.expect(1)
|
8
|
+
assert.ok($(document.body).scrollspy, 'scrollspy method is defined')
|
9
|
+
})
|
10
|
+
|
11
|
+
QUnit.module('scrollspy', {
|
12
|
+
beforeEach: function () {
|
13
|
+
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
|
14
|
+
$.fn.bootstrapScrollspy = $.fn.scrollspy.noConflict()
|
15
|
+
},
|
16
|
+
afterEach: function () {
|
17
|
+
$.fn.scrollspy = $.fn.bootstrapScrollspy
|
18
|
+
delete $.fn.bootstrapScrollspy
|
19
|
+
$('#qunit-fixture').html('')
|
20
|
+
}
|
21
|
+
})
|
22
|
+
|
23
|
+
QUnit.test('should provide no conflict', function (assert) {
|
24
|
+
assert.expect(1)
|
25
|
+
assert.strictEqual(typeof $.fn.scrollspy, 'undefined', 'scrollspy was set back to undefined (org value)')
|
26
|
+
})
|
27
|
+
|
28
|
+
QUnit.test('should throw explicit error on undefined method', function (assert) {
|
29
|
+
assert.expect(1)
|
30
|
+
var $el = $('<div/>').appendTo('#qunit-fixture')
|
31
|
+
$el.bootstrapScrollspy()
|
32
|
+
try {
|
33
|
+
$el.bootstrapScrollspy('noMethod')
|
34
|
+
} catch (err) {
|
35
|
+
assert.strictEqual(err.message, 'No method named "noMethod"')
|
36
|
+
}
|
37
|
+
})
|
38
|
+
|
39
|
+
QUnit.test('should return jquery collection containing the element', function (assert) {
|
40
|
+
assert.expect(2)
|
41
|
+
var $el = $('<div/>').appendTo('#qunit-fixture')
|
42
|
+
var $scrollspy = $el.bootstrapScrollspy()
|
43
|
+
assert.ok($scrollspy instanceof $, 'returns jquery collection')
|
44
|
+
assert.strictEqual($scrollspy[0], $el[0], 'collection contains element')
|
45
|
+
})
|
46
|
+
|
47
|
+
QUnit.test('should only switch "active" class on current target', function (assert) {
|
48
|
+
assert.expect(1)
|
49
|
+
var done = assert.async()
|
50
|
+
|
51
|
+
var sectionHTML = '<div id="root" class="active">' +
|
52
|
+
'<div class="topbar">' +
|
53
|
+
'<div class="topbar-inner">' +
|
54
|
+
'<div class="container" id="ss-target">' +
|
55
|
+
'<ul class="nav">' +
|
56
|
+
'<li class="nav-item"><a href="#masthead">Overview</a></li>' +
|
57
|
+
'<li class="nav-item"><a href="#detail">Detail</a></li>' +
|
58
|
+
'</ul>' +
|
59
|
+
'</div>' +
|
60
|
+
'</div>' +
|
61
|
+
'</div>' +
|
62
|
+
'<div id="scrollspy-example" style="height: 100px; overflow: auto;">' +
|
63
|
+
'<div style="height: 200px;">' +
|
64
|
+
'<h4 id="masthead">Overview</h4>' +
|
65
|
+
'<p style="height: 200px">' +
|
66
|
+
'Ad leggings keytar, brunch id art party dolor labore.' +
|
67
|
+
'</p>' +
|
68
|
+
'</div>' +
|
69
|
+
'<div style="height: 200px;">' +
|
70
|
+
'<h4 id="detail">Detail</h4>' +
|
71
|
+
'<p style="height: 200px">' +
|
72
|
+
'Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard.' +
|
73
|
+
'</p>' +
|
74
|
+
'</div>' +
|
75
|
+
'</div>' +
|
76
|
+
'</div>'
|
77
|
+
var $section = $(sectionHTML).appendTo('#qunit-fixture')
|
78
|
+
|
79
|
+
var $scrollspy = $section
|
80
|
+
.show()
|
81
|
+
.find('#scrollspy-example')
|
82
|
+
.bootstrapScrollspy({
|
83
|
+
target: '#ss-target'
|
84
|
+
})
|
85
|
+
|
86
|
+
$scrollspy.one('scroll', function () {
|
87
|
+
assert.ok($section.hasClass('active'), '"active" class still on root node')
|
88
|
+
done()
|
89
|
+
})
|
90
|
+
|
91
|
+
$scrollspy.scrollTop(350)
|
92
|
+
})
|
93
|
+
|
94
|
+
QUnit.test('should only switch "active" class on current target specified w element', function (assert) {
|
95
|
+
assert.expect(1)
|
96
|
+
var done = assert.async()
|
97
|
+
|
98
|
+
var sectionHTML = '<div id="root" class="active">' +
|
99
|
+
'<div class="topbar">' +
|
100
|
+
'<div class="topbar-inner">' +
|
101
|
+
'<div class="container" id="ss-target">' +
|
102
|
+
'<ul class="nav">' +
|
103
|
+
'<li class="nav-item"><a href="#masthead">Overview</a></li>' +
|
104
|
+
'<li class="nav-item"><a href="#detail">Detail</a></li>' +
|
105
|
+
'</ul>' +
|
106
|
+
'</div>' +
|
107
|
+
'</div>' +
|
108
|
+
'</div>' +
|
109
|
+
'<div id="scrollspy-example" style="height: 100px; overflow: auto;">' +
|
110
|
+
'<div style="height: 200px;">' +
|
111
|
+
'<h4 id="masthead">Overview</h4>' +
|
112
|
+
'<p style="height: 200px">' +
|
113
|
+
'Ad leggings keytar, brunch id art party dolor labore.' +
|
114
|
+
'</p>' +
|
115
|
+
'</div>' +
|
116
|
+
'<div style="height: 200px;">' +
|
117
|
+
'<h4 id="detail">Detail</h4>' +
|
118
|
+
'<p style="height: 200px">' +
|
119
|
+
'Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard.' +
|
120
|
+
'</p>' +
|
121
|
+
'</div>' +
|
122
|
+
'</div>' +
|
123
|
+
'</div>'
|
124
|
+
var $section = $(sectionHTML).appendTo('#qunit-fixture')
|
125
|
+
|
126
|
+
var $scrollspy = $section
|
127
|
+
.show()
|
128
|
+
.find('#scrollspy-example')
|
129
|
+
.bootstrapScrollspy({
|
130
|
+
target: document.getElementById('#ss-target')
|
131
|
+
})
|
132
|
+
|
133
|
+
$scrollspy.one('scroll', function () {
|
134
|
+
assert.ok($section.hasClass('active'), '"active" class still on root node')
|
135
|
+
done()
|
136
|
+
})
|
137
|
+
|
138
|
+
$scrollspy.scrollTop(350)
|
139
|
+
})
|
140
|
+
|
141
|
+
QUnit.test('should correctly select middle navigation option when large offset is used', function (assert) {
|
142
|
+
assert.expect(3)
|
143
|
+
var done = assert.async()
|
144
|
+
|
145
|
+
var sectionHTML = '<div id="header" style="height: 500px;"></div>' +
|
146
|
+
'<nav id="navigation" class="navbar">' +
|
147
|
+
'<ul class="navbar-nav">' +
|
148
|
+
'<li class="nav-item active"><a class="nav-link" id="one-link" href="#one">One</a></li>' +
|
149
|
+
'<li class="nav-item"><a class="nav-link" id="two-link" href="#two">Two</a></li>' +
|
150
|
+
'<li class="nav-item"><a class="nav-link" id="three-link" href="#three">Three</a></li>' +
|
151
|
+
'</ul>' +
|
152
|
+
'</nav>' +
|
153
|
+
'<div id="content" style="height: 200px; overflow-y: auto;">' +
|
154
|
+
'<div id="one" style="height: 500px;"></div>' +
|
155
|
+
'<div id="two" style="height: 300px;"></div>' +
|
156
|
+
'<div id="three" style="height: 10px;"></div>' +
|
157
|
+
'</div>'
|
158
|
+
var $section = $(sectionHTML).appendTo('#qunit-fixture')
|
159
|
+
var $scrollspy = $section
|
160
|
+
.show()
|
161
|
+
.filter('#content')
|
162
|
+
|
163
|
+
$scrollspy.bootstrapScrollspy({
|
164
|
+
target: '#navigation',
|
165
|
+
offset: $scrollspy.position().top
|
166
|
+
})
|
167
|
+
|
168
|
+
$scrollspy.one('scroll', function () {
|
169
|
+
assert.ok(!$section.find('#one-link').hasClass('active'), '"active" class removed from first section')
|
170
|
+
assert.ok($section.find('#two-link').hasClass('active'), '"active" class on middle section')
|
171
|
+
assert.ok(!$section.find('#three-link').hasClass('active'), '"active" class not on last section')
|
172
|
+
done()
|
173
|
+
})
|
174
|
+
|
175
|
+
$scrollspy.scrollTop(550)
|
176
|
+
})
|
177
|
+
|
178
|
+
QUnit.test('should add the active class to the correct element', function (assert) {
|
179
|
+
assert.expect(2)
|
180
|
+
var navbarHtml =
|
181
|
+
'<nav class="navbar">' +
|
182
|
+
'<ul class="nav">' +
|
183
|
+
'<li class="nav-item"><a class="nav-link" id="a-1" href="#div-1">div 1</a></li>' +
|
184
|
+
'<li class="nav-item"><a class="nav-link" id="a-2" href="#div-2">div 2</a></li>' +
|
185
|
+
'</ul>' +
|
186
|
+
'</nav>'
|
187
|
+
var contentHtml =
|
188
|
+
'<div class="content" style="overflow: auto; height: 50px">' +
|
189
|
+
'<div id="div-1" style="height: 100px; padding: 0; margin: 0">div 1</div>' +
|
190
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
191
|
+
'</div>'
|
192
|
+
|
193
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
194
|
+
var $content = $(contentHtml)
|
195
|
+
.appendTo('#qunit-fixture')
|
196
|
+
.bootstrapScrollspy({
|
197
|
+
offset: 0,
|
198
|
+
target: '.navbar'
|
199
|
+
})
|
200
|
+
|
201
|
+
var done = assert.async()
|
202
|
+
var testElementIsActiveAfterScroll = function (element, target) {
|
203
|
+
var deferred = $.Deferred()
|
204
|
+
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
205
|
+
$content.one('scroll', function () {
|
206
|
+
assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
207
|
+
deferred.resolve()
|
208
|
+
})
|
209
|
+
$content.scrollTop(scrollHeight)
|
210
|
+
return deferred.promise()
|
211
|
+
}
|
212
|
+
|
213
|
+
$.when(testElementIsActiveAfterScroll('#a-1', '#div-1'))
|
214
|
+
.then(function () {
|
215
|
+
return testElementIsActiveAfterScroll('#a-2', '#div-2')
|
216
|
+
})
|
217
|
+
.then(function () {
|
218
|
+
done()
|
219
|
+
})
|
220
|
+
})
|
221
|
+
|
222
|
+
QUnit.test('should add the active class to the correct element (nav markup)', function (assert) {
|
223
|
+
assert.expect(2)
|
224
|
+
var navbarHtml =
|
225
|
+
'<nav class="navbar">' +
|
226
|
+
'<nav class="nav">' +
|
227
|
+
'<a class="nav-link" id="a-1" href="#div-1">div 1</a>' +
|
228
|
+
'<a class="nav-link" id="a-2" href="#div-2">div 2</a>' +
|
229
|
+
'</nav>' +
|
230
|
+
'</nav>'
|
231
|
+
var contentHtml =
|
232
|
+
'<div class="content" style="overflow: auto; height: 50px">' +
|
233
|
+
'<div id="div-1" style="height: 100px; padding: 0; margin: 0">div 1</div>' +
|
234
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
235
|
+
'</div>'
|
236
|
+
|
237
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
238
|
+
var $content = $(contentHtml)
|
239
|
+
.appendTo('#qunit-fixture')
|
240
|
+
.bootstrapScrollspy({
|
241
|
+
offset: 0,
|
242
|
+
target: '.navbar'
|
243
|
+
})
|
244
|
+
|
245
|
+
var done = assert.async()
|
246
|
+
var testElementIsActiveAfterScroll = function (element, target) {
|
247
|
+
var deferred = $.Deferred()
|
248
|
+
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
249
|
+
$content.one('scroll', function () {
|
250
|
+
assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
251
|
+
deferred.resolve()
|
252
|
+
})
|
253
|
+
$content.scrollTop(scrollHeight)
|
254
|
+
return deferred.promise()
|
255
|
+
}
|
256
|
+
|
257
|
+
$.when(testElementIsActiveAfterScroll('#a-1', '#div-1'))
|
258
|
+
.then(function () {
|
259
|
+
return testElementIsActiveAfterScroll('#a-2', '#div-2')
|
260
|
+
})
|
261
|
+
.then(function () {
|
262
|
+
done()
|
263
|
+
})
|
264
|
+
})
|
265
|
+
|
266
|
+
QUnit.test('should add the active class to the correct element (list-group markup)', function (assert) {
|
267
|
+
assert.expect(2)
|
268
|
+
var navbarHtml =
|
269
|
+
'<nav class="navbar">' +
|
270
|
+
'<div class="list-group">' +
|
271
|
+
'<a class="list-group-item" id="a-1" href="#div-1">div 1</a>' +
|
272
|
+
'<a class="list-group-item" id="a-2" href="#div-2">div 2</a>' +
|
273
|
+
'</div>' +
|
274
|
+
'</nav>'
|
275
|
+
var contentHtml =
|
276
|
+
'<div class="content" style="overflow: auto; height: 50px">' +
|
277
|
+
'<div id="div-1" style="height: 100px; padding: 0; margin: 0">div 1</div>' +
|
278
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
279
|
+
'</div>'
|
280
|
+
|
281
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
282
|
+
var $content = $(contentHtml)
|
283
|
+
.appendTo('#qunit-fixture')
|
284
|
+
.bootstrapScrollspy({
|
285
|
+
offset: 0,
|
286
|
+
target: '.navbar'
|
287
|
+
})
|
288
|
+
|
289
|
+
var done = assert.async()
|
290
|
+
var testElementIsActiveAfterScroll = function (element, target) {
|
291
|
+
var deferred = $.Deferred()
|
292
|
+
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
293
|
+
$content.one('scroll', function () {
|
294
|
+
assert.ok($(element).hasClass('active'), 'target:' + target + ', element' + element)
|
295
|
+
deferred.resolve()
|
296
|
+
})
|
297
|
+
$content.scrollTop(scrollHeight)
|
298
|
+
return deferred.promise()
|
299
|
+
}
|
300
|
+
|
301
|
+
$.when(testElementIsActiveAfterScroll('#a-1', '#div-1'))
|
302
|
+
.then(function () {
|
303
|
+
return testElementIsActiveAfterScroll('#a-2', '#div-2')
|
304
|
+
})
|
305
|
+
.then(function () {
|
306
|
+
done()
|
307
|
+
})
|
308
|
+
})
|
309
|
+
|
310
|
+
QUnit.test('should add the active class correctly when there are nested elements at 0 scroll offset', function (assert) {
|
311
|
+
assert.expect(6)
|
312
|
+
var times = 0
|
313
|
+
var done = assert.async()
|
314
|
+
var navbarHtml = '<nav id="navigation" class="navbar">' +
|
315
|
+
'<ul class="nav">' +
|
316
|
+
'<li class="nav-item"><a id="a-1" class="nav-link" href="#div-1">div 1</a>' +
|
317
|
+
'<ul class="nav">' +
|
318
|
+
'<li class="nav-item"><a id="a-2" class="nav-link" href="#div-2">div 2</a></li>' +
|
319
|
+
'</ul>' +
|
320
|
+
'</li>' +
|
321
|
+
'</ul>' +
|
322
|
+
'</nav>'
|
323
|
+
|
324
|
+
var contentHtml = '<div class="content" style="position: absolute; top: 0px; overflow: auto; height: 50px">' +
|
325
|
+
'<div id="div-1" style="padding: 0; margin: 0">' +
|
326
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
327
|
+
'</div>' +
|
328
|
+
'</div>'
|
329
|
+
|
330
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
331
|
+
|
332
|
+
var $content = $(contentHtml)
|
333
|
+
.appendTo('#qunit-fixture')
|
334
|
+
.bootstrapScrollspy({
|
335
|
+
offset: 0,
|
336
|
+
target: '#navigation'
|
337
|
+
})
|
338
|
+
|
339
|
+
function testActiveElements() {
|
340
|
+
if (++times > 3) {
|
341
|
+
return done()
|
342
|
+
}
|
343
|
+
|
344
|
+
$content.one('scroll', function () {
|
345
|
+
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
|
346
|
+
assert.ok($('#a-2').hasClass('active'), 'nav item for inner element has "active" class')
|
347
|
+
testActiveElements()
|
348
|
+
})
|
349
|
+
|
350
|
+
$content.scrollTop($content.scrollTop() + 10)
|
351
|
+
}
|
352
|
+
|
353
|
+
testActiveElements()
|
354
|
+
})
|
355
|
+
|
356
|
+
QUnit.test('should add the active class correctly when there are nested elements (nav markup)', function (assert) {
|
357
|
+
assert.expect(6)
|
358
|
+
var times = 0
|
359
|
+
var done = assert.async()
|
360
|
+
var navbarHtml = '<nav id="navigation" class="navbar">' +
|
361
|
+
'<nav class="nav">' +
|
362
|
+
'<a id="a-1" class="nav-link" href="#div-1">div 1</a>' +
|
363
|
+
'<nav class="nav">' +
|
364
|
+
'<a id="a-2" class="nav-link" href="#div-2">div 2</a>' +
|
365
|
+
'</nav>' +
|
366
|
+
'</nav>' +
|
367
|
+
'</nav>'
|
368
|
+
|
369
|
+
var contentHtml = '<div class="content" style="position: absolute; top: 0px; overflow: auto; height: 50px">' +
|
370
|
+
'<div id="div-1" style="padding: 0; margin: 0">' +
|
371
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
372
|
+
'</div>' +
|
373
|
+
'</div>'
|
374
|
+
|
375
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
376
|
+
|
377
|
+
var $content = $(contentHtml)
|
378
|
+
.appendTo('#qunit-fixture')
|
379
|
+
.bootstrapScrollspy({
|
380
|
+
offset: 0,
|
381
|
+
target: '#navigation'
|
382
|
+
})
|
383
|
+
|
384
|
+
function testActiveElements() {
|
385
|
+
if (++times > 3) {
|
386
|
+
return done()
|
387
|
+
}
|
388
|
+
|
389
|
+
$content.one('scroll', function () {
|
390
|
+
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
|
391
|
+
assert.ok($('#a-2').hasClass('active'), 'nav item for inner element has "active" class')
|
392
|
+
testActiveElements()
|
393
|
+
})
|
394
|
+
|
395
|
+
$content.scrollTop($content.scrollTop() + 10)
|
396
|
+
}
|
397
|
+
|
398
|
+
testActiveElements()
|
399
|
+
})
|
400
|
+
|
401
|
+
QUnit.test('should add the active class correctly when there are nested elements (nav nav-item markup)', function (assert) {
|
402
|
+
assert.expect(6)
|
403
|
+
var times = 0
|
404
|
+
var done = assert.async()
|
405
|
+
var navbarHtml = '<nav id="navigation" class="navbar">' +
|
406
|
+
'<ul class="nav">' +
|
407
|
+
'<li class="nav-item"><a id="a-1" class="nav-link" href="#div-1">div 1</a></li>' +
|
408
|
+
'<ul class="nav">' +
|
409
|
+
'<li class="nav-item"><a id="a-2" class="nav-link" href="#div-2">div 2</a></li>' +
|
410
|
+
'</ul>' +
|
411
|
+
'</ul>' +
|
412
|
+
'</nav>'
|
413
|
+
|
414
|
+
var contentHtml = '<div class="content" style="position: absolute; top: 0px; overflow: auto; height: 50px">' +
|
415
|
+
'<div id="div-1" style="padding: 0; margin: 0">' +
|
416
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
417
|
+
'</div>' +
|
418
|
+
'</div>'
|
419
|
+
|
420
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
421
|
+
|
422
|
+
var $content = $(contentHtml)
|
423
|
+
.appendTo('#qunit-fixture')
|
424
|
+
.bootstrapScrollspy({
|
425
|
+
offset: 0,
|
426
|
+
target: '#navigation'
|
427
|
+
})
|
428
|
+
|
429
|
+
function testActiveElements() {
|
430
|
+
if (++times > 3) {
|
431
|
+
return done()
|
432
|
+
}
|
433
|
+
|
434
|
+
$content.one('scroll', function () {
|
435
|
+
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
|
436
|
+
assert.ok($('#a-2').hasClass('active'), 'nav item for inner element has "active" class')
|
437
|
+
testActiveElements()
|
438
|
+
})
|
439
|
+
|
440
|
+
$content.scrollTop($content.scrollTop() + 10)
|
441
|
+
}
|
442
|
+
|
443
|
+
testActiveElements()
|
444
|
+
})
|
445
|
+
|
446
|
+
QUnit.test('should add the active class correctly when there are nested elements (list-group markup)', function (assert) {
|
447
|
+
assert.expect(6)
|
448
|
+
var times = 0
|
449
|
+
var done = assert.async()
|
450
|
+
var navbarHtml = '<nav id="navigation" class="navbar">' +
|
451
|
+
'<div class="list-group">' +
|
452
|
+
'<a id="a-1" class="list-group-item" href="#div-1">div 1</a>' +
|
453
|
+
'<div class="list-group">' +
|
454
|
+
'<a id="a-2" class="list-group-item" href="#div-2">div 2</a>' +
|
455
|
+
'</div>' +
|
456
|
+
'</div>' +
|
457
|
+
'</nav>'
|
458
|
+
|
459
|
+
var contentHtml = '<div class="content" style="position: absolute; top: 0px; overflow: auto; height: 50px">' +
|
460
|
+
'<div id="div-1" style="padding: 0; margin: 0">' +
|
461
|
+
'<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>' +
|
462
|
+
'</div>' +
|
463
|
+
'</div>'
|
464
|
+
|
465
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
466
|
+
|
467
|
+
var $content = $(contentHtml)
|
468
|
+
.appendTo('#qunit-fixture')
|
469
|
+
.bootstrapScrollspy({
|
470
|
+
offset: 0,
|
471
|
+
target: '#navigation'
|
472
|
+
})
|
473
|
+
|
474
|
+
function testActiveElements() {
|
475
|
+
if (++times > 3) {
|
476
|
+
return done()
|
477
|
+
}
|
478
|
+
|
479
|
+
$content.one('scroll', function () {
|
480
|
+
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
|
481
|
+
assert.ok($('#a-2').hasClass('active'), 'nav item for inner element has "active" class')
|
482
|
+
testActiveElements()
|
483
|
+
})
|
484
|
+
|
485
|
+
$content.scrollTop($content.scrollTop() + 10)
|
486
|
+
}
|
487
|
+
|
488
|
+
testActiveElements()
|
489
|
+
})
|
490
|
+
|
491
|
+
QUnit.test('should clear selection if above the first section', function (assert) {
|
492
|
+
assert.expect(3)
|
493
|
+
var done = assert.async()
|
494
|
+
|
495
|
+
var sectionHTML = '<div id="header" style="height: 500px;"></div>' +
|
496
|
+
'<nav id="navigation" class="navbar">' +
|
497
|
+
'<ul class="navbar-nav">' +
|
498
|
+
'<li class="nav-item"><a id="one-link" class="nav-link active" href="#one">One</a></li>' +
|
499
|
+
'<li class="nav-item"><a id="two-link" class="nav-link" href="#two">Two</a></li>' +
|
500
|
+
'<li class="nav-item"><a id="three-link" class="nav-link" href="#three">Three</a></li>' +
|
501
|
+
'</ul>' +
|
502
|
+
'</nav>'
|
503
|
+
$(sectionHTML).appendTo('#qunit-fixture')
|
504
|
+
|
505
|
+
var scrollspyHTML = '<div id="content" style="height: 200px; overflow-y: auto;">' +
|
506
|
+
'<div id="spacer" style="height: 100px;"/>' +
|
507
|
+
'<div id="one" style="height: 100px;"/>' +
|
508
|
+
'<div id="two" style="height: 100px;"/>' +
|
509
|
+
'<div id="three" style="height: 100px;"/>' +
|
510
|
+
'<div id="spacer" style="height: 100px;"/>' +
|
511
|
+
'</div>'
|
512
|
+
var $scrollspy = $(scrollspyHTML).appendTo('#qunit-fixture')
|
513
|
+
|
514
|
+
$scrollspy
|
515
|
+
.bootstrapScrollspy({
|
516
|
+
target: '#navigation',
|
517
|
+
offset: $scrollspy.position().top
|
518
|
+
})
|
519
|
+
.one('scroll', function () {
|
520
|
+
assert.strictEqual($('.active').length, 1, '"active" class on only one element present')
|
521
|
+
assert.strictEqual($('.active').is('#two-link'), true, '"active" class on second section')
|
522
|
+
$scrollspy
|
523
|
+
.one('scroll', function () {
|
524
|
+
assert.strictEqual($('.active').length, 0, 'selection cleared')
|
525
|
+
done()
|
526
|
+
})
|
527
|
+
.scrollTop(0)
|
528
|
+
})
|
529
|
+
.scrollTop(201)
|
530
|
+
})
|
531
|
+
|
532
|
+
QUnit.test('should NOT clear selection if above the first section and first section is at the top', function (assert) {
|
533
|
+
assert.expect(4)
|
534
|
+
var done = assert.async()
|
535
|
+
|
536
|
+
var sectionHTML = '<div id="header" style="height: 500px;"></div>' +
|
537
|
+
'<nav id="navigation" class="navbar">' +
|
538
|
+
'<ul class="navbar-nav">' +
|
539
|
+
'<li class="nav-item"><a id="one-link" class="nav-link active" href="#one">One</a></li>' +
|
540
|
+
'<li class="nav-item"><a id="two-link" class="nav-link" href="#two">Two</a></li>' +
|
541
|
+
'<li class="nav-item"><a id="three-link" class="nav-link" href="#three">Three</a></li>' +
|
542
|
+
'</ul>' +
|
543
|
+
'</nav>'
|
544
|
+
$(sectionHTML).appendTo('#qunit-fixture')
|
545
|
+
|
546
|
+
var negativeHeight = -10
|
547
|
+
var startOfSectionTwo = 101
|
548
|
+
|
549
|
+
var scrollspyHTML = '<div id="content" style="height: 200px; overflow-y: auto;">' +
|
550
|
+
'<div id="one" style="height: 100px;"/>' +
|
551
|
+
'<div id="two" style="height: 100px;"/>' +
|
552
|
+
'<div id="three" style="height: 100px;"/>' +
|
553
|
+
'<div id="spacer" style="height: 100px;"/>' +
|
554
|
+
'</div>'
|
555
|
+
var $scrollspy = $(scrollspyHTML).appendTo('#qunit-fixture')
|
556
|
+
|
557
|
+
$scrollspy
|
558
|
+
.bootstrapScrollspy({
|
559
|
+
target: '#navigation',
|
560
|
+
offset: $scrollspy.position().top
|
561
|
+
})
|
562
|
+
.one('scroll', function () {
|
563
|
+
assert.strictEqual($('.active').length, 1, '"active" class on only one element present')
|
564
|
+
assert.strictEqual($('.active').is('#two-link'), true, '"active" class on second section')
|
565
|
+
$scrollspy
|
566
|
+
.one('scroll', function () {
|
567
|
+
assert.strictEqual($('.active').length, 1, '"active" class on only one element present')
|
568
|
+
assert.strictEqual($('.active').is('#one-link'), true, '"active" class on first section')
|
569
|
+
done()
|
570
|
+
})
|
571
|
+
.scrollTop(negativeHeight)
|
572
|
+
})
|
573
|
+
.scrollTop(startOfSectionTwo)
|
574
|
+
})
|
575
|
+
|
576
|
+
QUnit.test('should correctly select navigation element on backward scrolling when each target section height is 100%', function (assert) {
|
577
|
+
assert.expect(5)
|
578
|
+
var navbarHtml =
|
579
|
+
'<nav class="navbar">' +
|
580
|
+
'<ul class="nav">' +
|
581
|
+
'<li class="nav-item"><a id="li-100-1" class="nav-link" href="#div-100-1">div 1</a></li>' +
|
582
|
+
'<li class="nav-item"><a id="li-100-2" class="nav-link" href="#div-100-2">div 2</a></li>' +
|
583
|
+
'<li class="nav-item"><a id="li-100-3" class="nav-link" href="#div-100-3">div 3</a></li>' +
|
584
|
+
'<li class="nav-item"><a id="li-100-4" class="nav-link" href="#div-100-4">div 4</a></li>' +
|
585
|
+
'<li class="nav-item"><a id="li-100-5" class="nav-link" href="#div-100-5">div 5</a></li>' +
|
586
|
+
'</ul>' +
|
587
|
+
'</nav>'
|
588
|
+
var contentHtml =
|
589
|
+
'<div class="content" style="position: relative; overflow: auto; height: 100px">' +
|
590
|
+
'<div id="div-100-1" style="position: relative; height: 100%; padding: 0; margin: 0">div 1</div>' +
|
591
|
+
'<div id="div-100-2" style="position: relative; height: 100%; padding: 0; margin: 0">div 2</div>' +
|
592
|
+
'<div id="div-100-3" style="position: relative; height: 100%; padding: 0; margin: 0">div 3</div>' +
|
593
|
+
'<div id="div-100-4" style="position: relative; height: 100%; padding: 0; margin: 0">div 4</div>' +
|
594
|
+
'<div id="div-100-5" style="position: relative; height: 100%; padding: 0; margin: 0">div 5</div>' +
|
595
|
+
'</div>'
|
596
|
+
|
597
|
+
$(navbarHtml).appendTo('#qunit-fixture')
|
598
|
+
var $content = $(contentHtml)
|
599
|
+
.appendTo('#qunit-fixture')
|
600
|
+
.bootstrapScrollspy({
|
601
|
+
offset: 0,
|
602
|
+
target: '.navbar'
|
603
|
+
})
|
604
|
+
|
605
|
+
var testElementIsActiveAfterScroll = function (element, target) {
|
606
|
+
var deferred = $.Deferred()
|
607
|
+
var scrollHeight = Math.ceil($content.scrollTop() + $(target).position().top)
|
608
|
+
$content.one('scroll', function () {
|
609
|
+
assert.ok($(element).hasClass('active'), 'target:' + target + ', element: ' + element)
|
610
|
+
deferred.resolve()
|
611
|
+
})
|
612
|
+
$content.scrollTop(scrollHeight)
|
613
|
+
return deferred.promise()
|
614
|
+
}
|
615
|
+
|
616
|
+
var done = assert.async()
|
617
|
+
$.when(testElementIsActiveAfterScroll('#li-100-5', '#div-100-5'))
|
618
|
+
.then(function () {
|
619
|
+
return testElementIsActiveAfterScroll('#li-100-4', '#div-100-4')
|
620
|
+
})
|
621
|
+
.then(function () {
|
622
|
+
return testElementIsActiveAfterScroll('#li-100-3', '#div-100-3')
|
623
|
+
})
|
624
|
+
.then(function () {
|
625
|
+
return testElementIsActiveAfterScroll('#li-100-2', '#div-100-2')
|
626
|
+
})
|
627
|
+
.then(function () {
|
628
|
+
return testElementIsActiveAfterScroll('#li-100-1', '#div-100-1')
|
629
|
+
})
|
630
|
+
.then(function () {
|
631
|
+
done()
|
632
|
+
})
|
633
|
+
})
|
634
|
+
|
635
|
+
QUnit.test('should allow passed in option offset method: offset', function (assert) {
|
636
|
+
assert.expect(4)
|
637
|
+
|
638
|
+
var testOffsetMethod = function (type) {
|
639
|
+
var $navbar = $(
|
640
|
+
'<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>' +
|
641
|
+
'<ul class="nav">' +
|
642
|
+
'<li class="nav-item"><a id="li-' + type + 'm-1" class="nav-link" href="#div-' + type + 'm-1">div 1</a></li>' +
|
643
|
+
'<li class="nav-item"><a id="li-' + type + 'm-2" class="nav-link" href="#div-' + type + 'm-2">div 2</a></li>' +
|
644
|
+
'<li class="nav-item"><a id="li-' + type + 'm-3" class="nav-link" href="#div-' + type + 'm-3">div 3</a></li>' +
|
645
|
+
'</ul>' +
|
646
|
+
'</nav>'
|
647
|
+
)
|
648
|
+
var $content = $(
|
649
|
+
'<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="offset"' : '') + ' style="position: relative; overflow: auto; height: 100px">' +
|
650
|
+
'<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>' +
|
651
|
+
'<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>' +
|
652
|
+
'<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>' +
|
653
|
+
'</div>'
|
654
|
+
)
|
655
|
+
|
656
|
+
$navbar.appendTo('#qunit-fixture')
|
657
|
+
$content.appendTo('#qunit-fixture')
|
658
|
+
|
659
|
+
if (type === 'js') {
|
660
|
+
$content.bootstrapScrollspy({
|
661
|
+
target: '.navbar',
|
662
|
+
offset: 0,
|
663
|
+
method: 'offset'
|
664
|
+
})
|
665
|
+
} else if (type === 'data') {
|
666
|
+
$(window).trigger('load')
|
667
|
+
}
|
668
|
+
|
669
|
+
var $target = $('#div-' + type + 'm-2')
|
670
|
+
var scrollspy = $content.data('bs.scrollspy')
|
671
|
+
|
672
|
+
assert.ok(scrollspy._offsets[1] === $target.offset().top, 'offset method with ' + type + ' option')
|
673
|
+
assert.ok(scrollspy._offsets[1] !== $target.position().top, 'position method with ' + type + ' option')
|
674
|
+
$navbar.remove()
|
675
|
+
$content.remove()
|
676
|
+
}
|
677
|
+
|
678
|
+
testOffsetMethod('js')
|
679
|
+
testOffsetMethod('data')
|
680
|
+
})
|
681
|
+
|
682
|
+
QUnit.test('should allow passed in option offset method: position', function (assert) {
|
683
|
+
assert.expect(4)
|
684
|
+
|
685
|
+
var testOffsetMethod = function (type) {
|
686
|
+
var $navbar = $(
|
687
|
+
'<nav class="navbar"' + (type === 'data' ? ' id="navbar-offset-method-menu"' : '') + '>' +
|
688
|
+
'<ul class="nav">' +
|
689
|
+
'<li class="nav-item"><a class="nav-link" id="li-' + type + 'm-1" href="#div-' + type + 'm-1">div 1</a></li>' +
|
690
|
+
'<li class="nav-item"><a class="nav-link" id="li-' + type + 'm-2" href="#div-' + type + 'm-2">div 2</a></li>' +
|
691
|
+
'<li class="nav-item"><a class="nav-link" id="li-' + type + 'm-3" href="#div-' + type + 'm-3">div 3</a></li>' +
|
692
|
+
'</ul>' +
|
693
|
+
'</nav>'
|
694
|
+
)
|
695
|
+
var $content = $(
|
696
|
+
'<div class="content"' + (type === 'data' ? ' data-spy="scroll" data-target="#navbar-offset-method-menu" data-offset="0" data-method="position"' : '') + ' style="position: relative; overflow: auto; height: 100px">' +
|
697
|
+
'<div id="div-' + type + 'm-1" style="position: relative; height: 200px; padding: 0; margin: 0">div 1</div>' +
|
698
|
+
'<div id="div-' + type + 'm-2" style="position: relative; height: 150px; padding: 0; margin: 0">div 2</div>' +
|
699
|
+
'<div id="div-' + type + 'm-3" style="position: relative; height: 250px; padding: 0; margin: 0">div 3</div>' +
|
700
|
+
'</div>'
|
701
|
+
)
|
702
|
+
|
703
|
+
$navbar.appendTo('#qunit-fixture')
|
704
|
+
$content.appendTo('#qunit-fixture')
|
705
|
+
|
706
|
+
if (type === 'js') {
|
707
|
+
$content.bootstrapScrollspy({
|
708
|
+
target: '.navbar',
|
709
|
+
offset: 0,
|
710
|
+
method: 'position'
|
711
|
+
})
|
712
|
+
} else if (type === 'data') {
|
713
|
+
$(window).trigger('load')
|
714
|
+
}
|
715
|
+
|
716
|
+
var $target = $('#div-' + type + 'm-2')
|
717
|
+
var scrollspy = $content.data('bs.scrollspy')
|
718
|
+
|
719
|
+
assert.ok(scrollspy._offsets[1] !== $target.offset().top, 'offset method with ' + type + ' option')
|
720
|
+
assert.ok(scrollspy._offsets[1] === $target.position().top, 'position method with ' + type + ' option')
|
721
|
+
$navbar.remove()
|
722
|
+
$content.remove()
|
723
|
+
}
|
724
|
+
|
725
|
+
testOffsetMethod('js')
|
726
|
+
testOffsetMethod('data')
|
727
|
+
})
|
728
|
+
})
|