1 /*jshint node:true, indent:2, curly:true, eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
2 regexp:true, undef:true, trailing:true, white:true */
3 /*global XT:true, XV:true, Globalize:true, enyo:true, _:true */
8 @name XV.NumberSpinnerWidget
9 @extends XV.NumberWidget
12 /** @lends XV.Number# */{
13 name: "XV.NumberSpinnerWidget",
14 kind: "XV.NumberWidget",
26 {kind: "FittableColumns", components: [
27 {kind: "FittableRows", components: [
28 {name: "label", classes: "xv-label"}
30 {kind: "FittableRows", fit: true, components: [
31 {kind: "onyx.Slider", name: "slider", onChange: "sliderChanged", classes: "slider"},
32 {kind: "onyx.InputDecorator", tag: "div", classes: "input-decorator", components: [
33 {name: "input", kind: "onyx.Input", classes: "xv-subinput",
34 onchange: "inputChanged", onkeydown: "keyDown"},
35 {kind: "FittableRows", components: [
36 {kind: "onyx.Button", classes: "buttons", ontap: "increase",
37 attributes: {tabIndex: "-1"}, components: [
38 {tag: "i", classes: "icon-angle-up"}
40 {kind: "onyx.Button", classes: "buttons", ontap: "decrease",
41 attributes: {tabIndex: "-1"}, components: [
42 {tag: "i", classes: "icon-angle-down"}
50 this.inherited(arguments);
52 this.showSliderChanged();
53 this.showLabelChanged();
56 Decreases the value of the input field by an increment of
57 one until the value of 0.
59 decrease: function (inSender, inEvent) {
60 var value = Math.max(parseInt(this.$.input.getValue() || 0, 10) - 1, 0);
62 this.setSliderValue();
65 Increases the value of the input field by an increment of
66 one at at maximum of the published maximum value.
68 increase: function (inSender, inEvent) {
69 var value = Math.min(parseInt(this.$.input.getValue() || 0, 10) + 1, this.getMaxValue());
71 this.setSliderValue();
74 Set the slider value equal to the value
77 setSliderValue: function () {
78 this.$.slider.setValue(this.$.input.getValue());
81 Inherit setValue from NumberWidget and set
84 setValue: function (value, options) {
85 this.inherited(arguments);
86 this.setSliderValue();
88 showSliderChanged: function () {
89 this.$.slider.setShowing(this.showSlider);
92 Set the input value equal to the value
95 sliderChanged: function (inSender, inEvent) {
96 this.$.input.setValue(Math.round(this.$.slider.getValue()));