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:
authorJacob Thornton <jacobthornton@gmail.com>2011-11-21 08:58:04 +0400
committerJacob Thornton <jacobthornton@gmail.com>2011-11-21 08:58:04 +0400
commitbc65b58551575c9dfb2e4d9f4f7af97009e39432 (patch)
treecb27a6f15bfdd7650871f6f6aa5aba496201bd29 /js
parent0b1d5d9189ea82cde5e848e5a8771a8f4850e21f (diff)
merge in js from 1.4... start working through js docs
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-alerts.js44
-rw-r--r--js/bootstrap-dropdown.js43
-rw-r--r--js/bootstrap-modal.js48
-rw-r--r--js/bootstrap-popover.js6
-rw-r--r--js/bootstrap-scrollspy.js33
-rw-r--r--js/bootstrap-tabs.js2
-rw-r--r--js/bootstrap-transitions.js2
-rw-r--r--js/bootstrap-twipsy.js68
8 files changed, 81 insertions, 165 deletions
diff --git a/js/bootstrap-alerts.js b/js/bootstrap-alerts.js
index 3ef1672bc0..600440e40e 100644
--- a/js/bootstrap-alerts.js
+++ b/js/bootstrap-alerts.js
@@ -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 ); \ No newline at end of file
diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js
index cab0ec27ed..bb7d11b1fa 100644
--- a/js/bootstrap-dropdown.js
+++ b/js/bootstrap-dropdown.js
@@ -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 ); \ No newline at end of file
diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js
index be2315afba..ccc7b133b2 100644
--- a/js/bootstrap-modal.js
+++ b/js/bootstrap-modal.js
@@ -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() )
})
})
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js
index c23741735b..d0bd831317 100644
--- a/js/bootstrap-popover.js
+++ b/js/bootstrap-popover.js
@@ -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'
}
diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js
index 1269d91ecb..91c2dcb1ed 100644
--- a/js/bootstrap-scrollspy.js
+++ b/js/bootstrap-scrollspy.js
@@ -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 ) \ No newline at end of file
diff --git a/js/bootstrap-tabs.js b/js/bootstrap-tabs.js
index 790180ca2e..35418fd447 100644
--- a/js/bootstrap-tabs.js
+++ b/js/bootstrap-tabs.js
@@ -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.
diff --git a/js/bootstrap-transitions.js b/js/bootstrap-transitions.js
index 49b5338a8f..25f8b111f1 100644
--- a/js/bootstrap-transitions.js
+++ b/js/bootstrap-transitions.js
@@ -38,7 +38,7 @@ $(function () {
transitionEnd = "oTransitionEnd"
}
return transitionEnd
- })()
+ }())
}
})()
diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-twipsy.js
index fc22d0218b..19e43a7234 100644
--- a/js/bootstrap-twipsy.js
+++ b/js/bootstrap-twipsy.js
@@ -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>'
}