<commit_before>//(c) 2014 Indexia, Inc.
import Em from 'ember';
import Modal from './modal';
import WithConfigMixin from 'ember-idx-utils/mixin/with-config';
import StyleBindingsMixin from 'ember-idx-utils/mixin/style-bindings';

/**
 * `{{em-modal-toggler}}` component.
 *
 * A component to toggle the visibility of a modal
 *
 * @class ModalToggler
 * @event on-toggle triggered when the toggler is clicked before changing the visibility of the modal
 *   @param toggler Toggler - This instance of the toggler
 * @public
 */

export default Em.Component.extend(WithConfigMixin, StyleBindingsMixin, {
  attributeBindings: ['disabled', 'type'],
  tagName: 'button',
  classNameBindings: ['styleClasses'],
  type: 'button',

  /**
   * The CSS classes that will be attached to the DOM element of the modal
   * Classes should be configured externally by using the `config` object.
   *
   * @property styleClasses
   * @private
   * @type String
   */
  styleClasses: (function() {
    var _ref;
    return (_ref = this.get('config.modal.togglerClasses')) != null ? _ref.join(" ") : void 0;
  }).property(),

  /**
   * Toggle the visibility of the modal that this toggler controls.
   *
   * @method toggleVisibility
   * @private
   */
  toggleVisibility: (function() {
    this.sendAction('on-toggle', this);
    return this.get('modal').toggleVisibility();
  }).on('click'),

  /**
   * Find the modal view and set it as a `modal` property
   * A toggler can live as a descendant (not neccessarily a direct one) of a modal or outside of the modal chain
   * TODO: Assert modal existance
   * @method modalAsProperty
   */
  modalAsProperty: (function() {
    var modalAsAncestor;
    modalAsAncestor = this.nearestOfType(Modal);
    if (modalAsAncestor) {
      return this.set('modal', modalAsAncestor);
    } else {
      return Em.run.schedule('afterRender', this, function() {
        return this.set('modal', Em.View.views[this.get('modal-id')]);
      });
    }
  }).on('willInsertElement')
});<commit_msg>Allowing nested dependencies by changing the order for modal setting<commit_after>//(c) 2014 Indexia, Inc.
import Em from 'ember';
import Modal from './modal';
import WithConfigMixin from 'ember-idx-utils/mixin/with-config';
import StyleBindingsMixin from 'ember-idx-utils/mixin/style-bindings';

/**
 * `{{em-modal-toggler}}` component.
 *
 * A component to toggle the visibility of a modal
 *
 * @class ModalToggler
 * @event on-toggle triggered when the toggler is clicked before changing the visibility of the modal
 *   @param toggler Toggler - This instance of the toggler
 * @public
 */

export default Em.Component.extend(WithConfigMixin, StyleBindingsMixin, {
  attributeBindings: ['disabled', 'type'],
  tagName: 'button',
  classNameBindings: ['styleClasses'],
  type: 'button',

  /**
   * The CSS classes that will be attached to the DOM element of the modal
   * Classes should be configured externally by using the `config` object.
   *
   * @property styleClasses
   * @private
   * @type String
   */
  styleClasses: (function() {
    var _ref;
    return (_ref = this.get('config.modal.togglerClasses')) != null ? _ref.join(" ") : void 0;
  }).property(),

  /**
   * Toggle the visibility of the modal that this toggler controls.
   *
   * @method toggleVisibility
   * @private
   */
  toggleVisibility: (function() {
    this.sendAction('on-toggle', this);
    return this.get('modal').toggleVisibility();
  }).on('click'),

  /**
   * Find the modal view and set it as a `modal` property
   * A toggler can live as a descendant (not neccessarily a direct one) of a modal or outside of the modal chain
   * TODO: Assert modal existance
   * @method modalAsProperty
   */
  modalAsProperty: (function() {
    var modalId = this.get('modal-id'); 

    if (modalId) {
      return Em.run.schedule('afterRender', this, function() {
        return this.set('modal', Em.View.views[modalId]);
      });
    } else {
      return this.set('modal', this.nearestOfType(Modal));
    }
  }).on('willInsertElement')
});
{'fraction_non_alphanumeric': 0.12840178129638793, 'fraction_numerical': 0.002474022761009401, 'mean_word_length': 3.5274356103023514, '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': '6574634', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1218, 'n_words': 386}