Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorfat <jacobthornton@gmail.com>2013-05-16 22:06:30 +0400
committerfat <jacobthornton@gmail.com>2013-05-16 22:06:30 +0400
commit14651035deda4d02a1ca02c6088c34f770f897f6 (patch)
tree34002a1d364bb2618ab2526d5f0f9bd5c823bf47 /js
parent509f2244da757a60d3548a7d34d63080dc01ee19 (diff)
a bunch javascript junk
Diffstat (limited to 'js')
-rw-r--r--js/.jshintrc20
-rw-r--r--js/affix.js (renamed from js/bootstrap-affix.js)89
-rw-r--r--js/alert.js (renamed from js/bootstrap-alert.js)55
-rw-r--r--js/bootstrap-carousel.js207
-rw-r--r--js/bootstrap-typeahead.js335
-rw-r--r--js/button.js (renamed from js/bootstrap-button.js)66
-rw-r--r--js/carousel.js202
-rw-r--r--js/collapse.js (renamed from js/bootstrap-collapse.js)2
-rw-r--r--js/dropdown.js (renamed from js/bootstrap-dropdown.js)2
-rw-r--r--js/modal.js (renamed from js/bootstrap-modal.js)2
-rw-r--r--js/popover.js (renamed from js/bootstrap-popover.js)4
-rw-r--r--js/scrollspy.js (renamed from js/bootstrap-scrollspy.js)2
-rw-r--r--js/tab.js (renamed from js/bootstrap-tab.js)2
-rw-r--r--js/tests/index.html52
-rw-r--r--js/tests/unit/affix.js (renamed from js/tests/unit/bootstrap-affix.js)4
-rw-r--r--js/tests/unit/alert.js (renamed from js/tests/unit/bootstrap-alert.js)6
-rw-r--r--js/tests/unit/bootstrap-typeahead.js236
-rw-r--r--js/tests/unit/button.js (renamed from js/tests/unit/bootstrap-button.js)2
-rw-r--r--js/tests/unit/carousel.js (renamed from js/tests/unit/bootstrap-carousel.js)2
-rw-r--r--js/tests/unit/collapse.js (renamed from js/tests/unit/bootstrap-collapse.js)2
-rw-r--r--js/tests/unit/dropdown.js (renamed from js/tests/unit/bootstrap-dropdown.js)2
-rw-r--r--js/tests/unit/modal.js (renamed from js/tests/unit/bootstrap-modal.js)2
-rw-r--r--js/tests/unit/phantom.js (renamed from js/tests/unit/bootstrap-phantom.js)0
-rw-r--r--js/tests/unit/popover.js (renamed from js/tests/unit/bootstrap-popover.js)2
-rw-r--r--js/tests/unit/scrollspy.js (renamed from js/tests/unit/bootstrap-scrollspy.js)2
-rw-r--r--js/tests/unit/tab.js (renamed from js/tests/unit/bootstrap-tab.js)2
-rw-r--r--js/tests/unit/tooltip.js (renamed from js/tests/unit/bootstrap-tooltip.js)2
-rw-r--r--js/tests/unit/transition.js (renamed from js/tests/unit/bootstrap-transition.js)2
-rw-r--r--js/tooltip.js (renamed from js/bootstrap-tooltip.js)2
-rw-r--r--js/transition.js (renamed from js/bootstrap-transition.js)50
30 files changed, 385 insertions, 973 deletions
diff --git a/js/.jshintrc b/js/.jshintrc
index 83a3f8204f..849f6ebf00 100644
--- a/js/.jshintrc
+++ b/js/.jshintrc
@@ -1,12 +1,12 @@
{
- "validthis": true,
- "laxcomma" : true,
- "laxbreak" : true,
- "browser" : true,
- "eqnull" : true,
- "debug" : true,
- "devel" : true,
- "boss" : true,
- "expr" : true,
- "asi" : true
+ "validthis": true,
+ "laxcomma" : true,
+ "laxbreak" : true,
+ "browser" : true,
+ "eqnull" : true,
+ "debug" : true,
+ "devel" : true,
+ "boss" : true,
+ "expr" : true,
+ "asi" : true
}
diff --git a/js/bootstrap-affix.js b/js/affix.js
index e9a7306549..c70718c6da 100644
--- a/js/bootstrap-affix.js
+++ b/js/affix.js
@@ -1,5 +1,5 @@
/* ==========================================================
- * bootstrap-affix.js v3.0.0
+ * Bootstrap: affix.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#affix
* ==========================================================
* Copyright 2012 Twitter, Inc.
@@ -18,77 +18,81 @@
* ========================================================== */
-!function ($) {
+!function ($) { "use strict";
- "use strict"; // jshint ;_;
-
-
- /* AFFIX CLASS DEFINITION
- * ====================== */
+ // AFFIX CLASS DEFINITION
+ // ======================
var Affix = function (element, options) {
- this.options = $.extend({}, $.fn.affix.defaults, options)
+ this.options = $.extend({}, Affix.DEFAULTS, options)
this.$window = $(window)
- .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
- .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
+ .on('scroll.bs-affix.bs-data-api', $.proxy(this.checkPosition, this))
+ .on('click.bs-affix.bs-data-api', $.proxy(this.checkPositionWithEventLoop, this))
+
this.$element = $(element)
+ this.affixed =
+ this.unpin = null
+
this.checkPosition()
}
+ Affix.DEFAULTS = {
+ offset: 0
+ }
+
+ Affix.prototype.checkPositionWithEventLoop = function () {
+ setTimeout($.proxy(this.checkPosition, this), 1)
+ }
+
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var scrollHeight = $(document).height()
- , scrollTop = this.$window.scrollTop()
- , position = this.$element.offset()
- , offset = this.options.offset
- , offsetBottom = offset.bottom
- , offsetTop = offset.top
- , reset = 'affix affix-top affix-bottom'
- , affix
-
- if (typeof offset != 'object') offsetBottom = offsetTop = offset
- if (typeof offsetTop == 'function') offsetTop = offset.top()
+ var scrollTop = this.$window.scrollTop()
+ var position = this.$element.offset()
+ var offset = this.options.offset
+ var offsetTop = offset.top
+ var offsetBottom = offset.bottom
+ var reset = 'affix affix-top affix-bottom'
+
+ if (typeof offset != 'object') offsetBottom = offsetTop = offset
+ if (typeof offsetTop == 'function') offsetTop = offset.top()
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
- affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
- false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
- 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
- 'top' : false
+ var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
+ offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
+ offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return
this.affixed = affix
- this.unpin = affix == 'bottom' ? position.top - scrollTop : null
+ this.unpin = affix == 'bottom' ? position.top - scrollTop : null
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
}
- /* AFFIX PLUGIN DEFINITION
- * ======================= */
+ // AFFIX PLUGIN DEFINITION
+ // =======================
var old = $.fn.affix
$.fn.affix = function (option) {
return this.each(function () {
- var $this = $(this)
- , data = $this.data('affix')
- , options = typeof option == 'object' && option
- if (!data) $this.data('affix', (data = new Affix(this, options)))
+ var $this = $(this)
+ var data = $this.data('bs-affix')
+ var options = typeof option == 'object' && option
+
+ if (!data) $this.data('bs-affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.affix.Constructor = Affix
- $.fn.affix.defaults = {
- offset: 0
- }
-
- /* AFFIX NO CONFLICT
- * ================= */
+ // AFFIX NO CONFLICT
+ // =================
$.fn.affix.noConflict = function () {
$.fn.affix = old
@@ -96,22 +100,21 @@
}
- /* AFFIX DATA-API
- * ============== */
+ // AFFIX DATA-API
+ // ==============
$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
- , data = $spy.data()
+ var data = $spy.data()
data.offset = data.offset || {}
- data.offsetBottom && (data.offset.bottom = data.offsetBottom)
- data.offsetTop && (data.offset.top = data.offsetTop)
+ if (data.offsetBottom) data.offset.bottom = data.offsetBottom
+ if (data.offsetTop) data.offset.top = data.offsetTop
$spy.affix(data)
})
})
-
}(window.jQuery);
diff --git a/js/bootstrap-alert.js b/js/alert.js
index 7a9f62e2d4..9df950245c 100644
--- a/js/bootstrap-alert.js
+++ b/js/alert.js
@@ -1,8 +1,8 @@
/* ==========================================================
- * bootstrap-alert.js v3.0.0
+ * Bootstrap: alert.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#alerts
* ==========================================================
- * 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,45 +18,41 @@
* ========================================================== */
-!function ($) {
+!function ($) { "use strict";
- "use strict"; // jshint ;_;
-
-
- /* ALERT CLASS DEFINITION
- * ====================== */
+ // ALERT CLASS DEFINITION
+ // ======================
var dismiss = '[data-dismiss="alert"]'
- , Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
+ var Alert = function (el) {
+ $(el).on('click', dismiss, this.close)
+ }
Alert.prototype.close = function (e) {
- var $this = $(this)
- , selector = $this.attr('data-target')
- , $parent
+ var $this = $(this)
+ var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
- $parent = $(selector)
+ var $parent = $(selector)
- e && e.preventDefault()
+ if (e) e.preventDefault()
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
+ if (!$parent.length) {
+ $parent = $this.hasClass('alert') ? $this : $this.parent()
+ }
- $parent.trigger(e = $.Event('close'))
+ $parent.trigger(e = $.Event('bs-close'))
if (e.isDefaultPrevented()) return
$parent.removeClass('in')
function removeElement() {
- $parent
- .trigger('closed')
- .remove()
+ $parent.trigger('bs-closed').remove()
}
$.support.transition && $parent.hasClass('fade') ?
@@ -65,16 +61,17 @@
}
- /* ALERT PLUGIN DEFINITION
- * ======================= */
+ // ALERT PLUGIN DEFINITION
+ // =======================
var old = $.fn.alert
$.fn.alert = function (option) {
return this.each(function () {
var $this = $(this)
- , data = $this.data('alert')
- if (!data) $this.data('alert', (data = new Alert(this)))
+ var data = $this.data('bs-alert')
+
+ if (!data) $this.data('bs-alert', (data = new Alert(this)))
if (typeof option == 'string') data[option].call($this)
})
}
@@ -91,9 +88,9 @@
}
- /* ALERT DATA-API
- * ============== */
+ // ALERT DATA-API
+ // ============== */
- $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
+ $(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close)
}(window.jQuery);
diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js
deleted file mode 100644
index 0dfb70f8d9..0000000000
--- a/js/bootstrap-carousel.js
+++ /dev/null
@@ -1,207 +0,0 @@
-/* ==========================================================
- * bootstrap-carousel.js v3.0.0
- * http://twitter.github.com/bootstrap/javascript.html#carousel
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* CAROUSEL CLASS DEFINITION
- * ========================= */
-
- var Carousel = function (element, options) {
- this.$element = $(element)
- this.$indicators = this.$element.find('.carousel-indicators')
- this.options = options
- this.options.pause == 'hover' && this.$element
- .on('mouseenter', $.proxy(this.pause, this))
- .on('mouseleave', $.proxy(this.cycle, this))
- }
-
- Carousel.prototype = {
-
- cycle: function (e) {
- if (!e) this.paused = false
- if (this.interval) clearInterval(this.interval);
- this.options.interval
- && !this.paused
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
- return this
- }
-
- , getActiveIndex: function () {
- this.$active = this.$element.find('.item.active')
- this.$items = this.$active.parent().children()
- return this.$items.index(this.$active)
- }
-
- , to: function (pos) {
- var activeIndex = this.getActiveIndex()
- , that = this
-
- if (pos > (this.$items.length - 1) || pos < 0) return
-
- if (this.sliding) {
- return this.$element.one('slid', function () {
- that.to(pos)
- })
- }
-
- if (activeIndex == pos) {
- return this.pause().cycle()
- }
-
- return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
- }
-
- , pause: function (e) {
- if (!e) this.paused = true
- if (this.$element.find('.next, .prev').length && $.support.transition.end) {
- this.$element.trigger($.support.transition.end)
- this.cycle(true)
- }
- clearInterval(this.interval)
- this.interval = null
- return this
- }
-
- , next: function () {
- if (this.sliding) return
- return this.slide('next')
- }
-
- , prev: function () {
- if (this.sliding) return
- return this.slide('prev')
- }
-
- , slide: function (type, next) {
- var $active = this.$element.find('.item.active')
- , $next = next || $active[type]()
- , isCycling = this.interval
- , direction = type == 'next' ? 'left' : 'right'
- , fallback = type == 'next' ? 'first' : 'last'
- , that = this
- , e
-
- this.sliding = true
-
- isCycling && this.pause()
-
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
-
- e = $.Event('slide', {
- relatedTarget: $next[0]
- , direction: direction
- })
-
- if ($next.hasClass('active')) return
-
- if (this.$indicators.length) {
- this.$indicators.find('.active').removeClass('active')
- this.$element.one('slid', function () {
- var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
- $nextIndicator && $nextIndicator.addClass('active')
- })
- }
-
- if ($.support.transition && this.$element.hasClass('slide')) {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $next.addClass(type)
- $next[0].offsetWidth // force reflow
- $active.addClass(direction)
- $next.addClass(direction)
- this.$element.one($.support.transition.end, function () {
- $next.removeClass([type, direction].join(' ')).addClass('active')
- $active.removeClass(['active', direction].join(' '))
- that.sliding = false
- setTimeout(function () { that.$element.trigger('slid') }, 0)
- })
- } else {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $active.removeClass('active')
- $next.addClass('active')
- this.sliding = false
- this.$element.trigger('slid')
- }
-
- isCycling && this.cycle()
-
- return this
- }
-
- }
-
-
- /* CAROUSEL PLUGIN DEFINITION
- * ========================== */
-
- var old = $.fn.carousel
-
- $.fn.carousel = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('carousel')
- , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
- , action = typeof option == 'string' ? option : options.slide
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
- if (typeof option == 'number') data.to(option)
- else if (action) data[action]()
- else if (options.interval) data.pause().cycle()
- })
- }
-
- $.fn.carousel.defaults = {
- interval: 5000
- , pause: 'hover'
- }
-
- $.fn.carousel.Constructor = Carousel
-
-
- /* CAROUSEL NO CONFLICT
- * ==================== */
-
- $.fn.carousel.noConflict = function () {
- $.fn.carousel = old
- return this
- }
-
- /* CAROUSEL DATA-API
- * ================= */
-
- $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
- var $this = $(this), href
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- , options = $.extend({}, $target.data(), $this.data())
- , slideIndex
-
- $target.carousel(options)
-
- if (slideIndex = $this.attr('data-slide-to')) {
- $target.data('carousel').pause().to(slideIndex).cycle()
- }
-
- e.preventDefault()
- })
-
-}(window.jQuery);
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js
deleted file mode 100644
index a6bb0a09c2..0000000000
--- a/js/bootstrap-typeahead.js
+++ /dev/null
@@ -1,335 +0,0 @@
-/* =============================================================
- * bootstrap-typeahead.js v3.0.0
- * http://twitter.github.com/bootstrap/javascript.html#typeahead
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============================================================ */
-
-
-!function($){
-
- "use strict"; // jshint ;_;
-
-
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
- * ================================= */
-
- var Typeahead = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.typeahead.defaults, options)
- this.matcher = this.options.matcher || this.matcher
- this.sorter = this.options.sorter || this.sorter
- this.highlighter = this.options.highlighter || this.highlighter
- this.updater = this.options.updater || this.updater
- this.source = this.options.source
- this.$menu = $(this.options.menu)
- this.shown = false
- this.listen()
- }
-
- Typeahead.prototype = {
-
- constructor: Typeahead
-
- , select: function () {
- var val = this.$menu.find('.active').attr('data-value')
- this.$element
- .val(this.updater(val))
- .change()
- return this.hide()
- }
-
- , updater: function (item) {
- return item
- }
-
- , show: function () {
- var pos = $.extend({}, this.$element.position(), {
- height: this.$element[0].offsetHeight
- })
-
- this.$menu
- .insertAfter(this.$element)
- .css({
- top: pos.top + pos.height
- , left: pos.left
- })
- .show()
-
- this.shown = true
- return this
- }
-
- , hide: function () {
- this.$menu.hide()
- this.shown = false
- return this
- }
-
- , lookup: function (event) {
- var items
-
- this.query = this.$element.val()
-
- if (!this.query || this.query.length < this.options.minLength) {
- return this.shown ? this.hide() : this
- }
-
- items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
-
- return items ? this.process(items) : this
- }
-
- , process: function (items) {
- var that = this
-
- items = $.grep(items, function (item) {
- return that.matcher(item)
- })
-
- items = this.sorter(items)
-
- if (!items.length) {
- return this.shown ? this.hide() : this
- }
-
- return this.render(items.slice(0, this.options.items)).show()
- }
-
- , matcher: function (item) {
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
- }
-
- , sorter: function (items) {
- var beginswith = []
- , caseSensitive = []
- , caseInsensitive = []
- , item
-
- while (item = items.shift()) {
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
- else if (~item.indexOf(this.query)) caseSensitive.push(item)
- else caseInsensitive.push(item)
- }
-
- return beginswith.concat(caseSensitive, caseInsensitive)
- }
-
- , highlighter: function (item) {
- var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
- return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
- return '<strong>' + match + '</strong>'
- })
- }
-
- , render: function (items) {
- var that = this
-
- items = $(items).map(function (i, item) {
- i = $(that.options.item).attr('data-value', item)
- i.find('a').html(that.highlighter(item))
- return i[0]
- })
-
- items.first().addClass('active')
- this.$menu.html(items)
- return this
- }
-
- , next: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , next = active.next()
-
- if (!next.length) {
- next = $(this.$menu.find('li')[0])
- }
-
- next.addClass('active')
- }
-
- , prev: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , prev = active.prev()
-
- if (!prev.length) {
- prev = this.$menu.find('li').last()
- }
-
- prev.addClass('active')
- }
-
- , listen: function () {
- this.$element
- .on('focus', $.proxy(this.focus, this))
- .on('blur', $.proxy(this.blur, this))
- .on('keypress', $.proxy(this.keypress, this))
- .on('keyup', $.proxy(this.keyup, this))
-
- if (this.eventSupported('keydown')) {
- this.$element.on('keydown', $.proxy(this.keydown, this))
- }
-
- this.$menu
- .on('click', $.proxy(this.click, this))
- .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
- .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
- }
-
- , eventSupported: function(eventName) {
- var isSupported = eventName in this.$element
- if (!isSupported) {
- this.$element.setAttribute(eventName, 'return;')
- isSupported = typeof this.$element[eventName] === 'function'
- }
- return isSupported
- }
-
- , move: function (e) {
- if (!this.shown) return
-
- switch(e.keyCode) {
- case 9: // tab
- case 13: // enter
- case 27: // escape
- e.preventDefault()
- break
-
- case 38: // up arrow
- e.preventDefault()
- this.prev()
- break
-
- case 40: // down arrow
- e.preventDefault()
- this.next()
- break
- }
-
- e.stopPropagation()
- }
-
- , keydown: function (e) {
- this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
- this.move(e)
- }
-
- , keypress: function (e) {
- if (this.suppressKeyPressRepeat) return
- this.move(e)
- }
-
- , keyup: function (e) {
- switch(e.keyCode) {
- case 40: // down arrow
- case 38: // up arrow
- case 16: // shift
- case 17: // ctrl
- case 18: // alt
- break
-
- case 9: // tab
- case 13: // enter
- if (!this.shown) return
- this.select()
- break
-
- case 27: // escape
- if (!this.shown) return
- this.hide()
- break
-
- default:
- this.lookup()
- }
-
- e.stopPropagation()
- e.preventDefault()
- }
-
- , focus: function (e) {
- this.focused = true
- }
-
- , blur: function (e) {
- this.focused = false
- if (!this.mousedover && this.shown) this.hide()
- }
-
- , click: function (e) {
- e.stopPropagation()
- e.preventDefault()
- this.select()
- this.$element.focus()
- }
-
- , mouseenter: function (e) {
- this.mousedover = true
- this.$menu.find('.active').removeClass('active')
- $(e.currentTarget).addClass('active')
- }
-
- , mouseleave: function (e) {
- this.mousedover = false
- if (!this.focused && this.shown) this.hide()
- }
-
- }
-
-
- /* TYPEAHEAD PLUGIN DEFINITION
- * =========================== */
-
- var old = $.fn.typeahead
-
- $.fn.typeahead = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('typeahead')
- , options = typeof option == 'object' && option
- if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.typeahead.defaults = {
- source: []
- , items: 8
- , menu: '<ul class="typeahead dropdown-menu"></ul>'
- , item: '<li><a href="#"></a></li>'
- , minLength: 1
- }
-
- $.fn.typeahead.Constructor = Typeahead
-
-
- /* TYPEAHEAD NO CONFLICT
- * =================== */
-
- $.fn.typeahead.noConflict = function () {
- $.fn.typeahead = old
- return this
- }
-
-
- /* TYPEAHEAD DATA-API
- * ================== */
-
- $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
- var $this = $(this)
- if ($this.data('typeahead')) return
- $this.typeahead($this.data())
- })
-
-}(window.jQuery);
diff --git a/js/bootstrap-button.js b/js/button.js
index a42baf2a8a..f43bba18f9 100644
--- a/js/bootstrap-button.js
+++ b/js/button.js
@@ -1,8 +1,8 @@
/* ============================================================
- * bootstrap-button.js v3.0.0
+ * Bootstrap: button.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#buttons
* ============================================================
- * 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,27 +18,29 @@
* ============================================================ */
-!function ($) {
+!function ($) { "use strict";
- "use strict"; // jshint ;_;
-
-
- /* BUTTON PUBLIC CLASS DEFINITION
- * ============================== */
+ // BUTTON PUBLIC CLASS DEFINITION
+ // ==============================
var Button = function (element, options) {
this.$element = $(element)
- this.options = $.extend({}, $.fn.button.defaults, options)
+ this.options = $.extend({}, Button.DEFAULTS, options)
+ }
+
+ Button.DEFAULTS = {
+ loadingText: 'loading...'
}
Button.prototype.setState = function (state) {
- var d = 'disabled'
- , $el = this.$element
- , data = $el.data()
- , val = $el.is('input') ? 'val' : 'html'
+ var d = 'disabled'
+ var $el = this.$element
+ var val = $el.is('input') ? 'val' : 'html'
+ var data = $el.data()
state = state + 'Text'
- data.resetText || $el.data('resetText', $el[val]())
+
+ if (!data.resetText) $el.data('resetText', $el[val]())
$el[val](data[state] || this.options[state])
@@ -46,46 +48,44 @@
setTimeout(function () {
state == 'loadingText' ?
$el.addClass(d).attr(d, d) :
- $el.removeClass(d).removeAttr(d)
+ $el.removeClass(d).removeAttr(d);
}, 0)
}
Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
- $parent && $parent
- .find('.active')
- .removeClass('active')
+ if ($parent) {
+ $parent.find('.active').removeClass('active')
+ }
this.$element.toggleClass('active')
}
- /* BUTTON PLUGIN DEFINITION
- * ======================== */
+ // BUTTON PLUGIN DEFINITION
+ // ========================
var old = $.fn.button
$.fn.button = function (option) {
return this.each(function () {
- var $this = $(this)
- , data = $this.data('button')
- , options = typeof option == 'object' && option
- if (!data) $this.data('button', (data = new Button(this, options)))
+ var $this = $(this)
+ var data = $this.data('button')
+ var options = typeof option == 'object' && option
+
+ if (!data) $this.data('bs-button', (data = new Button(this, options)))
+
if (option == 'toggle') data.toggle()
else if (option) data.setState(option)
})
}
- $.fn.button.defaults = {
- loadingText: 'loading...'
- }
-
$.fn.button.Constructor = Button
- /* BUTTON NO CONFLICT
- * ================== */
+ // BUTTON NO CONFLICT
+ // ==================
$.fn.button.noConflict = function () {
$.fn.button = old
@@ -93,10 +93,10 @@
}
- /* BUTTON DATA-API
- * =============== */
+ // BUTTON DATA-API
+ // ===============
- $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
+ $(document).on('click.bs-button.bs-data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
diff --git a/js/carousel.js b/js/carousel.js
new file mode 100644
index 0000000000..b647ee9f15
--- /dev/null
+++ b/js/carousel.js
@@ -0,0 +1,202 @@
+/* ==========================================================
+ * Bootstrap: carousel.js v3.0.0
+ * http://twitter.github.com/bootstrap/javascript.html#carousel
+ * ==========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) { "use strict";
+
+ // CAROUSEL CLASS DEFINITION
+ // =========================
+
+ var Carousel = function (element, options) {
+ this.$element = $(element)
+ this.$indicators = this.$element.find('.carousel-indicators')
+ this.options = options
+ this.paused =
+ this.sliding =
+ this.interval =
+ this.$active =
+ this.$items = null
+
+ this.options.pause == 'hover' && this.$element
+ .on('mouseenter', $.proxy(this.pause, this))
+ .on('mouseleave', $.proxy(this.cycle, this))
+ }
+
+ Carousel.DEFAULTS = {
+ interval: 5000
+ , pause: 'hover'
+ }
+
+ Carousel.prototype.cycle = function (e) {
+ e || (this.paused = false)
+
+ this.interval && clearInterval(this.interval)
+
+ this.options.interval
+ && !this.paused
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
+
+ return this
+ }
+
+ Carousel.prototype.getActiveIndex = function () {
+ this.$active = this.$element.find('.item.active')
+ this.$items = this.$active.parent().children()
+
+ return this.$items.index(this.$active)
+ }
+
+ Carousel.prototype.to = function (pos) {
+ var that = this
+ var activeIndex = this.getActiveIndex()
+
+ if (pos > (this.$items.length - 1) || pos < 0) return
+
+ if (this.sliding) return this.$element.one('slid', function () { that.to(pos) })
+ if (activeIndex == pos) return this.pause().cycle()
+
+ return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
+ }
+
+ Carousel.prototype.pause = function (e) {
+ e || (this.paused = true)
+
+ if (this.$element.find('.next, .prev').length && $.support.transition.end) {
+ this.$element.trigger($.support.transition.end)
+ this.cycle(true)
+ }
+
+ this.interval = clearInterval(this.interval)
+
+ return this
+ }
+
+ Carousel.prototype.next = function () {
+ if (this.sliding) return
+ return this.slide('next')
+ }
+
+ Carousel.prototype.prev = function () {
+ if (this.sliding) return
+ return this.slide('prev')
+ }
+
+ Carousel.prototype.slide = function (type, next) {
+ var $active = this.$element.find('.item.active')
+ var $next = next || $active[type]()
+ var isCycling = this.interval
+ var direction = type == 'next' ? 'left' : 'right'
+ var fallback = type == 'next' ? 'first' : 'last'
+ var that = this
+
+ this.sliding = true
+
+ isCycling && this.pause()
+
+ $next = $next.length ? $next : this.$element.find('.item')[fallback]()
+
+ var e = $.Event('slide', { relatedTarget: $next[0], direction: direction })
+
+ if ($next.hasClass('active')) return
+
+ if (this.$indicators.length) {
+ this.$indicators.find('.active').removeClass('active')
+ this.$element.one('slid', function () {
+ var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
+ $nextIndicator && $nextIndicator.addClass('active')
+ })
+ }
+
+ if ($.support.transition && this.$element.hasClass('slide')) {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $next.addClass(type)
+ $next[0].offsetWidth // force reflow
+ $active.addClass(direction)
+ $next.addClass(direction)
+ this.$element.one($.support.transition.end, function () {
+ $next.removeClass([type, direction].join(' ')).addClass('active')
+ $active.removeClass(['active', direction].join(' '))
+ that.sliding = false
+ setTimeout(function () { that.$element.trigger('slid') }, 0)
+ })
+ } else {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $active.removeClass('active')
+ $next.addClass('active')
+ this.sliding = false
+ this.$element.trigger('slid')
+ }
+
+ isCycling && this.cycle()
+
+ return this
+ }
+
+
+ // CAROUSEL PLUGIN DEFINITION
+ // ==========================
+
+ var old = $.fn.carousel
+
+ $.fn.carousel = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ var data = $this.data('carousel')
+ var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option)
+ var action = typeof option == 'string' ? option : options.slide
+
+ if (!data) $this.data('carousel', (data = new Carousel(this, options)))
+ if (typeof option == 'number') data.to(option)
+ else if (action) data[action]()
+ else if (options.interval) data.pause().cycle()
+ })
+ }
+
+ $.fn.carousel.Constructor = Carousel
+
+
+ // CAROUSEL NO CONFLICT
+ // ====================
+
+ $.fn.carousel.noConflict = function () {
+ $.fn.carousel = old
+ return this
+ }
+
+ // CAROUSEL DATA-API
+ // =================
+
+ $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
+ var $this = $(this), href
+ var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
+ var options = $.extend({}, $target.data(), $this.data())
+ var slideIndex
+
+ $target.carousel(options)
+
+ if (slideIndex = $this.attr('data-slide-to')) {
+ $target.data('carousel').pause().to(slideIndex).cycle()
+ }
+
+ e.preventDefault()
+ })
+
+}(window.jQuery);
diff --git a/js/bootstrap-collapse.js b/js/collapse.js
index 7bd40c2339..bdf9eb4c8e 100644
--- a/js/bootstrap-collapse.js
+++ b/js/collapse.js
@@ -1,5 +1,5 @@
/* =============================================================
- * bootstrap-collapse.js v3.0.0
+ * Bootstrap: collapse.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#collapse
* =============================================================
* Copyright 2012 Twitter, Inc.
diff --git a/js/bootstrap-dropdown.js b/js/dropdown.js
index 0b1663f48f..342625074e 100644
--- a/js/bootstrap-dropdown.js
+++ b/js/dropdown.js
@@ -1,5 +1,5 @@
/* ============================================================
- * bootstrap-dropdown.js v3.0.0
+ * Bootstrap: dropdown.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================
* Copyright 2012 Twitter, Inc.
diff --git a/js/bootstrap-modal.js b/js/modal.js
index 34249a4063..9c88188129 100644
--- a/js/bootstrap-modal.js
+++ b/js/modal.js
@@ -1,5 +1,5 @@
/* =========================================================
- * bootstrap-modal.js v3.0.0
+ * Bootstrap: modal.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
diff --git a/js/bootstrap-popover.js b/js/popover.js
index 6ebbab1e61..aef6d4646f 100644
--- a/js/bootstrap-popover.js
+++ b/js/popover.js
@@ -1,5 +1,5 @@
/* ===========================================================
- * bootstrap-popover.js v3.0.0
+ * Bootstrap: popover.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#popovers
* ===========================================================
* Copyright 2012 Twitter, Inc.
@@ -31,7 +31,7 @@
}
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
+ /* NOTE: POPOVER EXTENDS tooltip.js
========================================== */
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
diff --git a/js/bootstrap-scrollspy.js b/js/scrollspy.js
index e5f0c3c1a8..53bd41eef1 100644
--- a/js/bootstrap-scrollspy.js
+++ b/js/scrollspy.js
@@ -1,5 +1,5 @@
/* =============================================================
- * bootstrap-scrollspy.js v3.0.0
+ * Bootstrap: scrollspy.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
* =============================================================
* Copyright 2012 Twitter, Inc.
diff --git a/js/bootstrap-tab.js b/js/tab.js
index a7a6a83e58..1df9f9098e 100644
--- a/js/bootstrap-tab.js
+++ b/js/tab.js
@@ -1,5 +1,5 @@
/* ========================================================
- * bootstrap-tab.js v3.0.0
+ * Bootstrap: tab.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2012 Twitter, Inc.
diff --git a/js/tests/index.html b/js/tests/index.html
index 887ac4deb6..322a8efd37 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -12,37 +12,35 @@
<script src="vendor/qunit.js"></script>
<!-- phantomjs logging script-->
- <script src="unit/bootstrap-phantom.js"></script>
+ <script src="unit/phantom.js"></script>
<!-- plugin sources -->
- <script src="../../js/bootstrap-transition.js"></script>
- <script src="../../js/bootstrap-alert.js"></script>
- <script src="../../js/bootstrap-button.js"></script>
- <script src="../../js/bootstrap-carousel.js"></script>
- <script src="../../js/bootstrap-collapse.js"></script>
- <script src="../../js/bootstrap-dropdown.js"></script>
- <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-tooltip.js"></script>
- <script src="../../js/bootstrap-popover.js"></script>
- <script src="../../js/bootstrap-typeahead.js"></script>
- <script src="../../js/bootstrap-affix.js"></script>
+ <script src="../../js/transition.js"></script>
+ <script src="../../js/alert.js"></script>
+ <script src="../../js/button.js"></script>
+ <script src="../../js/carousel.js"></script>
+ <script src="../../js/collapse.js"></script>
+ <script src="../../js/dropdown.js"></script>
+ <script src="../../js/modal.js"></script>
+ <script src="../../js/scrollspy.js"></script>
+ <script src="../../js/tab.js"></script>
+ <script src="../../js/tooltip.js"></script>
+ <script src="../../js/popover.js"></script>
+ <script src="../../js/affix.js"></script>
<!-- unit tests -->
- <script src="unit/bootstrap-transition.js"></script>
- <script src="unit/bootstrap-alert.js"></script>
- <script src="unit/bootstrap-button.js"></script>
- <script src="unit/bootstrap-carousel.js"></script>
- <script src="unit/bootstrap-collapse.js"></script>
- <script src="unit/bootstrap-dropdown.js"></script>
- <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-tooltip.js"></script>
- <script src="unit/bootstrap-popover.js"></script>
- <script src="unit/bootstrap-typeahead.js"></script>
- <script src="unit/bootstrap-affix.js"></script>
+ <script src="unit/transition.js"></script>
+ <script src="unit/alert.js"></script>
+ <script src="unit/button.js"></script>
+ <script src="unit/carousel.js"></script>
+ <script src="unit/collapse.js"></script>
+ <script src="unit/dropdown.js"></script>
+ <script src="unit/modal.js"></script>
+ <script src="unit/scrollspy.js"></script>
+ <script src="unit/tab.js"></script>
+ <script src="unit/tooltip.js"></script>
+ <script src="unit/popover.js"></script>
+ <script src="unit/affix.js"></script>
</head>
<body>
<div>
diff --git a/js/tests/unit/bootstrap-affix.js b/js/tests/unit/affix.js
index 2ade73b456..9829b05ad9 100644
--- a/js/tests/unit/bootstrap-affix.js
+++ b/js/tests/unit/affix.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-affix")
+ module("affix")
test("should provide no conflict", function () {
var affix = $.fn.affix.noConflict()
@@ -18,7 +18,7 @@ $(function () {
test("should exit early if element is not visible", function () {
var $affix = $('<div style="display: none"></div>').affix()
- $affix.data('affix').checkPosition()
+ $affix.data('bs-affix').checkPosition()
ok(!$affix.hasClass('affix'), 'affix class was not added')
})
diff --git a/js/tests/unit/bootstrap-alert.js b/js/tests/unit/alert.js
index dd2dfb9987..03993d07f8 100644
--- a/js/tests/unit/bootstrap-alert.js
+++ b/js/tests/unit/alert.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-alerts")
+ module("alerts")
test("should provide no conflict", function () {
var alert = $.fn.alert.noConflict()
@@ -48,12 +48,12 @@ $(function () {
$.support.transition = false
stop();
$('<div class="alert"/>')
- .bind('close', function (e) {
+ .bind('bs-close', function (e) {
e.preventDefault();
ok(true);
start();
})
- .bind('closed', function () {
+ .bind('bs-closed', function () {
ok(false);
})
.alert('close')
diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js
deleted file mode 100644
index 0aa2d61b17..0000000000
--- a/js/tests/unit/bootstrap-typeahead.js
+++ /dev/null
@@ -1,236 +0,0 @@
-$(function () {
-
- module("bootstrap-typeahead")
-
- test("should provide no conflict", function () {
- var typeahead = $.fn.typeahead.noConflict()
- ok(!$.fn.typeahead, 'typeahead was set back to undefined (org value)')
- $.fn.typeahead = typeahead
- })
-
- test("should be defined on jquery object", function () {
- ok($(document.body).typeahead, 'alert method is defined')
- })
-
- test("should return element", function () {
- ok($(document.body).typeahead()[0] == document.body, 'document.body returned')
- })
-
- test("should listen to an input", function () {
- var $input = $('<input />')
- $input.typeahead()
- ok($._data($input[0], 'events').blur, 'has a blur event')
- ok($._data($input[0], 'events').keypress, 'has a keypress event')
- ok($._data($input[0], 'events').keyup, 'has a keyup event')
- })
-
- test("should create a menu", function () {
- var $input = $('<input />')
- ok($input.typeahead().data('typeahead').$menu, 'has a menu')
- })
-
- test("should listen to the menu", function () {
- var $input = $('<input />')
- , $menu = $input.typeahead().data('typeahead').$menu
-
- ok($._data($menu[0], 'events').mouseover, 'has a mouseover(pseudo: mouseenter)')
- ok($._data($menu[0], 'events').click, 'has a click')
- })
-
- test("should show menu when query entered", function () {
- var $input = $('<input />')
- .appendTo('body')
- .typeahead({
- source: ['aa', 'ab', 'ac']
- })
- , typeahead = $input.data('typeahead')
-
- $input.val('a')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should accept data source via synchronous function", function () {
- var $input = $('<input />').typeahead({
- source: function () {
- return ['aa', 'ab', 'ac']
- }
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('a')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should accept data source via asynchronous function", function () {
- var $input = $('<input />').typeahead({
- source: function (query, process) {
- process(['aa', 'ab', 'ac'])
- }
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('a')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should not explode when regex chars are entered", function () {
- var $input = $('<input />').typeahead({
- source: ['aa', 'ab', 'ac', 'mdo*', 'fat+']
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('+')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 1, 'has 1 item in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should hide menu when query entered", function () {
- stop()
- var $input = $('<input />').typeahead({
- source: ['aa', 'ab', 'ac']
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('a')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
-
- $input.blur()
-
- setTimeout(function () {
- ok(!typeahead.$menu.is(":visible"), "typeahead is no longer visible")
- start()
- }, 200)
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should set next item when down arrow is pressed", function () {
- var $input = $('<input />').typeahead({
- source: ['aa', 'ab', 'ac']
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('a')
- typeahead.lookup()
-
- ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
- equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
- ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
-
- // simulate entire key pressing event
- $input.trigger({
- type: 'keydown'
- , keyCode: 40
- })
- .trigger({
- type: 'keypress'
- , keyCode: 40
- })
- .trigger({
- type: 'keyup'
- , keyCode: 40
- })
-
- ok(typeahead.$menu.find('li').first().next().hasClass('active'), "second item is active")
-
- $input.trigger({
- type: 'keydown'
- , keyCode: 38
- })
- .trigger({
- type: 'keypress'
- , keyCode: 38
- })
- .trigger({
- type: 'keyup'
- , keyCode: 38
- })
-
- ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active")
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
-
- test("should set input value to selected item", function () {
- var $input = $('<input />').typeahead({
- source: ['aa', 'ab', 'ac']
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
- , changed = false
- , focus = false
- , blur = false
-
- $input.val('a')
- typeahead.lookup()
-
- $input.change(function() { changed = true });
- $input.focus(function() { focus = true; blur = false });
- $input.blur(function() { blur = true; focus = false });
-
- $(typeahead.$menu.find('li')[2]).mouseover().click()
-
- equals($input.val(), 'ac', 'input value was correctly set')
- ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
- ok(changed, 'a change event was fired')
- ok(focus && !blur, 'focus is still set')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-
- test("should start querying when minLength is met", function () {
- var $input = $('<input />').typeahead({
- source: ['aaaa', 'aaab', 'aaac'],
- minLength: 3
- }).appendTo('body')
- , typeahead = $input.data('typeahead')
-
- $input.val('aa')
- typeahead.lookup()
-
- equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu')
-
- $input.val('aaa')
- typeahead.lookup()
-
- equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
-
- $input.remove()
- typeahead.$menu.remove()
- })
-})
diff --git a/js/tests/unit/bootstrap-button.js b/js/tests/unit/button.js
index 5849dad7b1..aaf480c32e 100644
--- a/js/tests/unit/bootstrap-button.js
+++ b/js/tests/unit/button.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-buttons")
+ module("buttons")
test("should provide no conflict", function () {
var button = $.fn.button.noConflict()
diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/carousel.js
index 1e821173e5..396217e754 100644
--- a/js/tests/unit/bootstrap-carousel.js
+++ b/js/tests/unit/carousel.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-carousel")
+ module("carousel")
test("should provide no conflict", function () {
var carousel = $.fn.carousel.noConflict()
diff --git a/js/tests/unit/bootstrap-collapse.js b/js/tests/unit/collapse.js
index 1f1fc2ff20..6750c7a87a 100644
--- a/js/tests/unit/bootstrap-collapse.js
+++ b/js/tests/unit/collapse.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-collapse")
+ module("collapse")
test("should provide no conflict", function () {
var collapse = $.fn.collapse.noConflict()
diff --git a/js/tests/unit/bootstrap-dropdown.js b/js/tests/unit/dropdown.js
index c67c073008..db84a95a5d 100644
--- a/js/tests/unit/bootstrap-dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-dropdowns")
+ module("dropdowns")
test("should provide no conflict", function () {
var dropdown = $.fn.dropdown.noConflict()
diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/modal.js
index 3762e72e98..1d3baa8125 100644
--- a/js/tests/unit/bootstrap-modal.js
+++ b/js/tests/unit/modal.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-modal")
+ module("modal")
test("should provide no conflict", function () {
var modal = $.fn.modal.noConflict()
diff --git a/js/tests/unit/bootstrap-phantom.js b/js/tests/unit/phantom.js
index c01e71c154..c01e71c154 100644
--- a/js/tests/unit/bootstrap-phantom.js
+++ b/js/tests/unit/phantom.js
diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/popover.js
index ef7f5cf3b9..c62bb8ac1b 100644
--- a/js/tests/unit/bootstrap-popover.js
+++ b/js/tests/unit/popover.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-popover")
+ module("popover")
test("should provide no conflict", function () {
var popover = $.fn.popover.noConflict()
diff --git a/js/tests/unit/bootstrap-scrollspy.js b/js/tests/unit/scrollspy.js
index 2c3d438931..06219a1c8d 100644
--- a/js/tests/unit/bootstrap-scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-scrollspy")
+ module("scrollspy")
test("should provide no conflict", function () {
var scrollspy = $.fn.scrollspy.noConflict()
diff --git a/js/tests/unit/bootstrap-tab.js b/js/tests/unit/tab.js
index 9a7e93d4db..2a92b4d320 100644
--- a/js/tests/unit/bootstrap-tab.js
+++ b/js/tests/unit/tab.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-tabs")
+ module("tabs")
test("should provide no conflict", function () {
var tab = $.fn.tab.noConflict()
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/tooltip.js
index 5b37b4e687..b97be3c9bd 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-tooltip")
+ module("tooltip")
test("should provide no conflict", function () {
var tooltip = $.fn.tooltip.noConflict()
diff --git a/js/tests/unit/bootstrap-transition.js b/js/tests/unit/transition.js
index d348189047..39c415bc23 100644
--- a/js/tests/unit/bootstrap-transition.js
+++ b/js/tests/unit/transition.js
@@ -1,6 +1,6 @@
$(function () {
- module("bootstrap-transition")
+ module("transition")
test("should be defined on jquery support object", function () {
ok($.support.transition !== undefined, 'transition object is defined')
diff --git a/js/bootstrap-tooltip.js b/js/tooltip.js
index 03a65e7e1d..f199a3e6af 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/tooltip.js
@@ -1,5 +1,5 @@
/* ===========================================================
- * bootstrap-tooltip.js v3.0.0
+ * Bootstrap: tooltip.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
* ===========================================================
diff --git a/js/bootstrap-transition.js b/js/transition.js
index e1bc4021b8..d3417b82c4 100644
--- a/js/bootstrap-transition.js
+++ b/js/transition.js
@@ -1,8 +1,8 @@
/* ===================================================
- * bootstrap-transition.js v3.0.0
+ * Bootstrap: transition.js v3.0.0
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
- * 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.
@@ -20,41 +20,31 @@
!function ($) {
- "use strict"; // jshint ;_;
+ "use strict";
- /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
+ /* CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
* ======================================================= */
- $(function () {
-
- $.support.transition = (function () {
-
- var transitionEnd = (function () {
-
- var el = document.createElement('bootstrap')
- , transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd'
- , 'MozTransition' : 'transitionend'
- , 'OTransition' : 'oTransitionEnd otransitionend'
- , 'transition' : 'transitionend'
- }
- , name
+ function transitionEnd() {
+ var el = document.createElement('bootstrap');
- for (name in transEndEventNames){
- if (el.style[name] !== undefined) {
- return transEndEventNames[name]
- }
- }
+ var transEndEventNames = {
+ 'WebkitTransition' : 'webkitTransitionEnd'
+ , 'MozTransition' : 'transitionend'
+ , 'OTransition' : 'oTransitionEnd otransitionend'
+ , 'transition' : 'transitionend'
+ };
- }())
-
- return transitionEnd && {
- end: transitionEnd
+ for (var name in transEndEventNames) {
+ if (el.style[name] !== undefined) {
+ return { end: transEndEventNames[name] };
}
+ }
+ }
- })()
-
- })
+ $(function () {
+ $.support.transition = transitionEnd();
+ });
}(window.jQuery);