<commit_before>/**
 * This class represents a view that is split either vertically or horizontally.
 * The split view is composed of three child views: a left or top view, a sash
 * view, and a right or bottom view.  The sash may be dragged to change the
 * relative width or height of the child views.
 *
 * Vertical SplitView example:
 *
 * ```handlebars
 * {{#view "split" isVertical=true}}
 *   {{#view "span" viewName="leftOrTop"}}
 *     Content of the left view here.
 *   {{/view}}{{view "sash" viewName="sash"}}{{#view "span" viewName="rightOrBottom"}}
 *     Content of the right view here.
 *   {{/view}}
 * {{/view}}
 * ```
 *
 * Horizontal SplitView example:
 *
 * ```handlebars
 * {{#view "split" isVertical=false}}
 *   {{#view "span" viewName="leftOrTop"}}
 *     Content of the top view here.
 *   {{/view}}{{view "sash" viewName="sash"}}{{#view "span" viewName="rightOrBottom"}}
 *     Content of the bottom view here.
 *   {{/view}}
 * {{/view}}
 * ```
 * 
 * @cLass SplitViewComponent
 * @extends Ember.Component
 */
export default Ember.Component.extend({
  /**
   * @property {boolean} isVertical - the orientation of the split: true = vertical, false = horizontal
   * @default true
   */
  isVertical: true,
    
  splitPercentage: 50,

  childViews: null,
  isDragging: false,
  width: 0,
  height: 0,

  didInsertElement: function(){
    this.set('parentView.childSplitView', this);
    this.set('width', this.$().width());
    this.set('height', this.$().height());
    this.set('childViews', Ember.A());
  },

  addChildView: function(child) {
    this.get('childViews').addObject(child);

    if(this.get('childViews').length === 2)
      this.updateOrientation();
  },

  updateOrientation: function() {
    var left = this.get('childViews').objectAt(0);
    var right = this.get('childViews').objectAt(1);

    if(this.get('isVertical')) {
      left.set('fixedSide', 'left');
      left.set('movableSide', 'right');
      right.set('fixedSide', 'right');
      right.set('movableSide', 'left');
    } else {
      left.set('fixedSide', 'top');
      left.set('movableSide', 'bottom');
      right.set('fixedSide', 'bottom');
      right.set('movableSide', 'top');
    }
  }.observes('isVertical'),

  updateWidth: function() {
    this.$().width(this.get('width'));
  }.observes('width'),

  updateHeight: function() {
    this.$().height(this.get('height'));
  }.observes('height'),

  constrainSplit: function() {
    var left = this.get('childViews').objectAt(0);
    var right = this.get('childViews').objectAt(1);

    if(left) {
      var minLeftPercentage = this.minChildPercentage(left);

      if(this.get('splitPercentage') < minLeftPercentage)
        this.set('splitPercentage', minLeftPercentage);
    }
    
    if (right) {
      var minRightPercentage = 100 - this.minChildPercentage(right);

      if(this.get('splitPercentage') > minRightPercentage)
        this.set('splitPercentage', minRightPercentage);
    } 
  }.observes('sash.widthPercentage'),

  mouseUp: function() {
    this.set('isDragging', false);
  },

  mouseMove: function(event) {
    if(!this.get('isDragging'))
      return;

    var posInParent;
    var percentage;
<commit_msg>Code cleanup<commit_after>/**
 * This class represents a view that is split either vertically or horizontally.
 * The split view is composed of three child views: a left or top view, a sash
 * view, and a right or bottom view.  The sash may be dragged to change the
 * relative width or height of the child views.
 *
 * Vertical SplitView example:
 *
 * ```handlebars
 * {{#view "split" isVertical=true}}
 *   {{#view "span" viewName="leftOrTop"}}
 *     Content of the left view here.
 *   {{/view}}{{view "sash" viewName="sash"}}{{#view "span" viewName="rightOrBottom"}}
 *     Content of the right view here.
 *   {{/view}}
 * {{/view}}
 * ```
 *
 * Horizontal SplitView example:
 *
 * ```handlebars
 * {{#view "split" isVertical=false}}
 *   {{#view "span" viewName="leftOrTop"}}
 *     Content of the top view here.
 *   {{/view}}{{view "sash" viewName="sash"}}{{#view "span" viewName="rightOrBottom"}}
 *     Content of the bottom view here.
 *   {{/view}}
 * {{/view}}
 * ```
 * 
 * @cLass SplitViewComponent
 * @extends Ember.Component
 */
export default Ember.Component.extend({
  /**
   * @property {boolean} isVertical - the orientation of the split: true = vertical, false = horizontal
   * @default true
   */
  isVertical: true,
    
  splitPercentage: 50,

  childViews: null,
  isDragging: false,
  width: 0,
  height: 0,

  didInsertElement: function(){
    this.set('parentView.childSplitView', this);
    this.set('width', this.$().width());
    this.set('height', this.$().height());
    this.set('childViews', Ember.A());
  },

  addChildView: function(child) {
    this.get('childViews').addObject(child);

    if(this.get('childViews').length === 2)
      this.updateOrientation();
  },

  updateOrientation: function() {
    var leftOrTop = this.get('childViews').objectAt(0);
    var rightOrBottom = this.get('childViews').objectAt(1);

    if(this.get('isVertical')) {
      leftOrTop.set('fixedSide', 'left');
      leftOrTop.set('movableSide', 'right');
      rightOrBottom.set('fixedSide', 'right');
      rightOrBottom.set('movableSide', 'left');
    } else {
      leftOrTop.set('fixedSide', 'top');
      leftOrTop.set('movableSide', 'bottom');
      rightOrBottom.set('fixedSide', 'bottom');
      rightOrBottom.set('movableSide', 'top');
    }
  }.observes('isVertical'),

  updateWidth: function() {
    this.$().width(this.get('width'));
  }.observes('width'),

  updateHeight: function() {
    this.$().height(this.get('height'));
  }.observes('height'),

  constrainSplit: function() {
    var leftOrTop = this.get('childViews').objectAt(0);
    var rightOrBottom = this.get('childViews').objectAt(1);

    if(leftOrTop) {
      var minLeftOrTopPercentage = this.minChildPercentage(leftOrTop);

      if(this.get('splitPercentage') < minLeftOrTopPercentage)
        this.set('splitPercentage', minLeftOrTopPercentage);
    }
    
    if (rightOrBottom) {
      var minRightOrBottomPercentage = 100 - this.minChildPercentage(rightOrBottom);

      if(this.get('splitPercentage') > minRightOrBottomPercentage)
        this.set('splitPercentage', minRightOrBottomPercentage);
    } 
  }.observes('sash.widthPercentage'),

  mouseUp: function() {
    this.set('isDragging', false);
  },

  mouseMove: function(event) {
    if(!this.get('isDragging'))
      return;

    var posInParent;
    var percentage;

{'fraction_non_alphanumeric': 0.16972477064220184, 'fraction_numerical': 0.003669724770642202, 'mean_word_length': 3.6128349788434413, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2333348', 'n_tokens_mistral': 2140, 'n_tokens_neox': 2069, 'n_words': 467}