1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-03 16:51:54 +02:00

merge in js from 1.4... start working through js docs

This commit is contained in:
Jacob Thornton
2011-11-20 20:58:04 -08:00
parent 0b1d5d9189
commit bc65b58551
15 changed files with 281 additions and 350 deletions

View File

@@ -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>'
}