diff options
author | Armen Kesablyan | 2012-06-20 15:16:30 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-20 15:16:30 -0700 |
commit | 65b989c7759af923fb9456d34bff89f91831ea1e (patch) | |
tree | e408be732a3eee71229bfc7dbf7cace998ce18de /node_modules/montage/ui/progress.reel/progress.js | |
parent | 38f571d1fdf02d36c3816637af7b2ca2493809da (diff) | |
parent | fc818d31de267d2b77fda3b3029ad38d48698be8 (diff) | |
download | ninja-65b989c7759af923fb9456d34bff89f91831ea1e.tar.gz |
Merge branch 'refs/heads/master' into binding
Conflicts:
node_modules/montage/ui/application.js
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/progress.reel/progress.js')
-rwxr-xr-x | node_modules/montage/ui/progress.reel/progress.js | 127 |
1 files changed, 98 insertions, 29 deletions
diff --git a/node_modules/montage/ui/progress.reel/progress.js b/node_modules/montage/ui/progress.reel/progress.js index 06704f9f..d5886561 100755 --- a/node_modules/montage/ui/progress.reel/progress.js +++ b/node_modules/montage/ui/progress.reel/progress.js | |||
@@ -3,47 +3,116 @@ | |||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | |||
7 | /** | 6 | /** |
8 | @module "montage/ui/progress.reel" | 7 | @module "montage/ui/bluemoon/progress.reel" |
9 | @requires montage/ui/commponent | 8 | @requires montage/core/core |
10 | @requires montage/ui/native-control | 9 | @requires montage/ui/component |
11 | */ | 10 | */ |
12 | |||
13 | var Montage = require("montage").Montage, | 11 | var Montage = require("montage").Montage, |
14 | Component = require("ui/component").Component, | 12 | Component = require("ui/component").Component, |
15 | NativeControl = require("ui/native-control").NativeControl; | 13 | NativeProgress = require("ui/native/progress.reel").Progress; |
16 | |||
17 | /** | 14 | /** |
18 | The Progress component wraps a native <code><progress></code> element and exposes its standard attributes as bindable properties. | 15 | @class module:montage/ui/progress.Progress |
19 | @class module:"montage/ui/progress.reel".Progress | 16 | @extends module:montage/ui/component.Component |
20 | @extends module:montage/native-control.NativeControl | ||
21 | |||
22 | */ | 17 | */ |
23 | var Progress = exports.Progress = Montage.create(NativeControl, { | 18 | exports.Progress = Montage.create(NativeProgress,/** @lends module:"montage/ui/bluemoon/progress.reel".Progress# */ { |
24 | 19 | ||
25 | }); | 20 | hasTemplate: {value: true}, |
26 | |||
27 | Progress.addAttributes( /** @lends module:"montage/ui/progress.reel".Progress# */{ | ||
28 | 21 | ||
29 | /** | 22 | /** |
30 | The value of the id attribute of the form with which to associate the component's element. | 23 | Description TODO |
31 | @type string} | 24 | @private |
32 | @default null | ||
33 | */ | 25 | */ |
34 | form: null, | 26 | _barElement: { |
35 | 27 | enumerable: false, | |
28 | serializable: true, | ||
29 | value: null | ||
30 | }, | ||
36 | /** | 31 | /** |
37 | The maximum value displayed but the progress control. | 32 | Description TODO |
38 | @type {number} | 33 | @private |
39 | @default null | ||
40 | */ | 34 | */ |
41 | max: {dataType: 'number'}, | 35 | _value: { |
36 | enumerable: false, | ||
37 | serializable: true, | ||
38 | value: null | ||
39 | }, | ||
40 | /** | ||
41 | Description TODO | ||
42 | @type {Function} | ||
43 | @default {Number} 0 | ||
44 | */ | ||
45 | value: { | ||
46 | serializable: true, | ||
47 | get: function() { | ||
48 | return this._value; | ||
49 | }, | ||
50 | set: function(val) { | ||
51 | if(val !== this._value) { | ||
52 | this._value = String.isString(val) ? parseInt(val, 10) : val; | ||
42 | 53 | ||
54 | if(this._max && (this._value > this._max)) { | ||
55 | this._value = this._max; | ||
56 | } | ||
57 | if(this._value < 0) { | ||
58 | this._value = 0; | ||
59 | } | ||
60 | this.needsDraw = true; | ||
61 | } | ||
62 | } | ||
63 | }, | ||
43 | /** | 64 | /** |
44 | The current value displayed but the progress control. | 65 | Description TODO |
45 | @type {number} | 66 | @private |
46 | @default null | ||
47 | */ | 67 | */ |
48 | value: {dataType: 'number'} | 68 | _max: { |
49 | }); \ No newline at end of file | 69 | enumerable: false, |
70 | serializable: true, | ||
71 | value: null | ||
72 | }, | ||
73 | /** | ||
74 | Description TODO | ||
75 | @type {Function} | ||
76 | @default {Number} 100 | ||
77 | */ | ||
78 | max: { | ||
79 | serializable: true, | ||
80 | get: function() { | ||
81 | return this._max; | ||
82 | }, | ||
83 | set: function(val) { | ||
84 | if(val !== this._max) { | ||
85 | this._max = String.isString(val) ? parseInt(val, 10) : val; | ||
86 | if(this._max <= 0) { | ||
87 | this._max = 1; // Prevent divide by zero errors | ||
88 | } | ||
89 | this.needsDraw = true; | ||
90 | } | ||
91 | } | ||
92 | }, | ||
93 | |||
94 | didCreate: { | ||
95 | value: function() { | ||
96 | |||
97 | if(NativeProgress.didCreate) { | ||
98 | NativeProgress.didCreate.call(this); | ||
99 | } | ||
100 | } | ||
101 | }, | ||
102 | |||
103 | /** | ||
104 | Description TODO | ||
105 | @function | ||
106 | */ | ||
107 | draw: { | ||
108 | enumerable: false, | ||
109 | value: function() { | ||
110 | var ratio = this._value / this._max; | ||
111 | // constrain to interval [0, 1] | ||
112 | ratio = Math.min(Math.max(ratio, 0), 1); | ||
113 | // map into [0, 100] | ||
114 | var percentage = ratio * 100; | ||
115 | this._barElement.style.width = percentage + '%'; | ||
116 | } | ||
117 | } | ||
118 | }); | ||