mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-11 08:04:59 +02:00
merge in js from 1.4... start working through js docs
This commit is contained in:
44
js/bootstrap-alerts.js
vendored
44
js/bootstrap-alerts.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ==========================================================
|
||||
* bootstrap-alerts.js v1.4.0
|
||||
* bootstrap-alerts.js v2.0.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
||||
* ==========================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
@@ -22,34 +22,6 @@
|
||||
|
||||
"use strict"
|
||||
|
||||
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
|
||||
* ======================================================= */
|
||||
|
||||
var transitionEnd
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$.support.transition = (function () {
|
||||
var thisBody = document.body || document.documentElement
|
||||
, thisStyle = thisBody.style
|
||||
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
|
||||
return support
|
||||
})()
|
||||
|
||||
// set CSS transition event type
|
||||
if ( $.support.transition ) {
|
||||
transitionEnd = "TransitionEnd"
|
||||
if ( $.browser.webkit ) {
|
||||
transitionEnd = "webkitTransitionEnd"
|
||||
} else if ( $.browser.mozilla ) {
|
||||
transitionEnd = "transitionend"
|
||||
} else if ( $.browser.opera ) {
|
||||
transitionEnd = "oTransitionEnd"
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
/* ALERT CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
@@ -76,7 +48,7 @@
|
||||
}
|
||||
|
||||
$.support.transition && $element.hasClass('fade') ?
|
||||
$element.bind(transitionEnd, removeElement) :
|
||||
$element.bind($.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
}
|
||||
|
||||
@@ -88,10 +60,6 @@
|
||||
|
||||
$.fn.alert = function ( options ) {
|
||||
|
||||
if ( options === true ) {
|
||||
return this.data('alert')
|
||||
}
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data
|
||||
@@ -112,13 +80,11 @@
|
||||
}
|
||||
|
||||
$.fn.alert.defaults = {
|
||||
selector: '.close'
|
||||
selector: '[data-dismiss="alert"]'
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
new Alert($('body'), {
|
||||
selector: '.alert-message[data-alert] .close'
|
||||
})
|
||||
$(function () {
|
||||
new Alert( $('body') )
|
||||
})
|
||||
|
||||
}( window.jQuery || window.ender );
|
43
js/bootstrap-dropdown.js
vendored
43
js/bootstrap-dropdown.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ============================================================
|
||||
* bootstrap-dropdown.js v1.4.0
|
||||
* bootstrap-dropdown.js v2.0.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdown
|
||||
* ============================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
@@ -22,34 +22,45 @@
|
||||
|
||||
"use strict"
|
||||
|
||||
/* SIMPLE DROPDOWN LOGIC
|
||||
* ===================== */
|
||||
|
||||
var s = '[data-toggle="dropdown"]'
|
||||
|
||||
function clearMenus() {
|
||||
$(s).parent('li').removeClass('open')
|
||||
}
|
||||
|
||||
function toggle(e) {
|
||||
var li = $(this).parent('li')
|
||||
, isActive = li.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
!isActive && li.toggleClass('open')
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/* DROPDOWN PLUGIN DEFINITION
|
||||
* ========================== */
|
||||
|
||||
$.fn.dropdown = function ( selector ) {
|
||||
return this.each(function () {
|
||||
$(this).delegate(selector || d, 'click', function (e) {
|
||||
var li = $(this).parent('li')
|
||||
, isActive = li.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
!isActive && li.toggleClass('open')
|
||||
return false
|
||||
})
|
||||
var args = ['click', toggle]
|
||||
, $this = $(this)
|
||||
selector && args.unshift(selector)
|
||||
$this[selector ? 'delegate' : 'bind'].apply($this, args)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||
* =================================== */
|
||||
|
||||
var d = 'a.menu, .dropdown-toggle'
|
||||
|
||||
function clearMenus() {
|
||||
$(d).parent('li').removeClass('open')
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('html').bind("click", clearMenus)
|
||||
$('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
|
||||
$('body').dropdown(s)
|
||||
})
|
||||
|
||||
}( window.jQuery || window.ender );
|
48
js/bootstrap-modal.js
vendored
48
js/bootstrap-modal.js
vendored
@@ -22,35 +22,6 @@
|
||||
|
||||
"use strict"
|
||||
|
||||
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
|
||||
* ======================================================= */
|
||||
|
||||
var transitionEnd
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$.support.transition = (function () {
|
||||
var thisBody = document.body || document.documentElement
|
||||
, thisStyle = thisBody.style
|
||||
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
|
||||
return support
|
||||
})()
|
||||
|
||||
// set CSS transition event type
|
||||
if ( $.support.transition ) {
|
||||
transitionEnd = "TransitionEnd"
|
||||
if ( $.browser.webkit ) {
|
||||
transitionEnd = "webkitTransitionEnd"
|
||||
} else if ( $.browser.mozilla ) {
|
||||
transitionEnd = "transitionend"
|
||||
} else if ( $.browser.opera ) {
|
||||
transitionEnd = "oTransitionEnd"
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
/* MODAL PUBLIC CLASS DEFINITION
|
||||
* ============================= */
|
||||
|
||||
@@ -92,7 +63,7 @@
|
||||
that.$element.addClass('in')
|
||||
|
||||
transition ?
|
||||
that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
|
||||
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
|
||||
that.$element.trigger('shown')
|
||||
|
||||
})
|
||||
@@ -130,14 +101,13 @@
|
||||
* ===================== */
|
||||
|
||||
function hideWithTransition() {
|
||||
// firefox drops transitionEnd events :{o
|
||||
var that = this
|
||||
, timeout = setTimeout(function () {
|
||||
that.$element.unbind(transitionEnd)
|
||||
that.$element.unbind($.support.transition.end)
|
||||
hideModal.call(that)
|
||||
}, 500)
|
||||
|
||||
this.$element.one(transitionEnd, function () {
|
||||
this.$element.one($.support.transition.end, function () {
|
||||
clearTimeout(timeout)
|
||||
hideModal.call(that)
|
||||
})
|
||||
@@ -171,14 +141,14 @@
|
||||
this.$backdrop.addClass('in')
|
||||
|
||||
doAnimate ?
|
||||
this.$backdrop.one(transitionEnd, callback) :
|
||||
this.$backdrop.one($.support.transition.end, callback) :
|
||||
callback()
|
||||
|
||||
} else if ( !this.isShown && this.$backdrop ) {
|
||||
this.$backdrop.removeClass('in')
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade')?
|
||||
this.$backdrop.one(transitionEnd, $.proxy(removeBackdrop, this)) :
|
||||
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
|
||||
removeBackdrop.call(this)
|
||||
|
||||
} else if ( callback ) {
|
||||
@@ -240,9 +210,9 @@
|
||||
$.fn.modal.Modal = Modal
|
||||
|
||||
$.fn.modal.defaults = {
|
||||
backdrop: false
|
||||
, keyboard: false
|
||||
, show: false
|
||||
backdrop: true
|
||||
, keyboard: true
|
||||
, show: true
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +222,7 @@
|
||||
$(document).ready(function () {
|
||||
$('body').delegate('[data-controls-modal]', 'click', function (e) {
|
||||
e.preventDefault()
|
||||
var $this = $(this).data('show', true)
|
||||
var $this = $(this)
|
||||
$('#' + $this.attr('data-controls-modal')).modal( $this.data() )
|
||||
})
|
||||
})
|
||||
|
6
js/bootstrap-popover.js
vendored
6
js/bootstrap-popover.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ===========================================================
|
||||
* bootstrap-popover.js v1.4.0
|
||||
* bootstrap-popover.js v2.0.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#popover
|
||||
* ===========================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
setContent: function () {
|
||||
var $tip = this.tip()
|
||||
$tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle())
|
||||
$tip.find('.content > *')[this.options.html ? 'html' : 'text'](this.getContent())
|
||||
$tip.find('.title')['html'](this.getTitle())
|
||||
$tip.find('.content > *')['html'](this.getContent())
|
||||
$tip[0].className = 'popover'
|
||||
}
|
||||
|
||||
|
33
js/bootstrap-scrollspy.js
vendored
33
js/bootstrap-scrollspy.js
vendored
@@ -20,33 +20,34 @@
|
||||
|
||||
!function ( $ ) {
|
||||
|
||||
var $window = $(window)
|
||||
|
||||
function ScrollSpy() {
|
||||
var process = $.proxy(this.process, this)
|
||||
this.$topbar = $('body')
|
||||
this.selector = '[data-scrollspy] li > a'
|
||||
this.selector = '.nav li > a'
|
||||
|
||||
this.$body = $('body').delegate(this.selector, 'click', process)
|
||||
this.$scrollElement = $('[data-spy="scroll"]').bind('scroll', process)
|
||||
|
||||
this.refresh()
|
||||
this.$topbar.delegate(this.selector, 'click', process)
|
||||
$window.scroll(process)
|
||||
this.process()
|
||||
}
|
||||
|
||||
ScrollSpy.prototype = {
|
||||
|
||||
refresh: function () {
|
||||
this.targets = this.$topbar.find(this.selector).map(function () {
|
||||
var href = $(this).attr('href')
|
||||
return /^#\w/.test(href) && $(href).length ? href : null
|
||||
})
|
||||
this.targets = this.$body
|
||||
.find(this.selector)
|
||||
.map(function () {
|
||||
var href = $(this).attr('href')
|
||||
return /^#\w/.test(href) && $(href).length ? href : null
|
||||
})
|
||||
|
||||
this.offsets = $.map(this.targets, function (id) {
|
||||
return $(id).offset().top
|
||||
return $(id).position().top
|
||||
})
|
||||
}
|
||||
|
||||
, process: function () {
|
||||
var scrollTop = $window.scrollTop() + 10
|
||||
var scrollTop = this.$scrollElement.scrollTop() + 10
|
||||
, offsets = this.offsets
|
||||
, targets = this.targets
|
||||
, activeTarget = this.activeTarget
|
||||
@@ -65,11 +66,11 @@
|
||||
|
||||
this.activeTarget = target
|
||||
|
||||
this.$topbar
|
||||
this.$body
|
||||
.find(this.selector).parent('.active')
|
||||
.removeClass('active')
|
||||
|
||||
active = this.$topbar
|
||||
active = this.$body
|
||||
.find(this.selector + '[href="' + target + '"]')
|
||||
.parent('li')
|
||||
.addClass('active')
|
||||
@@ -82,8 +83,6 @@
|
||||
|
||||
}
|
||||
|
||||
$(function () {
|
||||
new ScrollSpy()
|
||||
})
|
||||
$(function () { new ScrollSpy() })
|
||||
|
||||
}( window.jQuery || window.ender )
|
2
js/bootstrap-tabs.js
vendored
2
js/bootstrap-tabs.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ========================================================
|
||||
* bootstrap-tabs.js v1.4.0
|
||||
* bootstrap-tabs.js v2.0.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
|
2
js/bootstrap-transitions.js
vendored
2
js/bootstrap-transitions.js
vendored
@@ -38,7 +38,7 @@ $(function () {
|
||||
transitionEnd = "oTransitionEnd"
|
||||
}
|
||||
return transitionEnd
|
||||
})()
|
||||
}())
|
||||
}
|
||||
})()
|
||||
|
||||
|
68
js/bootstrap-twipsy.js
vendored
68
js/bootstrap-twipsy.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ==========================================================
|
||||
* bootstrap-twipsy.js v1.4.0
|
||||
* bootstrap-twipsy.js v2.0.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#twipsy
|
||||
* Adapted from the original jQuery.tipsy by Jason Frame
|
||||
* ==========================================================
|
||||
@@ -18,40 +18,10 @@
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function( $ ) {
|
||||
|
||||
"use strict"
|
||||
|
||||
/* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
|
||||
* ======================================================= */
|
||||
|
||||
var transitionEnd
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$.support.transition = (function () {
|
||||
var thisBody = document.body || document.documentElement
|
||||
, thisStyle = thisBody.style
|
||||
, support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
|
||||
return support
|
||||
})()
|
||||
|
||||
// set CSS transition event type
|
||||
if ( $.support.transition ) {
|
||||
transitionEnd = "TransitionEnd"
|
||||
if ( $.browser.webkit ) {
|
||||
transitionEnd = "webkitTransitionEnd"
|
||||
} else if ( $.browser.mozilla ) {
|
||||
transitionEnd = "transitionend"
|
||||
} else if ( $.browser.opera ) {
|
||||
transitionEnd = "oTransitionEnd"
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
/* TWIPSY PUBLIC CLASS DEFINITION
|
||||
* ============================== */
|
||||
|
||||
@@ -119,7 +89,7 @@
|
||||
|
||||
, setContent: function () {
|
||||
var $tip = this.tip()
|
||||
$tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
|
||||
$tip.find('.twipsy-inner').html(this.getTitle())
|
||||
$tip[0].className = 'twipsy'
|
||||
}
|
||||
|
||||
@@ -134,7 +104,7 @@
|
||||
}
|
||||
|
||||
$.support.transition && this.$tip.hasClass('fade') ?
|
||||
$tip.bind(transitionEnd, removeElement) :
|
||||
$tip.bind( $.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
}
|
||||
|
||||
@@ -164,7 +134,7 @@
|
||||
|
||||
title = ('' + title).replace(/(^\s*|\s*$)/, "")
|
||||
|
||||
return title || o.fallback
|
||||
return title
|
||||
}
|
||||
|
||||
, tip: function() {
|
||||
@@ -219,18 +189,21 @@
|
||||
, eventIn
|
||||
, eventOut
|
||||
|
||||
if (options === true) {
|
||||
return this.data(name)
|
||||
} else if (typeof options == 'string') {
|
||||
if (typeof options == 'string') {
|
||||
twipsy = this.data(name)
|
||||
if (twipsy) {
|
||||
twipsy[options]()
|
||||
}
|
||||
if (twipsy) twipsy[options]()
|
||||
return this
|
||||
}
|
||||
|
||||
options = $.extend({}, $.fn[name].defaults, options)
|
||||
|
||||
if (options.delay && typeof options.delay == 'number') {
|
||||
options.delay = {
|
||||
show: options.delay
|
||||
, hide: options.delay
|
||||
}
|
||||
}
|
||||
|
||||
function get(ele) {
|
||||
var twipsy = $.data(ele, name)
|
||||
|
||||
@@ -246,7 +219,7 @@
|
||||
var twipsy = get(this)
|
||||
twipsy.hoverState = 'in'
|
||||
|
||||
if (options.delayIn == 0) {
|
||||
if (!options.delay || !options.delay.show) {
|
||||
twipsy.show()
|
||||
} else {
|
||||
twipsy.fixTitle()
|
||||
@@ -254,21 +227,21 @@
|
||||
if (twipsy.hoverState == 'in') {
|
||||
twipsy.show()
|
||||
}
|
||||
}, options.delayIn)
|
||||
}, options.delay.show)
|
||||
}
|
||||
}
|
||||
|
||||
function leave() {
|
||||
var twipsy = get(this)
|
||||
twipsy.hoverState = 'out'
|
||||
if (options.delayOut == 0) {
|
||||
if (!options.delay || !options.delay.hide) {
|
||||
twipsy.hide()
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
if (twipsy.hoverState == 'out') {
|
||||
twipsy.hide()
|
||||
}
|
||||
}, options.delayOut)
|
||||
}, options.delay.hide)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,15 +265,12 @@
|
||||
|
||||
$.fn.twipsy.defaults = {
|
||||
animate: true
|
||||
, delayIn: 0
|
||||
, delayOut: 0
|
||||
, fallback: ''
|
||||
, delay: 0
|
||||
, placement: 'above'
|
||||
, html: false
|
||||
, live: false
|
||||
, offset: 0
|
||||
, title: 'title'
|
||||
, trigger: 'hover'
|
||||
, title: 'title'
|
||||
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user