1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
/*global require,exports */
/**
@module "montage/ui/input-range.reel"
@requires montage/ui/component
@requires montage/ui/text-input
@requires montage/ui/composer/press-composer
*/
var Montage = require("montage").Montage,
Component = require("ui/component").Component,
TextInput = require("ui/text-input").TextInput,
PressComposer = require("ui/composer/press-composer").PressComposer;
/**
* Wraps the a <input type="range"> element with binding support for the element's standard attributes.
@class module:"montage/ui/input-range.reel".InputRange
@extends module:montage/ui/text-input.TextInput
*/
var InputRange = exports.InputRange = Montage.create(TextInput, {
prepareForActivationEvents: {
value: function() {
var pressComposer = PressComposer.create();
pressComposer.delegate = this;
this.addComposer(pressComposer);
pressComposer.addEventListener("pressStart", this, false);
pressComposer.addEventListener("press", this, false);
pressComposer.addEventListener("pressCancel", this, false);
}
},
handlePressStart: {
value: function(e) {
var interactionStartEvent = document.createEvent("CustomEvent");
interactionStartEvent.initCustomEvent("montage_range_interaction_start", true, true, null);
this.dispatchEvent(interactionStartEvent);
}
},
handlePress: {
value: function(e) {
var interactionEndEvent = document.createEvent("CustomEvent");
interactionEndEvent.initCustomEvent("montage_range_interaction_end", true, true, null);
this.dispatchEvent(interactionEndEvent);
}
},
surrenderPointer: {
value: function(pointer, composer) {
// If the user is sliding us then we do not want anyone using
// the pointer
return false;
}
}
});
InputRange.addAttributes( /** @lends module:"montage/ui/input-range.reel".InputRange# */ {
/**
The maximum value displayed but the input control.
@type {number}
@default null
*/
max: {dataType: 'number'},
/**
The minimum value displayed but the input control.
@type {number}
@default null
*/
min: {dataType: 'number'},
/**
The amount the number changes with each step. The step size can be a number, or the string 'any'.
@type {number|string}
@default null
*/
step: null // number or 'any'
});
|