diff options
author | Jacob Thornton <jacobthornton@gmail.com> | 2011-10-20 08:56:06 +0400 |
---|---|---|
committer | Jacob Thornton <jacobthornton@gmail.com> | 2011-10-20 08:56:06 +0400 |
commit | 8545fe97877dc275df40ab98d408f21ce9a362cf (patch) | |
tree | 1748be70e5c1c3b96cb2d836a909350fd7855772 /js/bootstrap-modal.js | |
parent | c9669be1ec2862b88ffdb296191e82fed79f56a4 (diff) |
greatly simply js plugins - remove js api where reasonable
Diffstat (limited to 'js/bootstrap-modal.js')
-rw-r--r-- | js/bootstrap-modal.js | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 60b83d58fd..02f8b23827 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -20,35 +20,6 @@ !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" - } - } - - }) - - /* MODAL PUBLIC CLASS DEFINITION * ============================= */ @@ -76,25 +47,7 @@ this.$element.trigger('show') escape.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') - - }) + backdrop.call(this) return this } @@ -124,7 +77,7 @@ } $.support.transition && this.$element.hasClass('fade') ? - this.$element.one(transitionEnd, removeElement) : + this.$element.one($.support.transition.end, removeElement) : removeElement() return this @@ -136,9 +89,11 @@ /* MODAL PRIVATE METHODS * ===================== */ - function backdrop ( callback ) { + function backdrop () { var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' + , callback = $.proxy(show, this) + if ( this.isShown && this.settings.backdrop ) { var doAnimate = $.support.transition && animate @@ -156,7 +111,7 @@ this.$backdrop.addClass('in') doAnimate ? - this.$backdrop.one(transitionEnd, callback) : + this.$backdrop.one($.support.transition.end, callback) : callback() } else if ( !this.isShown && this.$backdrop ) { @@ -168,13 +123,33 @@ } $.support.transition && this.$element.hasClass('fade')? - this.$backdrop.one(transitionEnd, removeElement) : + this.$backdrop.one($.support.transition.end, removeElement) : removeElement() } 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 escape() { var that = this if ( this.isShown && this.settings.keyboard ) { @@ -233,7 +208,7 @@ /* MODAL DATA-IMPLEMENTATION * ========================= */ - $(document).ready(function () { + $(function () { $('body').delegate('[data-controls-modal]', 'click', function (e) { e.preventDefault() var $this = $(this).data('show', true) |