aboutsummaryrefslogtreecommitdiff
path: root/js/components/menu/menu-item.reel/menu-item.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/menu/menu-item.reel/menu-item.js')
-rwxr-xr-xjs/components/menu/menu-item.reel/menu-item.js198
1 files changed, 0 insertions, 198 deletions
diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js
deleted file mode 100755
index 63cc79b7..00000000
--- a/js/components/menu/menu-item.reel/menu-item.js
+++ /dev/null
@@ -1,198 +0,0 @@
1/* <copyright>
2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10
11* Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29POSSIBILITY OF SUCH DAMAGE.
30</copyright> */
31
32var Montage = require("montage/core/core").Montage;
33var Component = require("montage/ui/component").Component;
34
35exports.MenuItem = Montage.create(Component, {
36
37 itemBackground: {
38 value: null
39 },
40
41 itemText: {
42 value: null
43 },
44
45 subMenu: {
46 value: null
47 },
48
49 data: {
50 value: null
51 },
52
53 _enabled: {
54 value: false
55 },
56
57 enabled: {
58 get: function() {
59 return this._enabled;
60 },
61 set: function(value) {
62 if(value !== this._enabled) {
63 this._enabled = value;
64 this.needsDraw = true;
65 }
66 }
67 },
68
69 _checked: {
70 value: null
71 },
72
73 checked: {
74 get: function() {
75 return this._checked;
76 },
77 set: function(value) {
78 /*
79 if( Object.prototype.toString.call( value ) === '[object Array]' ) {
80 value = value.indexOf(this.data.displayText + "Panel") >= 0;
81 }
82 */
83
84 if(this._checked !== value) {
85 this._checked = value;
86 this.needsDraw = true;
87 }
88 }
89 },
90
91 submenu: {
92 value: false
93 },
94
95 subentries: {
96 value: []
97 },
98
99 prepareForDraw: {
100 value: function() {
101
102 if(!this.data) return;
103
104 if(this.data.separator) {
105 this.element.classList.add("itemSeparator");
106 this.itemBackground.classList.remove("menubg");
107 this.itemBackground.classList.add("separator");
108
109 return;
110
111 }
112
113 // Binding the checked to the assigned bound property
114 if(this.data.checked) {
115 Object.defineBinding(this, "checked", {
116 boundObject: this.application.ninja.appModel,
117 boundObjectPropertyPath: this.data.checked.boundProperty
118 });
119
120 }
121
122 if(this.data.submenu) {
123 this.submenu = true;
124 this.subentries = this.data.entries;
125 this.subMenu.classList.add("subMenu");
126 }
127
128 this.element.addEventListener("mouseover", this, false);
129 this.element.addEventListener("mouseout", this, false);
130
131 this.itemText.innerHTML = this.data.displayText;
132 this.element.addEventListener("mouseup", this, true);
133 }
134 },
135
136 draw: {
137 value: function() {
138
139 if(this.enabled) {
140 this.element.classList.remove("disabled");
141 } else {
142 this.element.classList.add("disabled");
143 }
144
145 if(this.checked) {
146 this.itemBackground.classList.add("checked");
147 } else {
148 this.itemBackground.classList.remove("checked");
149 }
150
151 if(this.submenu) {
152 this.itemBackground.classList.add("submenu");
153 }
154 }
155 },
156
157 captureMouseup: {
158 value: function(event) {
159
160 if(this.data.radio && this.checked){
161 this.parentComponent.ownerComponent.toggleOnMenuItemAction();
162 return;
163 }
164
165 if( ( this.enabled === true || this.enabled > 0 ) && (this.submenu === false) ) {
166 if(this.data.action) {
167 NJevent ( this.data.action );
168 } else if(this.checked !== null) {
169 this.checked = !this.checked;
170 }
171 this.parentComponent.ownerComponent.toggleOnMenuItemAction();
172 }
173
174 }
175 },
176
177 handleMouseover: {
178 value: function() {
179 if(this.enabled){
180 this.element.style.backgroundColor = "#7f7f7f";
181 this.element.style.cursor = "pointer";
182 if(this.data.submenu) {
183 this.subMenu.style.display = "block";
184 }
185 }
186 }
187 },
188
189 handleMouseout: {
190 value: function() {
191 this.element.style.backgroundColor = "#474747";
192 if(this.data.submenu) {
193 this.subMenu.style.display = "none";
194 }
195 }
196 }
197
198});