Sha256: 7d1faa14b8cf25e25d3e94947fc16d69ee644118aba50335f76f9e34050d6abb

Contents?: true

Size: 1.75 KB

Versions: 246

Compression:

Stored size: 1.75 KB

Contents

+function ($) {
  'use strict';

  // ALERT CLASS DEFINITION
  // ======================

  var dismiss = '[data-dismiss="alert"]';
  var Alert = function (el) {
    $(el).on('click', dismiss, this.close);
  };

  Alert.VERSION = '1.0.0';
  Alert.TRANSITION_DURATION = 150;

  Alert.prototype.constructor = Alert;

  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]*$)/, '');
    }

    var $parent = $(selector);

    if (e) e.preventDefault();
    if (!$parent.length) {
      $parent = $this.closest('.alert');
    }

    $parent.trigger(e = $.Event('close.bs.alert'));

    if (e.isDefaultPrevented()) return;

    $parent.removeClass('in');

    function removeElement() {
      $parent.detach().trigger('closed.bs.alert').remove();
    }

    $.support.transition && $parent.hasClass('fade') ?
      $parent.one('bsTransitionEnd', removeElement)
        .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
      removeElement();
  };

  // ALERT PLUGIN DEFINITION
  // =======================

  function Plugin(option) {
    return this.each(function () {
      var $this = $(this);
      var data = $this.data('bs.alert');

      if (!data) $this.data('bs.alert', (data = new Alert(this)));
      if (typeof option === 'string') data[option]();
    });
  }

  var old = $.fn.alert;

  $.fn.alert = Plugin;
  $.fn.alert.Constructor = Alert;

  // 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);

}(jQuery);

Version data entries

246 entries across 246 versions & 1 rubygems

Version Path
active_frontend-15.0.17 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.16 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.15 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.14 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.13 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.12 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.11 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.10 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.9 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.8 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.7 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.6 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.5 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.4 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.3 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.2 vendor/assets/javascripts/base/_alert.js
active_frontend-15.0.1 vendor/assets/javascripts/base/_alert.js
active_frontend-14.2.6 vendor/assets/javascripts/base/_alert.js
active_frontend-14.2.5 vendor/assets/javascripts/base/_alert.js
active_frontend-14.2.4 vendor/assets/javascripts/base/_alert.js