aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-03-09 22:01:38 -0700
committerMark Otto <[email protected]>2014-03-09 22:01:38 -0700
commitccb17f110de8e90773a6ebfda9e35306d625dc78 (patch)
treead1bc7e6bc41eb9805b6a2531c5c37df7a92cb87 /js
parentbdd7651e323a93a4e3d207463451dd374b0a70fa (diff)
parentb1f71e5292017aca978fabb74d256989e1eeea07 (diff)
downloadbootstrap-ccb17f110de8e90773a6ebfda9e35306d625dc78.tar.xz
bootstrap-ccb17f110de8e90773a6ebfda9e35306d625dc78.zip
Merge branch 'master' into fix-8869
Diffstat (limited to 'js')
-rw-r--r--js/.jscsrc (renamed from js/.jscs.json)12
-rw-r--r--js/.jshintrc4
-rw-r--r--js/affix.js2
-rw-r--r--js/collapse.js10
-rw-r--r--js/dropdown.js6
-rw-r--r--js/tests/index.html28
-rw-r--r--js/tests/unit/tooltip.js25
-rw-r--r--js/transition.js8
8 files changed, 63 insertions, 32 deletions
diff --git a/js/.jscs.json b/js/.jscsrc
index 313bfb690..fc8bc88ca 100644
--- a/js/.jscs.json
+++ b/js/.jscsrc
@@ -1,15 +1,23 @@
{
+ "disallowEmptyBlocks": true,
"disallowKeywords": ["with"],
- "requireLeftStickedOperators": [","],
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
+ "disallowMixedSpacesAndTabs": true,
+ "disallowMultipleLineStrings": true,
+ "disallowQuotedKeysInObjects": "allButReserved",
"disallowRightStickedOperators": ["?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
+ "disallowTrailingWhitespace": true,
+ "requireCamelCaseOrUpperCaseIdentifiers": true,
+ "requireLeftStickedOperators": [","],
"requireLineFeedAtFileEnd": true,
"requireRightStickedOperators": ["!"],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true },
- "validateLineBreaks": "LF"
+ "validateIndentation": 2,
+ "validateLineBreaks": "LF",
+ "validateQuoteMarks": "'"
}
diff --git a/js/.jshintrc b/js/.jshintrc
index ae8a0b404..e1ead322e 100644
--- a/js/.jshintrc
+++ b/js/.jshintrc
@@ -7,8 +7,6 @@
"eqeqeq" : false,
"eqnull" : true,
"expr" : true,
- "indent" : 2,
"laxbreak" : true,
- "quotmark" : "single",
"validthis": true
-} \ No newline at end of file
+}
diff --git a/js/affix.js b/js/affix.js
index 05c909e16..84953c5cd 100644
--- a/js/affix.js
+++ b/js/affix.js
@@ -66,7 +66,7 @@
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return
- if (this.unpin) this.$element.css('top', '')
+ if (this.unpin != null) this.$element.css('top', '')
var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix')
diff --git a/js/collapse.js b/js/collapse.js
index 7130282b0..59e27f13d 100644
--- a/js/collapse.js
+++ b/js/collapse.js
@@ -56,7 +56,8 @@
this.transitioning = 1
- var complete = function () {
+ var complete = function (e) {
+ if (e && e.target != this.$element[0]) return
this.$element
.removeClass('collapsing')
.addClass('collapse in')
@@ -95,7 +96,8 @@
this.transitioning = 1
- var complete = function () {
+ var complete = function (e) {
+ if (e && e.target != this.$element[0]) return
this.transitioning = 0
this.$element
.trigger('hidden.bs.collapse')
@@ -148,7 +150,7 @@
// COLLAPSE DATA-API
// =================
- $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
+ $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
var $this = $(this), href
var target = $this.attr('data-target')
|| e.preventDefault()
@@ -160,7 +162,7 @@
var $parent = parent && $(parent)
if (!data || !data.transitioning) {
- if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
+ if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
}
diff --git a/js/dropdown.js b/js/dropdown.js
index 6e206a0d1..b35ce562d 100644
--- a/js/dropdown.js
+++ b/js/dropdown.js
@@ -14,7 +14,7 @@
// =========================
var backdrop = '.dropdown-backdrop'
- var toggle = '[data-toggle=dropdown]'
+ var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
}
@@ -69,7 +69,7 @@
}
var desc = ' li:not(.divider):visible a'
- var $items = $parent.find('[role=menu]' + desc + ', [role=listbox]' + desc)
+ var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return
@@ -142,6 +142,6 @@
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
- .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu], [role=listbox]', Dropdown.prototype.keydown)
+ .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
}(jQuery);
diff --git a/js/tests/index.html b/js/tests/index.html
index 60f543abf..c6d3d27af 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -11,8 +11,32 @@
<script src="vendor/qunit.js"></script>
<script>
// See https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit
- QUnit.done(function (results) {
- window.global_test_results = results
+ var log = []
+ QUnit.done = function (test_results) {
+ var tests = log.map(function (details) {
+ return {
+ name: details.name,
+ result: details.result,
+ expected: details.expected,
+ actual: details.actual,
+ source: details.source
+ }
+ })
+ test_results.tests = tests
+
+ // Delaying results a bit because in real-world scenario you won't get them immediately
+ setTimeout(function () {
+ window.global_test_results = test_results
+ }, 2000)
+ }
+
+ QUnit.testStart(function (testDetails) {
+ QUnit.log = function (details) {
+ if (!details.result) {
+ details.name = testDetails.name
+ log.push(details)
+ }
+ }
})
</script>
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index c3af7d82e..9df234236 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -273,8 +273,7 @@ $(function () {
test('should show tooltip with delegate selector on click', function () {
var div = $('<div><a href="#" rel="tooltip" title="Another tooltip"></a></div>')
var tooltip = div.appendTo('#qunit-fixture')
- .tooltip({ selector: 'a[rel=tooltip]',
- trigger: 'click' })
+ .tooltip({ selector: 'a[rel=tooltip]', trigger: 'click' })
div.find('a').trigger('click')
ok($('.tooltip').is('.fade.in'), 'tooltip is faded in')
})
@@ -392,21 +391,21 @@ $(function () {
test('tooltips should be placed dynamically, with the dynamic placement option', function () {
$.support.transition = false
var ttContainer = $('<div id="dynamic-tt-test"/>').css({
- 'height' : 400,
- 'overflow' : 'hidden',
- 'position' : 'absolute',
- 'top' : 0,
- 'left' : 0,
- 'width' : 600
- })
- .appendTo('body')
+ height : 400,
+ overflow : 'hidden',
+ position : 'absolute',
+ top : 0,
+ left : 0,
+ width : 600
+ })
+ .appendTo('body')
var topTooltip = $('<div style="display: inline-block; position: absolute; left: 0; top: 0;" rel="tooltip" title="Top tooltip">Top Dynamic Tooltip</div>')
.appendTo('#dynamic-tt-test')
.tooltip({placement: 'auto'})
.tooltip('show')
- ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned bottom')
+ ok($('.tooltip').is('.bottom'), 'top positioned tooltip is dynamically positioned bottom')
topTooltip.tooltip('hide')
@@ -415,7 +414,7 @@ $(function () {
.tooltip({placement: 'right auto'})
.tooltip('show')
- ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
+ ok($('.tooltip').is('.left'), 'right positioned tooltip is dynamically positioned left')
rightTooltip.tooltip('hide')
var leftTooltip = $('<div style="display: inline-block; position: absolute; left: 0;" rel="tooltip" title="Left tooltip">Left Dynamic Tooltip</div>')
@@ -423,7 +422,7 @@ $(function () {
.tooltip({placement: 'auto left'})
.tooltip('show')
- ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
+ ok($('.tooltip').is('.right'), 'left positioned tooltip is dynamically positioned right')
leftTooltip.tooltip('hide')
ttContainer.remove()
diff --git a/js/transition.js b/js/transition.js
index efa8c1716..b8559c74e 100644
--- a/js/transition.js
+++ b/js/transition.js
@@ -17,10 +17,10 @@
var el = document.createElement('bootstrap')
var transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd',
- 'MozTransition' : 'transitionend',
- 'OTransition' : 'oTransitionEnd otransitionend',
- 'transition' : 'transitionend'
+ WebkitTransition : 'webkitTransitionEnd',
+ MozTransition : 'transitionend',
+ OTransition : 'oTransitionEnd otransitionend',
+ transition : 'transitionend'
}
for (var name in transEndEventNames) {