carousel.js 48 KB
Newer Older
1
$(function () {
2
  'use strict'
3

4
5
  window.Carousel = typeof bootstrap !== 'undefined' ? bootstrap.Carousel : Carousel

Johann-S's avatar
Johann-S committed
6
  var originWinPointerEvent = window.PointerEvent
Johann-S's avatar
Johann-S committed
7
  window.MSPointerEvent = null
Johann-S's avatar
Johann-S committed
8
9
10
11
12
13
14
15
16
17
18
19
  var supportPointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent)

  function clearPointerEvents() {
    window.PointerEvent = null
  }

  function restorePointerEvents() {
    window.PointerEvent = originWinPointerEvent
  }

  var stylesCarousel = [
    '<style>',
patrickhlauke's avatar
patrickhlauke committed
20
    '  .carousel.pointer-event { -ms-touch-action: none; touch-action: none; }',
Johann-S's avatar
Johann-S committed
21
22
23
    '</style>'
  ].join('')

fat's avatar
fat committed
24
  QUnit.module('carousel plugin')
25

fat's avatar
fat committed
26
27
28
  QUnit.test('should be defined on jQuery object', function (assert) {
    assert.expect(1)
    assert.ok($(document.body).carousel, 'carousel method is defined')
XhmikosR's avatar
XhmikosR committed
29
  })
30

fat's avatar
fat committed
31
32
  QUnit.module('carousel', {
    beforeEach: function () {
33
34
35
      // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
      $.fn.bootstrapCarousel = $.fn.carousel.noConflict()
    },
fat's avatar
fat committed
36
    afterEach: function () {
Johann-S's avatar
Johann-S committed
37
      $('.carousel').bootstrapCarousel('dispose')
38
39
      $.fn.carousel = $.fn.bootstrapCarousel
      delete $.fn.bootstrapCarousel
40
      $('#qunit-fixture').html('')
41
42
43
    }
  })

fat's avatar
fat committed
44
45
  QUnit.test('should provide no conflict', function (assert) {
    assert.expect(1)
XhmikosR's avatar
XhmikosR committed
46
    assert.strictEqual(typeof $.fn.carousel, 'undefined', 'carousel was set back to undefined (orig value)')
47
48
  })

49
50
51
52
53
54
55
56
57
58
59
60
61
62
  QUnit.test('should return version', function (assert) {
    assert.expect(1)

    assert.strictEqual(typeof Carousel.VERSION, 'string')
  })

  QUnit.test('should return default parameters', function (assert) {
    assert.expect(1)

    var defaultConfig = Carousel.Default

    assert.strictEqual(defaultConfig.touch, true)
  })

63
64
65
66
67
68
  QUnit.test('should throw explicit error on undefined method', function (assert) {
    assert.expect(1)
    var $el = $('<div/>')
    $el.bootstrapCarousel()
    try {
      $el.bootstrapCarousel('noMethod')
XhmikosR's avatar
XhmikosR committed
69
    } catch (err) {
70
71
72
73
      assert.strictEqual(err.message, 'No method named "noMethod"')
    }
  })

fat's avatar
fat committed
74
75
  QUnit.test('should return jquery collection containing the element', function (assert) {
    assert.expect(2)
76
77
    var $el = $('<div/>')
    var $carousel = $el.bootstrapCarousel()
fat's avatar
fat committed
78
79
    assert.ok($carousel instanceof $, 'returns jquery collection')
    assert.strictEqual($carousel[0], $el[0], 'collection contains element')
XhmikosR's avatar
XhmikosR committed
80
  })
81

fat's avatar
fat committed
82
  QUnit.test('should type check config options', function (assert) {
83
84
    assert.expect(2)

fat's avatar
fat committed
85
86
87
88
89
90
91
92
    var message
    var expectedMessage = 'CAROUSEL: Option "interval" provided type "string" but expected type "(number|boolean)".'
    var config = {
      interval: 'fat sux'
    }

    try {
      $('<div/>').bootstrapCarousel(config)
XhmikosR's avatar
XhmikosR committed
93
94
    } catch (err) {
      message = err.message
fat's avatar
fat committed
95
96
97
98
99
    }

    assert.ok(message === expectedMessage, 'correct error message')

    config = {
100
      keyboard: document.createElement('div')
fat's avatar
fat committed
101
102
103
104
105
    }
    expectedMessage = 'CAROUSEL: Option "keyboard" provided type "element" but expected type "boolean".'

    try {
      $('<div/>').bootstrapCarousel(config)
XhmikosR's avatar
XhmikosR committed
106
107
    } catch (err) {
      message = err.message
fat's avatar
fat committed
108
109
110
111
112
    }

    assert.ok(message === expectedMessage, 'correct error message')
  })

fat's avatar
fat committed
113
114
  QUnit.test('should not fire slid when slide is prevented', function (assert) {
    assert.expect(1)
115
    var done = assert.async()
Johann-S's avatar
Johann-S committed
116
117
118
119
120
121
122
123
124
125
126
127
    var $carousel = $('<div class="carousel"/>')
    $carousel.appendTo('#qunit-fixture')

    EventHandler.on($carousel[0], 'slide.bs.carousel', function (e) {
      e.preventDefault()
      assert.ok(true, 'slide event fired')
      done()
    })
    EventHandler.on($carousel[0], 'slid.bs.carousel', function () {
      assert.ok(false, 'slid event fired')
    })
    $carousel.bootstrapCarousel('next')
XhmikosR's avatar
XhmikosR committed
128
  })
129

fat's avatar
fat committed
130
131
  QUnit.test('should reset when slide is prevented', function (assert) {
    assert.expect(6)
XhmikosR's avatar
XhmikosR committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
    var carouselHTML = '<div id="carousel-example-generic" class="carousel slide">' +
        '<ol class="carousel-indicators">' +
        '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
        '</ol>' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
        '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
        '</div>'
152
    var $carousel = $(carouselHTML)
Johann-S's avatar
Johann-S committed
153
    $carousel.appendTo('#qunit-fixture')
154

155
    var done = assert.async()
Johann-S's avatar
Johann-S committed
156
157
    EventHandler
      .one($carousel[0], 'slide.bs.carousel', function (e) {
158
159
        e.preventDefault()
        setTimeout(function () {
160
161
          assert.ok($carousel.find('.carousel-item:nth-child(1)').is('.active'), 'first item still active')
          assert.ok($carousel.find('.carousel-indicators li:nth-child(1)').is('.active'), 'first indicator still active')
162
163
164
          $carousel.bootstrapCarousel('next')
        }, 0)
      })
Johann-S's avatar
Johann-S committed
165
166
167

    EventHandler
      .one($carousel[0], 'slid.bs.carousel', function () {
168
        setTimeout(function () {
169
170
171
172
          assert.ok(!$carousel.find('.carousel-item:nth-child(1)').is('.active'), 'first item still active')
          assert.ok(!$carousel.find('.carousel-indicators li:nth-child(1)').is('.active'), 'first indicator still active')
          assert.ok($carousel.find('.carousel-item:nth-child(2)').is('.active'), 'second item active')
          assert.ok($carousel.find('.carousel-indicators li:nth-child(2)').is('.active'), 'second indicator active')
173
          done()
174
175
        }, 0)
      })
Johann-S's avatar
Johann-S committed
176
177

    $carousel.bootstrapCarousel('next')
XhmikosR's avatar
XhmikosR committed
178
  })
179

fat's avatar
fat committed
180
181
  QUnit.test('should fire slide event with direction', function (assert) {
    assert.expect(4)
XhmikosR's avatar
XhmikosR committed
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
    var carouselHTML = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
215
    var $carousel = $(carouselHTML)
Johann-S's avatar
Johann-S committed
216
    $carousel.appendTo('#qunit-fixture')
217

218
    var done = assert.async()
219

Johann-S's avatar
Johann-S committed
220
221
    EventHandler
      .one($carousel[0], 'slide.bs.carousel', function (e) {
fat's avatar
fat committed
222
223
        assert.ok(e.direction, 'direction present on next')
        assert.strictEqual(e.direction, 'left', 'direction is left on next')
224

Johann-S's avatar
Johann-S committed
225
226
        EventHandler
          .one($carousel[0], 'slide.bs.carousel', function (e) {
fat's avatar
fat committed
227
228
            assert.ok(e.direction, 'direction present on prev')
            assert.strictEqual(e.direction, 'right', 'direction is right on prev')
229
            done()
230
          })
Johann-S's avatar
Johann-S committed
231
        $carousel.bootstrapCarousel('prev')
232
      })
Johann-S's avatar
Johann-S committed
233
    $carousel.bootstrapCarousel('next')
XhmikosR's avatar
XhmikosR committed
234
  })
235

fat's avatar
fat committed
236
237
  QUnit.test('should fire slid event with direction', function (assert) {
    assert.expect(4)
XhmikosR's avatar
XhmikosR committed
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
    var carouselHTML = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
271
    var $carousel = $(carouselHTML)
Johann-S's avatar
Johann-S committed
272
    $carousel.appendTo('#qunit-fixture')
273

274
    var done = assert.async()
275

Johann-S's avatar
Johann-S committed
276
277
    EventHandler
      .one($carousel[0], 'slid.bs.carousel', function (e) {
fat's avatar
fat committed
278
279
        assert.ok(e.direction, 'direction present on next')
        assert.strictEqual(e.direction, 'left', 'direction is left on next')
280

Johann-S's avatar
Johann-S committed
281
282
        EventHandler
          .one($carousel[0], 'slid.bs.carousel', function (e) {
fat's avatar
fat committed
283
284
            assert.ok(e.direction, 'direction present on prev')
            assert.strictEqual(e.direction, 'right', 'direction is right on prev')
285
            done()
286
          })
Johann-S's avatar
Johann-S committed
287
        $carousel.bootstrapCarousel('prev')
288
      })
Johann-S's avatar
Johann-S committed
289
    $carousel.bootstrapCarousel('next')
290
291
  })

fat's avatar
fat committed
292
293
  QUnit.test('should fire slide event with relatedTarget', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
    var template = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
327

328
    var done = assert.async()
Johann-S's avatar
Johann-S committed
329
330
    var $carousel = $(template)
    $carousel.appendTo('#qunit-fixture')
331

Johann-S's avatar
Johann-S committed
332
333
    EventHandler
      .one($carousel[0], 'slide.bs.carousel', function (e) {
fat's avatar
fat committed
334
        assert.ok(e.relatedTarget, 'relatedTarget present')
fat's avatar
fat committed
335
        assert.ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "item"')
336
        done()
Dmitriy Budnik's avatar
Dmitriy Budnik committed
337
      })
Johann-S's avatar
Johann-S committed
338
339

    $carousel.bootstrapCarousel('next')
XhmikosR's avatar
XhmikosR committed
340
  })
341

fat's avatar
fat committed
342
343
  QUnit.test('should fire slid event with relatedTarget', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
    var template = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
377

378
    var done = assert.async()
Johann-S's avatar
Johann-S committed
379
380
    var $carousel = $(template)
    $carousel.appendTo('#qunit-fixture')
381

Johann-S's avatar
Johann-S committed
382
383
    EventHandler
      .one($carousel[0], 'slid.bs.carousel', function (e) {
fat's avatar
fat committed
384
        assert.ok(e.relatedTarget, 'relatedTarget present')
fat's avatar
fat committed
385
        assert.ok($(e.relatedTarget).hasClass('carousel-item'), 'relatedTarget has class "item"')
386
        done()
387
      })
Johann-S's avatar
Johann-S committed
388
389

    $carousel.bootstrapCarousel('next')
390
  })
391

392
393
  QUnit.test('should fire slid and slide events with from and to', function (assert) {
    assert.expect(4)
XhmikosR's avatar
XhmikosR committed
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
    var template = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
418
419

    var done = assert.async()
Johann-S's avatar
Johann-S committed
420
421
422
423
    var $carousel = $(template)

    EventHandler
      .one($carousel[0], 'slid.bs.carousel', function (e) {
XhmikosR's avatar
XhmikosR committed
424
425
        assert.ok(typeof e.from !== 'undefined', 'from present')
        assert.ok(typeof e.to !== 'undefined', 'to present')
426
427
        done()
      })
Johann-S's avatar
Johann-S committed
428
429
430

    EventHandler
      .one($carousel[0], 'slide.bs.carousel', function (e) {
XhmikosR's avatar
XhmikosR committed
431
432
        assert.ok(typeof e.from !== 'undefined', 'from present')
        assert.ok(typeof e.to !== 'undefined', 'to present')
433
      })
Johann-S's avatar
Johann-S committed
434
435

    $carousel.bootstrapCarousel('next')
436
437
  })

fat's avatar
fat committed
438
439
  QUnit.test('should set interval from data attribute', function (assert) {
    assert.expect(4)
XhmikosR's avatar
XhmikosR committed
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
    var templateHTML = '<div id="myCarousel" class="carousel slide">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
473
474
    var $carousel = $(templateHTML)
    $carousel.attr('data-interval', 1814)
Dmitriy Budnik's avatar
Dmitriy Budnik committed
475

476
    $carousel.appendTo('body')
Johann-S's avatar
Johann-S committed
477
478
    EventHandler.trigger($('[data-slide]').first()[0], 'click')
    assert.strictEqual(Data.getData($carousel[0], 'bs.carousel')._config.interval, 1814)
479
    $carousel.remove()
dmitriybudnik's avatar
dmitriybudnik committed
480

481
    $carousel.appendTo('body').attr('data-modal', 'foobar')
Johann-S's avatar
Johann-S committed
482
483
    EventHandler.trigger($('[data-slide]').first()[0], 'click')
    assert.strictEqual(Data.getData($carousel[0], 'bs.carousel')._config.interval, 1814, 'even if there is an data-modal attribute set')
484
    $carousel.remove()
Dmitriy Budnik's avatar
Dmitriy Budnik committed
485

486
    $carousel.appendTo('body')
Johann-S's avatar
Johann-S committed
487
    EventHandler.trigger($('[data-slide]').first()[0], 'click')
488
    $carousel.attr('data-interval', 1860)
Johann-S's avatar
Johann-S committed
489
490
491
    EventHandler.trigger($('[data-slide]').first()[0], 'click')
    assert.strictEqual(Data.getData($carousel[0], 'bs.carousel')._config.interval, 1814, 'attributes should be read only on initialization')
    $carousel.bootstrapCarousel('dispose')
492
493
494
495
496
    $carousel.remove()

    $carousel.attr('data-interval', false)
    $carousel.appendTo('body')
    $carousel.bootstrapCarousel(1)
Johann-S's avatar
Johann-S committed
497
    assert.strictEqual(Data.getData($carousel[0], 'bs.carousel')._config.interval, false, 'data attribute has higher priority than default options')
498
    $carousel.remove()
XhmikosR's avatar
XhmikosR committed
499
  })
500

501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
  QUnit.test('should set interval from data attribute on individual carousel-item', function (assert) {
    assert.expect(2)
    var templateHTML = '<div id="myCarousel" class="carousel slide" data-interval="1814">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active" data-interval="2814">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>First Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item" data-interval="3814">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Second Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '<div class="carousel-caption">' +
        '<h4>Third Thumbnail label</h4>' +
        '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec ' +
        'id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ' +
        'ultricies vehicula ut id elit.</p>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
        '<a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
        '</div>'
    var $carousel = $(templateHTML)

    $carousel.appendTo('body')
    $carousel.bootstrapCarousel(1)
    assert.strictEqual($carousel.data('bs.carousel')._config.interval, 3814)
    $carousel.remove()

    $carousel.appendTo('body')
    $carousel.bootstrapCarousel(2)
    assert.strictEqual($carousel.data('bs.carousel')._config.interval, 1814, 'reverts to default interval if no data-interval is set')
    $carousel.remove()
  })

fat's avatar
fat committed
549
550
  QUnit.test('should skip over non-items when using item indices', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
551
552
553
554
555
556
557
558
559
560
561
562
563
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '<script type="text/x-metamorph" id="thingy"/>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div class="carousel-item">' +
        '</div>' +
        '</div>' +
        '</div>'
564
    var $template = $(templateHTML)
565

566
    $template.bootstrapCarousel()
567

fat's avatar
fat committed
568
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
569

570
    $template.bootstrapCarousel(1)
571

fat's avatar
fat committed
572
    assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
573
  })
574

fat's avatar
fat committed
575
576
  QUnit.test('should skip over non-items when using next/prev methods', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
577
578
579
580
581
582
583
584
585
586
587
588
589
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '<script type="text/x-metamorph" id="thingy"/>' +
        '<div class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div class="carousel-item">' +
        '</div>' +
        '</div>' +
        '</div>'
590
591
592
593
    var $template = $(templateHTML)

    $template.bootstrapCarousel()

fat's avatar
fat committed
594
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
595
596
597

    $template.bootstrapCarousel('next')

fat's avatar
fat committed
598
    assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
599
  })
600

fat's avatar
fat committed
601
602
  QUnit.test('should go to previous item if left arrow key is pressed', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
603
604
605
606
607
608
609
610
611
612
613
614
615
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
        '<div class="carousel-inner">' +
        '<div id="first" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div id="second" class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '<div id="third" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '</div>' +
        '</div>'
616
617
618
619
    var $template = $(templateHTML)

    $template.bootstrapCarousel()

fat's avatar
fat committed
620
    assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
621

622
    EventHandler.trigger($template[0], 'keydown', {
XhmikosR's avatar
XhmikosR committed
623
      which: 37
624
    })
625

fat's avatar
fat committed
626
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
627
628
  })

fat's avatar
fat committed
629
630
  QUnit.test('should go to next item if right arrow key is pressed', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
631
632
633
634
635
636
637
638
639
640
641
642
643
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
        '<div class="carousel-inner">' +
        '<div id="first" class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '<div id="second" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div id="third" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '</div>' +
        '</div>'
644
645
646
647
    var $template = $(templateHTML)

    $template.bootstrapCarousel()

fat's avatar
fat committed
648
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
649

650
    EventHandler.trigger($template[0], 'keydown', {
XhmikosR's avatar
XhmikosR committed
651
      which: 39
652
    })
653

fat's avatar
fat committed
654
    assert.strictEqual($template.find('.carousel-item')[1], $template.find('.active')[0], 'second item active')
655
656
  })

657
658
  QUnit.test('should not prevent keydown if key is not ARROW_LEFT or ARROW_RIGHT', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
659
660
661
662
663
664
665
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
        '<div class="carousel-inner">' +
        '<div id="first" class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '</div>' +
        '</div>'
666
667
668
669
670
    var $template = $(templateHTML)

    $template.bootstrapCarousel()
    var done = assert.async()

Johann-S's avatar
Johann-S committed
671
672
    EventHandler.one($template[0], 'keydown', function (event) {
      assert.strictEqual(event.defaultPrevented, false)
673
674
    })

Johann-S's avatar
Johann-S committed
675
    // arrow down
676
677
678
    EventHandler.trigger($template[0], 'keydown', {
      which: 40
    })
679

Johann-S's avatar
Johann-S committed
680
681
    EventHandler.one($template[0], 'keydown', function (event) {
      assert.strictEqual(event.defaultPrevented, false)
682
683
684
      done()
    })

Johann-S's avatar
Johann-S committed
685
    // arrow up
686
687
688
    EventHandler.trigger($template[0], 'keydown', {
      which: 38
    })
689
690
  })

fat's avatar
fat committed
691
692
  QUnit.test('should support disabling the keyboard navigation', function (assert) {
    assert.expect(3)
XhmikosR's avatar
XhmikosR committed
693
694
695
696
697
698
699
700
701
702
703
704
705
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">' +
        '<div class="carousel-inner">' +
        '<div id="first" class="carousel-item active">' +
        '<img alt="">' +
        '</div>' +
        '<div id="second" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div id="third" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '</div>' +
        '</div>'
706
707
708
709
    var $template = $(templateHTML)

    $template.bootstrapCarousel()

fat's avatar
fat committed
710
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
711

XhmikosR's avatar
XhmikosR committed
712
713
714
    $template.trigger($.Event('keydown', {
      which: 39
    }))
715

fat's avatar
fat committed
716
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press')
717

XhmikosR's avatar
XhmikosR committed
718
719
720
    $template.trigger($.Event('keydown', {
      which: 37
    }))
721

fat's avatar
fat committed
722
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press')
723
724
  })

fat's avatar
fat committed
725
726
  QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
    assert.expect(7)
XhmikosR's avatar
XhmikosR committed
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
        '<div class="carousel-inner">' +
        '<div id="first" class="carousel-item active">' +
        '<img alt="">' +
        '<input type="text" id="in-put">' +
        '<textarea id="text-area"></textarea>' +
        '</div>' +
        '<div id="second" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '<div id="third" class="carousel-item">' +
        '<img alt="">' +
        '</div>' +
        '</div>' +
        '</div>'
742
743
744
745
    var $template = $(templateHTML)
    var $input = $template.find('#in-put')
    var $textarea = $template.find('#text-area')

fat's avatar
fat committed
746
747
    assert.strictEqual($input.length, 1, 'found <input>')
    assert.strictEqual($textarea.length, 1, 'found <textarea>')
748
749
750

    $template.bootstrapCarousel()

fat's avatar
fat committed
751
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item active')
752

XhmikosR's avatar
XhmikosR committed
753
754
755
    $input.trigger($.Event('keydown', {
      which: 39
    }))
fat's avatar
fat committed
756
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <input>')
757

XhmikosR's avatar
XhmikosR committed
758
759
760
    $input.trigger($.Event('keydown', {
      which: 37
    }))
fat's avatar
fat committed
761
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <input>')
762

XhmikosR's avatar
XhmikosR committed
763
764
765
    $textarea.trigger($.Event('keydown', {
      which: 39
    }))
fat's avatar
fat committed
766
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after right arrow press in <textarea>')
767

XhmikosR's avatar
XhmikosR committed
768
769
770
    $textarea.trigger($.Event('keydown', {
      which: 37
    }))
fat's avatar
fat committed
771
    assert.strictEqual($template.find('.carousel-item')[0], $template.find('.active')[0], 'first item still active after left arrow press in <textarea>')
772
773
  })

fat's avatar
fat committed
774
775
  QUnit.test('should wrap around from end to start when wrap option is true', function (assert) {
    assert.expect(3)
XhmikosR's avatar
XhmikosR committed
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
    var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' +
        '<ol class="carousel-indicators">' +
        '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
        '</ol>' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active" id="one">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="two">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="three">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
        '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
        '</div>'
796
    var $carousel = $(carouselHTML)
XhmikosR's avatar
XhmikosR committed
797
798
799
    var getActiveId = function () {
      return $carousel.find('.carousel-item.active').attr('id')
    }
800

801
    var done = assert.async()
802

Johann-S's avatar
Johann-S committed
803
804
805
806
807
808
809
810
811
812
813
    EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
      assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')

      EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
        assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')

        EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
          assert.strictEqual(getActiveId(), 'one', 'carousel wrapped around and slid from 3rd to 1st slide')
          done()
        })
        $carousel.bootstrapCarousel('next')
814
      })
Johann-S's avatar
Johann-S committed
815
816
817
      $carousel.bootstrapCarousel('next')
    })
    $carousel.bootstrapCarousel('next')
818
819
  })

fat's avatar
fat committed
820
821
  QUnit.test('should wrap around from start to end when wrap option is true', function (assert) {
    assert.expect(1)
XhmikosR's avatar
XhmikosR committed
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
    var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">' +
        '<ol class="carousel-indicators">' +
        '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
        '</ol>' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active" id="one">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="two">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="three">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
        '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
        '</div>'
842
843
    var $carousel = $(carouselHTML)

844
    var done = assert.async()
845

Johann-S's avatar
Johann-S committed
846
847
848
849
850
    EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
      assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'three', 'carousel wrapped around and slid from 1st to 3rd slide')
      done()
    })
    $carousel.bootstrapCarousel('prev')
851
852
  })

fat's avatar
fat committed
853
854
  QUnit.test('should stay at the end when the next method is called and wrap is false', function (assert) {
    assert.expect(3)
XhmikosR's avatar
XhmikosR committed
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
    var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' +
        '<ol class="carousel-indicators">' +
        '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
        '</ol>' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active" id="one">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="two">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="three">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
        '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
        '</div>'
875
    var $carousel = $(carouselHTML)
XhmikosR's avatar
XhmikosR committed
876
877
878
    var getActiveId = function () {
      return $carousel.find('.carousel-item.active').attr('id')
    }
879

880
    var done = assert.async()
881

Johann-S's avatar
Johann-S committed
882
883
884
885
886
887
888
889
890
891
892
893
    EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
      assert.strictEqual(getActiveId(), 'two', 'carousel slid from 1st to 2nd slide')

      EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
        assert.strictEqual(getActiveId(), 'three', 'carousel slid from 2nd to 3rd slide')

        EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
          assert.ok(false, 'carousel slid when it should not have slid')
        })
        $carousel.bootstrapCarousel('next')
        assert.strictEqual(getActiveId(), 'three', 'carousel did not wrap around and stayed on 3rd slide')
        done()
894
      })
Johann-S's avatar
Johann-S committed
895
896
897
      $carousel.bootstrapCarousel('next')
    })
    $carousel.bootstrapCarousel('next')
898
899
  })

fat's avatar
fat committed
900
901
  QUnit.test('should stay at the start when the prev method is called and wrap is false', function (assert) {
    assert.expect(1)
XhmikosR's avatar
XhmikosR committed
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
    var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">' +
        '<ol class="carousel-indicators">' +
        '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="1"/>' +
        '<li data-target="#carousel-example-generic" data-slide-to="2"/>' +
        '</ol>' +
        '<div class="carousel-inner">' +
        '<div class="carousel-item active" id="one">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="two">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '<div class="carousel-item" id="three">' +
        '<div class="carousel-caption"/>' +
        '</div>' +
        '</div>' +
        '<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"/>' +
        '<a class="right carousel-control" href="#carousel-example-generic" data-slide="next"/>' +
        '</div>'
922
923
    var $carousel = $(carouselHTML)

Johann-S's avatar
Johann-S committed
924
925
926
927
    EventHandler.one($carousel[0], 'slid.bs.carousel', function () {
      assert.ok(false, 'carousel slid when it should not have slid')
    })
    $carousel.bootstrapCarousel('prev')
fat's avatar
fat committed
928
    assert.strictEqual($carousel.find('.carousel-item.active').attr('id'), 'one', 'carousel did not wrap around and stayed on 1st slide')
929
  })
930
931
932

  QUnit.test('should not prevent keydown for inputs and textareas', function (assert) {
    assert.expect(2)
XhmikosR's avatar
XhmikosR committed
933
934
935
936
937
938
939
940
941
942
    var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">' +
        '<div class="carousel-inner">' +
          '<div id="first" class="carousel-item">' +
            '<input type="text" id="inputText" />' +
          '</div>' +
          '<div id="second" class="carousel-item active">' +
            '<textarea id="txtArea"></textarea>' +
          '</div>' +
        '</div>' +
        '</div>'
943
944
945
946
947
948
949
    var $template = $(templateHTML)
    var done = assert.async()
    $template.appendTo('#qunit-fixture')
    var $inputText = $template.find('#inputText')
    var $textArea = $template.find('#txtArea')
    $template.bootstrapCarousel()

XhmikosR's avatar
XhmikosR committed
950
951
952
    var eventKeyDown = $.Event('keydown', {
      which: 65
    }) // 65 for "a"
953
954
955
956
957
958
959
960
961
962
963
    $inputText.on('keydown', function (event) {
      assert.strictEqual(event.isDefaultPrevented(), false)
    })
    $inputText.trigger(eventKeyDown)

    $textArea.on('keydown', function (event) {
      assert.strictEqual(event.isDefaultPrevented(), false)
      done()
    })
    $textArea.trigger(eventKeyDown)
  })
964

965
  QUnit.test('should not go to the next item when the carousel is not visible', function (assert) {
966
967
    assert.expect(2)
    var done = assert.async()
XhmikosR's avatar
XhmikosR committed
968
969
970
971
972
973
974
975
976
977
978
979
980
981
    var html = '<div id="myCarousel" class="carousel slide" data-interval="50" style="display: none;">' +
             '  <div class="carousel-inner">' +
             '    <div id="firstItem" class="carousel-item active">' +
             '      <img alt="">' +
             '    </div>' +
             '    <div class="carousel-item">' +
             '      <img alt="">' +
             '    </div>' +
             '    <div class="carousel-item">' +
             '      <img alt="">' +
             '    </div>' +
             '  <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>' +
             '  <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>' +
             '</div>'
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
    var $html = $(html)
    $html
      .appendTo('#qunit-fixture')
      .bootstrapCarousel()

    var $firstItem = $('#firstItem')
    setTimeout(function () {
      assert.ok($firstItem.hasClass('active'))
      $html
        .bootstrapCarousel('dispose')
        .attr('style', 'visibility: hidden;')
        .bootstrapCarousel()

      setTimeout(function () {
        assert.ok($firstItem.hasClass('active'))
        done()
      }, 80)
    }, 80)
  })
For faster browsing, not all history is shown. View entire blame