diff options
Diffstat (limited to 'js/alert.js')
| -rw-r--r-- | js/alert.js | 118 |
1 files changed, 56 insertions, 62 deletions
diff --git a/js/alert.js b/js/alert.js index f34f84a28..721e9aa47 100644 --- a/js/alert.js +++ b/js/alert.js @@ -7,92 +7,86 @@ * ======================================================================== */ -+function () { 'use strict'; ++function ($) { + 'use strict'; - (function (o_o) { - typeof define == 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) - })(function ($) { + // ALERT CLASS DEFINITION + // ====================== - // ALERT CLASS DEFINITION - // ====================== + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } - var dismiss = '[data-dismiss="alert"]' - var Alert = function (el) { - $(el).on('click', dismiss, this.close) - } - - Alert.VERSION = '3.1.1' + Alert.VERSION = '3.1.1' - Alert.prototype.close = function (e) { - var $this = $(this) - var selector = $this.attr('data-target') + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 - } - - var $parent = $(selector) + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } - if (e) e.preventDefault() + var $parent = $(selector) - if (!$parent.length) { - $parent = $this.hasClass('alert') ? $this : $this.parent() - } + if (e) e.preventDefault() - $parent.trigger(e = $.Event('close.bs.alert')) + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } - if (e.isDefaultPrevented()) return + $parent.trigger(e = $.Event('close.bs.alert')) - $parent.removeClass('in') + if (e.isDefaultPrevented()) return - function removeElement() { - // detach from parent, fire event then clean up data - $parent.detach().trigger('closed.bs.alert').remove() - } + $parent.removeClass('in') - $.support.transition && $parent.hasClass('fade') ? - $parent - .one('bsTransitionEnd', removeElement) - .emulateTransitionEnd(150) : - removeElement() + function removeElement() { + // detach from parent, fire event then clean up data + $parent.detach().trigger('closed.bs.alert').remove() } + $.support.transition && $parent.hasClass('fade') ? + $parent + .one('bsTransitionEnd', removeElement) + .emulateTransitionEnd(150) : + removeElement() + } - // ALERT PLUGIN DEFINITION - // ======================= - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.alert') + // ALERT PLUGIN DEFINITION + // ======================= - if (!data) $this.data('bs.alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) - }) - } + function Plugin(option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') - var old = $.fn.alert + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } - $.fn.alert = Plugin - $.fn.alert.Constructor = Alert + var old = $.fn.alert + $.fn.alert = Plugin + $.fn.alert.Constructor = Alert - // ALERT NO CONFLICT - // ================= - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this - } + // ALERT NO CONFLICT + // ================= + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } - // ALERT DATA-API - // ============== - $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + // ALERT DATA-API + // ============== - }) + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) -}(); +}(jQuery); |
