aboutsummaryrefslogtreecommitdiff
path: root/js/ui/menu
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-17 23:34:57 -0700
committerValerio Virgillito2012-07-17 23:34:57 -0700
commit8f78cb1377009dabde95f4a81d5090b79b9de0da (patch)
tree4b984909acba691eac8376e3b60412f632e3cdc3 /js/ui/menu
parent4f737b24c19ddc02d20f9783b8b080fc6ef11142 (diff)
downloadninja-8f78cb1377009dabde95f4a81d5090b79b9de0da.tar.gz
menu design update and bug fixes - Moved Preview to the document bar
- Redesigned the menu and improved DOM structure. - Removed un-used entires - Fixed layout and snap entries - Moved the preview button to the document bar. - Fixes for bugs: #1750, #1867, #1876, #1895 Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/ui/menu')
-rw-r--r--js/ui/menu/menu-controller.js636
-rwxr-xr-xjs/ui/menu/menu-entry.reel/menu-entry.css80
-rwxr-xr-xjs/ui/menu/menu-entry.reel/menu-entry.html102
-rwxr-xr-xjs/ui/menu/menu-entry.reel/menu-entry.js110
-rwxr-xr-xjs/ui/menu/menu-item.reel/menu-item.css149
-rwxr-xr-xjs/ui/menu/menu-item.reel/menu-item.html120
-rwxr-xr-xjs/ui/menu/menu-item.reel/menu-item.js208
-rwxr-xr-xjs/ui/menu/menu.reel/menu.css39
-rwxr-xr-xjs/ui/menu/menu.reel/menu.html94
-rwxr-xr-xjs/ui/menu/menu.reel/menu.js183
10 files changed, 1721 insertions, 0 deletions
diff --git a/js/ui/menu/menu-controller.js b/js/ui/menu/menu-controller.js
new file mode 100644
index 00000000..43e1b0b0
--- /dev/null
+++ b/js/ui/menu/menu-controller.js
@@ -0,0 +1,636 @@
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,
33 Component = require("montage/ui/component").Component;
34
35exports.MenuController = Montage.create(Component, {
36
37 _currentDocument: {
38 value : null
39 },
40
41 currentDocument : {
42 get : function() {
43 return this._currentDocument;
44 },
45 set : function(value) {
46 if (value === this._currentDocument) {
47 return;
48 }
49
50 if(this._currentDocument && this._currentDocument.currentView === "design") {
51 this._currentDocument.model.draw3DGrid = document.application.model.show3dGrid;
52 }
53
54 this._currentDocument = value;
55
56 if(this._currentDocument && this._currentDocument.currentView === "design") {
57 document.application.model.show3dGrid = this._currentDocument.model.draw3DGrid;
58 this.topLevelMenu[2].entries[4].checked = this._currentDocument.model.draw3DGrid;
59 }
60
61 if(!this._currentDocument) {
62 // No document - disable all menu items
63 this.documentEnabledItems.forEach(function(index) {
64 index.enabled = false;
65 });
66 this.designDocumentEnabledItems.forEach(function(index) {
67 index.enabled = false;
68 });
69 } else {
70 this.documentEnabledItems.forEach(function(index) {
71 index.enabled = true;
72 });
73
74 if(this.currentDocument.currentView === "design") {
75 this.designDocumentEnabledItems.forEach(function(index) {
76 index.enabled = true;
77 });
78 } else {
79 this.designDocumentEnabledItems.forEach(function(index) {
80 index.enabled = false;
81 });
82 }
83 }
84
85 }
86 },
87
88 didCreate: {
89 value: function() {
90 var self = this;
91
92 this.topLevelMenu.forEach(function(item) {
93 item.entries.forEach(function(entry) {
94 if(entry.depend) {
95 if(entry.depend === "document") {
96 self.documentEnabledItems.push(entry);
97 } else if(entry.depend === "designDocument") {
98 self.designDocumentEnabledItems.push(entry);
99 }
100 }
101 });
102 });
103 }
104 },
105
106 documentEnabledItems: {
107 value: []
108 },
109
110 designDocumentEnabledItems: {
111 value: []
112 },
113
114 toggleItem: {
115 value: function(value) {
116// var f = value.substr(0, value.indexOf("-"));
117// var c = value.slice(value.indexOf("-") + 1);
118
119 this['handle' + value.substr(0, value.indexOf("-"))](value.slice(value.indexOf("-") + 1));
120 }
121 },
122
123
124 handlelayout: {
125 value: function(value) {
126 this.topLevelMenu[2].entries[2].entries.forEach(function(entry) {
127 if(entry.boundProperty === value && !entry.checked){
128 entry.checked = true;
129 document.application.model.layoutView = value;
130 } else if(entry.boundProperty !== value && entry.checked) {
131 entry.checked = false;
132 }
133 });
134 }
135 },
136
137 handlesnap: {
138 value: function(value) {
139 if(value === "onoff") {
140 this.topLevelMenu[2].entries[3].checked = !this.topLevelMenu[2].entries[3].checked;
141 this.topLevelMenu[2].entries[4].enabled = this.topLevelMenu[2].entries[3].checked;
142 document.application.model.snap = value;
143 } else {
144 this.topLevelMenu[2].entries[4].entries.forEach(function(entry) {
145 if(entry.boundProperty === value) {
146 entry.checked = !entry.checked;
147 document.application.model[entry.boundProperty] = entry.checked;
148 }
149 });
150 }
151 }
152 },
153
154 handlegrid: {
155 value: function(value) {
156 this.topLevelMenu[2].entries[4].checked = !this.topLevelMenu[2].entries[4].checked;
157 document.application.model.show3dGrid = this.topLevelMenu[2].entries[4].checked;
158 }
159 },
160
161 handleview: {
162 value: function(value) {
163 if(this.topLevelMenu[2].entries[7].boundProperty === value) {
164 if(!this.topLevelMenu[2].entries[7].checked) {
165 this.topLevelMenu[2].entries[7].checked = true;
166 this.topLevelMenu[2].entries[8].checked = false;
167 this.topLevelMenu[2].entries[9].checked = false;
168 document.application.model.documentStageView = value;
169 }
170 } else if(this.topLevelMenu[2].entries[8].boundProperty === value) {
171 if(!this.topLevelMenu[2].entries[8].checked) {
172 this.topLevelMenu[2].entries[7].checked = false;
173 this.topLevelMenu[2].entries[8].checked = true;
174 this.topLevelMenu[2].entries[9].checked = false;
175 document.application.model.documentStageView = value;
176 }
177 } else {
178 if(!this.topLevelMenu[2].entries[9].checked) {
179 this.topLevelMenu[2].entries[7].checked = false;
180 this.topLevelMenu[2].entries[8].checked = false;
181 this.topLevelMenu[2].entries[9].checked = true;
182 document.application.model.documentStageView = value;
183 }
184 }
185 }
186 },
187
188 topLevelMenu: {
189 value: [
190 {
191 "label": "File",
192 "entries": [
193 {
194 "label" : "New Project",
195 "checked": false,
196 "submenu" : false,
197 "entries": [],
198 "enabled": false,
199 "action": "executeNewProject"
200 },
201 {
202 "label" : "New File",
203 "checked": false,
204 "submenu" : false,
205 "entries": [],
206 "enabled": true,
207 "action": "executeNewFile"
208 },
209 {
210 "label" : "Open File",
211 "checked": false,
212 "submenu" : false,
213 "entries": [],
214 "enabled": true,
215 "action": "executeFileOpen"
216 },
217 {