diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/.jscs.json | 14 | ||||
| -rw-r--r-- | js/.jshintrc | 1 | ||||
| -rw-r--r-- | js/affix.js | 10 | ||||
| -rw-r--r-- | js/alert.js | 8 | ||||
| -rw-r--r-- | js/button.js | 22 | ||||
| -rw-r--r-- | js/carousel.js | 18 | ||||
| -rw-r--r-- | js/collapse.js | 10 | ||||
| -rw-r--r-- | js/dropdown.js | 20 | ||||
| -rw-r--r-- | js/modal.js | 12 | ||||
| -rw-r--r-- | js/popover.js | 10 | ||||
| -rw-r--r-- | js/scrollspy.js | 12 | ||||
| -rw-r--r-- | js/tab.js | 12 | ||||
| -rw-r--r-- | js/tests/index.html | 2 | ||||
| -rw-r--r-- | js/tests/unit/affix.js | 10 | ||||
| -rw-r--r-- | js/tests/unit/alert.js | 14 | ||||
| -rw-r--r-- | js/tests/unit/button.js | 36 | ||||
| -rw-r--r-- | js/tests/unit/carousel.js | 34 | ||||
| -rw-r--r-- | js/tests/unit/collapse.js | 24 | ||||
| -rw-r--r-- | js/tests/unit/dropdown.js | 34 | ||||
| -rw-r--r-- | js/tests/unit/modal.js | 152 | ||||
| -rw-r--r-- | js/tests/unit/phantom.js | 24 | ||||
| -rw-r--r-- | js/tests/unit/popover.js | 38 | ||||
| -rw-r--r-- | js/tests/unit/scrollspy.js | 12 | ||||
| -rw-r--r-- | js/tests/unit/tab.js | 36 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 210 | ||||
| -rw-r--r-- | js/tests/unit/transition.js | 6 | ||||
| -rw-r--r-- | js/tooltip.js | 18 | ||||
| -rw-r--r-- | js/transition.js | 8 |
28 files changed, 417 insertions, 390 deletions
diff --git a/js/.jscs.json b/js/.jscs.json new file mode 100644 index 000000000..e02344fd5 --- /dev/null +++ b/js/.jscs.json @@ -0,0 +1,14 @@ +{ + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "requireRightStickedOperators": ["!"], + "disallowRightStickedOperators": ["?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowKeywords": ["with"], + "validateLineBreaks": "LF", + "requireLineFeedAtFileEnd": true +} diff --git a/js/.jshintrc b/js/.jshintrc index fdfdfbbfb..c8cccda37 100644 --- a/js/.jshintrc +++ b/js/.jshintrc @@ -10,5 +10,6 @@ "expr" : true, "laxbreak" : true, "laxcomma" : true, + "quotmark" : "single", "validthis": true }
\ No newline at end of file diff --git a/js/affix.js b/js/affix.js index c7be96e1d..0650ce3ae 100644 --- a/js/affix.js +++ b/js/affix.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: affix.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#affix + * Bootstrap: affix.js v3.0.3 + * http://getbootstrap.com/javascript/#affix * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // AFFIX CLASS DEFINITION // ====================== @@ -123,4 +123,4 @@ }) }) -}(window.jQuery); +}(jQuery); diff --git a/js/alert.js b/js/alert.js index 663029ed8..13a0cab91 100644 --- a/js/alert.js +++ b/js/alert.js @@ -1,6 +1,6 @@ /* ======================================================================== - * Bootstrap: alert.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#alerts + * Bootstrap: alert.js v3.0.3 + * http://getbootstrap.com/javascript/#alerts * ======================================================================== * Copyright 2013 Twitter, Inc. * @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // ALERT CLASS DEFINITION // ====================== @@ -95,4 +95,4 @@ $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) -}(window.jQuery); +}(jQuery); diff --git a/js/button.js b/js/button.js index fc73b555f..6c66960d8 100644 --- a/js/button.js +++ b/js/button.js @@ -1,6 +1,6 @@ /* ======================================================================== - * Bootstrap: button.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#buttons + * Bootstrap: button.js v3.0.3 + * http://getbootstrap.com/javascript/#buttons * ======================================================================== * Copyright 2013 Twitter, Inc. * @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // BUTTON PUBLIC CLASS DEFINITION // ============================== @@ -54,15 +54,21 @@ Button.prototype.toggle = function () { var $parent = this.$element.closest('[data-toggle="buttons"]') + var changed = true if ($parent.length) { var $input = this.$element.find('input') - .prop('checked', !this.$element.hasClass('active')) - .trigger('change') - if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + if ($input.prop('type') === 'radio') { + // see if clicking on current one + if ($input.prop('checked') && this.$element.hasClass('active')) + changed = false + else + $parent.find('.active').removeClass('active') + } + if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } - this.$element.toggleClass('active') + if (changed) this.$element.toggleClass('active') } @@ -106,4 +112,4 @@ e.preventDefault() }) -}(window.jQuery); +}(jQuery); diff --git a/js/carousel.js b/js/carousel.js index d8c4c243c..26f3832ff 100644 --- a/js/carousel.js +++ b/js/carousel.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: carousel.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#carousel + * Bootstrap: carousel.js v3.0.3 + * http://getbootstrap.com/javascript/#carousel * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // CAROUSEL CLASS DEFINITION // ========================= @@ -69,7 +69,7 @@ if (pos > (this.$items.length - 1) || pos < 0) return - if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) if (activeIndex == pos) return this.pause().cycle() return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) @@ -121,7 +121,7 @@ if (this.$indicators.length) { this.$indicators.find('.active').removeClass('active') - this.$element.one('slid', function () { + this.$element.one('slid.bs.carousel', function () { var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) $nextIndicator && $nextIndicator.addClass('active') }) @@ -139,7 +139,7 @@ $next.removeClass([type, direction].join(' ')).addClass('active') $active.removeClass(['active', direction].join(' ')) that.sliding = false - setTimeout(function () { that.$element.trigger('slid') }, 0) + setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) }) .emulateTransitionEnd(600) } else { @@ -148,7 +148,7 @@ $active.removeClass('active') $next.addClass('active') this.sliding = false - this.$element.trigger('slid') + this.$element.trigger('slid.bs.carousel') } isCycling && this.cycle() @@ -214,4 +214,4 @@ }) }) -}(window.jQuery); +}(jQuery); diff --git a/js/collapse.js b/js/collapse.js index 92cc0bc76..7bc9fcb42 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: collapse.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#collapse + * Bootstrap: collapse.js v3.0.3 + * http://getbootstrap.com/javascript/#collapse * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION // ================================ @@ -176,4 +176,4 @@ $target.collapse(option) }) -}(window.jQuery); +}(jQuery); diff --git a/js/dropdown.js b/js/dropdown.js index 6093f11a8..3f71c7569 100644 --- a/js/dropdown.js +++ b/js/dropdown.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: dropdown.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * Bootstrap: dropdown.js v3.0.3 + * http://getbootstrap.com/javascript/#dropdowns * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // DROPDOWN CLASS DEFINITION // ========================= @@ -26,7 +26,7 @@ var backdrop = '.dropdown-backdrop' var toggle = '[data-toggle=dropdown]' var Dropdown = function (element) { - var $el = $(element).on('click.bs.dropdown', this.toggle) + $(element).on('click.bs.dropdown', this.toggle) } Dropdown.prototype.toggle = function (e) { @@ -41,7 +41,7 @@ if (!isActive) { if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { - // if mobile we we use a backdrop because click events don't delegate + // if mobile we use a backdrop because click events don't delegate $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) } @@ -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() } @@ -123,9 +123,9 @@ $.fn.dropdown = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('dropdown') + var data = $this.data('bs.dropdown') - if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) if (typeof option == 'string') data[option].call($this) }) } @@ -151,4 +151,4 @@ .on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) -}(window.jQuery); +}(jQuery); diff --git a/js/modal.js b/js/modal.js index 65eba481e..15b81c362 100644 --- a/js/modal.js +++ b/js/modal.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: modal.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#modals + * Bootstrap: modal.js v3.0.3 + * http://getbootstrap.com/javascript/#modals * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // MODAL CLASS DEFINITION // ====================== @@ -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) : @@ -243,4 +243,4 @@ .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') }) -}(window.jQuery); +}(jQuery); diff --git a/js/popover.js b/js/popover.js index ecd37ac23..d26d386b6 100644 --- a/js/popover.js +++ b/js/popover.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: popover.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#popovers + * Bootstrap: popover.js v3.0.3 + * http://getbootstrap.com/javascript/#popovers * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // POPOVER PUBLIC CLASS DEFINITION // =============================== @@ -114,4 +114,4 @@ return this } -}(window.jQuery); +}(jQuery); diff --git a/js/scrollspy.js b/js/scrollspy.js index 10f95f249..8c4d13490 100644 --- a/js/scrollspy.js +++ b/js/scrollspy.js @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: scrollspy.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#scrollspy + * Bootstrap: scrollspy.js v3.0.3 + * http://getbootstrap.com/javascript/#scrollspy * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // SCROLLSPY CLASS DEFINITION // ========================== @@ -113,7 +113,7 @@ .addClass('active') } - active.trigger('activate') + active.trigger('activate.bs.scrollspy') } @@ -155,4 +155,4 @@ }) }) -}(window.jQuery); +}(jQuery); @@ -1,8 +1,8 @@ /* ======================================================================== - * Bootstrap: tab.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#tabs + * Bootstrap: tab.js v3.0.3 + * http://getbootstrap.com/javascript/#tabs * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // TAB CLASS DEFINITION // ==================== @@ -30,7 +30,7 @@ Tab.prototype.show = function () { var $this = this.element var $ul = $this.closest('ul:not(.dropdown-menu)') - var selector = $this.attr('data-target') + var selector = $this.data('target') if (!selector) { selector = $this.attr('href') @@ -132,4 +132,4 @@ $(this).tab('show') }) -}(window.jQuery); +}(jQuery); diff --git a/js/tests/index.html b/js/tests/index.html index 501bf38f2..4e3d487db 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -8,7 +8,7 @@ <script src="vendor/jquery.js"></script> <!-- qunit --> - <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" /> + <link rel="stylesheet" href="vendor/qunit.css" media="screen"> <script src="vendor/qunit.js"></script> <!-- plugin sources --> diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index b74bc51e4..6085a141e 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -1,22 +1,22 @@ $(function () { - module("affix") + module('affix') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var affix = $.fn.affix.noConflict() ok(!$.fn.affix, 'affix was set back to undefined (org value)') $.fn.affix = affix }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).affix, 'affix method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).affix()[0] == document.body, 'document.body returned') }) - test("should exit early if element is not visible", function () { + test('should exit early if element is not visible', function () { var $affix = $('<div style="display: none"></div>').affix() $affix.data('bs.affix').checkPosition() ok(!$affix.hasClass('affix'), 'affix class was not added') diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 98b10059e..5e39bbab6 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -1,22 +1,22 @@ $(function () { - module("alert") + module('alert') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var alert = $.fn.alert.noConflict() ok(!$.fn.alert, 'alert was set back to undefined (org value)') $.fn.alert = alert }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).alert, 'alert method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).alert()[0] == document.body, 'document.body returned') }) - test("should fade element out on clicking .close", function () { + test('should fade element out on clicking .close', function () { var alertHTML = '<div class="alert-message warning fade in">' + '<a class="close" href="#" data-dismiss="alert">×</a>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' @@ -28,7 +28,7 @@ $(function () { ok(!alert.hasClass('in'), 'remove .in class on .close click') }) - test("should remove element when clicking .close", function () { + test('should remove element when clicking .close', function () { $.support.transition = false var alertHTML = '<div class="alert-message warning fade in">' @@ -44,7 +44,7 @@ $(function () { ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom') }) - test("should not fire closed when close is prevented", function () { + test('should not fire closed when close is prevented', function () { $.support.transition = false stop(); $('<div class="alert"/>') diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 41ddb5c2f..45397aeff 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -1,26 +1,26 @@ $(function () { - module("button") + module('button') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var button = $.fn.button.noConflict() ok(!$.fn.button, 'button was set back to undefined (org value)') $.fn.button = button }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).button, 'button method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).button()[0] == document.body, 'document.body returned') }) - test("should return set state to loading", function () { + test('should return set state to loading', function () { var btn = $('<button class="btn" data-loading-text="fat">mdo</button>') - equals(btn.html(), 'mdo', 'btn text equals mdo') + equal(btn.html(), 'mdo', 'btn text equals mdo') btn.button('loading') - equals(btn.html(), 'fat', 'btn text equals fat') + equal(btn.html(), 'fat', 'btn text equals fat') stop() setTimeout(function () { ok(btn.attr('disabled'), 'btn is disabled') @@ -29,11 +29,11 @@ $(function () { }, 0) }) - test("should return reset state", function () { + test('should return reset state', function () { var btn = $('<button class="btn" data-loading-text="fat">mdo</button>') - equals(btn.html(), 'mdo', 'btn text equals mdo') + equal(btn.html(), 'mdo', 'btn text equals mdo') btn.button('loading') - equals(btn.html(), 'fat', 'btn text equals fat') + equal(btn.html(), 'fat', 'btn text equals fat') stop() setTimeout(function () { ok(btn.attr('disabled'), 'btn is disabled') @@ -41,7 +41,7 @@ $(function () { start() stop() btn.button('reset') - equals(btn.html(), 'mdo', 'btn text equals mdo') + equal(btn.html(), 'mdo', 'btn text equals mdo') setTimeout(function () { ok(!btn.attr('disabled'), 'btn is not disabled') ok(!btn.hasClass('disabled'), 'btn does not have disabled class') @@ -51,14 +51,14 @@ $(function () { }) - test("should toggle active", function () { + test('should toggle active', function () { var btn = $('<button class="btn">mdo</button>') ok(!btn.hasClass('active'), 'btn does not have active class') btn.button('toggle') ok(btn.hasClass('active'), 'btn has class active') }) - test("should toggle active when btn children are clicked", function () { + test('should toggle active when btn children are clicked', function () { var btn = $('<button class="btn" data-toggle="button">mdo</button>') , inner = $('<i></i>') btn @@ -69,7 +69,7 @@ $(function () { ok(btn.hasClass('active'), 'btn has class active') }) - test("should toggle active when btn children are clicked within btn-group", function () { + test('should toggle active when btn children are clicked within btn-group', function () { var btngroup = $('<div class="btn-group" data-toggle="buttons"></div>') , btn = $('<button class="btn">fat</button>') , inner = $('<i></i>') @@ -81,7 +81,7 @@ $(function () { ok(btn.hasClass('active'), 'btn has class active') }) - test("should check for closest matching toggle", function () { + test('should check for closest matching toggle', function () { var group = '<div class="btn-group" data-toggle="buttons">' + '<label class="btn btn-primary active">' + '<input type="radio" name="options" id="option1" checked="true"> Option 1' + @@ -111,6 +111,12 @@ $(function () { ok(!btn1.find('input').prop('checked'), 'btn1 is checked') ok(btn2.hasClass('active'), 'btn2 has active class') ok(btn2.find('input').prop('checked'), 'btn2 is checked') + + btn2.find('input').click() /* clicking an already checked radio should not un-check it */ + ok(!btn1.hasClass('active'), 'btn1 does not have active class') + ok(!btn1.find('input').prop('checked'), 'btn1 is checked') + ok(btn2.hasClass('active'), 'btn2 has active class') + ok(btn2.find('input').prop('checked'), 'btn2 is checked') }) }) diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index badf0886d..8d1726b71 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -1,22 +1,22 @@ $(function () { - module("carousel") + module('carousel') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var carousel = $.fn.carousel.noConflict() ok(!$.fn.carousel, 'carousel was set back to undefined (org value)') $.fn.carousel = carousel }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).carousel, 'carousel method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).carousel()[0] == document.body, 'document.body returned') }) - test("should not fire sliden when slide is prevented", function () { + test('should not fire sliden when slide is prevented', function () { $.support.transition = false stop() $('<div class="carousel"/>') @@ -31,7 +31,7 @@ $(function () { .carousel('next') }) - test("should fire slide event with direction", function () { + test('should fire slide event with direction', function () { var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</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="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</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="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</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">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>' $.support.transition = false stop() @@ -43,7 +43,7 @@ $(function () { }).carousel('next') }) - test("should fire slide event with relatedTarget", function () { + test('should fire slide event with relatedTarget', function () { var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</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="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</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="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</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">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>' $.support.transition = false stop() @@ -57,31 +57,31 @@ $(function () { .carousel('next') }) - test("should set interval from data attribute", 4, function () { + test('should set interval from data attribute', 4, function () { var template = $('<div id="myCarousel" class="carousel slide"> <div class="carousel-inner"> <div class="item active"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}First Thumbnail label{{/i}}</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="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Second Thumbnail label{{/i}}</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="item"> <img alt=""> <div class="carousel-caption"> <h4>{{_i}}Third Thumbnail label{{/i}}</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">‹</a> <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a> </div>'); - template.attr("data-interval", 1814); + template.attr('data-interval', 1814); - template.appendTo("body"); + template.appendTo('body'); $('[data-slide]').first().click(); ok($('#myCarousel').data('bs.carousel').options.interval == 1814); $('#myCarousel').remove(); - template.appendTo("body").attr("data-modal", "foobar"); + template.appendTo('body').attr('data-modal', 'foobar'); $('[data-slide]').first().click(); - ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "even if there is an data-modal attribute set"); + ok($('#myCarousel').data('bs.carousel').options.interval == 1814, 'even if there is an data-modal attribute set'); $('#myCarousel').remove(); - template.appendTo("body"); + template.appendTo('body'); $('[data-slide]').first().click(); $('#myCarousel').attr('data-interval', 1860); $('[data-slide]').first().click(); - ok($('#myCarousel').data('bs.carousel').options.interval == 1814, "attributes should be read only on intitialization"); + ok($('#myCarousel').data('bs.carousel').options.interval == 1814, 'attributes should be read only on intitialization'); $('#myCarousel').remove(); - template.attr("data-interval", false); - template.appendTo("body"); + template.attr('data-interval', false); + template.appendTo('body'); $('#myCarousel').carousel(1); - ok($('#myCarousel').data('bs.carousel').options.interval === false, "data attribute has higher priority than default options"); + ok($('#myCarousel').data('bs.carousel').options.interval === false, 'data attribute has higher priority than default options'); $('#myCarousel').remove(); }) }) diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 11b2cf838..10d5aeda6 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -1,34 +1,34 @@ $(function () { - module("collapse") + module('collapse') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var collapse = $.fn.collapse.noConflict() ok(!$.fn.collapse, 'collapse was set back to undefined (org value)') $.fn.collapse = collapse }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).collapse, 'collapse method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).collapse()[0] == document.body, 'document.body returned') }) - test("should show a collapsed element", function () { + test('should show a collapsed element', function () { var el = $('<div class="collapse"></div>').collapse('show') ok(el.hasClass('in'), 'has class in') ok(/height/.test(el.attr('style')), 'has height set') }) - test("should hide a collapsed element", function () { + test('should hide a collapsed element', function () { var el = $('<div class="collapse"></div>').collapse('hide') ok(!el.hasClass('in'), 'does not have class in') ok(/height/.test(el.attr('style')), 'has height set') }) - test("should not fire shown when show is prevented", function () { + test('should not fire shown when show is prevented', function () { $.support.transition = false stop() $('<div class="collapse"/>') @@ -43,7 +43,7 @@ $(function () { .collapse('show') }) - test("should reset style to auto after finishing opening collapse", function () { + test('should reset style to auto after finishing opening collapse', function () { $.support.transition = false stop() $('<div class="collapse" style="height: 0px"/>') @@ -57,7 +57,7 @@ $(function () { .collapse('show') }) - test("should add active class to target when collapse shown", function () { + test('should add active class to target when collapse shown', function () { $.support.transition = false stop() @@ -74,7 +74,7 @@ $(function () { target.click() }) - test("should remove active class to target when collapse hidden", function () { + test('should remove active class to target when collapse hidden', function () { $.support.transition = false stop() @@ -91,7 +91,7 @@ $(function () { target.click() }) - test("should remove active class from inactive accordion targets", function () { + test('should remove active class from inactive accordion targets', function () { $.support.transition = false stop() @@ -126,7 +126,7 @@ $(function () { target3.click() }) - test("should allow dots in data-parent", function () { + test('should allow dots in data-parent', function () { $.support.transition = false stop() diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 02256965d..c94cf4fca 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -1,23 +1,23 @@ $(function () { - module("dropdowns") + module('dropdowns') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var dropdown = $.fn.dropdown.noConflict() ok(!$.fn.dropdown, 'dropdown was set back to undefined (org value)') $.fn.dropdown = dropdown }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).dropdown, 'dropdown method is defined') }) - test("should return element", function () { - var el = $("<div />") + test('should return element', function () { + var el = $('<div />') ok(el.dropdown()[0] === el[0], 'same element returned') }) - test("should not open dropdown if target is disabled", function () { + test('should not open dropdown if target is disabled', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>' @@ -34,7 +34,7 @@ $(function () { ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) - test("should not open dropdown if target is disabled", function () { + test('should not open dropdown if target is disabled', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>' @@ -51,7 +51,7 @@ $(function () { ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) - test("should add class open to menu if clicked", function () { + test('should add class open to menu if clicked', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' @@ -68,7 +68,7 @@ $(function () { ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) - test("should test if element has a # before assuming it's a selector", function () { + test('should test if element has a # before assuming it\'s a selector', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' @@ -86,7 +86,7 @@ $(function () { }) - test("should remove open class if body clicked", function () { + test('should remove open class if body clicked', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' @@ -110,7 +110,7 @@ $(function () { dropdown.remove() }) - test("should remove open class if body clicked, with multiple drop downs", function () { + test('should remove open class if body clicked, with multiple drop downs', function () { var dropdownHTML = '<ul class="nav">' + ' <li><a href="#menu1">Menu 1</a></li>' @@ -132,24 +132,24 @@ $(function () { , first = dropdowns.first() , last = dropdowns.last() - ok(dropdowns.length == 2, "Should be two dropdowns") + ok(dropdowns.length == 2, 'Should be two dropdowns') first.click() ok(first.parents('.open').length == 1, 'open class added on click') ok($('#qunit-fixture .open').length == 1, 'only one object is open') $('body').click() - ok($("#qunit-fixture .open").length === 0, 'open class removed') + ok($('#qunit-fixture .open').length === 0, 'open class removed') last.click() ok(last.parent('.open').length == 1, 'open class added on click') ok($('#qunit-fixture .open').length == 1, 'only one object is open') $('body').click() - ok($("#qunit-fixture .open").length === 0, 'open class removed') + ok($('#qunit-fixture .open').length === 0, 'open class removed') - $("#qunit-fixture").html("") + $('#qunit-fixture').html('') }) - test("should fire show and hide event", function () { + test('should fire show and hide event', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' @@ -183,7 +183,7 @@ $(function () { }) - test("should fire shown and hiden event", function () { + test('should fire shown and hiden event', function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>' diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 5755d2751..6b2074327 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -1,195 +1,195 @@ $(function () { - module("modal") + module('modal') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var modal = $.fn.modal.noConflict() ok(!$.fn.modal, 'modal was set back to undefined (org value)') $.fn.modal = modal }) - test("should be defined on jquery object", function () { - var div = $("<div id='modal-test'></div>") + test('should be defined on jquery object', function () { + var div = $('<div id="modal-test"></div>') ok(div.modal, 'modal method is defined') }) - test("should return element", function () { - var div = $("<div id='modal-test'></div>") + test('should return element', function () { + var div = $('<div id="modal-test"></div>') ok(div.modal() == div, 'document.body returned') $('#modal-test').remove() }) - test("should expose defaults var for settings", function () { + test('should expose defaults var for settings', function () { ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed') }) - test("should insert into dom when show method is called", function () { + test('should insert into dom when show method is called', function () { stop() $.support.transition = false - $("<div id='modal-test'></div>") - .on("shown.bs.modal", function () { + $('<div id="modal-test"></div>') + .on('shown.bs.modal', function () { ok($('#modal-test').length, 'modal inserted into dom') $(this).remove() start() }) - .modal("show") + .modal('show') }) - test("should fire show event", function () { + test('should fire show event', function () { stop() $.support.transition = false - $("<div id='modal-test'></div>") - .on("show.bs.modal", function () { - ok(true, "show was called") + $('<div id="modal-test"></div>') + .on('show.bs.modal', function () { + ok(true, 'show was called') }) - .on("shown.bs.modal", function () { + .on('shown.bs.modal', function () { $(this).remove() start() }) - .modal("show") + .modal('show') }) - test("should not fire shown when default prevented", function () { + test('should not fire shown when default prevented', function () { stop() $.support.transition = false - $("<div id='modal-test'></div>") - .on("show.bs.modal", function (e) { + $('<div id="modal-test"></div>') + .on('show.bs.modal', function (e) { e.preventDefault() - ok(true, "show was called") + ok(true, 'show was called') start() }) - .on("shown.bs.modal", function () { - ok(false, "shown was called") + .on('shown.bs.modal', function () { + ok(false, 'shown was called') }) - .modal("show") + .modal('show') }) - test("should hide modal when hide is called", function () { + test('should hide modal when hide is called', function () { stop() $.support.transition = false - $("<div id='modal-test'></div>") - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') + $('<div id="modal-test"></div>') + .on('shown.bs.modal', function () { + ok($('#modal-test').is(':visible'), 'modal visible') ok($('#modal-test').length, 'modal inserted into dom') - $(this).modal("hide") + $(this).modal('hide') }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') + .on('hidden.bs.modal', function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') $('#modal-test').remove() start() }) - .modal("show") + .modal('show') }) - test("should toggle when toggle is called", function () { + test('should toggle when toggle is called', function () { stop() $.support.transition = false - var div = $("<div id='modal-test'></div>") + var div = $('<div id="modal-test"></div>') div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') + .on('shown.bs.modal', function () { + ok($('#modal-test').is(':visible'), 'modal visible') ok($('#modal-test').length, 'modal inserted into dom') - div.modal("toggle") + div.modal('toggle') }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') + .on('hidden.bs.modal', function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') div.remove() start() }) - .modal("toggle") + .modal('toggle') }) - test("should remove from dom when click [data-dismiss=modal]", function () { + test('should remove from dom when click [data-dismiss=modal]', function () { stop() $.support.transition = false - var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>") + var div = $('<div id="modal-test"><span class="close" data-dismiss="modal"></span></div>') div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') + .on('shown.bs.modal', function () { + ok($('#modal-test').is(':visible'), 'modal visible') ok($('#modal-test').length, 'modal inserted into dom') div.find('.close').click() }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') + .on('hidden.bs.modal', function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') div.remove() start() }) - .modal("toggle") + .modal('toggle') }) - test("should allow modal close with 'backdrop:false'", function () { + test('should allow modal close with "backdrop:false"', function () { stop() $.support.transition = false - var div = $("<div>", { id: 'modal-test', "data-backdrop": false }) + var div = $('<div>', { id: 'modal-test', 'data-backdrop': false }) div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - div.modal("hide") + .on('shown.bs.modal', function () { + ok($('#modal-test').is(':visible'), 'modal visible') + div.modal('hide') }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') + .on('hidden.bs.modal', function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') div.remove() start() }) - .modal("show") + .modal('show') }) - test("should close modal when clicking outside of modal-content", function () { + test('should close modal when clicking outside of modal-content', function () { stop() $.support.transition = false - var div = $("<div id='modal-test'><div class='contents'></div></div>") + var div = $('<div id="modal-test"><div class="contents"></div></div>') div - .bind("shown.bs.modal", function () { + .bind('shown.bs.modal', function () { ok($('#modal-test').length, 'modal insterted into dom') $('.contents').click() - ok($('#modal-test').is(":visible"), 'modal visible') + ok($('#modal-test').is(':visible'), 'modal visible') $('#modal-test').click() }) - .bind("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') + .bind('hidden.bs.modal', function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') div.remove() start() }) - .modal("show") + .modal('show') }) - test("should trigger hide event once when clicking outside of modal-content", function () { + test('should trigger hide event once when clicking outside of modal-content', function () { stop() $.support.transition = false - var div = $("<div id='modal-test'><div class='contents'></div></div>") + var div = $('<div id="modal-test"><div class="contents"></div></div>') var triggered div - .bind("shown.bs.modal", function () { + .bind('shown.bs.modal', function () { triggered = 0 $('#modal-test').click() }) - .one("hidden.bs.modal", function() { - div.modal("show") + .one('hidden.bs.modal', function () { + div.modal('show') }) - .bind("hide.bs.modal", function () { + .bind('hide.bs.modal', function () { triggered += 1 ok(triggered === 1, 'modal hide triggered once') start() }) - .modal("show") + .modal('show') }) - test("should close reopened modal with [data-dismiss=modal] click", function () { + test('should close reopened modal with [data-dismiss=modal] click', function () { stop() $.support.transition = false - var div = $("<div id='modal-test'><div class='contents'><div id='close' data-dismiss='modal'></div></div></div>") + var div = $('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"></div></div></div>') div - .bind("shown.bs.modal", function () { + .bind('shown.bs.modal', function () { $('#close').click() - ok(!$('#modal-test').is(":visible"), 'modal hidden') + 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") + }).modal('show') }) - .modal("show") + .modal('show') div.remove() }) diff --git a/js/tests/unit/phantom.js b/js/tests/unit/phantom.js index c584c5a35..bf480ecaa 100644 --- a/js/tests/unit/phantom.js +++ b/js/tests/unit/phantom.js @@ -2,7 +2,7 @@ * grunt-contrib-qunit * http://gruntjs.com/ * - * Copyright (c) 2013 "Cowboy" Ben Alman, contributors + * Copyright (c) 2013 'Cowboy' Ben Alman, contributors * Licensed under the MIT license. */ @@ -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,37 +32,37 @@ 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) } QUnit.begin = function () { sendMessage('qunit.begin') - console.log("Starting test suite") - console.log("================================================\n") + console.log('Starting test suite') + console.log('================================================\n') } QUnit.moduleDone = function (opts) { if (opts.failed === 0) { - console.log("\r\u2714 All tests passed in '" + opts.name + "' module") + console.log('\r\u2714 All tests passed in "' + opts.name + '" module') } else { - console.log("\u2716 " + opts.failed + " tests failed in '" + opts.name + "' module") + console.log('\u2716 ' + opts.failed + ' tests failed in "' + opts.name + '" module') } sendMessage('qunit.moduleDone', opts.name, opts.failed, opts.passed, opts.total) } QUnit.done = function (opts) { - console.log("\n================================================") - console.log("Tests completed in " + opts.runtime + " milliseconds") - console.log(opts.passed + " tests of " + opts.total + " passed, " + opts.failed + " failed.") + console.log('\n================================================') + console.log('Tests completed in ' + opts.runtime + ' milliseconds') + console.log(opts.passed + ' tests of ' + opts.total + ' passed, ' + opts.failed + ' failed.') sendMessage('qunit.done', opts.failed, opts.passed, opts.total, opts.runtime) } diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 767d79864..5ed4252be 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -1,24 +1,24 @@ $(function () { - module("popover") + module('popover') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var popover = $.fn.popover.noConflict() ok(!$.fn.popover, 'popover was set back to undefined (org value)') $.fn.popover = popover }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { var div = $('<div></div>') ok(div.popover, 'popover method is defined') }) - test("should return element", function () { + test('should return element', function () { var div = $('<div></div>') ok(div.popover() == div, 'document.body returned') }) - test("should render popover element", function () { + test('should render popover element', function () { $.support.transition = false var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') .appendTo('#qunit-fixture') @@ -26,10 +26,10 @@ $(function () { ok($('.popover').length, 'popover was inserted') popover.popover('hide') - ok(!$(".popover").length, 'popover removed') + ok(!$('.popover').length, 'popover removed') }) - test("should store popover instance in popover data object", function () { + test('should store popover instance in popover data object', function () { $.support.transition = false var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') .popover() @@ -37,7 +37,7 @@ $(function () { ok(!!popover.data('bs.popover'), 'popover instance exists') }) - test("should get title and content from options", function () { + test('should get title and content from options', function () { $.support.transition = false var popover = $('<a href="#">@fat</a>') .appendTo('#qunit-fixture') @@ -53,15 +53,15 @@ $(function () { popover.popover('show') ok($('.popover').length, 'popover was inserted') - equals($('.popover .popover-title').text(), '@fat', 'title correctly inserted') - equals($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted') + equal($('.popover .popover-title').text(), '@fat', 'title correctly inserted') + equal($('.popover .popover-content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted') popover.popover('hide') ok(!$('.popover').length, 'popover was removed') $('#qunit-fixture').empty() }) - test("should get title and content from attributes", function () { + test('should get title and content from attributes', function () { $.support.transition = false var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') .appendTo('#qunit-fixture') @@ -69,8 +69,8 @@ $(function () { .popover('show') ok($('.popover').length, 'popover was inserted') - equals($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') - equals($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted') + equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') + equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted') popover.popover('hide') ok(!$('.popover').length, 'popover was removed') @@ -78,7 +78,7 @@ $(function () { }) - test("should get title and content from attributes #2", function () { + test('should get title and content from attributes #2', function () { $.support.transition = false var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>') .appendTo('#qunit-fixture') @@ -89,15 +89,15 @@ $(function () { .popover('show') ok($('.popover').length, 'popover was inserted') - equals($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') - equals($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted') + equal($('.popover .popover-title').text(), '@mdo', 'title correctly inserted') + equal($('.popover .popover-content').text(), 'loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻', 'content correctly inserted') popover.popover('hide') ok(!$('.popover').length, 'popover was removed') $('#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') @@ -117,8 +117,8 @@ $(function () { $('#qunit-fixture').empty() }) - test("should destroy popover", function () { - var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){}) + test('should destroy popover', 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..8ebf3dcdf 100644 --- a/js/tests/unit/scrollspy.js +++ b/js/tests/unit/scrollspy.js @@ -1,25 +1,25 @@ $(function () { - module("scrollspy") + module('scrollspy') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var scrollspy = $.fn.scrollspy.noConflict() ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)') $.fn.scrollspy = scrollspy }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).scrollspy, 'scrollspy method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).scrollspy()[0] == document.body, 'document.body returned') }) - test("should switch active class on scroll", 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 aede32abb..6da7dc9a4 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -1,55 +1,55 @@ $(function () { - module("tabs") + module('tabs') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var tab = $.fn.tab.noConflict() ok(!$.fn.tab, 'tab was set back to undefined (org value)') $.fn.tab = tab }) - test("should be defined on jquery object", function () { + test('should be defined on jquery object', function () { ok($(document.body).tab, 'tabs method is defined') }) - test("should return element", function () { + test('should return element', function () { ok($(document.body).tab()[0] == document.body, 'document.body returned') }) - test("should activate element by tab id", function () { + test('should activate element by tab id', function () { var tabsHTML = '<ul class="tabs">' + '<li><a href="#home">Home</a></li>' + '<li><a href="#profile">Profile</a></li>' + '</ul>' - $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture") + $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') $(tabsHTML).find('li:last a').tab('show') - equals($("#qunit-fixture").find('.active').attr('id'), "profile") + equal($('#qunit-fixture').find('.active').attr('id'), 'profile') $(tabsHTML).find('li:first a').tab('show') - equals($("#qunit-fixture").find('.active').attr('id'), "home") + equal($('#qunit-fixture').find('.active').attr('id'), 'home') }) - test("should activate element by tab id", function () { + test('should activate element by tab id', function () { var pillsHTML = '<ul class="pills">' + '<li><a href="#home">Home</a></li>' + '<li><a href="#profile">Profile</a></li>' + '</ul>' - $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture") + $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') $(pillsHTML).find('li:last a').tab('show') - equals($("#qunit-fixture").find('.active').attr('id'), "profile") + equal($('#qunit-fixture').find('.active').attr('id'), 'profile') $(pillsHTML).find('li:first a').tab('show') - equals($("#qunit-fixture").find('.active').attr('id'), "home") + equal($('#qunit-fixture').find('.active').attr('id'), 'home') }) - test("should not fire closed when close is prevented", function () { + test('should not fire closed when close is prevented', function () { $.support.transition = false stop(); $('<div class="tab"/>') @@ -64,7 +64,7 @@ $(function () { .tab('show') }) - test("show and shown events should reference correct relatedTarget", function () { + test('show and shown events should reference correct relatedTarget', function () { var dropHTML = '<ul class="drop">' + '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>' @@ -76,10 +76,10 @@ $(function () { + '</ul>' $(dropHTML).find('ul>li:first a').tab('show').end() - .find('ul>li:last a').on('show', function(event){ - equals(event.relatedTarget.hash, "#1-1") - }).on('shown', function(event){ - equals(event.relatedTarget.hash, "#1-1") + .find('ul>li:last a').on('show', function (event) { + equal(event.relatedTarget.hash, '#1-1') + }).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 ed1bf54b3..dbfeacb82 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -1,49 +1,49 @@ $(function () { - module("tooltip") + module('tooltip') - test("should provide no conflict", function () { + test('should provide no conflict', function () { var tooltip = $.fn.tooltip.noConflict() ok(!$.fn.tooltip, 'tooltip was set back to undefined (org value)') $.fn.tooltip = tooltip }) - test("should be defined on jquery object", function () { - var div = $("<div></div>") + test('should be defined on jquery object', function () { + var div = $('<div></div>') ok(div.tooltip, 'popover method is defined') }) - test("should return element", function () { - var div = $("<div></div>") + test('should return element', function () { + var div = $('<div></div>') ok(div.tooltip() == div, 'document.body returned') }) - test("should expose default settings", function () { + test('should expose default settings', function () { ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined') }) - test("should empty title attribute", function () { + test('should empty title attribute', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').tooltip() ok(tooltip.attr('title') === '', 'title attribute was emptied') }) - test("should add data attribute for referencing original title", function () { + test('should add data attribute for referencing original title', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').tooltip() - equals(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute') + equal(tooltip.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute') }) - test("should place tooltips relative to placement option", function () { + test('should place tooltips relative to placement option', function () { $.support.transition = false var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({placement: 'bottom'}) .tooltip('show') - ok($(".tooltip").is('.fade.bottom.in'), 'has correct classes applied') + ok($('.tooltip').is('.fade.bottom.in'), 'has correct classes applied') tooltip.tooltip('hide') }) - test("should allow html entities", function () { + test('should allow html entities', function () { $.support.transition = false var tooltip = $('<a href="#" rel="tooltip" title="<b>@fat</b>"></a>') .appendTo('#qunit-fixture') @@ -52,10 +52,10 @@ $(function () { ok($('.tooltip b').length, 'b tag was inserted') tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') + ok(!$('.tooltip').length, 'tooltip removed') }) - test("should respect custom classes", function () { + test('should respect custom classes', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ template: '<div class="tooltip some-class"><div class="tooltip-arrow"/><div class="tooltip-inner"/></div>'}) @@ -63,87 +63,87 @@ $(function () { ok($('.tooltip').hasClass('some-class'), 'custom class is present') tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') + ok(!$('.tooltip').length, 'tooltip removed') }) - test("should fire show event", function () { + test('should fire show event', function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .on("show.bs.tooltip", function() { - ok(true, "show was called") + .on('show.bs.tooltip', function () { + ok(true, 'show was called') start() }) .tooltip('show') }) - test("should fire shown event", function () { + test('should fire shown event', function () { stop() var tooltip = $('<div title="tooltip title"></div>') - .on("shown.bs.tooltip", function() { - ok(true, "shown was called") + .on('shown.bs.tooltip', function () { + ok(true, 'shown was called') start() }) .tooltip('show') }) - test("should not fire shown event when default prevented", 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") + ok(true, 'show was called') start() }) - .on("shown.bs.tooltip", function() { - ok(false, "shown was called") + .on('shown.bs.tooltip', function () { + ok(false, 'shown was called') }) .tooltip('show') }) - test("should fire hide event", 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() { - ok(true, "hide was called") + .on('hide.bs.tooltip', function () { + ok(true, 'hide was called') start() }) .tooltip('show') }) - test("should fire hidden event", 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() { - ok(true, "hidden was called") + .on('hidden.bs.tooltip', function () { + ok(true, 'hidden was called') start() }) .tooltip('show') }) - test("should not fire hidden event when default prevented", 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") + ok(true, 'hide was called') start() }) - .on("hidden.bs.tooltip", function() { - ok(false, "hidden was called") + .on('hidden.bs.tooltip', function () { + ok(false, 'hidden was called') }) .tooltip('show') }) - test("should not show tooltip if leave event occurs before delay expires", function () { + test('should not show tooltip if leave event occurs before delay expires', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: 200 }) @@ -153,16 +153,16 @@ $(function () { tooltip.trigger('mouseenter') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') tooltip.trigger('mouseout') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') start() }, 200) }, 100) }) - test("should not show tooltip if leave event occurs before delay expires, even if hide delay is 0", function () { + test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: { show: 200, hide: 0} }) @@ -172,16 +172,16 @@ $(function () { tooltip.trigger('mouseenter') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') tooltip.trigger('mouseout') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') start() }, 200) }, 100) }) - test("should wait 200 ms before hiding the tooltip", 3, function () { + test('should wait 200 ms before hiding the tooltip', 3, function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: { show: 0, hide: 200} }) @@ -191,19 +191,19 @@ $(function () { tooltip.trigger('mouseenter') setTimeout(function () { - ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + ok($('.tooltip').is('.fade.in'), 'tooltip is faded in') tooltip.trigger('mouseout') setTimeout(function () { - ok($(".tooltip").is('.fade.in'), '100ms:tooltip is still faded in') + ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in') setTimeout(function () { - ok(!$(".tooltip").is('.in'), 'tooltip removed') + ok(!$('.tooltip').is('.in'), 'tooltip removed') start() }, 150) }, 100) }, 1) }) - test("should not hide tooltip if leave event occurs, then tooltip is show immediately again", function () { + test('should not hide tooltip if leave event occurs, then tooltip is show immediately again', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: { show: 0, hide: 200} }) @@ -213,52 +213,52 @@ $(function () { tooltip.trigger('mouseenter') setTimeout(function () { - ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + ok($('.tooltip').is('.fade.in'), 'tooltip is faded in') tooltip.trigger('mouseout') setTimeout(function () { - ok($(".tooltip").is('.fade.in'), '100ms:tooltip is still faded in') + ok($('.tooltip').is('.fade.in'), '100ms:tooltip is still faded in') tooltip.trigger('mouseenter') setTimeout(function () { - ok($(".tooltip").is('.in'), 'tooltip removed') + ok($('.tooltip').is('.in'), 'tooltip removed') start() }, 150) }, 100) }, 1) }) - test("should not show tooltip if leave event occurs before delay expires", function () { + test('should not show tooltip if leave event occurs before delay expires', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: 100 }) stop() tooltip.trigger('mouseenter') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') tooltip.trigger('mouseout') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') start() }, 100) }, 50) }) - test("should show tooltip if leave event hasn't occured before delay expires", function () { + test('should show tooltip if leave event hasn\'t occured before delay expires', function () { var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') .tooltip({ delay: 150 }) stop() tooltip.trigger('mouseenter') setTimeout(function () { - ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in') + ok(!$('.tooltip').is('.fade.in'), 'tooltip is not faded in') }, 100) setTimeout(function () { - ok($(".tooltip").is('.fade.in'), 'tooltip has faded in') + ok($('.tooltip').is('.fade.in'), 'tooltip has faded in') start() }, 200) }) - test("should destroy tooltip", function () { - var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) + test('should destroy tooltip', 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') @@ -270,66 +270,66 @@ $(function () { ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') }) - test("should show tooltip with delegate selector on click", 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' }) div.find('a').trigger('click') - ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + ok($('.tooltip').is('.fade.in'), 'tooltip is faded in') }) - test("should show tooltip when toggle is called", function () { + test('should show tooltip when toggle is called', function () { var tooltip = $('<a href="#" rel="tooltip" title="tooltip on toggle"></a>') .appendTo('#qunit-fixture') .tooltip({trigger: 'manual'}) .tooltip('toggle') - ok($(".tooltip").is('.fade.in'), 'tooltip should be toggled in') + ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in') }) - test("should place tooltips inside the body", 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') + 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(){ - 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}) + 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}) .appendTo(container) - .tooltip({placement: "top", animate: false}) - .tooltip("show") + .tooltip({placement: 'top', animate: false}) + .tooltip('show') stop() - setTimeout(function(){ - ok($(".tooltip").offset().left >= 0) + setTimeout(function () { + ok($('.tooltip').offset().left >= 0) start() container.remove() }, 100) }) - 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) - , tooltiped = $("<a href='#' title='very very very very very very very long tooltip'>Hover me</a>") + 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) + , tooltiped = $('<a href="#" title="very very very very very very very long tooltip">Hover me</a>') .css({marginTop: 200}) .appendTo(p) - .tooltip({placement: "top", animate: false}) - .tooltip("show") + .tooltip({placement: 'top', animate: false}) + .tooltip('show') stop() - setTimeout(function(){ - var tooltip = container.find(".tooltip") + setTimeout(function () { + var tooltip = container.find('.tooltip') start() ok(tooltip.offset().top + tooltip.outerHeight() <= tooltiped.offset().top) @@ -337,21 +337,21 @@ $(function () { }, 100) }) - 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>') + 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") + var container = $('<div />').appendTo('body') , target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line"></a>') .appendTo(container) .tooltip({placement: 'right'}) .tooltip('show') - , tooltip = container.find(".tooltip") + , 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') }) - test("tooltip title test #1", function () { + test('tooltip title test #1', function () { var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>') .appendTo('#qunit-fixture') .tooltip({ @@ -359,10 +359,10 @@ $(function () { .tooltip('show') equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title from title attribute is set') tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') + ok(!$('.tooltip').length, 'tooltip removed') }) - test("tooltip title test #2", function () { + test('tooltip title test #2', function () { var tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>') .appendTo('#qunit-fixture') .tooltip({ @@ -371,10 +371,10 @@ $(function () { .tooltip('show') equal($('.tooltip').children('.tooltip-inner').text(), 'Simple tooltip', 'title is set from title attribute while prefered over title option') tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') + ok(!$('.tooltip').length, 'tooltip removed') }) - test("tooltip title test #3", function () { + test('tooltip title test #3', function () { var tooltip = $('<a href="#" rel="tooltip" style="display: inline-block; position: absolute; top: 0; left: 0;"></a>') .appendTo('#qunit-fixture') .tooltip({ @@ -383,10 +383,10 @@ $(function () { .tooltip('show') equal($('.tooltip').children('.tooltip-inner').text(), 'This is a tooltip with some content', 'title from title option is set') tooltip.tooltip('hide') - ok(!$(".tooltip").length, 'tooltip removed') + ok(!$('.tooltip').length, 'tooltip removed') }) - test("tooltips should be placed dynamically, with the dynamic placement option", 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 @@ -403,7 +403,7 @@ $(function () { .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') @@ -412,7 +412,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 bottomTooltip = $('<div style="display: inline-block; position: absolute; bottom: 0;" rel="tooltip" title="Bottom tooltip">Bottom Dynamic Tooltip</div>') @@ -420,7 +420,7 @@ $(function () { .tooltip({placement: 'auto bottom'}) .tooltip('show') - ok($(".tooltip").is('.top'), 'bottom positioned tooltip is dynamically positioned top') + ok($('.tooltip').is('.top'), 'bottom positioned tooltip is dynamically positioned top') bottomTooltip.tooltip('hide') var leftTooltip = $('<div style="display: inline-block; position: absolute; left: 0;" rel="tooltip" title="Left tooltip">Left Dynamic Tooltip</div>') @@ -428,7 +428,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/tests/unit/transition.js b/js/tests/unit/transition.js index 39c415bc2..79722f808 100644 --- a/js/tests/unit/transition.js +++ b/js/tests/unit/transition.js @@ -1,12 +1,12 @@ $(function () { - module("transition") + module('transition') - test("should be defined on jquery support object", function () { + test('should be defined on jquery support object', function () { ok($.support.transition !== undefined, 'transition object is defined') }) - test("should provide an end object", function () { + test('should provide an end object', function () { ok($.support.transition ? $.support.transition.end : true, 'end string is defined') }) diff --git a/js/tooltip.js b/js/tooltip.js index 89802287a..7b10d43a2 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -1,9 +1,9 @@ /* ======================================================================== - * Bootstrap: tooltip.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#tooltip + * Bootstrap: tooltip.js v3.0.3 + * http://getbootstrap.com/javascript/#tooltip * Inspired by the original jQuery.tipsy by Jason Frame * ======================================================================== - * Copyright 2012 Twitter, Inc. + * Copyright 2013 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // TOOLTIP PUBLIC CLASS DEFINITION // =============================== @@ -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,8 +243,8 @@ if (replace) $tip.offset(offset) } - Tooltip.prototype.replaceArrow = function(delta, dimension, position) { - this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') + Tooltip.prototype.replaceArrow = function (delta, dimension, position) { + this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '') } Tooltip.prototype.setContent = function () { @@ -383,4 +383,4 @@ return this } -}(window.jQuery); +}(jQuery); diff --git a/js/transition.js b/js/transition.js index e8f318beb..5be3b01d4 100644 --- a/js/transition.js +++ b/js/transition.js @@ -1,6 +1,6 @@ /* ======================================================================== - * Bootstrap: transition.js v3.0.0 - * http://twbs.github.com/bootstrap/javascript.html#transitions + * Bootstrap: transition.js v3.0.3 + * http://getbootstrap.com/javascript/#transitions * ======================================================================== * Copyright 2013 Twitter, Inc. * @@ -18,7 +18,7 @@ * ======================================================================== */ -+function ($) { "use strict"; ++function ($) { 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) // ============================================================ @@ -53,4 +53,4 @@ $.support.transition = transitionEnd() }) -}(window.jQuery); +}(jQuery); |
