import Ember from 'ember';
import layout from '../templates/components/uni-input-price';

const { Component, $, computed } = Ember;

const INPUT_TYPE_NUMBER = 'number';

export default Component.extend({
  classNames: ['uni-input-price'],
  layout,

  value: '',
  minValue: 1,
  offset: 1,
  currency: '€',
  min: '0',
  max: '99999',
  maxLength: 4,
  placeholder: '0',
  isRightSideCurrency: true,
  type: INPUT_TYPE_NUMBER,
  options: null,

  /**
   * Converts a value to an integer when able, or leaves it as a string
   * @public
   */
  numberAsInt: computed('value', {
    get() {
      return this.get('value');
    },

    set(_, value) {
      if (this.get('type') !== INPUT_TYPE_NUMBER) {
        this.set('value', value);

        return value;
      }

      let newValue = isNaN(value) ? value : parseInt(value);
      this.set('value', newValue);

      return newValue;
    }
  }),

  onInvalidInput() {},
  onChange() {},

  actions: {
    onChange() {
      if (!parseFloat(this.get('value')) && this.get('value') < this.get('minValue')) {
        this.get('onInvalidInput')(this.get('options'));
      }

      this.get('onChange')(this.get('value'));
    },

    onFocusIn() {
      $('input').focus(function() {
        $(this).parent('.uni-input-price').addClass('uni-input-price--focused');
      }).blur(function() {
        $(this).parent('.uni-input-price').removeClass('uni-input-price--focused');
      });
    }
  }
});

@@ -647,126 +647,8 @@
 ) %7B%0A
-      if (this.get('type') !== INPUT_TYPE_NUMBER) %7B%0A        this.set('value', value);%0A%0A        return value;%0A      %7D%0A%0A
     
@@ -679,21 +679,17 @@
 alue) ? 
-value
+0
  : parse

Update price input to always parseInt (#127)