<commit_before>import Ember from 'ember';
import layout from '../templates/components/floating-mobile-buttons';

export default Ember.Component.extend({
  layout,
  tagName: 'ul',
  classNames: ['floating-buttons'],
  classNameBindings: ['active:active', 'bottom:bottom', 'top:top', 'left:left', 'right:right'],
  active: false,
  childrenActive: false,
  hasChildren: false,
  position: 'bottom right',
  didReceiveAttrs(){
    this._super(...arguments);
    let classes = this.get('position').trim().split(" ");
    let vClasses = classes.filter( c => {
      if(c.match(/(bottom|top)/i)){
        return c;
      }
    });
    let hClasses = classes.filter( c => {
      if(c.match(/(right|left)/i)){
        return c;
      }
    });

    if(vClasses.length === 0 || vClasses.length > 1 || hClasses.length === 0 || hClasses.length > 1){
      Ember.assert('The position property must be a string with the values top|bottom and left|right.');
    }

    classes.forEach( c => {
        this.set(c, true);
    });
  },
  didInsertElement(){
    this._super(...arguments);
    this.set('active', true);

    if(Ember.$(`#${this.get('elementId')} .floating-child-button`).length > 1){
      this.set('hasChildren', true);
    }
  },
  actions: {
    toggleChildren(){
      this.toggleProperty('childrenActive');
    }
  }
});<commit_msg>Use the afterRender run loop to check if has children<commit_after>import Ember from 'ember';
import layout from '../templates/components/floating-mobile-buttons';

export default Ember.Component.extend({
  layout,
  tagName: 'ul',
  classNames: ['floating-buttons'],
  classNameBindings: ['active:active', 'bottom:bottom', 'top:top', 'left:left', 'right:right'],
  active: false,
  childrenActive: false,
  hasChildren: false,
  position: 'bottom right',
  didReceiveAttrs(){
    this._super(...arguments);

    this.set('active', true);

    let classes = this.get('position').trim().split(" ");
    let vClasses = classes.filter( c => {
      if(c.match(/(bottom|top)/i)){
        return c;
      }
    });
    let hClasses = classes.filter( c => {
      if(c.match(/(right|left)/i)){
        return c;
      }
    });

    if(vClasses.length === 0 || vClasses.length > 1 || hClasses.length === 0 || hClasses.length > 1){
      Ember.assert('The position property must be a string with the values top|bottom and left|right.');
    }

    classes.forEach( c => {
        this.set(c, true);
    });

    Ember.run.schedule('afterRender', () => {
      if(Ember.$(`#${this.get('elementId')} .floating-child-button`).length > 1){
        this.set('hasChildren', true);
      }
    });
  },
  actions: {
    toggleChildren(){
      this.toggleProperty('childrenActive');
    }
  }
});
{'fraction_non_alphanumeric': 0.18161764705882352, 'fraction_numerical': 0.003676470588235294, 'mean_word_length': 3.0733532934131738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '4728722', 'n_tokens_mistral': 877, 'n_tokens_neox': 854, 'n_words': 182}