1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-25 21:09:06 +02:00

greatly simply js plugins - remove js api where reasonable

This commit is contained in:
Jacob Thornton
2011-10-19 21:56:06 -07:00
parent c9669be1ec
commit 8545fe9787
10 changed files with 138 additions and 206 deletions

View File

@@ -17,90 +17,32 @@
* limitations under the License.
* ========================================================== */
(function( $ ){
/* 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
* ====================== */
var Alert = function ( content, selector ) {
this.$element = $(content)
.delegate('[data-alert-dismiss]', 'click', this.close)
}
function close(e) {
var $element = $(this).parent('.alert-message')
Alert.prototype = {
e && e.preventDefault()
$element.removeClass('in')
close: function (e) {
var $element = $(this).parent('.alert-message')
e && e.preventDefault()
e && e.stopPropagation()
$element.removeClass('in')
function removeElement () {
$element.remove()
}
$.support.transition && $element.hasClass('fade') ?
$element.bind(transitionEnd, removeElement) :
removeElement()
function removeElement () {
$element.remove()
}
$.support.transition && $element.hasClass('fade') ?
$element.bind($.support.transition.end, removeElement) :
removeElement()
}
/* ALERT PLUGIN DEFINITION
* ======================= */
$.fn.alert = function ( options ) {
if ( options === true ) {
return this.data('alert')
}
return this.each(function () {
var $this = $(this)
if ( typeof options == 'string' ) {
return $this.data('alert')[options]()
}
$(this).data('alert', new Alert( this ))
})
}
$(document).ready(function () {
new Alert($('body'))
$(function () {
$('body').delegate('[data-alert-dismiss]', 'click', close)
})
})( window.jQuery || window.ender )