1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-18 11:21:23 +02:00

Make JS compliant with the new ESLint rules.

This commit is contained in:
Bardi Harborow
2016-11-22 01:36:00 +11:00
parent 26c16743fc
commit c2616fb74e
22 changed files with 234 additions and 260 deletions

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('alert plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('button plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('carousel plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('collapse plugin')
@@ -56,14 +56,14 @@ $(function () {
assert.expect(2)
var html = [
'<div class="panel-group" id="accordion1">',
'<div class="panel">',
'<div id="collapse1" class="collapse"/>',
'</div>',
'<div class="panel">',
'<div id="collapse1" class="collapse"/>',
'</div>',
'</div>',
'<div class="panel-group" id="accordion2">',
'<div class="panel">',
'<div id="collapse2" class="collapse active"/>',
'</div>',
'<div class="panel">',
'<div id="collapse2" class="collapse active"/>',
'</div>',
'</div>'
].join('')
$(html).appendTo('#qunit-fixture')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('dropdowns plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('modal plugin')
@@ -374,7 +374,7 @@ $(function () {
var paddingRight = parseInt($(document.body).css('padding-right'), 10)
assert.strictEqual(isNaN(paddingRight), false)
assert.strictEqual(paddingRight !== 0, true)
$(document.body).css('padding-right', ''); // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not
$(document.body).css('padding-right', '') // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not
done()
})
.bootstrapModal('show')

View File

@@ -7,7 +7,7 @@
*/
(function () {
'use strict';
'use strict'
// Don't re-order tests.
QUnit.config.reorder = false
@@ -70,32 +70,3 @@
})
}())
// bind polyfill
// shoutout mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1)
var fToBind = this
var FNOP = function () {}
var fBound = function () {
return fToBind.apply(this instanceof FNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
}
if (this.prototype) {
// native functions don't have a prototype
FNOP.prototype = this.prototype
}
fBound.prototype = new FNOP()
return fBound
}
}

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('popover plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('scrollspy plugin')
@@ -231,8 +231,8 @@ $(function () {
.appendTo('#qunit-fixture')
.bootstrapScrollspy({ offset: 0, target: '#navigation' })
!function testActiveElements() {
if (++times > 3) return done()
function testActiveElements() {
if (++times > 3) { return done() }
$content.one('scroll', function () {
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
@@ -241,7 +241,9 @@ $(function () {
})
$content.scrollTop($content.scrollTop() + 10)
}()
}
testActiveElements()
})
QUnit.test('should clear selection if above the first section', function (assert) {
@@ -399,8 +401,8 @@ $(function () {
$navbar.appendTo('#qunit-fixture')
$content.appendTo('#qunit-fixture')
if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' })
else if (type === 'data') $(window).trigger('load')
if (type === 'js') { $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) }
else if (type === 'data') { $(window).trigger('load') }
var $target = $('#div-' + type + 'm-2')
var scrollspy = $content.data('bs.scrollspy')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('tabs plugin')

View File

@@ -1,5 +1,5 @@
$(function () {
'use strict';
'use strict'
QUnit.module('tooltip plugin')
@@ -382,7 +382,7 @@ $(function () {
var $tooltip = $($target.data('bs.tooltip').tip)
// this is some dumb hack stuff because sub pixels in firefox
var top = Math.round($target.offset().top + ($target[0].offsetHeight / 2) - ($tooltip[0].offsetHeight / 2))
var top = Math.round($target.offset().top + $target[0].offsetHeight / 2 - $tooltip[0].offsetHeight / 2)
var top2 = Math.round($tooltip.offset().top)
var topDiff = top - top2
assert.ok(topDiff <= 1 && topDiff >= -1)
@@ -540,7 +540,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ delay: { show: 0, hide: 150 }})
.bootstrapTooltip({ delay: { show: 0, hide: 150 } })
setTimeout(function () {
assert.ok($('.tooltip').is('.fade.active'), '1ms: tooltip faded active')
@@ -587,7 +587,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ delay: { show: 150, hide: 0 }})
.bootstrapTooltip({ delay: { show: 150, hide: 0 } })
setTimeout(function () {
assert.ok(!$('.tooltip').is('.fade.active'), '100ms: tooltip not faded active')
@@ -608,7 +608,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ delay: { show: 0, hide: 150 }})
.bootstrapTooltip({ delay: { show: 0, hide: 150 } })
setTimeout(function () {
assert.ok($($tooltip.data('bs.tooltip').tip).is('.fade.active'), '1ms: tooltip faded active')
@@ -723,10 +723,10 @@ $(function () {
$('#tt-outer').trigger('mouseleave')
assert.strictEqual(currentUid, $('#tt-content').text())
assert.ok(obj._hoverState == 'out', 'the tooltip hoverState should be set to "out"')
assert.ok(obj._hoverState === 'out', 'the tooltip hoverState should be set to "out"')
$('#tt-outer').trigger('mouseenter')
assert.ok(obj._hoverState == 'active', 'the tooltip hoverState should be set to "active"')
assert.ok(obj._hoverState === 'active', 'the tooltip hoverState should be set to "active"')
assert.strictEqual(currentUid, $('#tt-content').text())
})
@@ -788,7 +788,7 @@ $(function () {
var tooltip = $el.data('bs.tooltip')
var $tooltip = $(tooltip.getTipElement())
function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState == 'active' }
function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState === 'active' }
var tests = [
['mouseenter', 'mouseleave'],
@@ -812,8 +812,8 @@ $(function () {
$.each(tests, function (idx, triggers) {
for (var i = 0, len = triggers.length; i < len; i++) {
$el.trigger(triggers[i]);
assert.equal(i < (len - 1), showingTooltip())
$el.trigger(triggers[i])
assert.equal(i < len - 1, showingTooltip())
}
})
})