mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 21:09:06 +02:00
revert all js stuff back to 1.4 :/
This commit is contained in:
104
js/bootstrap-alerts.js
vendored
104
js/bootstrap-alerts.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* ==========================================================
|
||||
* bootstrap-alerts.js v2.0.0
|
||||
* bootstrap-alerts.js v1.4.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
||||
* ==========================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
@@ -17,32 +17,108 @@
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
(function( $ ){
|
||||
|
||||
!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"
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
/* ALERT CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
function close(e) {
|
||||
var $element = $(this).parent('.alert-message')
|
||||
var Alert = function ( content, options ) {
|
||||
if (options == 'close') return this.close.call(content)
|
||||
this.settings = $.extend({}, $.fn.alert.defaults, options)
|
||||
this.$element = $(content)
|
||||
.delegate(this.settings.selector, 'click', this.close)
|
||||
}
|
||||
|
||||
e && e.preventDefault()
|
||||
$element.removeClass('in')
|
||||
Alert.prototype = {
|
||||
|
||||
function removeElement () {
|
||||
$element.remove()
|
||||
close: function (e) {
|
||||
var $element = $(this)
|
||||
, className = 'alert-message'
|
||||
|
||||
$element = $element.hasClass(className) ? $element : $element.parent()
|
||||
|
||||
e && e.preventDefault()
|
||||
$element.removeClass('in')
|
||||
|
||||
function removeElement () {
|
||||
$element.remove()
|
||||
}
|
||||
|
||||
$.support.transition && $element.hasClass('fade') ?
|
||||
$element.bind(transitionEnd, removeElement) :
|
||||
removeElement()
|
||||
}
|
||||
|
||||
$.support.transition && $element.hasClass('fade') ?
|
||||
$element.bind($.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
}
|
||||
|
||||
|
||||
/* ALERT PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$(function () {
|
||||
$('body').delegate('[data-alert-dismiss]', 'click', close)
|
||||
$.fn.alert = function ( options ) {
|
||||
|
||||
if ( options === true ) {
|
||||
return this.data('alert')
|
||||
}
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data
|
||||
|
||||
if ( typeof options == 'string' ) {
|
||||
|
||||
data = $this.data('alert')
|
||||
|
||||
if (typeof data == 'object') {
|
||||
return data[options].call( $this )
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(this).data('alert', new Alert( this, options ))
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.alert.defaults = {
|
||||
selector: '.close'
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
new Alert($('body'), {
|
||||
selector: '.alert-message[data-alert] .close'
|
||||
})
|
||||
})
|
||||
|
||||
})( window.jQuery || window.ender )
|
||||
}( window.jQuery || window.ender );
|
Reference in New Issue
Block a user