aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/.jscs.json14
-rw-r--r--js/dropdown.js2
-rw-r--r--js/modal.js2
-rw-r--r--js/tests/unit/modal.js14
-rw-r--r--js/tests/unit/phantom.js8
-rw-r--r--js/tests/unit/popover.js4
-rw-r--r--js/tests/unit/scrollspy.js2
-rw-r--r--js/tests/unit/tab.js4
-rw-r--r--js/tests/unit/tooltip.js40
-rw-r--r--js/tooltip.js6
10 files changed, 55 insertions, 41 deletions
diff --git a/js/.jscs.json b/js/.jscs.json
new file mode 100644
index 000000000..2f04d9cd6
--- /dev/null
+++ b/js/.jscs.json
@@ -0,0 +1,14 @@
+{
+ "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return"],
+ "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true },
+ "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
+ "requireRightStickedOperators": ["!"],
+ "disallowRightStickedOperators": ["?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
+ "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
+ "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
+ "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
+ "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
+ "disallowKeywords": ["with"],
+ "validateLineBreaks": "LF",
+ "requireLineFeedAtFileEnd": true
+}
diff --git a/js/dropdown.js b/js/dropdown.js
index 13352ef7c..b84d219bd 100644
--- a/js/dropdown.js
+++ b/js/dropdown.js
@@ -85,7 +85,7 @@
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
- if (!~index) index=0
+ if (!~index) index = 0
$items.eq(index).focus()
}
diff --git a/js/modal.js b/js/modal.js
index 3ead5ee88..5544cf04e 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -180,7 +180,7 @@
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
- $.support.transition && this.$element.hasClass('fade')?
+ $.support.transition && this.$element.hasClass('fade') ?
this.$backdrop
.one($.support.transition.end, callback)
.emulateTransitionEnd(150) :
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index 5755d2751..a6dade99b 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -74,7 +74,7 @@ $(function () {
ok($('#modal-test').length, 'modal inserted into dom')
$(this).modal("hide")
})
- .on("hidden.bs.modal", function() {
+ .on("hidden.bs.modal", function () {
ok(!$('#modal-test').is(":visible"), 'modal hidden')
$('#modal-test').remove()
start()
@@ -92,7 +92,7 @@ $(function () {
ok($('#modal-test').length, 'modal inserted into dom')
div.modal("toggle")
})
- .on("hidden.bs.modal", function() {
+ .on("hidden.bs.modal", function () {
ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove()
start()
@@ -110,7 +110,7 @@ $(function () {
ok($('#modal-test').length, 'modal inserted into dom')
div.find('.close').click()
})
- .on("hidden.bs.modal", function() {
+ .on("hidden.bs.modal", function () {
ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove()
start()
@@ -127,7 +127,7 @@ $(function () {
ok($('#modal-test').is(":visible"), 'modal visible')
div.modal("hide")
})
- .on("hidden.bs.modal", function() {
+ .on("hidden.bs.modal", function () {
ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove()
start()
@@ -146,7 +146,7 @@ $(function () {
ok($('#modal-test').is(":visible"), 'modal visible')
$('#modal-test').click()
})
- .bind("hidden.bs.modal", function() {
+ .bind("hidden.bs.modal", function () {
ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove()
start()
@@ -164,7 +164,7 @@ $(function () {
triggered = 0
$('#modal-test').click()
})
- .one("hidden.bs.modal", function() {
+ .one("hidden.bs.modal", function () {
div.modal("show")
})
.bind("hide.bs.modal", function () {
@@ -184,7 +184,7 @@ $(function () {
$('#close').click()
ok(!$('#modal-test').is(":visible"), 'modal hidden')
})
- .one("hidden.bs.modal", function() {
+ .one("hidden.bs.modal", function () {
div.one('hidden.bs.modal', function () {
start()
}).modal("show")
diff --git a/js/tests/unit/phantom.js b/js/tests/unit/phantom.js
index c584c5a35..cf9da2537 100644
--- a/js/tests/unit/phantom.js
+++ b/js/tests/unit/phantom.js
@@ -22,7 +22,7 @@
}
// These methods connect QUnit to PhantomJS.
- QUnit.log = function(obj) {
+ QUnit.log = function (obj) {
// What is this I don’t even
if (obj.message === '[object Object], undefined:undefined') { return }
// Parse some stuff before sending it.
@@ -32,15 +32,15 @@
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source)
}
- QUnit.testStart = function(obj) {
+ QUnit.testStart = function (obj) {
sendMessage('qunit.testStart', obj.name)
}
- QUnit.testDone = function(obj) {
+ QUnit.testDone = function (obj) {
sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total)
}
- QUnit.moduleStart = function(obj) {
+ QUnit.moduleStart = function (obj) {
sendMessage('qunit.moduleStart', obj.name)
}
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index c9f7d63a7..2a11e0fdf 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -97,7 +97,7 @@ $(function () {
$('#qunit-fixture').empty()
})
- test("should respect custom classes", function() {
+ test("should respect custom classes", function () {
$.support.transition = false
var popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
@@ -118,7 +118,7 @@ $(function () {
})
test("should destroy popover", function () {
- var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
+ var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function () {})
ok(popover.data('bs.popover'), 'popover has data')
ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event')
ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index 06219a1c8..1b546a579 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -19,7 +19,7 @@ $(function () {
test("should switch active class on scroll", function () {
var sectionHTML = '<div id="masthead"></div>'
, $section = $(sectionHTML).append('#qunit-fixture')
- , topbarHTML ='<div class="topbar">'
+ , topbarHTML = '<div class="topbar">'
+ '<div class="topbar-inner">'
+ '<div class="container">'
+ '<h3><a href="#">Bootstrap</a></h3>'
diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js
index 0db7cdb5b..812262812 100644
--- a/js/tests/unit/tab.js
+++ b/js/tests/unit/tab.js
@@ -76,9 +76,9 @@ $(function () {
+ '</ul>'
$(dropHTML).find('ul>li:first a').tab('show').end()
- .find('ul>li:last a').on('show', function(event){
+ .find('ul>li:last a').on('show', function (event) {
equal(event.relatedTarget.hash, "#1-1")
- }).on('shown', function(event){
+ }).on('shown', function (event) {
equal(event.relatedTarget.hash, "#1-1")
}).tab('show')
})
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index dc3ddd377..cc559ccb6 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -69,7 +69,7 @@ $(function () {
test("should fire show event", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("show.bs.tooltip", function() {
+ .on("show.bs.tooltip", function () {
ok(true, "show was called")
start()
})
@@ -79,7 +79,7 @@ $(function () {
test("should fire shown event", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("shown.bs.tooltip", function() {
+ .on("shown.bs.tooltip", function () {
ok(true, "shown was called")
start()
})
@@ -89,12 +89,12 @@ $(function () {
test("should not fire shown event when default prevented", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("show.bs.tooltip", function(e) {
+ .on("show.bs.tooltip", function (e) {
e.preventDefault()
ok(true, "show was called")
start()
})
- .on("shown.bs.tooltip", function() {
+ .on("shown.bs.tooltip", function () {
ok(false, "shown was called")
})
.tooltip('show')
@@ -103,10 +103,10 @@ $(function () {
test("should fire hide event", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("shown.bs.tooltip", function() {
+ .on("shown.bs.tooltip", function () {
$(this).tooltip('hide')
})
- .on("hide.bs.tooltip", function() {
+ .on("hide.bs.tooltip", function () {
ok(true, "hide was called")
start()
})
@@ -116,10 +116,10 @@ $(function () {
test("should fire hidden event", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("shown.bs.tooltip", function() {
+ .on("shown.bs.tooltip", function () {
$(this).tooltip('hide')
})
- .on("hidden.bs.tooltip", function() {
+ .on("hidden.bs.tooltip", function () {
ok(true, "hidden was called")
start()
})
@@ -129,15 +129,15 @@ $(function () {
test("should not fire hidden event when default prevented", function () {
stop()
var tooltip = $('<div title="tooltip title"></div>')
- .on("shown.bs.tooltip", function() {
+ .on("shown.bs.tooltip", function () {
$(this).tooltip('hide')
})
- .on("hide.bs.tooltip", function(e) {
+ .on("hide.bs.tooltip", function (e) {
e.preventDefault()
ok(true, "hide was called")
start()
})
- .on("hidden.bs.tooltip", function() {
+ .on("hidden.bs.tooltip", function () {
ok(false, "hidden was called")
})
.tooltip('show')
@@ -258,7 +258,7 @@ $(function () {
})
test("should destroy tooltip", function () {
- var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
+ var tooltip = $('<div/>').tooltip().on('click.foo', function () {})
ok(tooltip.data('bs.tooltip'), 'tooltip has data')
ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
@@ -290,25 +290,25 @@ $(function () {
test("should place tooltips inside the body", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
- .tooltip({container:'body'})
+ .tooltip({container: 'body'})
.tooltip('show')
ok($("body > .tooltip").length, 'inside the body')
ok(!$("#qunit-fixture > .tooltip").length, 'not found in parent')
tooltip.tooltip('hide')
})
- test("should place tooltip inside window", function(){
+ test("should place tooltip inside window", function () {
var container = $("<div />").appendTo("body")
.css({position: "absolute", width: 200, height: 200, bottom: 0, left: 0})
, tooltip = $("<a href='#' title='Very very very very very very very very long tooltip'>Hover me</a>")
- .css({position: "absolute", top:0, left: 0})
+ .css({position: "absolute", top: 0, left: 0})
.appendTo(container)
.tooltip({placement: "top", animate: false})
.tooltip("show")
stop()
- setTimeout(function(){
+ setTimeout(function () {
ok($(".tooltip").offset().left >= 0)
start()
@@ -316,7 +316,7 @@ $(function () {
}, 100)
})
- test("should place tooltip on top of element", function(){
+ test("should place tooltip on top of element", function () {
var container = $("<div />").appendTo("body")
.css({position: "absolute", bottom: 0, left: 0, textAlign: "right", width: 300, height: 300})
, p = $("<p style='margin-top:200px' />").appendTo(container)
@@ -328,7 +328,7 @@ $(function () {
stop()
- setTimeout(function(){
+ setTimeout(function () {
var tooltip = container.find(".tooltip")
start()
@@ -337,7 +337,7 @@ $(function () {
}, 100)
})
- test("should add position class before positioning so that position-specific styles are taken into account", function(){
+ test("should add position class before positioning so that position-specific styles are taken into account", function () {
$("head").append('<style> .tooltip.right { white-space: nowrap; } .tooltip.right .tooltip-inner { max-width: none; } </style>')
var container = $("<div />").appendTo("body")
@@ -347,7 +347,7 @@ $(function () {
.tooltip('show')
, tooltip = container.find(".tooltip")
- ok( Math.round(target.offset().top + target[0].offsetHeight/2 - tooltip[0].offsetHeight/2) === Math.round(tooltip.offset().top) )
+ ok( Math.round(target.offset().top + (target[0].offsetHeight / 2) - (tooltip[0].offsetHeight / 2)) === Math.round(tooltip.offset().top) )
target.tooltip('hide')
})
diff --git a/js/tooltip.js b/js/tooltip.js
index 4c848f0e2..d3bf41fb2 100644
--- a/js/tooltip.js
+++ b/js/tooltip.js
@@ -133,7 +133,7 @@
}
Tooltip.prototype.show = function () {
- var e = $.Event('show.bs.'+ this.type)
+ var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
@@ -192,7 +192,7 @@
}
}
- Tooltip.prototype.applyPlacement = function(offset, placement) {
+ Tooltip.prototype.applyPlacement = function (offset, placement) {
var replace
var $tip = this.tip()
var width = $tip[0].offsetWidth
@@ -243,7 +243,7 @@
if (replace) $tip.offset(offset)
}
- Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
+ Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}