You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

4 years ago
  1. /* ========================================================================
  2. * Bootstrap: alert.js v3.3.7
  3. * http://getbootstrap.com/javascript/#alerts
  4. * ========================================================================
  5. * Copyright 2011-2016 Twitter, Inc.
  6. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  7. * ======================================================================== */
  8. +function ($) {
  9. 'use strict';
  10. // ALERT CLASS DEFINITION
  11. // ======================
  12. var dismiss = '[data-dismiss="alert"]'
  13. var Alert = function (el) {
  14. $(el).on('click', dismiss, this.close)
  15. }
  16. Alert.VERSION = '3.3.7'
  17. Alert.TRANSITION_DURATION = 150
  18. Alert.prototype.close = function (e) {
  19. var $this = $(this)
  20. var selector = $this.attr('data-target')
  21. if (!selector) {
  22. selector = $this.attr('href')
  23. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  24. }
  25. var $parent = $(selector === '#' ? [] : selector)
  26. if (e) e.preventDefault()
  27. if (!$parent.length) {
  28. $parent = $this.closest('.alert')
  29. }
  30. $parent.trigger(e = $.Event('close.bs.alert'))
  31. if (e.isDefaultPrevented()) return
  32. $parent.removeClass('in')
  33. function removeElement() {
  34. // detach from parent, fire event then clean up data
  35. $parent.detach().trigger('closed.bs.alert').remove()
  36. }
  37. $.support.transition && $parent.hasClass('fade') ?
  38. $parent
  39. .one('bsTransitionEnd', removeElement)
  40. .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
  41. removeElement()
  42. }
  43. // ALERT PLUGIN DEFINITION
  44. // =======================
  45. function Plugin(option) {
  46. return this.each(function () {
  47. var $this = $(this)
  48. var data = $this.data('bs.alert')
  49. if (!data) $this.data('bs.alert', (data = new Alert(this)))
  50. if (typeof option == 'string') data[option].call($this)
  51. })
  52. }
  53. var old = $.fn.alert
  54. $.fn.alert = Plugin
  55. $.fn.alert.Constructor = Alert
  56. // ALERT NO CONFLICT
  57. // =================
  58. $.fn.alert.noConflict = function () {
  59. $.fn.alert = old
  60. return this
  61. }
  62. // ALERT DATA-API
  63. // ==============
  64. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  65. }(jQuery);