diff options
| author | Jacob Thornton <[email protected]> | 2012-01-11 21:42:55 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-01-11 21:42:55 -0800 |
| commit | 6f2f947a4309a8fdeb7067612447c0f1a15dcfd9 (patch) | |
| tree | d634c55bd53f807a4c6d5265462bcf1b03cbfe24 /js | |
| parent | 51e4e77034e14074cb442138e84b98efd288ccfd (diff) | |
| download | bootstrap-6f2f947a4309a8fdeb7067612447c0f1a15dcfd9.tar.xz bootstrap-6f2f947a4309a8fdeb7067612447c0f1a15dcfd9.zip | |
add build tool for js + rename twipsy to tooltip + lots of little doc cleanup
Diffstat (limited to 'js')
| -rw-r--r-- | js/bootstrap-popover.js | 8 | ||||
| -rw-r--r-- | js/bootstrap-tooltip.js (renamed from js/bootstrap-twipsy.js) | 38 | ||||
| -rw-r--r-- | js/bootstrap-typeahead.js | 2 | ||||
| -rw-r--r-- | js/tests/index.html | 4 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-twipsy.js | 48 |
5 files changed, 51 insertions, 49 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index 746699d37..9f60cbe95 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -26,10 +26,10 @@ this.init('popover', element, options) } - /* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js - ========================================= */ + /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js + ========================================== */ - Popover.prototype = $.extend({}, $.fn.twipsy.Constructor.prototype, { + Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, { constructor: Popover @@ -86,7 +86,7 @@ $.fn.popover.Constructor = Popover - $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { + $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, { placement: 'right' , content: '' , template: '<div class="popover"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>' diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-tooltip.js index b7b802926..241a44e24 100644 --- a/js/bootstrap-twipsy.js +++ b/js/bootstrap-tooltip.js @@ -1,8 +1,8 @@ -/* ========================================================== - * bootstrap-twipsy.js v2.0.0 - * http://twitter.github.com/bootstrap/javascript.html#twipsy +/* =========================================================== + * bootstrap-tooltip.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#tooltip * Inspired by the original jQuery.tipsy by Jason Frame - * ========================================================== + * =========================================================== * Copyright 2011 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,16 +22,16 @@ "use strict" - /* TWIPSY PUBLIC CLASS DEFINITION - * ============================== */ + /* TOOLTIP PUBLIC CLASS DEFINITION + * =============================== */ - var Twipsy = function ( element, options ) { - this.init('twipsy', element, options) + var Tooltip = function ( element, options ) { + this.init('tooltip', element, options) } - Twipsy.prototype = { + Tooltip.prototype = { - constructor: Twipsy + constructor: Tooltip , init: function ( type, element, options ) { var eventIn @@ -154,7 +154,7 @@ , setContent: function () { var $tip = this.tip() - $tip.find('.twipsy-inner').html(this.getTitle()) + $tip.find('.tooltip-inner').html(this.getTitle()) $tip.removeClass('fade in top bottom left right') } @@ -242,29 +242,29 @@ } - /* TWIPSY PLUGIN DEFINITION - * ======================== */ + /* TOOLTIP PLUGIN DEFINITION + * ========================= */ - $.fn.twipsy = function ( option ) { + $.fn.tooltip = function ( option ) { return this.each(function () { var $this = $(this) - , data = $this.data('twipsy') + , data = $this.data('tooltip') , options = typeof option == 'object' && option - if (!data) $this.data('twipsy', (data = new Twipsy(this, options))) + if (!data) $this.data('tooltip', (data = new Tooltip(this, options))) if (typeof option == 'string') data[option]() }) } - $.fn.twipsy.Constructor = Twipsy + $.fn.tooltip.Constructor = Tooltip - $.fn.twipsy.defaults = { + $.fn.tooltip.defaults = { animation: true , delay: 0 , selector: false , placement: 'top' , trigger: 'hover' , title: '' - , template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>' + , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' } }( window.jQuery )
\ No newline at end of file diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index 4933f9605..180466a74 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -156,11 +156,13 @@ break case 38: // up arrow + if (!this.shown) return e.preventDefault() this.prev() break case 40: // down arrow + if (!this.shown) return e.preventDefault() this.next() break diff --git a/js/tests/index.html b/js/tests/index.html index 27c2b3412..8c710de36 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -20,7 +20,7 @@ <script src="../../js/bootstrap-modal.js"></script> <script src="../../js/bootstrap-scrollspy.js"></script> <script src="../../js/bootstrap-tab.js"></script> - <script src="../../js/bootstrap-twipsy.js"></script> + <script src="../../js/bootstrap-tooltip.js"></script> <script src="../../js/bootstrap-popover.js"></script> <script src="../../js/bootstrap-typeahead.js"></script> @@ -33,7 +33,7 @@ <script src="unit/bootstrap-modal.js"></script> <script src="unit/bootstrap-scrollspy.js"></script> <script src="unit/bootstrap-tab.js"></script> - <script src="unit/bootstrap-twipsy.js"></script> + <script src="unit/bootstrap-tooltip.js"></script> <script src="unit/bootstrap-popover.js"></script> <script src="unit/bootstrap-typeahead.js"></script> diff --git a/js/tests/unit/bootstrap-twipsy.js b/js/tests/unit/bootstrap-twipsy.js index 08512ca97..8543162c6 100644 --- a/js/tests/unit/bootstrap-twipsy.js +++ b/js/tests/unit/bootstrap-twipsy.js @@ -1,62 +1,62 @@ $(function () { - module("bootstrap-twipsy") + module("bootstrap-tooltip") test("should be defined on jquery object", function () { var div = $("<div></div>") - ok(div.twipsy, 'popover method is defined') + ok(div.tooltip, 'popover method is defined') }) test("should return element", function () { var div = $("<div></div>") - ok(div.twipsy() == div, 'document.body returned') + ok(div.tooltip() == div, 'document.body returned') }) test("should expose default settings", function () { - ok(!!$.fn.twipsy.defaults, 'defaults is defined') + ok(!!$.fn.tooltip.defaults, 'defaults is defined') }) test("should remove title attribute", function () { - var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>').twipsy() - ok(!twipsy.attr('title'), 'title tag was removed') + var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>').tooltip() + ok(!tooltip.attr('title'), 'title tag was removed') }) test("should add data attribute for referencing original title", function () { - var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>').twipsy() - equals(twipsy.attr('data-original-title'), 'Another twipsy', 'original title preserved in data attribute') + 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') }) test("should place tooltips relative to placement option", function () { $.support.transition = false - var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>') + var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') - .twipsy({placement: 'bottom'}) - .twipsy('show') + .tooltip({placement: 'bottom'}) + .tooltip('show') - ok($(".twipsy").hasClass('fade bottom in'), 'has correct classes applied') - twipsy.twipsy('hide') + ok($(".tooltip").hasClass('fade bottom in'), 'has correct classes applied') + tooltip.tooltip('hide') }) test("should always allow html entities", function () { $.support.transition = false - var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>') + var tooltip = $('<a href="#" rel="tooltip" title="<b>@fat</b>"></a>') .appendTo('#qunit-fixture') - .twipsy('show') + .tooltip('show') - ok($('.twipsy b').length, 'b tag was inserted') - twipsy.twipsy('hide') - ok(!$(".twipsy").length, 'twipsy removed') + ok($('.tooltip b').length, 'b tag was inserted') + tooltip.tooltip('hide') + ok(!$(".tooltip").length, 'tooltip removed') }) test("should respect custom classes", function () { - var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>') + var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>') .appendTo('#qunit-fixture') - .twipsy({ template: '<div class="twipsy some-class"><div class="twipsy-arrow"/><div class="twipsy-inner"/></div>'}) - .twipsy('show') + .tooltip({ template: '<div class="tooltip some-class"><div class="tooltip-arrow"/><div class="tooltip-inner"/></div>'}) + .tooltip('show') - ok($('.twipsy').hasClass('some-class'), 'custom class is present') - twipsy.twipsy('hide') - ok(!$(".twipsy").length, 'twipsy removed') + ok($('.tooltip').hasClass('some-class'), 'custom class is present') + tooltip.tooltip('hide') + ok(!$(".tooltip").length, 'tooltip removed') }) })
\ No newline at end of file |
