Last active
January 5, 2016 17:28
-
-
Save hergaiety/1b9a37d7f0cab9d364bd to your computer and use it in GitHub Desktop.
Ember + rangeslider.js by andreruffert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extend {{input}} to support html5 range. | |
* Example: {{input type="range" value=myProperty max="500"}} | |
* Uses rangeslider.js plugin for IE9 support and to look pretty | |
* Fires optional onInit, onSlide, and onSlideEnd events | |
*/ | |
Ember.TextSupport.reopen({ | |
attributeBindings: ['min', 'max', 'step'], | |
initRangeSlider: function() { | |
if (this.get('type') === 'range') { | |
var self = this; | |
self.$().rangeslider({ | |
polyfill: false, | |
onInit: function() { | |
self.sendAction('onInit'); | |
}, | |
onSlide: function(position, value) { | |
self.set('value', value); | |
self.sendAction('onSlide', position, value); | |
}, | |
onSlideEnd: function(position, value) { | |
self.set('value', value); | |
self.sendAction('onSlideEnd', position, value); | |
} | |
}); | |
} | |
}.on('didInsertElement'), | |
removeRangeSlider: function() { | |
this.$().rangeslider('destroy'); | |
}.on('willDestroyElement') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment