github.com/kayoticsully/syncthing@v0.8.9-0.20140724133906-c45a2fdc03f8/assets/bootstrap-3.1.1/js/alert.js (about)

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