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:
131
js/bootstrap-modal.js
vendored
131
js/bootstrap-modal.js
vendored
@@ -1,5 +1,5 @@
|
||||
/* =========================================================
|
||||
* bootstrap-modal.js v2.0.0
|
||||
* bootstrap-modal.js v1.4.0
|
||||
* http://twitter.github.com/bootstrap/javascript.html#modal
|
||||
* =========================================================
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
@@ -20,13 +20,44 @@
|
||||
|
||||
!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"
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
/* MODAL PUBLIC CLASS DEFINITION
|
||||
* ============================= */
|
||||
|
||||
var Modal = function ( content, options ) {
|
||||
this.settings = $.extend({}, $.fn.modal.defaults, options)
|
||||
this.$element = $(content)
|
||||
.delegate('[data-modal-dismiss]', 'click', $.proxy(this.hide, this))
|
||||
.delegate('.close', 'click.modal', $.proxy(this.hide, this))
|
||||
|
||||
if ( this.settings.show ) {
|
||||
this.show()
|
||||
@@ -47,7 +78,24 @@
|
||||
this.$element.trigger('show')
|
||||
|
||||
escape.call(this)
|
||||
backdrop.call(this)
|
||||
backdrop.call(this, function () {
|
||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
||||
|
||||
that.$element
|
||||
.appendTo(document.body)
|
||||
.show()
|
||||
|
||||
if (transition) {
|
||||
that.$element[0].offsetWidth // force reflow
|
||||
}
|
||||
|
||||
that.$element.addClass('in')
|
||||
|
||||
transition ?
|
||||
that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
|
||||
that.$element.trigger('shown')
|
||||
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
@@ -68,17 +116,9 @@
|
||||
.trigger('hide')
|
||||
.removeClass('in')
|
||||
|
||||
function removeElement () {
|
||||
that.$element
|
||||
.hide()
|
||||
.trigger('hidden')
|
||||
|
||||
backdrop.call(that)
|
||||
}
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade') ?
|
||||
this.$element.one($.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
hideWithTransition.call(this) :
|
||||
hideModal.call(this)
|
||||
|
||||
return this
|
||||
}
|
||||
@@ -89,11 +129,31 @@
|
||||
/* MODAL PRIVATE METHODS
|
||||
* ===================== */
|
||||
|
||||
function backdrop () {
|
||||
function hideWithTransition() {
|
||||
// firefox drops transitionEnd events :{o
|
||||
var that = this
|
||||
, timeout = setTimeout(function () {
|
||||
that.$element.unbind(transitionEnd)
|
||||
hideModal.call(that)
|
||||
}, 500)
|
||||
|
||||
this.$element.one(transitionEnd, function () {
|
||||
clearTimeout(timeout)
|
||||
hideModal.call(that)
|
||||
})
|
||||
}
|
||||
|
||||
function hideModal (that) {
|
||||
this.$element
|
||||
.hide()
|
||||
.trigger('hidden')
|
||||
|
||||
backdrop.call(this)
|
||||
}
|
||||
|
||||
function backdrop ( callback ) {
|
||||
var that = this
|
||||
, animate = this.$element.hasClass('fade') ? 'fade' : ''
|
||||
, callback = $.proxy(show, this)
|
||||
|
||||
if ( this.isShown && this.settings.backdrop ) {
|
||||
var doAnimate = $.support.transition && animate
|
||||
|
||||
@@ -111,43 +171,24 @@
|
||||
this.$backdrop.addClass('in')
|
||||
|
||||
doAnimate ?
|
||||
this.$backdrop.one($.support.transition.end, callback) :
|
||||
this.$backdrop.one(transitionEnd, callback) :
|
||||
callback()
|
||||
|
||||
} else if ( !this.isShown && this.$backdrop ) {
|
||||
this.$backdrop.removeClass('in')
|
||||
|
||||
function removeElement() {
|
||||
that.$backdrop.remove()
|
||||
that.$backdrop = null
|
||||
}
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade')?
|
||||
this.$backdrop.one($.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
this.$backdrop.one(transitionEnd, $.proxy(removeBackdrop, this)) :
|
||||
removeBackdrop.call(this)
|
||||
|
||||
} else if ( callback ) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
function show() {
|
||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
||||
, that = this
|
||||
|
||||
this.$element
|
||||
.appendTo(document.body)
|
||||
.show()
|
||||
|
||||
if (transition) {
|
||||
this.$element[0].offsetWidth // force reflow
|
||||
}
|
||||
|
||||
this.$element
|
||||
.addClass('in')
|
||||
|
||||
transition ?
|
||||
this.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
|
||||
this.$element.trigger('shown')
|
||||
function removeBackdrop() {
|
||||
this.$backdrop.remove()
|
||||
this.$backdrop = null
|
||||
}
|
||||
|
||||
function escape() {
|
||||
@@ -205,10 +246,10 @@
|
||||
}
|
||||
|
||||
|
||||
/* MODAL DATA-IMPLEMENTATION
|
||||
* ========================= */
|
||||
/* MODAL DATA- IMPLEMENTATION
|
||||
* ========================== */
|
||||
|
||||
$(function () {
|
||||
$(document).ready(function () {
|
||||
$('body').delegate('[data-controls-modal]', 'click', function (e) {
|
||||
e.preventDefault()
|
||||
var $this = $(this).data('show', true)
|
||||
|
Reference in New Issue
Block a user