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

const { computed } = Ember;
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;

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

  value: 0,
  offset: 1,
  max: MAX_SAFE_INTEGER,
  min: 0,
  placeholder: "placeholder",

  isDecrementDisabled: computed('value', function() {
    return this.get('value') <= this.get('min');
  }),
  isIncrementDisabled: computed('value', function() {
    return this.get('value') >= this.get('max');
  }),

  actions: {
    decrement() {
      if (this.get('isDecrementDisabled')) {
        return;
      }

      this.decrementProperty('value', this.get('offset'));
    },

    increment() {
      if (this.get('isIncrementDisabled')) {
        return;
      }

      this.incrementProperty('value', this.get('offset'));
    }
  }
});

@@ -90,16 +90,27 @@
 %0Aconst %7B
+ Component,
  compute
@@ -110,16 +110,19 @@
 computed
+, K
  %7D = Emb
@@ -128,58 +128,8 @@
 ber;
-%0Aconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
 %0A%0Aex
@@ -145,14 +145,8 @@
 ult 
-Ember.
 Comp
@@ -238,16 +238,23 @@
 %0A  max: 
+Number.
 MAX_SAFE
@@ -302,16 +302,31 @@
 holder%22,
+%0A  onChange: K,
 %0A%0A  isDe
@@ -567,36 +567,32 @@
 ement() %7B%0A      
-if (
 this.get('isDecr
@@ -589,94 +589,44 @@
 et('
-isDecrementDisabled')) %7B%0A        return;%0A      %7D%0A%0A      this.decrementProperty
+onChange')(Math.max(this.get
 ('value'
 , th
@@ -613,33 +613,35 @@
 this.get('value'
-,
+) -
  this.get('offse
@@ -635,32 +635,50 @@
 is.get('offset')
+, this.get('min')
+)
 );%0A    %7D,%0A%0A    i
@@ -700,12 +700,8 @@
     
-if (
 this
@@ -710,94 +710,44 @@
 et('
-isIncrementDisabled')) %7B%0A        return;%0A      %7D%0A%0A      this.incrementProperty
+onChange')(Math.min(this.get
 ('value'
 , th
@@ -742,17 +742,19 @@
 ('value'
-,
+) +
  this.ge
@@ -764,16 +764,34 @@
 offset')
+, this.get('max'))
 );%0A    %7D

Change uni-input-range bindings (#33)