# ------------------------------------------------------------------- # components / alerts.coffee # ALERTS_CONTAINER_ID = 'pa-page-alerts-box' ### * @class Alert ### Alert = -> @ Alert.DEFAULTS = type: 'warning' # Default types: warning, danger, success, info close_btn: true classes: false # string or false namespace: 'pa_page_alerts' animate: true auto_close: false # seconds or false Alert.TYPES_HASH = warning: '' danger: 'alert-danger' success: 'alert-success' info: 'alert-info' ### * Initialize plugin. ### Alert.prototype.init = -> self = @ # Close button $('#main-wrapper').on 'click.pa.alerts', '#' + ALERTS_CONTAINER_ID + ' .close', -> self.close $(@).parents('.alert') false ### * Add new alert. * * @param {String} html * @param {Object} options ### Alert.prototype.add = (html, options) -> # Extend default options options = $.extend({}, Alert.DEFAULTS, options || {}); # Create alert $alert = $('
').html(html) # Add custom classes $alert.addClass(options.classes) if options.classes # Add close button $alert.prepend($('