mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 21:09:06 +02:00
giant refactor - all spec passing again...
This commit is contained in:
20
js/bootstrap-modal.js
vendored
20
js/bootstrap-modal.js
vendored
@@ -26,10 +26,9 @@
|
||||
* ====================== */
|
||||
|
||||
var Modal = function ( content, options ) {
|
||||
this.settings = $.extend({}, $.fn.modal.defaults, options)
|
||||
this.options = $.extend({}, $.fn.modal.defaults, options)
|
||||
this.$element = $(content)
|
||||
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
|
||||
this.settings.show && this.show()
|
||||
}
|
||||
|
||||
Modal.prototype = {
|
||||
@@ -107,7 +106,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
function hideModal (that) {
|
||||
function hideModal( that ) {
|
||||
this.$element
|
||||
.hide()
|
||||
.trigger('hidden')
|
||||
@@ -115,17 +114,17 @@
|
||||
backdrop.call(this)
|
||||
}
|
||||
|
||||
function backdrop ( callback ) {
|
||||
function backdrop( callback ) {
|
||||
var that = this
|
||||
, animate = this.$element.hasClass('fade') ? 'fade' : ''
|
||||
|
||||
if (this.isShown && this.settings.backdrop) {
|
||||
if (this.isShown && this.options.backdrop) {
|
||||
var doAnimate = $.support.transition && animate
|
||||
|
||||
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
||||
.appendTo(document.body)
|
||||
|
||||
if (this.settings.backdrop != 'static') {
|
||||
if (this.options.backdrop != 'static') {
|
||||
this.$backdrop.click($.proxy(this.hide, this))
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@
|
||||
|
||||
function escape() {
|
||||
var that = this
|
||||
if (this.isShown && this.settings.keyboard) {
|
||||
if (this.isShown && this.options.keyboard) {
|
||||
$(document).bind('keyup.dismiss.modal', function ( e ) {
|
||||
e.which == 27 && that.hide()
|
||||
})
|
||||
@@ -176,6 +175,7 @@
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('modal', (data = new Modal(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
else if (data.options.show) data.show()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@
|
||||
/* MODAL DATA-API
|
||||
* ============== */
|
||||
|
||||
$(document).ready(function () {
|
||||
$('body').delegate('[data-toggle="modal"]', 'click.modal.data-api', function ( e ) {
|
||||
$(function () {
|
||||
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
||||
var $this = $(this)
|
||||
, target = $this.attr('data-target') || $this.attr('href')
|
||||
, option = $(target).data('modal') ? 'toggle' : $this.data()
|
||||
@@ -201,4 +201,4 @@
|
||||
})
|
||||
})
|
||||
|
||||
}( window.jQuery || window.ender )
|
||||
}( window.jQuery )
|
Reference in New Issue
Block a user