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",
25 classes: "xv-spinnerwidget",
27 {controlClasses: 'enyo-inline', components: [
28 {name: "label", classes: "xv-label"},
29 {controlClasses: 'enyo-inline', components: [
30 {kind: "onyx.Slider", name: "slider", onChange: "sliderChanged", classes: "slider"},
31 {kind: "onyx.InputDecorator", tag: "div", components: [
32 {name: "input", kind: "onyx.Input",
33 onchange: "inputChanged", onkeydown: "keyDown"},
34 {kind: "FittableRows", components: [
35 {kind: "onyx.Button", classes: "buttons", ontap: "increase",
36 attributes: {tabIndex: "-1"}, components: [
37 {tag: "i", classes: "icon-angle-up"}
39 {kind: "onyx.Button", classes: "buttons", ontap: "decrease",
40 attributes: {tabIndex: "-1"}, components: [
41 {tag: "i", classes: "icon-angle-down"}
49 this.inherited(arguments);
50 this.showSliderChanged();
53 Decreases the value of the input field by an increment of
54 one until the value of 0.
56 decrease: function (inSender, inEvent) {
57 var value = Math.max(parseInt(this.$.input.getValue() || 0, 10) - 1, 0);
59 this.setSliderValue();
62 Increases the value of the input field by an increment of
63 one at at maximum of the published maximum value.
65 increase: function (inSender, inEvent) {
66 var value = Math.min(parseInt(this.$.input.getValue() || 0, 10) + 1, this.getMaxValue());
68 this.setSliderValue();
71 Set the slider value equal to the value
74 setSliderValue: function () {
75 this.$.slider.setValue(this.$.input.getValue());
78 Inherit setValue from NumberWidget and set
81 setValue: function (value, options) {
82 this.inherited(arguments);
83 this.setSliderValue();
85 showSliderChanged: function () {
86 this.$.slider.setShowing(this.showSlider);
89 Set the input value equal to the value
92 sliderChanged: function (inSender, inEvent) {
93 this.$.input.setValue(Math.round(this.$.slider.getValue()));