js/bootstrap-alert.js
changeset 0 ba8ab09f730e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/bootstrap-alert.js	Fri Jul 04 16:42:41 2014 +0400
     1.3 @@ -0,0 +1,99 @@
     1.4 +/* ==========================================================
     1.5 + * bootstrap-alert.js v2.3.1
     1.6 + * http://twitter.github.com/bootstrap/javascript.html#alerts
     1.7 + * ==========================================================
     1.8 + * Copyright 2012 Twitter, Inc.
     1.9 + *
    1.10 + * Licensed under the Apache License, Version 2.0 (the "License");
    1.11 + * you may not use this file except in compliance with the License.
    1.12 + * You may obtain a copy of the License at
    1.13 + *
    1.14 + * http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing, software
    1.17 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.19 + * See the License for the specific language governing permissions and
    1.20 + * limitations under the License.
    1.21 + * ========================================================== */
    1.22 +
    1.23 +
    1.24 +!function ($) {
    1.25 +
    1.26 +  "use strict"; // jshint ;_;
    1.27 +
    1.28 +
    1.29 + /* ALERT CLASS DEFINITION
    1.30 +  * ====================== */
    1.31 +
    1.32 +  var dismiss = '[data-dismiss="alert"]'
    1.33 +    , Alert = function (el) {
    1.34 +        $(el).on('click', dismiss, this.close)
    1.35 +      }
    1.36 +
    1.37 +  Alert.prototype.close = function (e) {
    1.38 +    var $this = $(this)
    1.39 +      , selector = $this.attr('data-target')
    1.40 +      , $parent
    1.41 +
    1.42 +    if (!selector) {
    1.43 +      selector = $this.attr('href')
    1.44 +      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
    1.45 +    }
    1.46 +
    1.47 +    $parent = $(selector)
    1.48 +
    1.49 +    e && e.preventDefault()
    1.50 +
    1.51 +    $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
    1.52 +
    1.53 +    $parent.trigger(e = $.Event('close'))
    1.54 +
    1.55 +    if (e.isDefaultPrevented()) return
    1.56 +
    1.57 +    $parent.removeClass('in')
    1.58 +
    1.59 +    function removeElement() {
    1.60 +      $parent
    1.61 +        .trigger('closed')
    1.62 +        .remove()
    1.63 +    }
    1.64 +
    1.65 +    $.support.transition && $parent.hasClass('fade') ?
    1.66 +      $parent.on($.support.transition.end, removeElement) :
    1.67 +      removeElement()
    1.68 +  }
    1.69 +
    1.70 +
    1.71 + /* ALERT PLUGIN DEFINITION
    1.72 +  * ======================= */
    1.73 +
    1.74 +  var old = $.fn.alert
    1.75 +
    1.76 +  $.fn.alert = function (option) {
    1.77 +    return this.each(function () {
    1.78 +      var $this = $(this)
    1.79 +        , data = $this.data('alert')
    1.80 +      if (!data) $this.data('alert', (data = new Alert(this)))
    1.81 +      if (typeof option == 'string') data[option].call($this)
    1.82 +    })
    1.83 +  }
    1.84 +
    1.85 +  $.fn.alert.Constructor = Alert
    1.86 +
    1.87 +
    1.88 + /* ALERT NO CONFLICT
    1.89 +  * ================= */
    1.90 +
    1.91 +  $.fn.alert.noConflict = function () {
    1.92 +    $.fn.alert = old
    1.93 +    return this
    1.94 +  }
    1.95 +
    1.96 +
    1.97 + /* ALERT DATA-API
    1.98 +  * ============== */
    1.99 +
   1.100 +  $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
   1.101 +
   1.102 +}(window.jQuery);
   1.103 \ No newline at end of file