vertx-howtos-jekyll-theme 0.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 (164) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +52 -0
  4. data/_layouts/page.html +61 -0
  5. data/_sass/bootstrap/js/dist/alert.js +199 -0
  6. data/_sass/bootstrap/js/dist/alert.js.map +1 -0
  7. data/_sass/bootstrap/js/dist/button.js +187 -0
  8. data/_sass/bootstrap/js/dist/button.js.map +1 -0
  9. data/_sass/bootstrap/js/dist/carousel.js +666 -0
  10. data/_sass/bootstrap/js/dist/carousel.js.map +1 -0
  11. data/_sass/bootstrap/js/dist/collapse.js +428 -0
  12. data/_sass/bootstrap/js/dist/collapse.js.map +1 -0
  13. data/_sass/bootstrap/js/dist/dropdown.js +591 -0
  14. data/_sass/bootstrap/js/dist/dropdown.js.map +1 -0
  15. data/_sass/bootstrap/js/dist/index.js +23 -0
  16. data/_sass/bootstrap/js/dist/index.js.map +1 -0
  17. data/_sass/bootstrap/js/dist/modal.js +644 -0
  18. data/_sass/bootstrap/js/dist/modal.js.map +1 -0
  19. data/_sass/bootstrap/js/dist/popover.js +261 -0
  20. data/_sass/bootstrap/js/dist/popover.js.map +1 -0
  21. data/_sass/bootstrap/js/dist/scrollspy.js +375 -0
  22. data/_sass/bootstrap/js/dist/scrollspy.js.map +1 -0
  23. data/_sass/bootstrap/js/dist/tab.js +266 -0
  24. data/_sass/bootstrap/js/dist/tab.js.map +1 -0
  25. data/_sass/bootstrap/js/dist/toast.js +278 -0
  26. data/_sass/bootstrap/js/dist/toast.js.map +1 -0
  27. data/_sass/bootstrap/js/dist/tooltip.js +745 -0
  28. data/_sass/bootstrap/js/dist/tooltip.js.map +1 -0
  29. data/_sass/bootstrap/js/dist/util.js +168 -0
  30. data/_sass/bootstrap/js/dist/util.js.map +1 -0
  31. data/_sass/bootstrap/js/src/alert.js +179 -0
  32. data/_sass/bootstrap/js/src/button.js +171 -0
  33. data/_sass/bootstrap/js/src/carousel.js +604 -0
  34. data/_sass/bootstrap/js/src/collapse.js +402 -0
  35. data/_sass/bootstrap/js/src/dropdown.js +538 -0
  36. data/_sass/bootstrap/js/src/index.js +52 -0
  37. data/_sass/bootstrap/js/src/modal.js +587 -0
  38. data/_sass/bootstrap/js/src/popover.js +184 -0
  39. data/_sass/bootstrap/js/src/scrollspy.js +326 -0
  40. data/_sass/bootstrap/js/src/tab.js +257 -0
  41. data/_sass/bootstrap/js/src/toast.js +223 -0
  42. data/_sass/bootstrap/js/src/tooltip.js +735 -0
  43. data/_sass/bootstrap/js/src/util.js +173 -0
  44. data/_sass/bootstrap/js/tests/README.md +69 -0
  45. data/_sass/bootstrap/js/tests/browsers.js +82 -0
  46. data/_sass/bootstrap/js/tests/index.html +145 -0
  47. data/_sass/bootstrap/js/tests/integration/bundle.js +8 -0
  48. data/_sass/bootstrap/js/tests/integration/index.html +66 -0
  49. data/_sass/bootstrap/js/tests/integration/rollup.bundle.js +20 -0
  50. data/_sass/bootstrap/js/tests/karma.conf.js +145 -0
  51. data/_sass/bootstrap/js/tests/unit/.eslintrc.json +40 -0
  52. data/_sass/bootstrap/js/tests/unit/alert.js +123 -0
  53. data/_sass/bootstrap/js/tests/unit/button.js +222 -0
  54. data/_sass/bootstrap/js/tests/unit/carousel.js +1273 -0
  55. data/_sass/bootstrap/js/tests/unit/collapse.js +892 -0
  56. data/_sass/bootstrap/js/tests/unit/dropdown.js +1364 -0
  57. data/_sass/bootstrap/js/tests/unit/modal.js +796 -0
  58. data/_sass/bootstrap/js/tests/unit/popover.js +471 -0
  59. data/_sass/bootstrap/js/tests/unit/scrollspy.js +728 -0
  60. data/_sass/bootstrap/js/tests/unit/tab.js +462 -0
  61. data/_sass/bootstrap/js/tests/unit/toast.js +239 -0
  62. data/_sass/bootstrap/js/tests/unit/tooltip.js +1072 -0
  63. data/_sass/bootstrap/js/tests/unit/util.js +164 -0
  64. data/_sass/bootstrap/js/tests/visual/alert.html +58 -0
  65. data/_sass/bootstrap/js/tests/visual/button.html +51 -0
  66. data/_sass/bootstrap/js/tests/visual/carousel.html +66 -0
  67. data/_sass/bootstrap/js/tests/visual/collapse.html +78 -0
  68. data/_sass/bootstrap/js/tests/visual/dropdown.html +212 -0
  69. data/_sass/bootstrap/js/tests/visual/modal.html +268 -0
  70. data/_sass/bootstrap/js/tests/visual/popover.html +46 -0
  71. data/_sass/bootstrap/js/tests/visual/scrollspy.html +95 -0
  72. data/_sass/bootstrap/js/tests/visual/tab.html +234 -0
  73. data/_sass/bootstrap/js/tests/visual/toast.html +72 -0
  74. data/_sass/bootstrap/js/tests/visual/tooltip.html +106 -0
  75. data/_sass/bootstrap/scss/_alert.scss +51 -0
  76. data/_sass/bootstrap/scss/_badge.scss +53 -0
  77. data/_sass/bootstrap/scss/_breadcrumb.scss +41 -0
  78. data/_sass/bootstrap/scss/_button-group.scss +163 -0
  79. data/_sass/bootstrap/scss/_buttons.scss +140 -0
  80. data/_sass/bootstrap/scss/_card.scss +310 -0
  81. data/_sass/bootstrap/scss/_carousel.scss +198 -0
  82. data/_sass/bootstrap/scss/_close.scss +44 -0
  83. data/_sass/bootstrap/scss/_code.scss +48 -0
  84. data/_sass/bootstrap/scss/_custom-forms.scss +507 -0
  85. data/_sass/bootstrap/scss/_dropdown.scss +191 -0
  86. data/_sass/bootstrap/scss/_forms.scss +334 -0
  87. data/_sass/bootstrap/scss/_functions.scss +86 -0
  88. data/_sass/bootstrap/scss/_grid.scss +52 -0
  89. data/_sass/bootstrap/scss/_images.scss +42 -0
  90. data/_sass/bootstrap/scss/_input-group.scss +193 -0
  91. data/_sass/bootstrap/scss/_jumbotron.scss +16 -0
  92. data/_sass/bootstrap/scss/_list-group.scss +121 -0
  93. data/_sass/bootstrap/scss/_media.scss +8 -0
  94. data/_sass/bootstrap/scss/_mixins.scss +41 -0
  95. data/_sass/bootstrap/scss/_modal.scss +186 -0
  96. data/_sass/bootstrap/scss/_nav.scss +120 -0
  97. data/_sass/bootstrap/scss/_navbar.scss +299 -0
  98. data/_sass/bootstrap/scss/_pagination.scss +78 -0
  99. data/_sass/bootstrap/scss/_popover.scss +183 -0
  100. data/_sass/bootstrap/scss/_print.scss +141 -0
  101. data/_sass/bootstrap/scss/_progress.scss +34 -0
  102. data/_sass/bootstrap/scss/_reboot.scss +462 -0
  103. data/_sass/bootstrap/scss/_root.scss +19 -0
  104. data/_sass/bootstrap/scss/_spinners.scss +53 -0
  105. data/_sass/bootstrap/scss/_tables.scss +187 -0
  106. data/_sass/bootstrap/scss/_toasts.scss +43 -0
  107. data/_sass/bootstrap/scss/_tooltip.scss +115 -0
  108. data/_sass/bootstrap/scss/_transitions.scss +22 -0
  109. data/_sass/bootstrap/scss/_type.scss +125 -0
  110. data/_sass/bootstrap/scss/_utilities.scss +16 -0
  111. data/_sass/bootstrap/scss/_variables.scss +1091 -0
  112. data/_sass/bootstrap/scss/bootstrap-grid.scss +29 -0
  113. data/_sass/bootstrap/scss/bootstrap-reboot.scss +12 -0
  114. data/_sass/bootstrap/scss/bootstrap.scss +44 -0
  115. data/_sass/bootstrap/scss/mixins/_alert.scss +13 -0
  116. data/_sass/bootstrap/scss/mixins/_background-variant.scss +21 -0
  117. data/_sass/bootstrap/scss/mixins/_badge.scss +11 -0
  118. data/_sass/bootstrap/scss/mixins/_border-radius.scss +35 -0
  119. data/_sass/bootstrap/scss/mixins/_box-shadow.scss +5 -0
  120. data/_sass/bootstrap/scss/mixins/_breakpoints.scss +123 -0
  121. data/_sass/bootstrap/scss/mixins/_buttons.scss +111 -0
  122. data/_sass/bootstrap/scss/mixins/_caret.scss +62 -0
  123. data/_sass/bootstrap/scss/mixins/_clearfix.scss +7 -0
  124. data/_sass/bootstrap/scss/mixins/_float.scss +11 -0
  125. data/_sass/bootstrap/scss/mixins/_forms.scss +198 -0
  126. data/_sass/bootstrap/scss/mixins/_gradients.scss +45 -0
  127. data/_sass/bootstrap/scss/mixins/_grid-framework.scss +66 -0
  128. data/_sass/bootstrap/scss/mixins/_grid.scss +51 -0
  129. data/_sass/bootstrap/scss/mixins/_hover.scss +37 -0
  130. data/_sass/bootstrap/scss/mixins/_image.scss +36 -0
  131. data/_sass/bootstrap/scss/mixins/_list-group.scss +21 -0
  132. data/_sass/bootstrap/scss/mixins/_lists.scss +7 -0
  133. data/_sass/bootstrap/scss/mixins/_nav-divider.scss +10 -0
  134. data/_sass/bootstrap/scss/mixins/_pagination.scss +22 -0
  135. data/_sass/bootstrap/scss/mixins/_reset-text.scss +17 -0
  136. data/_sass/bootstrap/scss/mixins/_resize.scss +6 -0
  137. data/_sass/bootstrap/scss/mixins/_screen-reader.scss +33 -0
  138. data/_sass/bootstrap/scss/mixins/_size.scss +6 -0
  139. data/_sass/bootstrap/scss/mixins/_table-row.scss +39 -0
  140. data/_sass/bootstrap/scss/mixins/_text-emphasis.scss +14 -0
  141. data/_sass/bootstrap/scss/mixins/_text-hide.scss +13 -0
  142. data/_sass/bootstrap/scss/mixins/_text-truncate.scss +8 -0
  143. data/_sass/bootstrap/scss/mixins/_transition.scss +16 -0
  144. data/_sass/bootstrap/scss/mixins/_visibility.scss +7 -0
  145. data/_sass/bootstrap/scss/utilities/_align.scss +8 -0
  146. data/_sass/bootstrap/scss/utilities/_background.scss +19 -0
  147. data/_sass/bootstrap/scss/utilities/_borders.scss +63 -0
  148. data/_sass/bootstrap/scss/utilities/_clearfix.scss +3 -0
  149. data/_sass/bootstrap/scss/utilities/_display.scss +38 -0
  150. data/_sass/bootstrap/scss/utilities/_embed.scss +39 -0
  151. data/_sass/bootstrap/scss/utilities/_flex.scss +51 -0
  152. data/_sass/bootstrap/scss/utilities/_float.scss +9 -0
  153. data/_sass/bootstrap/scss/utilities/_overflow.scss +5 -0
  154. data/_sass/bootstrap/scss/utilities/_position.scss +32 -0
  155. data/_sass/bootstrap/scss/utilities/_screenreaders.scss +11 -0
  156. data/_sass/bootstrap/scss/utilities/_shadows.scss +6 -0
  157. data/_sass/bootstrap/scss/utilities/_sizing.scss +20 -0
  158. data/_sass/bootstrap/scss/utilities/_spacing.scss +73 -0
  159. data/_sass/bootstrap/scss/utilities/_text.scss +67 -0
  160. data/_sass/bootstrap/scss/utilities/_visibility.scss +11 -0
  161. data/_sass/custom.scss +1 -0
  162. data/assets/css/style.scss +65 -0
  163. data/assets/images/vertx-square.svg +1 -0
  164. metadata +248 -0
@@ -0,0 +1,1273 @@
1
+ $(function () {
2
+ 'use strict'
3
+
4
+ window.Carousel = typeof bootstrap !== 'undefined' ? bootstrap.Carousel : Carousel
5
+
6
+ var originWinPointerEvent = window.PointerEvent
7
+ window.MSPointerEvent = null
8
+ var supportPointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent)
9
+
10
+ function clearPointerEvents() {
11
+ window.PointerEvent = null
12
+ }
13
+
14
+ function restorePointerEvents() {
15
+ window.PointerEvent = originWinPointerEvent
16
+ }
17
+
18
+ var stylesCarousel = [
19
+ '<style>',
20
+ ' .carousel.pointer-event { -ms-touch-action: none; touch-action: none; }',
21
+ '</style>'
22
+ ].join('')
23
+
24
+ QUnit.module('carousel plugin')
25
+
26
+ QUnit.test('should be defined on jQuery object', function (assert) {
27
+ assert.expect(1)
28
+ assert.ok($(document.body).carousel, 'carousel method is defined')
29
+ })
30
+
31
+ QUnit.module('carousel', {
32
+ beforeEach: function () {
33
+ // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
34
+ $.fn.bootstrapCarousel = $.fn.carousel.noConflict()
35
+ },
36
+ afterEach: function () {
37
+ $.fn.carousel = $.fn.bootstrapCarousel
38
+ delete $.fn.bootstrapCarousel
39
+ $('#qunit-fixture').html('')
40
+ }
41
+ })
42
+
43
+ QUnit.test('should provide no conflict', function (assert) {
44
+ assert.expect(1)
45
+ assert.strictEqual(typeof $.fn.carousel, 'undefined', 'carousel was set back to undefined (orig value)')
46
+ })
47
+
48
+ QUnit.test('should return version', function (assert) {
49
+ assert.expect(1)
50
+
51
+ assert.strictEqual(typeof Carousel.VERSION, 'string')
52
+ })
53
+
54
+ QUnit.test('should return default parameters', function (assert) {
55
+ assert.expect(1)
56
+
57
+ var defaultConfig = Carousel.Default
58
+
59
+ assert.strictEqual(defaultConfig.touch, true)
60
+ })
61
+
62
+ QUnit.test('should throw explicit error on undefined method', function (assert) {
63
+ assert.expect(1)
64
+ var $el = $('<div/>')
65
+ $el.bootstrapCarousel()
66
+ try {
67
+ $el.bootstrapCarousel('noMethod')
68
+ } catch (err) {
69
+ assert.strictEqual(err.message, 'No method named "noMethod"')
70
+ }
71
+ })
72
+
73
+ QUnit.test('should return jquery collection containing the element', function (assert) {
74
+ assert.expect(2)
75
+ var $el = $('<div/>')
76
+ var $carousel = $el.bootstrapCarousel()
77
+ assert.ok($carousel instanceof $, 'returns jquery collection')
78
+ assert.strictEqual($carousel[0], $el[0], 'collection contains element')
79
+ })
80
+
81
+ QUnit.test('should type check config options', function (assert) {
82
+ assert.expect(2)
83
+
84
+ var message
85
+ var expectedMessage = 'CAROUSEL: Option "interval" provided type "string" but expected type "(number|boolean)".'
86
+ var config = {
87
+ interval: 'fat sux'
88
+ }
89
+
90
+ try {
91
+ $('<div/>').bootstrapCarousel(config)
92
+ } catch (err) {
93
+ message = err.message
94
+ }
95
+
96
+ assert.ok(message === expectedMessage, 'correct error message')
97
+
98
+ config = {
99
+ keyboard: document.createElement('div')
100
+ }
101
+ expectedMessage = 'CAROUSEL: Option "keyboard" provided type "element" but expected type "boolean".'
102
+
103
+ try {
104
+ $('<div/>').bootstrapCarousel(config)
105
+ } catch (err) {
106
+ message = err.message
107
+ }
108
+
109
+ assert.ok(message === expectedMessage, 'correct error message')
110
+ })
111
+
112
+ QUnit.test('should not fire slid when slide is prevented', function (assert) {
113
+ assert.expect(1)
114
+ var done = assert.async()
115
+ $('<div class="carousel"/>')
116
+ .on('slide.bs.carousel', function (e) {
117
+ e.preventDefault()
118
+ assert.ok(true, 'slide event fired')
119
+ done()
120
+ })
121
+ .on('slid.bs.carousel', function () {
122
+ assert.ok(false, 'slid event fired')
123
+ })
124
+ .bootstrapCarousel('next')
125
+ })
126
+
127
+ QUnit.test('should reset when slide is prevented', function (assert) {
128
+ assert.expect(6)
129
+ var carouselHTML = '<div id="carousel-example-generic" class="carousel slide">' +
130
+ '<ol class="carousel-indicators">' +
131
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
132
+ '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
133
+ '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
134
+ '</ol>' +
135
+ '<div class="carousel-inner">' +
136
+ '<div class="carousel-item active">' +
137
+ '<div class="carousel-caption"/>' +
138
+ '</div>' +
139
+ '<div class="carousel-item">' +
140
+ '<div class="carousel-caption"/>' +
141
+ '</div>' +
142
+ '<div class="carousel-item">' +
143
+ '<div class="carousel-caption"/>' +
144
+ '</div>' +
145
+ '</div>' +
146
+ '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
147
+ '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
148
+ '</div>'
149
+ var $carousel = $(carouselHTML)
150
+
151
+ var done = assert.async()
152
+ $carousel
153
+ .one('slide.bs.carousel', function (e) {
154
+ e.preventDefault()
155
+ setTimeout(function () {
156
+ assert.ok($carousel.find('.carousel-item:nth-child(1)').is('.active'), 'first item still active')
157
+ assert.ok($carousel.find('.carousel-indicators li:nth-child(1)').is('.active'), 'first indicator still active')
158
+ $carousel.bootstrapCarousel('next')
159
+ }, 0)
160
+ })
161
+ .one('slid.bs.carousel', function () {
162
+ setTimeout(function () {
163
+ assert.ok(!$carousel.find('.carousel-item:nth-child(1)').is('.active'), 'first item still active')
164
+ assert.ok(!$carousel.find('.carousel-indicators li:nth-child(1)').is('.active'), 'first indicator still active')
165
+ assert.ok($carousel.find('.carousel-item:nth-child(2)').is('.active'), 'second item active')
166
+ assert.ok($carousel.find('.carousel-indicators li:nth-child(2)').is('.active'), 'second indicator active')
167
+ done()
168
+ }, 0)
169
+ })
170
+ .bootstrapCarousel('next')
171
+ })
172
+
173
+ QUnit.test('should fire slide event with direction', function (assert) {
174
+ assert.expect(4)
175
+ var carouselHTML = '<div id="myCarousel" class="carousel slide">' +
176
+ '<div class="carousel-inner">' +
177
+ '<div class="carousel-item active">' +
178
+ '<img alt="">' +
179
+ '<div class="carousel-caption">' +
180
+ '<h4>First Thumbnail label</h4>' +
181
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
182
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
183
+ 'ultricies vehicula ut id elit.</p>' +
184
+ '</div>' +
185
+ '</div>' +
186
+ '<div class="carousel-item">' +
187
+ '<img alt="">' +
188
+ '<div class="carousel-caption">' +
189
+ '<h4>Second Thumbnail label</h4>' +
190
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
191
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
192
+ 'ultricies vehicula ut id elit.</p>' +
193
+ '</div>' +
194
+ '</div>' +
195
+ '<div class="carousel-item">' +
196
+ '<img alt="">' +
197
+ '<div class="carousel-caption">' +
198
+ '<h4>Third Thumbnail label</h4>' +
199
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
200
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
201
+ 'ultricies vehicula ut id elit.</p>' +
202
+ '</div>' +
203
+ '</div>' +
204
+ '</div>' +
205
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
206
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
207
+ '</div>'
208
+ var $carousel = $(carouselHTML)
209
+
210
+ var done = assert.async()
211
+
212
+ $carousel
213
+ .one('slide.bs.carousel', function (e) {
214
+ assert.ok(e.direction, 'direction present on next')
215
+ assert.strictEqual(e.direction, 'left', 'direction is left on next')
216
+
217
+ $carousel
218
+ .one('slide.bs.carousel', function (e) {
219
+ assert.ok(e.direction, 'direction present on prev')
220
+ assert.strictEqual(e.direction, 'right', 'direction is right on prev')
221
+ done()
222
+ })
223
+ .bootstrapCarousel('prev')
224
+ })
225
+ .bootstrapCarousel('next')
226
+ })
227
+
228
+ QUnit.test('should fire slid event with direction', function (assert) {
229
+ assert.expect(4)
230
+ var carouselHTML = '<div id="myCarousel" class="carousel slide">' +
231
+ '<div class="carousel-inner">' +
232
+ '<div class="carousel-item active">' +
233
+ '<img alt="">' +
234
+ '<div class="carousel-caption">' +
235
+ '<h4>First Thumbnail label</h4>' +
236
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
237
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
238
+ 'ultricies vehicula ut id elit.</p>' +
239
+ '</div>' +
240
+ '</div>' +
241
+ '<div class="carousel-item">' +
242
+ '<img alt="">' +
243
+ '<div class="carousel-caption">' +
244
+ '<h4>Second Thumbnail label</h4>' +
245
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
246
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
247
+ 'ultricies vehicula ut id elit.</p>' +
248
+ '</div>' +
249
+ '</div>' +
250
+ '<div class="carousel-item">' +
251
+ '<img alt="">' +
252
+ '<div class="carousel-caption">' +
253
+ '<h4>Third Thumbnail label</h4>' +
254
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
255
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
256
+ 'ultricies vehicula ut id elit.</p>' +
257
+ '</div>' +
258
+ '</div>' +
259
+ '</div>' +
260
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
261
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
262
+ '</div>'
263
+ var $carousel = $(carouselHTML)
264
+
265
+ var done = assert.async()
266
+
267
+ $carousel
268
+ .one('slid.bs.carousel', function (e) {
269
+ assert.ok(e.direction, 'direction present on next')
270
+ assert.strictEqual(e.direction, 'left', 'direction is left on next')
271
+
272
+ $carousel
273
+ .one('slid.bs.carousel', function (e) {
274
+ assert.ok(e.direction, 'direction present on prev')
275
+ assert.strictEqual(e.direction, 'right', 'direction is right on prev')
276
+ done()
277
+ })
278
+ .bootstrapCarousel('prev')
279
+ })
280
+ .bootstrapCarousel('next')
281
+ })
282
+
283
+ QUnit.test('should fire slide event with relatedTarget', function (assert) {
284
+ assert.expect(2)
285
+ var template = '<div id="myCarousel" class="carousel slide">' +
286
+ '<div class="carousel-inner">' +
287
+ '<div class="carousel-item active">' +
288
+ '<img alt="">' +
289
+ '<div class="carousel-caption">' +
290
+ '<h4>First Thumbnail label</h4>' +
291
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
292
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
293
+ 'ultricies vehicula ut id elit.</p>' +
294
+ '</div>' +
295
+ '</div>' +
296
+ '<div class="carousel-item">' +
297
+ '<img alt="">' +
298
+ '<div class="carousel-caption">' +
299
+ '<h4>Second Thumbnail label</h4>' +
300
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
301
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
302
+ 'ultricies vehicula ut id elit.</p>' +
303
+ '</div>' +
304
+ '</div>' +
305
+ '<div class="carousel-item">' +
306
+ '<img alt="">' +
307
+ '<div class="carousel-caption">' +
308
+ '<h4>Third Thumbnail label</h4>' +
309
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
310
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
311
+ 'ultricies vehicula ut id elit.</p>' +
312
+ '</div>' +
313
+ '</div>' +
314
+ '</div>' +
315
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
316
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
317
+ '</div>'
318
+
319
+ var done = assert.async()
320
+
321
+ $(template)
322
+ .on('slide.bs.carousel', function (e) {
323
+ assert.ok(e.relatedTarget, 'relatedTarget present')
324
+ assert.ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "item"')
325
+ done()
326
+ })
327
+ .bootstrapCarousel('next')
328
+ })
329
+
330
+ QUnit.test('should fire slid event with relatedTarget', function (assert) {
331
+ assert.expect(2)
332
+ var template = '<div id="myCarousel" class="carousel slide">' +
333
+ '<div class="carousel-inner">' +
334
+ '<div class="carousel-item active">' +
335
+ '<img alt="">' +
336
+ '<div class="carousel-caption">' +
337
+ '<h4>First Thumbnail label</h4>' +
338
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
339
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
340
+ 'ultricies vehicula ut id elit.</p>' +
341
+ '</div>' +
342
+ '</div>' +
343
+ '<div class="carousel-item">' +
344
+ '<img alt="">' +
345
+ '<div class="carousel-caption">' +
346
+ '<h4>Second Thumbnail label</h4>' +
347
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
348
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
349
+ 'ultricies vehicula ut id elit.</p>' +
350
+ '</div>' +
351
+ '</div>' +
352
+ '<div class="carousel-item">' +
353
+ '<img alt="">' +
354
+ '<div class="carousel-caption">' +
355
+ '<h4>Third Thumbnail label</h4>' +
356
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
357
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
358
+ 'ultricies vehicula ut id elit.</p>' +
359
+ '</div>' +
360
+ '</div>' +
361
+ '</div>' +
362
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
363
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
364
+ '</div>'
365
+
366
+ var done = assert.async()
367
+
368
+ $(template)
369
+ .on('slid.bs.carousel', function (e) {
370
+ assert.ok(e.relatedTarget, 'relatedTarget present')
371
+ assert.ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "item"')
372
+ done()
373
+ })
374
+ .bootstrapCarousel('next')
375
+ })
376
+
377
+ QUnit.test('should fire slid and slide events with from and to', function (assert) {
378
+ assert.expect(4)
379
+ var template = '<div id="myCarousel" class="carousel slide">' +
380
+ '<div class="carousel-inner">' +
381
+ '<div class="carousel-item active">' +
382
+ '<img alt="">' +
383
+ '<div class="carousel-caption">' +
384
+ '<h4>First Thumbnail label</h4>' +
385
+ '</div>' +
386
+ '</div>' +
387
+ '<div class="carousel-item">' +
388
+ '<img alt="">' +
389
+ '<div class="carousel-caption">' +
390
+ '<h4>Second Thumbnail label</h4>' +
391
+ '</div>' +
392
+ '</div>' +
393
+ '<div class="carousel-item">' +
394
+ '<img alt="">' +
395
+ '<div class="carousel-caption">' +
396
+ '<h4>Third Thumbnail label</h4>' +
397
+ '</div>' +
398
+ '</div>' +
399
+ '</div>' +
400
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
401
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
402
+ '</div>'
403
+
404
+ var done = assert.async()
405
+ $(template)
406
+ .on('slid.bs.carousel', function (e) {
407
+ assert.ok(typeof e.from !== 'undefined', 'from present')
408
+ assert.ok(typeof e.to !== 'undefined', 'to present')
409
+ $(this).off()
410
+ done()
411
+ })
412
+ .on('slide.bs.carousel', function (e) {
413
+ assert.ok(typeof e.from !== 'undefined', 'from present')
414
+ assert.ok(typeof e.to !== 'undefined', 'to present')
415
+ $(this).off('slide.bs.carousel')
416
+ })
417
+ .bootstrapCarousel('next')
418
+ })
419
+
420
+ QUnit.test('should set interval from data attribute', function (assert) {
421
+ assert.expect(4)
422
+ var templateHTML = '<div id="myCarousel" class="carousel slide">' +
423
+ '<div class="carousel-inner">' +
424
+ '<div class="carousel-item active">' +
425
+ '<img alt="">' +
426
+ '<div class="carousel-caption">' +
427
+ '<h4>First Thumbnail label</h4>' +
428
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
429
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
430
+ 'ultricies vehicula ut id elit.</p>' +
431
+ '</div>' +
432
+ '</div>' +
433
+ '<div class="carousel-item">' +
434
+ '<img alt="">' +
435
+ '<div class="carousel-caption">' +
436
+ '<h4>Second Thumbnail label</h4>' +
437
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
438
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
439
+ 'ultricies vehicula ut id elit.</p>' +
440
+ '</div>' +
441
+ '</div>' +
442
+ '<div class="carousel-item">' +
443
+ '<img alt="">' +
444
+ '<div class="carousel-caption">' +
445
+ '<h4>Third Thumbnail label</h4>' +
446
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
447
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
448
+ 'ultricies vehicula ut id elit.</p>' +
449
+ '</div>' +
450
+ '</div>' +
451
+ '</div>' +
452
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
453
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
454
+ '</div>'
455
+ var $carousel = $(templateHTML)
456
+ $carousel.attr('data-interval', 1814)
457
+
458
+ $carousel.appendTo('body')
459
+ $('[data-slide]').first().trigger('click')
460
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814)
461
+ $carousel.remove()
462
+
463
+ $carousel.appendTo('body').attr('data-modal', 'foobar')
464
+ $('[data-slide]').first().trigger('click')
465
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814, 'even if there is an data-modal attribute set')
466
+ $carousel.remove()
467
+
468
+ $carousel.appendTo('body')
469
+ $('[data-slide]').first().trigger('click')
470
+ $carousel.attr('data-interval', 1860)
471
+ $('[data-slide]').first().trigger('click')
472
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814, 'attributes should be read only on initialization')
473
+ $carousel.remove()
474
+
475
+ $carousel.attr('data-interval', false)
476
+ $carousel.appendTo('body')
477
+ $carousel.bootstrapCarousel(1)
478
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, false, 'data attribute has higher priority than default options')
479
+ $carousel.remove()
480
+ })
481
+
482
+ QUnit.test('should set interval from data attribute on individual carousel-item', function (assert) {
483
+ assert.expect(2)
484
+ var templateHTML = '<div id="myCarousel" class="carousel slide" data-interval="1814">' +
485
+ '<div class="carousel-inner">' +
486
+ '<div class="carousel-item active" data-interval="2814">' +
487
+ '<img alt="">' +
488
+ '<div class="carousel-caption">' +
489
+ '<h4>First Thumbnail label</h4>' +
490
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
491
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
492
+ 'ultricies vehicula ut id elit.</p>' +
493
+ '</div>' +
494
+ '</div>' +
495
+ '<div class="carousel-item" data-interval="3814">' +
496
+ '<img alt="">' +
497
+ '<div class="carousel-caption">' +
498
+ '<h4>Second Thumbnail label</h4>' +
499
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
500
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
501
+ 'ultricies vehicula ut id elit.</p>' +
502
+ '</div>' +
503
+ '</div>' +
504
+ '<div class="carousel-item">' +
505
+ '<img alt="">' +
506
+ '<div class="carousel-caption">' +
507
+ '<h4>Third Thumbnail label</h4>' +
508
+ '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
509
+ 'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
510
+ 'ultricies vehicula ut id elit.</p>' +
511
+ '</div>' +
512
+ '</div>' +
513
+ '</div>' +
514
+ '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
515
+ '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
516
+ '</div>'
517
+ var $carousel = $(templateHTML)
518
+
519
+ $carousel.appendTo('body')
520
+ $carousel.bootstrapCarousel(1)
521
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, 3814)
522
+ $carousel.remove()
523
+
524
+ $carousel.appendTo('body')
525
+ $carousel.bootstrapCarousel(2)
526
+ assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814, 'reverts to default interval if no data-interval is set')
527
+ $carousel.remove()
528
+ })
529
+
530
+ QUnit.test('should skip over non-items when using item indices', function (assert) {
531
+ assert.expect(2)
532
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' +
533
+ '<div class="carousel-inner">' +
534
+ '<div class="carousel-item active">' +
535
+ '<img alt="">' +
536
+ '</div>' +
537
+ '<script type="text/x-metamorph" id="thingy"/>' +
538
+ '<div class="carousel-item">' +
539
+ '<img alt="">' +
540
+ '</div>' +
541
+ '<div class="carousel-item">' +
542
+ '</div>' +
543
+ '</div>' +
544
+ '</div>'
545
+ var $template = $(templateHTML)
546
+
547
+ $template.bootstrapCarousel()
548
+
549
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
550
+
551
+ $template.bootstrapCarousel(1)
552
+
553
+ assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
554
+ })
555
+
556
+ QUnit.test('should skip over non-items when using next/prev methods', function (assert) {
557
+ assert.expect(2)
558
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' +
559
+ '<div class="carousel-inner">' +
560
+ '<div class="carousel-item active">' +
561
+ '<img alt="">' +
562
+ '</div>' +
563
+ '<script type="text/x-metamorph" id="thingy"/>' +
564
+ '<div class="carousel-item">' +
565
+ '<img alt="">' +
566
+ '</div>' +
567
+ '<div class="carousel-item">' +
568
+ '</div>' +
569
+ '</div>' +
570
+ '</div>'
571
+ var $template = $(templateHTML)
572
+
573
+ $template.bootstrapCarousel()
574
+
575
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
576
+
577
+ $template.bootstrapCarousel('next')
578
+
579
+ assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
580
+ })
581
+
582
+ QUnit.test('should go to previous item if left arrow key is pressed', function (assert) {
583
+ assert.expect(2)
584
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
585
+ '<div class="carousel-inner">' +
586
+ '<div id="first" class="carousel-item">' +
587
+ '<img alt="">' +
588
+ '</div>' +
589
+ '<div id="second" class="carousel-item active">' +
590
+ '<img alt="">' +
591
+ '</div>' +
592
+ '<div id="third" class="carousel-item">' +
593
+ '<img alt="">' +
594
+ '</div>' +
595
+ '</div>' +
596
+ '</div>'
597
+ var $template = $(templateHTML)
598
+
599
+ $template.bootstrapCarousel()
600
+
601
+ assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
602
+
603
+ $template.trigger($.Event('keydown', {
604
+ which: 37
605
+ }))
606
+
607
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
608
+ })
609
+
610
+ QUnit.test('should go to next item if right arrow key is pressed', function (assert) {
611
+ assert.expect(2)
612
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
613
+ '<div class="carousel-inner">' +
614
+ '<div id="first" class="carousel-item active">' +
615
+ '<img alt="">' +
616
+ '</div>' +
617
+ '<div id="second" class="carousel-item">' +
618
+ '<img alt="">' +
619
+ '</div>' +
620
+ '<div id="third" class="carousel-item">' +
621
+ '<img alt="">' +
622
+ '</div>' +
623
+ '</div>' +
624
+ '</div>'
625
+ var $template = $(templateHTML)
626
+
627
+ $template.bootstrapCarousel()
628
+
629
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
630
+
631
+ $template.trigger($.Event('keydown', {
632
+ which: 39
633
+ }))
634
+
635
+ assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
636
+ })
637
+
638
+ QUnit.test('should not prevent keydown if key is not ARROW_LEFT or ARROW_RIGHT', function (assert) {
639
+ assert.expect(2)
640
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
641
+ '<div class="carousel-inner">' +
642
+ '<div id="first" class="carousel-item active">' +
643
+ '<img alt="">' +
644
+ '</div>' +
645
+ '</div>' +
646
+ '</div>'
647
+ var $template = $(templateHTML)
648
+
649
+ $template.bootstrapCarousel()
650
+ var done = assert.async()
651
+
652
+ var eventArrowDown = $.Event('keydown', {
653
+ which: 40
654
+ })
655
+ var eventArrowUp = $.Event('keydown', {
656
+ which: 38
657
+ })
658
+
659
+ $template.one('keydown', function (event) {
660
+ assert.strictEqual(event.isDefaultPrevented(), false)
661
+ })
662
+
663
+ $template.trigger(eventArrowDown)
664
+
665
+ $template.one('keydown', function (event) {
666
+ assert.strictEqual(event.isDefaultPrevented(), false)
667
+ done()
668
+ })
669
+
670
+ $template.trigger(eventArrowUp)
671
+ })
672
+
673
+ QUnit.test('should support disabling the keyboard navigation', function (assert) {
674
+ assert.expect(3)
675
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">' +
676
+ '<div class="carousel-inner">' +
677
+ '<div id="first" class="carousel-item active">' +
678
+ '<img alt="">' +
679
+ '</div>' +
680
+ '<div id="second" class="carousel-item">' +
681
+ '<img alt="">' +
682
+ '</div>' +
683
+ '<div id="third" class="carousel-item">' +
684
+ '<img alt="">' +
685
+ '</div>' +
686
+ '</div>' +
687
+ '</div>'
688
+ var $template = $(templateHTML)
689
+
690
+ $template.bootstrapCarousel()
691
+
692
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
693
+
694
+ $template.trigger($.Event('keydown', {
695
+ which: 39
696
+ }))
697
+
698
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press')
699
+
700
+ $template.trigger($.Event('keydown', {
701
+ which: 37
702
+ }))
703
+
704
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press')
705
+ })
706
+
707
+ QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
708
+ assert.expect(7)
709
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
710
+ '<div class="carousel-inner">' +
711
+ '<div id="first" class="carousel-item active">' +
712
+ '<img alt="">' +
713
+ '<input type="text" id="in-put">' +
714
+ '<textarea id="text-area"></textarea>' +
715
+ '</div>' +
716
+ '<div id="second" class="carousel-item">' +
717
+ '<img alt="">' +
718
+ '</div>' +
719
+ '<div id="third" class="carousel-item">' +
720
+ '<img alt="">' +
721
+ '</div>' +
722
+ '</div>' +
723
+ '</div>'
724
+ var $template = $(templateHTML)
725
+ var $input = $template.find('#in-put')
726
+ var $textarea = $template.find('#text-area')
727
+
728
+ assert.strictEqual($input.length, 1, 'found <input>')
729
+ assert.strictEqual($textarea.length, 1, 'found <textarea>')
730
+
731
+ $template.bootstrapCarousel()
732
+
733
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
734
+
735
+ $input.trigger($.Event('keydown', {
736
+ which: 39
737
+ }))
738
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>')
739
+
740
+ $input.trigger($.Event('keydown', {
741
+ which: 37
742
+ }))
743
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>')
744
+
745
+ $textarea.trigger($.Event('keydown', {
746
+ which: 39
747
+ }))
748
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>')
749
+
750
+ $textarea.trigger($.Event('keydown', {
751
+ which: 37
752
+ }))
753
+ assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>')
754
+ })
755
+
756
+ QUnit.test('should wrap around from end to start when wrap option is true', function (assert) {
757
+ assert.expect(3)
758
+ var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' +
759
+ '<ol class="carousel-indicators">' +
760
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
761
+ '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
762
+ '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
763
+ '</ol>' +
764
+ '<div class="carousel-inner">' +
765
+ '<div class="carousel-item active" id="one">' +
766
+ '<div class="carousel-caption"/>' +
767
+ '</div>' +
768
+ '<div class="carousel-item" id="two">' +
769
+ '<div class="carousel-caption"/>' +
770
+ '</div>' +
771
+ '<div class="carousel-item" id="three">' +
772
+ '<div class="carousel-caption"/>' +
773
+ '</div>' +
774
+ '</div>' +
775
+ '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
776
+ '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
777
+ '</div>'
778
+ var $carousel = $(carouselHTML)
779
+ var getActiveId = function () {
780
+ return $carousel.find('.carousel-item.active').attr('id')
781
+ }
782
+
783
+ var done = assert.async()
784
+
785
+ $carousel
786
+ .one('slid.bs.carousel', function () {
787
+ assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
788
+ $carousel
789
+ .one('slid.bs.carousel', function () {
790
+ assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
791
+ $carousel
792
+ .one('slid.bs.carousel', function () {
793
+ assert.strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide')
794
+ done()
795
+ })
796
+ .bootstrapCarousel('next')
797
+ })
798
+ .bootstrapCarousel('next')
799
+ })
800
+ .bootstrapCarousel('next')
801
+ })
802
+
803
+ QUnit.test('should wrap around from start to end when wrap option is true', function (assert) {
804
+ assert.expect(1)
805
+ var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' +
806
+ '<ol class="carousel-indicators">' +
807
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
808
+ '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
809
+ '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
810
+ '</ol>' +
811
+ '<div class="carousel-inner">' +
812
+ '<div class="carousel-item active" id="one">' +
813
+ '<div class="carousel-caption"/>' +
814
+ '</div>' +
815
+ '<div class="carousel-item" id="two">' +
816
+ '<div class="carousel-caption"/>' +
817
+ '</div>' +
818
+ '<div class="carousel-item" id="three">' +
819
+ '<div class="carousel-caption"/>' +
820
+ '</div>' +
821
+ '</div>' +
822
+ '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
823
+ '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
824
+ '</div>'
825
+ var $carousel = $(carouselHTML)
826
+
827
+ var done = assert.async()
828
+
829
+ $carousel
830
+ .on('slid.bs.carousel', function () {
831
+ assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide')
832
+ done()
833
+ })
834
+ .bootstrapCarousel('prev')
835
+ })
836
+
837
+ QUnit.test('should stay at the end when the next method is called and wrap is false', function (assert) {
838
+ assert.expect(3)
839
+ var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' +
840
+ '<ol class="carousel-indicators">' +
841
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
842
+ '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
843
+ '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
844
+ '</ol>' +
845
+ '<div class="carousel-inner">' +
846
+ '<div class="carousel-item active" id="one">' +
847
+ '<div class="carousel-caption"/>' +
848
+ '</div>' +
849
+ '<div class="carousel-item" id="two">' +
850
+ '<div class="carousel-caption"/>' +
851
+ '</div>' +
852
+ '<div class="carousel-item" id="three">' +
853
+ '<div class="carousel-caption"/>' +
854
+ '</div>' +
855
+ '</div>' +
856
+ '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
857
+ '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
858
+ '</div>'
859
+ var $carousel = $(carouselHTML)
860
+ var getActiveId = function () {
861
+ return $carousel.find('.carousel-item.active').attr('id')
862
+ }
863
+
864
+ var done = assert.async()
865
+
866
+ $carousel
867
+ .one('slid.bs.carousel', function () {
868
+ assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')
869
+ $carousel
870
+ .one('slid.bs.carousel', function () {
871
+ assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')
872
+ $carousel
873
+ .one('slid.bs.carousel', function () {
874
+ assert.ok(false, 'carousel slid when it should not have slid')
875
+ })
876
+ .bootstrapCarousel('next')
877
+ assert.strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide')
878
+ done()
879
+ })
880
+ .bootstrapCarousel('next')
881
+ })
882
+ .bootstrapCarousel('next')
883
+ })
884
+
885
+ QUnit.test('should stay at the start when the prev method is called and wrap is false', function (assert) {
886
+ assert.expect(1)
887
+ var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' +
888
+ '<ol class="carousel-indicators">' +
889
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
890
+ '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
891
+ '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
892
+ '</ol>' +
893
+ '<div class="carousel-inner">' +
894
+ '<div class="carousel-item active" id="one">' +
895
+ '<div class="carousel-caption"/>' +
896
+ '</div>' +
897
+ '<div class="carousel-item" id="two">' +
898
+ '<div class="carousel-caption"/>' +
899
+ '</div>' +
900
+ '<div class="carousel-item" id="three">' +
901
+ '<div class="carousel-caption"/>' +
902
+ '</div>' +
903
+ '</div>' +
904
+ '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
905
+ '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
906
+ '</div>'
907
+ var $carousel = $(carouselHTML)
908
+
909
+ $carousel
910
+ .on('slid.bs.carousel', function () {
911
+ assert.ok(false, 'carousel slid when it should not have slid')
912
+ })
913
+ .bootstrapCarousel('prev')
914
+ assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide')
915
+ })
916
+
917
+ QUnit.test('should not prevent keydown for inputs and textareas', function (assert) {
918
+ assert.expect(2)
919
+ var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
920
+ '<div class="carousel-inner">' +
921
+ '<div id="first" class="carousel-item">' +
922
+ '<input type="text" id="inputText" />' +
923
+ '</div>' +
924
+ '<div id="second" class="carousel-item active">' +
925
+ '<textarea id="txtArea"></textarea>' +
926
+ '</div>' +
927
+ '</div>' +
928
+ '</div>'
929
+ var $template = $(templateHTML)
930
+ var done = assert.async()
931
+ $template.appendTo('#qunit-fixture')
932
+ var $inputText = $template.find('#inputText')
933
+ var $textArea = $template.find('#txtArea')
934
+ $template.bootstrapCarousel()
935
+
936
+ var eventKeyDown = $.Event('keydown', {
937
+ which: 65
938
+ }) // 65 for "a"
939
+ $inputText.on('keydown', function (event) {
940
+ assert.strictEqual(event.isDefaultPrevented(), false)
941
+ })
942
+ $inputText.trigger(eventKeyDown)
943
+
944
+ $textArea.on('keydown', function (event) {
945
+ assert.strictEqual(event.isDefaultPrevented(), false)
946
+ done()
947
+ })
948
+ $textArea.trigger(eventKeyDown)
949
+ })
950
+
951
+ QUnit.test('Should not go to the next item when the carousel is not visible', function (assert) {
952
+ assert.expect(2)
953
+ var done = assert.async()
954
+ var html = '<div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">' +
955
+ ' <div class="carousel-inner">' +
956
+ ' <div id="firstItem" class="carousel-item active">' +
957
+ ' <img alt="">' +
958
+ ' </div>' +
959
+ ' <div class="carousel-item">' +
960
+ ' <img alt="">' +
961
+ ' </div>' +
962
+ ' <div class="carousel-item">' +
963
+ ' <img alt="">' +
964
+ ' </div>' +
965
+ ' <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
966
+ ' <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
967
+ '</div>'
968
+ var $html = $(html)
969
+ $html
970
+ .appendTo('#qunit-fixture')
971
+ .bootstrapCarousel()
972
+
973
+ var $firstItem = $('#firstItem')
974
+ setTimeout(function () {
975
+ assert.ok($firstItem.hasClass('active'))
976
+ $html
977
+ .bootstrapCarousel('dispose')
978
+ .attr('style', 'visibility: hidden;')
979
+ .bootstrapCarousel()
980
+
981
+ setTimeout(function () {
982
+ assert.ok($firstItem.hasClass('active'))
983
+ done()
984
+ }, 80)
985
+ }, 80)
986
+ })
987
+
988
+ QUnit.test('Should not go to the next item when the parent of the carousel is not visible', function (assert) {
989
+ assert.expect(2)
990
+ var done = assert.async()
991
+ var html = '<div id="parent" style="display: none;">' +
992
+ ' <div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">' +
993
+ ' <div class="carousel-inner">' +
994
+ ' <div id="firstItem" class="carousel-item active">' +
995
+ ' <img alt="">' +
996
+ ' </div>' +
997
+ ' <div class="carousel-item">' +
998
+ ' <img alt="">' +
999
+ ' </div>' +
1000
+ ' <div class="carousel-item">' +
1001
+ ' <img alt="">' +
1002
+ ' </div>' +
1003
+ ' <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
1004
+ ' <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
1005
+ ' </div>' +
1006
+ '</div>'
1007
+ var $html = $(html)
1008
+ $html.appendTo('#qunit-fixture')
1009
+ var $parent = $html.find('#parent')
1010
+ var $carousel = $html.find('#myCarousel')
1011
+ $carousel.bootstrapCarousel()
1012
+ var $firstItem = $('#firstItem')
1013
+
1014
+ setTimeout(function () {
1015
+ assert.ok($firstItem.hasClass('active'))
1016
+ $carousel.bootstrapCarousel('dispose')
1017
+ $parent.attr('style', 'visibility: hidden;')
1018
+ $carousel.bootstrapCarousel()
1019
+
1020
+ setTimeout(function () {
1021
+ assert.ok($firstItem.hasClass('active'))
1022
+ done()
1023
+ }, 80)
1024
+ }, 80)
1025
+ })
1026
+
1027
+ QUnit.test('should allow swiperight and call prev with pointer events', function (assert) {
1028
+ if (!supportPointerEvent) {
1029
+ assert.expect(0)
1030
+ return
1031
+ }
1032
+
1033
+ document.documentElement.ontouchstart = $.noop
1034
+ Simulator.setType('pointer')
1035
+ assert.expect(3)
1036
+ var $styles = $(stylesCarousel).appendTo('head')
1037
+ var done = assert.async()
1038
+
1039
+ var carouselHTML =
1040
+ '<div class="carousel" data-interval="false">' +
1041
+ ' <div class="carousel-inner">' +
1042
+ ' <div id="item" class="carousel-item">' +
1043
+ ' <img alt="">' +
1044
+ ' </div>' +
1045
+ ' <div class="carousel-item active">' +
1046
+ ' <img alt="">' +
1047
+ ' </div>' +
1048
+ ' </div>' +
1049
+ '</div>'
1050
+
1051
+ var $carousel = $(carouselHTML).appendTo('#qunit-fixture')
1052
+ var $item = $('#item')
1053
+ $carousel.bootstrapCarousel()
1054
+ var carousel = $carousel.data('bs.carousel')
1055
+ var spy = sinon.spy(carousel, 'prev')
1056
+
1057
+ $carousel.one('slid.bs.carousel', function () {
1058
+ assert.ok(true, 'slid event fired')
1059
+ assert.ok($item.hasClass('active'))
1060
+ assert.ok(spy.called)
1061
+ $styles.remove()
1062
+ delete document.documentElement.ontouchstart
1063
+ done()
1064
+ })
1065
+
1066
+ Simulator.gestures.swipe($carousel[0], {
1067
+ deltaX: 300,
1068
+ deltaY: 0
1069
+ })
1070
+ })
1071
+
1072
+ QUnit.test('should allow swiperight and call prev with touch events', function (assert) {
1073
+ Simulator.setType('touch')
1074
+ clearPointerEvents()
1075
+
1076
+ assert.expect(3)
1077
+ var done = assert.async()
1078
+ document.documentElement.ontouchstart = $.noop
1079
+
1080
+ var carouselHTML =
1081
+ '<div class="carousel" data-interval="false">' +
1082
+ ' <div class="carousel-inner">' +
1083
+ ' <div id="item" class="carousel-item">' +
1084
+ ' <img alt="">' +
1085
+ ' </div>' +
1086
+ ' <div class="carousel-item active">' +
1087
+ ' <img alt="">' +
1088
+ ' </div>' +
1089
+ ' </div>' +
1090
+ '</div>'
1091
+
1092
+ var $carousel = $(carouselHTML)
1093
+ $carousel.appendTo('#qunit-fixture')
1094
+ var $item = $('#item')
1095
+ $carousel.bootstrapCarousel()
1096
+ var carousel = $carousel.data('bs.carousel')
1097
+ var spy = sinon.spy(carousel, 'prev')
1098
+
1099
+ $carousel.one('slid.bs.carousel', function () {
1100
+ assert.ok(true, 'slid event fired')
1101
+ assert.ok($item.hasClass('active'))
1102
+ assert.ok(spy.called)
1103
+ delete document.documentElement.ontouchstart
1104
+ restorePointerEvents()
1105
+ done()
1106
+ })
1107
+
1108
+ Simulator.gestures.swipe($carousel[0], {
1109
+ deltaX: 300,
1110
+ deltaY: 0
1111
+ })
1112
+ })
1113
+
1114
+ QUnit.test('should allow swipeleft and call next with pointer events', function (assert) {
1115
+ if (!supportPointerEvent) {
1116
+ assert.expect(0)
1117
+ return
1118
+ }
1119
+
1120
+ document.documentElement.ontouchstart = $.noop
1121
+ assert.expect(3)
1122
+ Simulator.setType('pointer')
1123
+
1124
+ var $styles = $(stylesCarousel).appendTo('head')
1125
+ var done = assert.async()
1126
+
1127
+ var carouselHTML =
1128
+ '<div class="carousel" data-interval="false">' +
1129
+ ' <div class="carousel-inner">' +
1130
+ ' <div id="item" class="carousel-item active">' +
1131
+ ' <img alt="">' +
1132
+ ' </div>' +
1133
+ ' <div class="carousel-item">' +
1134
+ ' <img alt="">' +
1135
+ ' </div>' +
1136
+ ' </div>' +
1137
+ '</div>'
1138
+
1139
+ var $carousel = $(carouselHTML)
1140
+ $carousel.appendTo('#qunit-fixture')
1141
+ var $item = $('#item')
1142
+ $carousel.bootstrapCarousel()
1143
+ var carousel = $carousel.data('bs.carousel')
1144
+ var spy = sinon.spy(carousel, 'next')
1145
+
1146
+ $carousel.one('slid.bs.carousel', function () {
1147
+ assert.ok(true, 'slid event fired')
1148
+ assert.ok(!$item.hasClass('active'))
1149
+ assert.ok(spy.called)
1150
+ $styles.remove()
1151
+ delete document.documentElement.ontouchstart
1152
+ done()
1153
+ })
1154
+
1155
+ Simulator.gestures.swipe($carousel[0], {
1156
+ pos: [300, 10],
1157
+ deltaX: -300,
1158
+ deltaY: 0
1159
+ })
1160
+ })
1161
+
1162
+ QUnit.test('should allow swipeleft and call next with touch events', function (assert) {
1163
+ assert.expect(3)
1164
+ clearPointerEvents()
1165
+ Simulator.setType('touch')
1166
+ document.documentElement.ontouchstart = $.noop
1167
+
1168
+ var done = assert.async()
1169
+
1170
+ var carouselHTML =
1171
+ '<div class="carousel" data-interval="false">' +
1172
+ ' <div class="carousel-inner">' +
1173
+ ' <div id="item" class="carousel-item active">' +
1174
+ ' <img alt="">' +
1175
+ ' </div>' +
1176
+ ' <div class="carousel-item">' +
1177
+ ' <img alt="">' +
1178
+ ' </div>' +
1179
+ ' </div>' +
1180
+ '</div>'
1181
+
1182
+ var $carousel = $(carouselHTML)
1183
+ $carousel.appendTo('#qunit-fixture')
1184
+ var $item = $('#item')
1185
+ $carousel.bootstrapCarousel()
1186
+ var carousel = $carousel.data('bs.carousel')
1187
+ var spy = sinon.spy(carousel, 'next')
1188
+
1189
+ $carousel.one('slid.bs.carousel', function () {
1190
+ assert.ok(true, 'slid event fired')
1191
+ assert.ok(!$item.hasClass('active'))
1192
+ assert.ok(spy.called)
1193
+ restorePointerEvents()
1194
+ delete document.documentElement.ontouchstart
1195
+ done()
1196
+ })
1197
+
1198
+ Simulator.gestures.swipe($carousel[0], {
1199
+ pos: [300, 10],
1200
+ deltaX: -300,
1201
+ deltaY: 0
1202
+ })
1203
+ })
1204
+
1205
+ QUnit.test('should not allow pinch with touch events', function (assert) {
1206
+ assert.expect(0)
1207
+ clearPointerEvents()
1208
+
1209
+ Simulator.setType('touch')
1210
+ var done = assert.async()
1211
+ document.documentElement.ontouchstart = $.noop
1212
+
1213
+ var carouselHTML = '<div class="carousel" data-interval="false"></div>'
1214
+ var $carousel = $(carouselHTML)
1215
+ $carousel.appendTo('#qunit-fixture')
1216
+ $carousel.bootstrapCarousel()
1217
+
1218
+ Simulator.gestures.swipe($carousel[0], {
1219
+ pos: [300, 10],
1220
+ deltaX: -300,
1221
+ deltaY: 0,
1222
+ touches: 2
1223
+ }, function () {
1224
+ restorePointerEvents()
1225
+ delete document.documentElement.ontouchstart
1226
+ done()
1227
+ })
1228
+ })
1229
+
1230
+ QUnit.test('should not call _slide if the carousel is sliding', function (assert) {
1231
+ assert.expect(1)
1232
+
1233
+ var carouselHTML = '<div class="carousel" data-interval="false"></div>'
1234
+ var $carousel = $(carouselHTML)
1235
+ $carousel.appendTo('#qunit-fixture')
1236
+ $carousel.bootstrapCarousel()
1237
+
1238
+ var carousel = $carousel.data('bs.carousel')
1239
+
1240
+ var spy = sinon.spy(carousel, '_slide')
1241
+
1242
+ carousel._isSliding = true
1243
+
1244
+ carousel.next()
1245
+
1246
+ assert.strictEqual(spy.called, false)
1247
+ })
1248
+
1249
+ QUnit.test('should call next when the page is visible', function (assert) {
1250
+ assert.expect(1)
1251
+
1252
+ var carouselHTML = '<div class="carousel" data-interval="false"></div>'
1253
+ var $carousel = $(carouselHTML)
1254
+ $carousel.appendTo('#qunit-fixture')
1255
+ $carousel.bootstrapCarousel()
1256
+
1257
+ var carousel = $carousel.data('bs.carousel')
1258
+
1259
+ var spy = sinon.spy(carousel, 'next')
1260
+ var sandbox = sinon.createSandbox()
1261
+
1262
+ sandbox.replaceGetter(document, 'hidden', function () {
1263
+ return false
1264
+ })
1265
+ sandbox.stub($carousel, 'is').returns(true)
1266
+ sandbox.stub($carousel, 'css').returns('block')
1267
+
1268
+ carousel.nextWhenVisible()
1269
+
1270
+ assert.strictEqual(spy.called, true)
1271
+ sandbox.restore()
1272
+ })
1273
+ })