diff options
author | Valerio Virgillito | 2012-05-16 00:54:30 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-16 00:54:30 -0700 |
commit | 6dfe2e62b1d7a71daf097aac3a31213d564e6122 (patch) | |
tree | c40c07be0bfcdd9001723b65bf4cc3b0358da9fe /js/components | |
parent | 9464de58d5bb8b467829926b9d01c0760ec4d790 (diff) | |
download | ninja-6dfe2e62b1d7a71daf097aac3a31213d564e6122.tar.gz |
Removing the old checkbox components. Created a new LabelCheckbox
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/components')
-rwxr-xr-x | js/components/checkbox.reel/checkbox.html | 23 | ||||
-rwxr-xr-x | js/components/checkbox.reel/checkbox.js | 120 | ||||
-rw-r--r-- | js/components/ui/label-checkbox.reel/label-checkbox.css | 9 | ||||
-rwxr-xr-x | js/components/ui/label-checkbox.reel/label-checkbox.html | 54 | ||||
-rwxr-xr-x | js/components/ui/label-checkbox.reel/label-checkbox.js | 67 | ||||
-rwxr-xr-x | js/components/ui/property-control.reel/property-control.js | 2 |
6 files changed, 131 insertions, 144 deletions
diff --git a/js/components/checkbox.reel/checkbox.html b/js/components/checkbox.reel/checkbox.html deleted file mode 100755 index ded91fc2..00000000 --- a/js/components/checkbox.reel/checkbox.html +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!-- <copyright> | ||
3 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
4 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
5 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
6 | </copyright> --> | ||
7 | <html> | ||
8 | <head> | ||
9 | <script type="text/montage-serialization"> | ||
10 | { | ||
11 | "owner": { | ||
12 | "prototype": "js/components/checkbox.reel", | ||
13 | "properties": { | ||
14 | "element": {"#": "ch_comp"} | ||
15 | } | ||
16 | } | ||
17 | } | ||
18 | </script> | ||
19 | </head> | ||
20 | <body> | ||
21 | <input data-montage-id="ch_comp" class="nj-skinned" type="checkbox"> | ||
22 | </body> | ||
23 | </html> \ No newline at end of file | ||
diff --git a/js/components/checkbox.reel/checkbox.js b/js/components/checkbox.reel/checkbox.js deleted file mode 100755 index be331f4e..00000000 --- a/js/components/checkbox.reel/checkbox.js +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<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. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.Checkbox = Montage.create(Component, { | ||
11 | |||
12 | _valueSyncedWithInputField: { | ||
13 | enumerable: false, | ||
14 | value: false | ||
15 | }, | ||
16 | |||
17 | _wasSetByCode: { | ||
18 | enumerable: false, | ||
19 | value: true | ||
20 | }, | ||
21 | |||
22 | prependLabel: { | ||
23 | value: false | ||
24 | }, | ||
25 | |||
26 | label: { | ||
27 | value: null | ||
28 | }, | ||
29 | |||
30 | value: { | ||
31 | value: false | ||
32 | }, | ||
33 | |||
34 | _checked: { | ||
35 | enumerable: false, | ||
36 | value: false | ||
37 | }, | ||
38 | |||
39 | checked: { | ||
40 | enumerable: true, | ||
41 | serializable: true, | ||
42 | get: function() { | ||
43 | return this._checked; | ||
44 | }, | ||
45 | set: function(value) { | ||
46 | this._checked = value; | ||
47 | this.needsDraw = true; | ||
48 | |||
49 | var e = document.createEvent("CustomEvent"); | ||
50 | e.initEvent("change", true, true); | ||
51 | e.type = "change"; | ||
52 | e.wasSetByCode = this._wasSetByCode; | ||
53 | e.value = value; | ||
54 | this.value = value; | ||
55 | this.dispatchEvent(e); | ||
56 | |||
57 | this._wasSetByCode = true; | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | _enabled: { | ||
62 | enumerable: false, | ||
63 | value: true | ||
64 | }, | ||
65 | |||
66 | enabled: { | ||
67 | enumerable: true, | ||
68 | serializable: true, | ||
69 | get: function() { | ||
70 | return this._enabled; | ||
71 | }, | ||
72 | set: function(value) { | ||
73 | if(value !== this._enabled) | ||
74 | { | ||
75 | this._enabled = value; | ||
76 | this.needsDraw = true; | ||
77 | } | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | handleChange: | ||
82 | { | ||
83 | value:function(event) | ||
84 | { | ||
85 | this._valueSyncedWithInputField = true; | ||
86 | this._wasSetByCode = false; | ||
87 | this.checked = this.element.checked; | ||
88 | } | ||
89 | }, | ||
90 | handleClick: { | ||
91 | value: function() { | ||
92 | this._wasSetByCode = false; | ||
93 | this.checked = !this.element.checked; | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | draw: { | ||
98 | value: function() { | ||
99 | this.element.disabled = !this._enabled; | ||
100 | if(!this._valueSyncedWithInputField) | ||
101 | { | ||
102 | this.element.checked = this._checked; | ||
103 | } | ||
104 | this._valueSyncedWithInputField = false; | ||
105 | } | ||
106 | }, | ||
107 | |||
108 | prepareForDraw: { | ||
109 | value: function() { | ||
110 | if (this.label !== null) { | ||
111 | var b = document.createElement("label"); | ||
112 | b.innerHTML = this.label; | ||
113 | this.element.appendChild(b); | ||
114 | b.addEventListener("click", this, false); | ||
115 | } | ||
116 | this.element.addEventListener("change", this, false); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | }); \ No newline at end of file | ||
diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.css b/js/components/ui/label-checkbox.reel/label-checkbox.css new file mode 100644 index 00000000..6eb75a0e --- /dev/null +++ b/js/components/ui/label-checkbox.reel/label-checkbox.css | |||
@@ -0,0 +1,9 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<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. | ||
5 | </copyright> */ | ||
6 | |||
7 | .label-checkbox { | ||
8 | display: inline-block; | ||
9 | } \ No newline at end of file | ||
diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.html b/js/components/ui/label-checkbox.reel/label-checkbox.html new file mode 100755 index 00000000..0efc7ae0 --- /dev/null +++ b/js/components/ui/label-checkbox.reel/label-checkbox.html | |||
@@ -0,0 +1,54 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!-- <copyright> | ||
3 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
4 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
5 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
6 | </copyright> --> | ||
7 | <html> | ||
8 | <head> | ||
9 | <link rel="stylesheet" href="label-checkbox.css" /> | ||
10 | <script type="text/montage-serialization"> | ||
11 | { | ||
12 | "owner": { | ||
13 | "prototype": "js/components/ui/label-checkbox.reel", | ||
14 | "properties": { | ||
15 | "element": {"#": "labelCheckbox"}, | ||
16 | |||
17 | "_checkbox": {"@": "checkbox"}, | ||
18 | "_labelText": {"@": "labelText"} | ||
19 | } | ||
20 | }, | ||
21 | |||
22 | "checkbox": { | ||
23 | "prototype": "montage/ui/checkbox.reel", | ||
24 | "properties": { | ||
25 | "element": {"#": "checkbox"}, | ||
26 | "checked": false | ||
27 | }, | ||
28 | "listeners": [ | ||
29 | { | ||
30 | "type": "action", | ||
31 | "listener": {"@": "owner"}, | ||
32 | "capture": false | ||
33 | } | ||
34 | ] | ||
35 | }, | ||
36 | |||
37 | "labelText": { | ||
38 | "prototype": "montage/ui/dynamic-text.reel", | ||
39 | "properties": { | ||
40 | "element": {"#": "label"} | ||
41 | } | ||
42 | } | ||
43 | } | ||
44 | </script> | ||
45 | </head> | ||
46 | <body> | ||
47 | <!--<span data-montage-id="labelCheckbox" class="labelCheckbox">--> | ||
48 | <label data-montage-id="labelCheckbox" class="label-checkbox"> | ||
49 | <input data-montage-id="checkbox" class="nj-skinned" type="checkbox"> | ||
50 | <span data-montage-id="label" class="checkbox-label"></span> | ||
51 | </label> | ||
52 | <!--</span>--> | ||
53 | </body> | ||
54 | </html> \ No newline at end of file | ||
diff --git a/js/components/ui/label-checkbox.reel/label-checkbox.js b/js/components/ui/label-checkbox.reel/label-checkbox.js new file mode 100755 index 00000000..82c01262 --- /dev/null +++ b/js/components/ui/label-checkbox.reel/label-checkbox.js | |||
@@ -0,0 +1,67 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<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. | ||