Because sometimes slider is the answer
LSD.Trait.Slider = new Class({
options: {
actions: {
slider: {
enable: function() {
if (!this.slider) this.getSlider();
else this.slider.attach();
},
disable: function() {
if (this.slider) this.slider.detach()
}
}
},
events: {
parent: {
resize: 'onParentResize'
},
slider: {}
},
slider: {},
value: 0,
mode: 'horizontal',
},
onParentResize: function(current, old) {
if (this.slider) this.slider.update();
},
getSlider: Macro.getter('slider', function (update) {
var slider = new Slider(document.id(this.getTrack()), document.id(this.getTrackThumb()), Object.merge(this.options.slider, {
mode: this.options.mode
})).set(parseFloat(this.options.value));
slider.addEvent('change', this.onSet.bind(this));
slider.addEvents(this.events.slider)
return slider;
}),
onSet: Macro.defaults(function() {
return true;
}),
getTrack: Macro.defaults(function() {
return this
}),
getTrackThumb: Macro.defaults(function() {
return this.thumb;
}),
increment: function() {
this.slider.set((this.slider.step || 0) + 10)
},
decrement: function() {
this.slider.set((this.slider.step || 0) - 10)
}
});
Slider = new Class({
Extends: Slider,
initialize: function() {
(this.Binds.push ? this.Binds : [this.Binds]).each(function(name){
var original = this[name];
if (original) this[name] = original.bind(this);
}, this);
return this.parent.apply(this, arguments);
}
})