Update bootstrap version 2.2.2

This commit is contained in:
chris 2013-01-07 17:25:32 +08:00
parent 67136cf595
commit 423e2ac54e
1 changed files with 263 additions and 130 deletions

View File

@ -1,5 +1,5 @@
/* =================================================== /* ===================================================
* bootstrap-transition.js v2.1.1 * bootstrap-transition.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#transitions * http://twitter.github.com/bootstrap/javascript.html#transitions
* =================================================== * ===================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -20,14 +20,14 @@
!function ($) { !function ($) {
"use strict"; // jshint ;_;
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
* ======================================================= */
$(function () { $(function () {
"use strict"; // jshint ;_;
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
* ======================================================= */
$.support.transition = (function () { $.support.transition = (function () {
var transitionEnd = (function () { var transitionEnd = (function () {
@ -58,7 +58,7 @@
}) })
}(window.jQuery);/* ========================================================== }(window.jQuery);/* ==========================================================
* bootstrap-alert.js v2.1.1 * bootstrap-alert.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#alerts * http://twitter.github.com/bootstrap/javascript.html#alerts
* ========================================================== * ==========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -127,6 +127,8 @@
/* ALERT PLUGIN DEFINITION /* ALERT PLUGIN DEFINITION
* ======================= */ * ======================= */
var old = $.fn.alert
$.fn.alert = function (option) { $.fn.alert = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -139,15 +141,22 @@
$.fn.alert.Constructor = Alert $.fn.alert.Constructor = Alert
/* ALERT NO CONFLICT
* ================= */
$.fn.alert.noConflict = function () {
$.fn.alert = old
return this
}
/* ALERT DATA-API /* ALERT DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})
}(window.jQuery);/* ============================================================ }(window.jQuery);/* ============================================================
* bootstrap-button.js v2.1.1 * bootstrap-button.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#buttons * http://twitter.github.com/bootstrap/javascript.html#buttons
* ============================================================ * ============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -212,6 +221,8 @@
/* BUTTON PLUGIN DEFINITION /* BUTTON PLUGIN DEFINITION
* ======================== */ * ======================== */
var old = $.fn.button
$.fn.button = function (option) { $.fn.button = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -230,19 +241,26 @@
$.fn.button.Constructor = Button $.fn.button.Constructor = Button
/* BUTTON NO CONFLICT
* ================== */
$.fn.button.noConflict = function () {
$.fn.button = old
return this
}
/* BUTTON DATA-API /* BUTTON DATA-API
* =============== */ * =============== */
$(function () { $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) { var $btn = $(e.target)
var $btn = $(e.target) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') $btn.button('toggle')
$btn.button('toggle')
})
}) })
}(window.jQuery);/* ========================================================== }(window.jQuery);/* ==========================================================
* bootstrap-carousel.js v2.1.1 * bootstrap-carousel.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#carousel * http://twitter.github.com/bootstrap/javascript.html#carousel
* ========================================================== * ==========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -272,7 +290,6 @@
var Carousel = function (element, options) { var Carousel = function (element, options) {
this.$element = $(element) this.$element = $(element)
this.options = options this.options = options
this.options.slide && this.slide(this.options.slide)
this.options.pause == 'hover' && this.$element this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this)) .on('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this)) .on('mouseleave', $.proxy(this.cycle, this))
@ -337,9 +354,7 @@
, direction = type == 'next' ? 'left' : 'right' , direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last' , fallback = type == 'next' ? 'first' : 'last'
, that = this , that = this
, e = $.Event('slide', { , e
relatedTarget: $next[0]
})
this.sliding = true this.sliding = true
@ -347,6 +362,10 @@
$next = $next.length ? $next : this.$element.find('.item')[fallback]() $next = $next.length ? $next : this.$element.find('.item')[fallback]()
e = $.Event('slide', {
relatedTarget: $next[0]
})
if ($next.hasClass('active')) return if ($next.hasClass('active')) return
if ($.support.transition && this.$element.hasClass('slide')) { if ($.support.transition && this.$element.hasClass('slide')) {
@ -382,6 +401,8 @@
/* CAROUSEL PLUGIN DEFINITION /* CAROUSEL PLUGIN DEFINITION
* ========================== */ * ========================== */
var old = $.fn.carousel
$.fn.carousel = function (option) { $.fn.carousel = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -403,21 +424,27 @@
$.fn.carousel.Constructor = Carousel $.fn.carousel.Constructor = Carousel
/* CAROUSEL NO CONFLICT
* ==================== */
$.fn.carousel.noConflict = function () {
$.fn.carousel = old
return this
}
/* CAROUSEL DATA-API /* CAROUSEL DATA-API
* ================= */ * ================= */
$(function () { $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href
var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 , options = $.extend({}, $target.data(), $this.data())
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) $target.carousel(options)
$target.carousel(options) e.preventDefault()
e.preventDefault()
})
}) })
}(window.jQuery);/* ============================================================= }(window.jQuery);/* =============================================================
* bootstrap-collapse.js v2.1.1 * bootstrap-collapse.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#collapse * http://twitter.github.com/bootstrap/javascript.html#collapse
* ============================================================= * =============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -506,6 +533,7 @@
[0].offsetWidth [0].offsetWidth
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
return this return this
} }
@ -539,8 +567,10 @@
} }
/* COLLAPSIBLE PLUGIN DEFINITION /* COLLAPSE PLUGIN DEFINITION
* ============================== */ * ========================== */
var old = $.fn.collapse
$.fn.collapse = function (option) { $.fn.collapse = function (option) {
return this.each(function () { return this.each(function () {
@ -559,26 +589,33 @@
$.fn.collapse.Constructor = Collapse $.fn.collapse.Constructor = Collapse
/* COLLAPSIBLE DATA-API /* COLLAPSE NO CONFLICT
* ==================== */ * ==================== */
$(function () { $.fn.collapse.noConflict = function () {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { $.fn.collapse = old
var $this = $(this), href return this
, target = $this.attr('data-target') }
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data() /* COLLAPSE DATA-API
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') * ================= */
$(target).collapse(option)
// for orbit $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
$this.parents('li').siblings().removeClass('active'); var $this = $(this), href
$this.parents('li').toggleClass('active'); , target = $this.attr('data-target')
}) || e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data()
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$(target).collapse(option)
// for orbit
$this.parents('li').siblings().removeClass('active');
$this.parents('li').toggleClass('active');
}) })
}(window.jQuery);/* ============================================================ }(window.jQuery);/* ============================================================
* bootstrap-dropdown.js v2.1.1 * bootstrap-dropdown.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#dropdowns * http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================ * ============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -632,9 +669,10 @@
if (!isActive) { if (!isActive) {
$parent.toggleClass('open') $parent.toggleClass('open')
$this.focus()
} }
$this.focus()
return false return false
} }
@ -661,7 +699,7 @@
if (!isActive || (isActive && e.keyCode == 27)) return $this.click() if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
$items = $('[role=menu] li:not(.divider) a', $parent) $items = $('[role=menu] li:not(.divider):visible a', $parent)
if (!$items.length) return if (!$items.length) return
@ -679,8 +717,9 @@
} }
function clearMenus() { function clearMenus() {
getParent($(toggle)) $(toggle).each(function () {
.removeClass('open') getParent($(this)).removeClass('open')
})
} }
function getParent($this) { function getParent($this) {
@ -702,6 +741,8 @@
/* DROPDOWN PLUGIN DEFINITION /* DROPDOWN PLUGIN DEFINITION
* ========================== */ * ========================== */
var old = $.fn.dropdown
$.fn.dropdown = function (option) { $.fn.dropdown = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -714,20 +755,27 @@
$.fn.dropdown.Constructor = Dropdown $.fn.dropdown.Constructor = Dropdown
/* DROPDOWN NO CONFLICT
* ==================== */
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
/* APPLY TO STANDARD DROPDOWN ELEMENTS /* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ * =================================== */
$(function () { $(document)
$('html') .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
$('body') .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
})
}(window.jQuery);/* ========================================================= }(window.jQuery);/* =========================================================
* bootstrap-modal.js v2.1.1 * bootstrap-modal.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#modals * http://twitter.github.com/bootstrap/javascript.html#modals
* ========================================================= * =========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -777,8 +825,6 @@
if (this.isShown || e.isDefaultPrevented()) return if (this.isShown || e.isDefaultPrevented()) return
$('body').addClass('modal-open')
this.isShown = true this.isShown = true
this.escape() this.escape()
@ -800,13 +846,12 @@
that.$element that.$element
.addClass('in') .addClass('in')
.attr('aria-hidden', false) .attr('aria-hidden', false)
.focus()
that.enforceFocus() that.enforceFocus()
transition ? transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
that.$element.trigger('shown') that.$element.focus().trigger('shown')
}) })
} }
@ -824,8 +869,6 @@
this.isShown = false this.isShown = false
$('body').removeClass('modal-open')
this.escape() this.escape()
$(document).off('focusin.modal') $(document).off('focusin.modal')
@ -895,9 +938,11 @@
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body) .appendTo(document.body)
if (this.options.backdrop != 'static') { this.$backdrop.click(
this.$backdrop.click($.proxy(this.hide, this)) this.options.backdrop == 'static' ?
} $.proxy(this.$element[0].focus, this.$element[0])
: $.proxy(this.hide, this)
)
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
@ -924,6 +969,8 @@
/* MODAL PLUGIN DEFINITION /* MODAL PLUGIN DEFINITION
* ======================= */ * ======================= */
var old = $.fn.modal
$.fn.modal = function (option) { $.fn.modal = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -944,28 +991,36 @@
$.fn.modal.Constructor = Modal $.fn.modal.Constructor = Modal
/* MODAL NO CONFLICT
* ================= */
$.fn.modal.noConflict = function () {
$.fn.modal = old
return this
}
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(function () { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { var $this = $(this)
var $this = $(this) , href = $this.attr('href')
, href = $this.attr('href') , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
$target $target
.modal(option) .modal(option)
.one('hide', function () { .one('hide', function () {
$this.focus() $this.focus()
}) })
})
}) })
}(window.jQuery);/* =========================================================== }(window.jQuery);
* bootstrap-tooltip.js v2.1.1 /* ===========================================================
* bootstrap-tooltip.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#tooltips * http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame * Inspired by the original jQuery.tipsy by Jason Frame
* =========================================================== * ===========================================================
@ -1085,9 +1140,9 @@
inside = /in/.test(placement) inside = /in/.test(placement)
$tip $tip
.remove() .detach()
.css({ top: 0, left: 0, display: 'block' }) .css({ top: 0, left: 0, display: 'block' })
.appendTo(inside ? this.$element : document.body) .insertAfter(this.$element)
pos = this.getPosition(inside) pos = this.getPosition(inside)
@ -1110,7 +1165,7 @@
} }
$tip $tip
.css(tp) .offset(tp)
.addClass(placement) .addClass(placement)
.addClass('in') .addClass('in')
} }
@ -1132,18 +1187,18 @@
function removeWithAnimation() { function removeWithAnimation() {
var timeout = setTimeout(function () { var timeout = setTimeout(function () {
$tip.off($.support.transition.end).remove() $tip.off($.support.transition.end).detach()
}, 500) }, 500)
$tip.one($.support.transition.end, function () { $tip.one($.support.transition.end, function () {
clearTimeout(timeout) clearTimeout(timeout)
$tip.remove() $tip.detach()
}) })
} }
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() : removeWithAnimation() :
$tip.remove() $tip.detach()
return this return this
} }
@ -1201,8 +1256,9 @@
this.enabled = !this.enabled this.enabled = !this.enabled
} }
, toggle: function () { , toggle: function (e) {
this[this.tip().hasClass('in') ? 'hide' : 'show']() var self = $(e.currentTarget)[this.type](this._options).data(this.type)
self[self.tip().hasClass('in') ? 'hide' : 'show']()
} }
, destroy: function () { , destroy: function () {
@ -1215,6 +1271,8 @@
/* TOOLTIP PLUGIN DEFINITION /* TOOLTIP PLUGIN DEFINITION
* ========================= */ * ========================= */
var old = $.fn.tooltip
$.fn.tooltip = function ( option ) { $.fn.tooltip = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -1235,12 +1293,20 @@
, trigger: 'hover' , trigger: 'hover'
, title: '' , title: ''
, delay: 0 , delay: 0
, html: true , html: false
} }
}(window.jQuery);
/* =========================================================== /* TOOLTIP NO CONFLICT
* bootstrap-popover.js v2.1.1 * =================== */
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old
return this
}
}(window.jQuery);/* ===========================================================
* bootstrap-popover.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#popovers * http://twitter.github.com/bootstrap/javascript.html#popovers
* =========================================================== * ===========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -1285,7 +1351,7 @@
, content = this.getContent() , content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content) $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
$tip.removeClass('fade top bottom left right in') $tip.removeClass('fade top bottom left right in')
} }
@ -1322,6 +1388,8 @@
/* POPOVER PLUGIN DEFINITION /* POPOVER PLUGIN DEFINITION
* ======================= */ * ======================= */
var old = $.fn.popover
$.fn.popover = function (option) { $.fn.popover = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -1338,11 +1406,20 @@
placement: 'right' placement: 'right'
, trigger: 'click' , trigger: 'click'
, content: '' , content: ''
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>' , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>'
}) })
/* POPOVER NO CONFLICT
* =================== */
$.fn.popover.noConflict = function () {
$.fn.popover = old
return this
}
}(window.jQuery);/* ============================================================= }(window.jQuery);/* =============================================================
* bootstrap-scrollspy.js v2.1.1 * bootstrap-scrollspy.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#scrollspy * http://twitter.github.com/bootstrap/javascript.html#scrollspy
* ============================================================= * =============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -1402,7 +1479,7 @@
, $href = /^#\w/.test(href) && $(href) , $href = /^#\w/.test(href) && $(href)
return ( $href return ( $href
&& $href.length && $href.length
&& [[ $href.position().top, href ]] ) || null && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null
}) })
.sort(function (a, b) { return a[0] - b[0] }) .sort(function (a, b) { return a[0] - b[0] })
.each(function () { .each(function () {
@ -1464,6 +1541,8 @@
/* SCROLLSPY PLUGIN DEFINITION /* SCROLLSPY PLUGIN DEFINITION
* =========================== */ * =========================== */
var old = $.fn.scrollspy
$.fn.scrollspy = function (option) { $.fn.scrollspy = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -1481,6 +1560,15 @@
} }
/* SCROLLSPY NO CONFLICT
* ===================== */
$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
return this
}
/* SCROLLSPY DATA-API /* SCROLLSPY DATA-API
* ================== */ * ================== */
@ -1492,7 +1580,7 @@
}) })
}(window.jQuery);/* ======================================================== }(window.jQuery);/* ========================================================
* bootstrap-tab.js v2.1.1 * bootstrap-tab.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#tabs * http://twitter.github.com/bootstrap/javascript.html#tabs
* ======================================================== * ========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -1542,7 +1630,7 @@
if ( $this.parent('li').hasClass('active') ) return if ( $this.parent('li').hasClass('active') ) return
previous = $ul.find('.active a').last()[0] previous = $ul.find('.active:last a')[0]
e = $.Event('show', { e = $.Event('show', {
relatedTarget: previous relatedTarget: previous
@ -1603,6 +1691,8 @@
/* TAB PLUGIN DEFINITION /* TAB PLUGIN DEFINITION
* ===================== */ * ===================== */
var old = $.fn.tab
$.fn.tab = function ( option ) { $.fn.tab = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -1615,18 +1705,25 @@
$.fn.tab.Constructor = Tab $.fn.tab.Constructor = Tab
/* TAB NO CONFLICT
* =============== */
$.fn.tab.noConflict = function () {
$.fn.tab = old
return this
}
/* TAB DATA-API /* TAB DATA-API
* ============ */ * ============ */
$(function () { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { e.preventDefault()
e.preventDefault() $(this).tab('show')
$(this).tab('show')
})
}) })
}(window.jQuery);/* ============================================================= }(window.jQuery);/* =============================================================
* bootstrap-typeahead.js v2.1.1 * bootstrap-typeahead.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#typeahead * http://twitter.github.com/bootstrap/javascript.html#typeahead
* ============================================================= * =============================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -1660,8 +1757,8 @@
this.sorter = this.options.sorter || this.sorter this.sorter = this.options.sorter || this.sorter
this.highlighter = this.options.highlighter || this.highlighter this.highlighter = this.options.highlighter || this.highlighter
this.updater = this.options.updater || this.updater this.updater = this.options.updater || this.updater
this.$menu = $(this.options.menu).appendTo('body')
this.source = this.options.source this.source = this.options.source
this.$menu = $(this.options.menu)
this.shown = false this.shown = false
this.listen() this.listen()
} }
@ -1683,16 +1780,18 @@
} }
, show: function () { , show: function () {
var pos = $.extend({}, this.$element.offset(), { var pos = $.extend({}, this.$element.position(), {
height: this.$element[0].offsetHeight height: this.$element[0].offsetHeight
}) })
this.$menu.css({ this.$menu
top: pos.top + pos.height .insertAfter(this.$element)
, left: pos.left .css({
}) top: pos.top + pos.height
, left: pos.left
})
.show()
this.$menu.show()
this.shown = true this.shown = true
return this return this
} }
@ -1801,7 +1900,7 @@
.on('keypress', $.proxy(this.keypress, this)) .on('keypress', $.proxy(this.keypress, this))
.on('keyup', $.proxy(this.keyup, this)) .on('keyup', $.proxy(this.keyup, this))
if ($.browser.chrome || $.browser.webkit || $.browser.msie) { if (this.eventSupported('keydown')) {
this.$element.on('keydown', $.proxy(this.keydown, this)) this.$element.on('keydown', $.proxy(this.keydown, this))
} }
@ -1810,6 +1909,15 @@
.on('mouseenter', 'li', $.proxy(this.mouseenter, this)) .on('mouseenter', 'li', $.proxy(this.mouseenter, 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) { , move: function (e) {
if (!this.shown) return if (!this.shown) return
@ -1835,7 +1943,7 @@
} }
, keydown: function (e) { , keydown: function (e) {
this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27]) this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
this.move(e) this.move(e)
} }
@ -1848,6 +1956,9 @@
switch(e.keyCode) { switch(e.keyCode) {
case 40: // down arrow case 40: // down arrow
case 38: // up arrow case 38: // up arrow
case 16: // shift
case 17: // ctrl
case 18: // alt
break break
case 9: // tab case 9: // tab
@ -1891,6 +2002,8 @@
/* TYPEAHEAD PLUGIN DEFINITION /* TYPEAHEAD PLUGIN DEFINITION
* =========================== */ * =========================== */
var old = $.fn.typeahead
$.fn.typeahead = function (option) { $.fn.typeahead = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -1912,21 +2025,28 @@
$.fn.typeahead.Constructor = Typeahead $.fn.typeahead.Constructor = Typeahead
/* TYPEAHEAD DATA-API /* TYPEAHEAD NO CONFLICT
* =================== */
$.fn.typeahead.noConflict = function () {
$.fn.typeahead = old
return this
}
/* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(function () { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { var $this = $(this)
var $this = $(this) if ($this.data('typeahead')) return
if ($this.data('typeahead')) return e.preventDefault()
e.preventDefault() $this.typeahead($this.data())
$this.typeahead($this.data())
})
}) })
}(window.jQuery); }(window.jQuery);
/* ========================================================== /* ==========================================================
* bootstrap-affix.js v2.1.1 * bootstrap-affix.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#affix * http://twitter.github.com/bootstrap/javascript.html#affix
* ========================================================== * ==========================================================
* Copyright 2012 Twitter, Inc. * Copyright 2012 Twitter, Inc.
@ -1955,7 +2075,9 @@
var Affix = function (element, options) { var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options) this.options = $.extend({}, $.fn.affix.defaults, options)
this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this)) 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))
this.$element = $(element) this.$element = $(element)
this.checkPosition() this.checkPosition()
} }
@ -1993,6 +2115,8 @@
/* AFFIX PLUGIN DEFINITION /* AFFIX PLUGIN DEFINITION
* ======================= */ * ======================= */
var old = $.fn.affix
$.fn.affix = function (option) { $.fn.affix = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
@ -2010,6 +2134,15 @@
} }
/* AFFIX NO CONFLICT
* ================= */
$.fn.affix.noConflict = function () {
$.fn.affix = old
return this
}
/* AFFIX DATA-API /* AFFIX DATA-API
* ============== */ * ============== */