<commit_before>/*   RSence
 *   Copyright 2010 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */

// Simple view for centering a view.
// The rect's left position is used as the minimum left position, the rects
// top and width are used as-is and the HCenterView itself is geometrically
// centered inside its parent by adjusting its "left" style property.
// Designed to be used as a root-level view, listens to the resize event and
// re-calculates the center position accordingly. Likely to evolve a lot still.
HCenterView = HControl.extend({
  defaultEvents: {
    resize: true
  },
  drawRect: function(_selfCalled){
    this.base();
    if(!_selfCalled){
      this.resize();
    }
  },
  minLeft: false,
  resize: function(){
    if(this.minLeft === false){
      this.minLeft = this.rect.left;
    }
    var
    _rect = this.rect,
    _winSize = ELEM.windowSize(),
    _winWidth = _winSize[0],
    _winHeight = _winSize[1],
    _rectWidth = _rect.width,
    _rectWidthHalf = Math.floor(_rectWidth/2),
    _winWidthHalf = Math.floor(_winWidth/2),
    _left = _winWidthHalf - _rectWidthHalf;
    if( _left < this.minLeft ){
      _left = this.minLeft;
    }
    _rect.offsetTo( _left, _rect.top );
    this.drawRect(true);
  }
});<commit_msg>HCenterView uses the following boolean options: centerX, centerY. centerX is default for HCenterView. Added HMiddleView, which has centerY enabled by default. Combinations are possible for both.<commit_after>/*   RSence
 *   Copyright 2010 Riassence Inc.
 *   http://riassence.com/
 *
 *   You should have received a copy of the GNU General Public License along
 *   with this software package. If not, contact <EMAIL>
 */

// Simple view for centering a view.
// The rect's left position is used as the minimum left position, the rects
// top and width are used as-is and the HCenterView itself is geometrically
// centered inside its parent by adjusting its "left" style property.
// Designed to be used as a root-level view, listens to the resize event and
// re-calculates the center position accordingly. Likely to evolve a lot still.
HCenterView = HControl.extend({
  defaultEvents: {
    resize: true
  },
  controlDefaults: HControlDefaults.extend({
    centerX: true,
    centerY: false
  }),
  drawRect: function(_selfCalled){
    this.base();
    if(!_selfCalled){
      this.resize();
    }
  },
  minLeft: false,
  minTop: false,
  resize: function(){
    if(this.minLeft === false){
      this.minLeft = this.rect.left;
    }
    if(this.minTop === false){
      this.minTop = this.rect.top;
    }
    var
    _rect = this.rect,
    _winSize = ELEM.windowSize(),
    _winWidth = _winSize[0],
    _winHeight = _winSize[1],
    _rectWidth = _rect.width,
    _rectWidthHalf = Math.floor(_rectWidth/2),
    _winWidthHalf = Math.floor(_winWidth/2),
    _left = _winWidthHalf - _rectWidthHalf,
    _rectHeight = _rect.height,
    _rectHeightHalf = Math.floor(_rectHeight/2),
    _winHeightHalf = Math.floor(_winHeight/2),
    _top = _winHeightHalf - _rectHeightHalf;
    if (!this.options.centerX){
      _left = _rect.left;
    }
    else if( _left < this.minLeft ){
      _left = this.minLeft;
    }
    if (!this.options.centerY){
      _top = _rect.top;
    }
    else if( _top < this.minTop ){
      _top = this.minTop;
    }
    _rect.offsetTo( _left, _top );
    this.drawRect(true);
  }
});

HMiddleView = HCenterView.extend({
  controlDefaults: HControlDefaults.extend({
    centerX: false,
    centerY: true
  })
});
{'fraction_non_alphanumeric': 0.10899031811894883, 'fraction_numerical': 0.004979253112033195, 'mean_word_length': 2.9955801104972375, 'pattern_counts': {'":': 0, '<': 8, '<?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': '4131184', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1150, 'n_words': 347}