<commit_before>import Ember from 'ember';
import Notify from 'ember-notify';
import Message from 'ember-notify/message';

export default Ember.Component.extend({
  source: null,
  messages: null,
  closeAfter: 2500,

  classNames: ['ember-notify-cn'],
  messageStyle: 'foundation',

  init: function() {
    this._super();
    this.messages = [];

    if (Ember.isNone(this.get('source'))) this.set('source', Notify);
    this.set('source.target', this);

    var style = this.get('messageStyle'), klass;
    if (style) {
      if ('foundation' === style) klass = FoundationView;
      else if ('bootstrap' === style) klass = BootstrapView;
      else throw new Error(
        "Unknown messageStyle %s: options are 'foundation' and 'bootstrap'".fmt(style)
      );
    }
    this.set('messageClass', klass || this.constructor.defaultViewClass);
  },
  show: function(message) {
    if (!(message instanceof Message)) {
      message = Message.create(message);
    }
    this.messages.pushObject(message);
    return message;
  }
});

export var MessageView = Ember.View.extend({
  message: null,
  closeAfter: null,

  classNames: ['ember-notify'],
  classNameBindings: ['typeCss', 'message.visible:ember-notify-show:ember-notify-hidden'],
  attributeBindings: ['data-alert'],
  'data-alert': '',

  run: null,

  init: function() {
    this._super();
    this.run = Runner.create({
      // disable all the scheduling in tests
      disabled: Ember.testing && !Notify.testing
    });
  },<commit_msg>only show a notification if the component hasn't been destroyed; this cropped up when running tests on an application using it; and seems like generally a good idea<commit_after>import Ember from 'ember';
import Notify from 'ember-notify';
import Message from 'ember-notify/message';

export default Ember.Component.extend({
  source: null,
  messages: null,
  closeAfter: 2500,

  classNames: ['ember-notify-cn'],
  messageStyle: 'foundation',

  init: function() {
    this._super();
    this.messages = [];

    if (Ember.isNone(this.get('source'))) this.set('source', Notify);
    this.set('source.target', this);

    var style = this.get('messageStyle'), klass;
    if (style) {
      if ('foundation' === style) klass = FoundationView;
      else if ('bootstrap' === style) klass = BootstrapView;
      else throw new Error(
        "Unknown messageStyle %s: options are 'foundation' and 'bootstrap'".fmt(style)
      );
    }
    this.set('messageClass', klass || this.constructor.defaultViewClass);
  },
  show: function(message) {
    if (!(message instanceof Message)) {
      message = Message.create(message);
    }
    if (!this.get('isDestroyed')) {
      this.messages.pushObject(message);
    }
    return message;
  }
});

export var MessageView = Ember.View.extend({
  message: null,
  closeAfter: null,

  classNames: ['ember-notify'],
  classNameBindings: ['typeCss', 'message.visible:ember-notify-show:ember-notify-hidden'],
  attributeBindings: ['data-alert'],
  'data-alert': '',

  run: null,

  init: function() {
    this._super();
    this.run = Runner.create({
      // disable all the scheduling in tests
      disabled: Ember.testing && !Notify.testing
    });
  },
{'fraction_non_alphanumeric': 0.14920237722865187, 'fraction_numerical': 0.0025023459493274947, 'mean_word_length': 3.5490753911806543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3606005', 'n_tokens_mistral': 973, 'n_tokens_neox': 953, 'n_words': 249}