<commit_before>/*globals define*/
define([
  'underscore',
  'geometry/views/object2d-view',
  'text!geometry/templates/path-view.html'
], function( _, Object2DView, pathTemplate ) {
  'use strict';

  var interpolations = [ 'linear', 'quadratic' ];

  var PathView = Object2DView.extend({
    pathTemplate: _.template( pathTemplate ),

    events: {
      'change input.coordinate': 'changeCoordinate',
      'change select': 'changeString',
      'change input[type=checkbox]': 'changeCheckbox',
      'change input': 'change'
    },

    render: function() {
      Object2DView.prototype.render.call( this );

      this.$el.prepend(this.pathTemplate({
        model: this.model,
        pointCount: this.model.pointCount,
        points: this.model.get( 'points' ),
        interpolations: interpolations
      }));

      return this;
    },

    update: function() {
      // Update closed checkbox.
      if ( !_.isUndefined( this.model.changedAttributes().closed ) ) {
        this.$( '#closed' ).prop( 'checked', this.model.get( 'closed' ) );
      }

      Object2DView.prototype.update.call( this );

      var pointCount = this.model.pointCount;
      var points = this.model.get( 'points' );

      var xEl, yEl;
      var x, y;
      for ( var i = 0; i < pointCount; i++ ) {
        xEl = this.$( '#x' + i );
        yEl = this.$( '#y' + i );

        x = points[ 2 * i ];
        y = points[ 2 * i + 1 ];

        // Dirty checking appears to be faster than just setting all values.
        if ( xEl.val() !== x.toString() ) { xEl.val( x ); }
        if ( yEl.val() !== y.toString() ) { yEl.val( y ); }
      }
    },

    changeCoordinate: function( event ) {
      event.stopImmediatePropagation();

      var $target = this.$( event.currentTarget ),
          value = parseFloat( $target.val() ),
          axis  = parseInt( $target.attr( 'data-axis' ), 10 ),
          index = parseInt( $target.attr( 'data-index' ), 10 );<commit_msg>canvas-animation: Rerender PathView if pointCount is different.<commit_after>/*globals define*/
define([
  'underscore',
  'geometry/views/object2d-view',
  'text!geometry/templates/path-view.html'
], function( _, Object2DView, pathTemplate ) {
  'use strict';

  var interpolations = [ 'linear', 'quadratic' ];

  var PathView = Object2DView.extend({
    pathTemplate: _.template( pathTemplate ),

    events: {
      'change input.coordinate': 'changeCoordinate',
      'change select': 'changeString',
      'change input[type=checkbox]': 'changeCheckbox',
      'change input': 'change'
    },

    initialize: function() {
      Object2DView.prototype.initialize.apply( this, arguments );
      this.renderedPointCount = 0;
    },

    render: function() {
      Object2DView.prototype.render.call( this );

      this.renderedPointCount = this.model.pointCount;

      this.$el.prepend(this.pathTemplate({
        model: this.model,
        pointCount: this.renderedPointCount,
        points: this.model.get( 'points' ),
        interpolations: interpolations
      }));

      return this;
    },

    update: function() {
      // Update closed checkbox.
      if ( !_.isUndefined( this.model.changedAttributes().closed ) ) {
        this.$( '#closed' ).prop( 'checked', this.model.get( 'closed' ) );
      }

      Object2DView.prototype.update.call( this );

      var pointCount = this.model.pointCount;
      var points = this.model.get( 'points' );

      if ( pointCount !== this.renderedPointCount ) {
        this.render();
      }

      // Update coordinate values.
      var xEl, yEl;
      var x, y;
      for ( var i = 0; i < pointCount; i++ ) {
        xEl = this.$( '#x' + i );
        yEl = this.$( '#y' + i );

        x = points[ 2 * i ];
        y = points[ 2 * i + 1 ];

        // Dirty checking appears to be faster than just setting all values.
        if ( xEl.val() !== x.toString() ) { xEl.val( x ); }
        if ( yEl.val() !== y.toString() ) { yEl.val( y ); }
      }
    },

    changeCoordinate: function( event ) {
      event.stopImmediatePropagation();

      var $target = this.$( event.currentTarget ),
          value = parseFloat( $target.val() ),
          axis  = parseInt( $target.attr( 'data-axis' ), 10 ),
          index = parseInt( $target.attr( 'data-index' ), 10 );
{'fraction_non_alphanumeric': 0.15586239176222794, 'fraction_numerical': 0.006552773227240814, 'mean_word_length': 2.3706624605678233, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7651767', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1305, 'n_words': 312}