<commit_before>/**
 * This class provides the basic effect for styles manipulation
 *
 * Copyright (C) 2008-2009 <NAME> aka St. <nemshilov#gma-ilc-om>
 */
Fx.Morph = new Class(Fx, {
  extend: {
    STYLES: $w('width height lineHeight opacity borderWidth borderColor padding margin color fontSize backgroundColor marginTop marginLeft marginRight marginBottom top left right bottom')
  },

// protected
  
  /**
   * starts the effect
   *
   * @param mixed an Object with an end style or a string with the end class-name(s)
   * @return Fx this
   */
  prepare: function(style) {
    this.endStyle   = this._findStyle(style);
    this.startStyle = this._getStyle(this.element, Object.keys(this.endStyle));

    this._cleanStyles(this.startStyle, this.endStyle);
    
    return Object.empty(this.endStyle) ? this.finish() : this.$super();
  },
  
  render: function(delta) {
    var style = {}, value;
    
    for (var key in this.endStyle) {
      value = this._calcStyle(key, delta);
      if (key == 'opacity') {
        this.element.setOpacity(value);
      } else {
        this.element.style[key] = value;
      }
    }
  },
  
// private

  // calculates the current style value
  _calcStyle: function(key, delta) {
    var start = this.startStyle[key], end = this.endStyle[key];
    
    if (typeof(start) == 'number') {
      // handling floats like opacity
      return start + (end - start) * delta;
      
    } else if(start.length == 2) {
      // handling usual sizes with dimensions
      return (start[0] + (end[0] - start[0]) * delta) + end[1];
      
    } else if(start.length == 3) {
      // calculating colors
      return end.map(function(value, i) {
        return start[i] + (value - start[i]) * delta;
      }).toRgb();
    }
  },

  // finds the style definition by a css-selector string
  _findStyle: function(style) {
    var a_class = isString(style);
    
    Fx.Morph.$c = Fx.Morph.$c || $E('div').insertTo(document.body
      ).setStyle({ overflow: 'hidden', display: 'none' });
    
    var element = $(this.element.cloneNode(false)).insertTo(Fx.Morph.$c)[a_class ? 'addClass' : 'setStyle'](style);
    var result  = this._getStyle(element, a_class ? Fx.Morph.STYLES : Object.keys(style));
    
    if (a_class && ('width' in result || 'height' in result) ) {
      // fixing the width and heights
      var styles = element.computedStyles();
      var width  = element._getStyle(styles, 'width');
      var height = element._getStyle(styles, 'height');
      
      if (!width  || width == 'auto')  delete(result['width']);
      if (!height || height == 'auto') delete(result['height']);
    }
    
    // assigning the border style if the end style has a border
    var border_style = element.getStyle('borderTopStyle');
    var element_border_style = this.element.getStyle('borderTopStyle');
    if (border_style != element_border_style) {
      if (element_border_style  == 'none') {<commit_msg>Konq4 fix<commit_after>/**
 * This class provides the basic effect for styles manipulation
 *
 * Copyright (C) 2008-2009 <NAME> aka St. <nemshilov#gma-ilc-om>
 */
Fx.Morph = new Class(Fx, {
  extend: {
    STYLES: $w('width height lineHeight opacity borderWidth borderColor padding margin color fontSize backgroundColor marginTop marginLeft marginRight marginBottom top left right bottom')
  },

// protected
  
  /**
   * starts the effect
   *
   * @param mixed an Object with an end style or a string with the end class-name(s)
   * @return Fx this
   */
  prepare: function(style) {
    this.endStyle   = this._findStyle(style);
    this.startStyle = this._getStyle(this.element, Object.keys(this.endStyle));

    this._cleanStyles(this.startStyle, this.endStyle);
    
    return Object.empty(this.endStyle) ? this.finish() : this.$super();
  },
  
  render: function(delta) {
    var style = {}, value;
    
    for (var key in this.endStyle) {
      value = this._calcStyle(key, delta);
      if (key == 'opacity') {
        this.element.setOpacity(value);
      } else {
        this.element.style[key] = value;
      }
    }
  },
  
// private

  // calculates the current style value
  _calcStyle: function(key, delta) {
    var start = this.startStyle[key], end = this.endStyle[key];
    
    if (typeof(start) == 'number') {
      // handling floats like opacity
      return start + (end - start) * delta;
      
    } else if(start.length == 2) {
      // handling usual sizes with dimensions
      return (start[0] + (end[0] - start[0]) * delta) + end[1];
      
    } else if(start.length == 3) {
      // calculating colors
      return end.map(function(value, i) {
        return start[i] + (value - start[i]) * delta;
      }).toRgb();
    }
  },

  // finds the style definition by a css-selector string
  _findStyle: function(style) {
    var a_class = isString(style);
    
    Fx.Morph.$c = Fx.Morph.$c || $E('div', {style: "visibility:hidden;overflow:hidden;height:0;width:0"})
    Fx.Morph.$c.insertTo(this.element, 'after');
    
    var element = $(this.element.cloneNode(false)).insertTo(Fx.Morph.$c)[a_class ? 'addClass' : 'setStyle'](style);
    var result  = this._getStyle(element, a_class ? Fx.Morph.STYLES : Object.keys(style));
    
    if (a_class && ('width' in result || 'height' in result) ) {
      // fixing the width and heights
      var styles = element.computedStyles();
      var width  = element._getStyle(styles, 'width');
      var height = element._getStyle(styles, 'height');
      
      if (!width  || width == 'auto')  delete(result['width']);
      if (!height || height == 'auto') delete(result['height']);
    }
    
    // assigning the border style if the end style has a border
    var border_style = element.getStyle('borderTopStyle');
    var element_border_style = this.element.getStyle('borderTopStyle');
    if (border_style != element_border_style) {
      if (element_border_style  == 'none') {
{'fraction_non_alphanumeric': 0.1419606512890095, 'fraction_numerical': 0.005257801899592945, 'mean_word_length': 2.8719632304661853, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2052289', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1843, 'n_words': 478}