diff options
author | Valerio Virgillito | 2012-07-18 16:24:45 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-18 16:24:45 -0700 |
commit | f79f7c540d8533eed8fc562b809e15dcfea94438 (patch) | |
tree | 955b0d51fb163fb0a5165a6e16bf503de4cda712 /js/ui/menu/menu.reel | |
parent | 71650434d5b78c2b86dc8a689d0c9034d418f38b (diff) | |
parent | 6f2e455a77179f81dfd19037c078c158d3e14ee2 (diff) | |
download | ninja-f79f7c540d8533eed8fc562b809e15dcfea94438.tar.gz |
Merge branch 'menu-fixes' of https://github.com/mencio/ninja
Diffstat (limited to 'js/ui/menu/menu.reel')
-rwxr-xr-x | js/ui/menu/menu.reel/menu.css | 39 | ||||
-rwxr-xr-x | js/ui/menu/menu.reel/menu.html | 94 | ||||
-rwxr-xr-x | js/ui/menu/menu.reel/menu.js | 183 |
3 files changed, 316 insertions, 0 deletions
diff --git a/js/ui/menu/menu.reel/menu.css b/js/ui/menu/menu.reel/menu.css new file mode 100755 index 00000000..a02d488d --- /dev/null +++ b/js/ui/menu/menu.reel/menu.css | |||
@@ -0,0 +1,39 @@ | |||
1 | /* <copyright> | ||
2 | Copyright (c) 2012, Motorola Mobility LLC. | ||
3 | All Rights Reserved. | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without | ||
6 | modification, 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 | |||
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
29 | POSSIBILITY OF SUCH DAMAGE. | ||
30 | </copyright> */ | ||
31 | |||
32 | .horizontal-menu { | ||
33 | list-style: none; | ||
34 | margin: 0; | ||
35 | padding: 0 5px 0 5px; | ||
36 | float: left; | ||
37 | cursor: default; | ||
38 | display: block; | ||
39 | } | ||
diff --git a/js/ui/menu/menu.reel/menu.html b/js/ui/menu/menu.reel/menu.html new file mode 100755 index 00000000..4708c2cb --- /dev/null +++ b/js/ui/menu/menu.reel/menu.html | |||
@@ -0,0 +1,94 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!-- <copyright> | ||
3 | Copyright (c) 2012, Motorola Mobility LLC. | ||
4 | All Rights Reserved. | ||
5 | |||
6 | Redistribution and use in source and binary forms, with or without | ||
7 | modification, are permitted provided that the following conditions are met: | ||
8 | |||
9 | * Redistributions of source code must retain the above copyright notice, | ||
10 | this list of conditions and the following disclaimer. | ||
11 | |||
12 | * Redistributions in binary form must reproduce the above copyright notice, | ||
13 | this list of conditions and the following disclaimer in the documentation | ||
14 | and/or other materials provided with the distribution. | ||
15 | |||
16 | * Neither the name of Motorola Mobility LLC nor the names of its | ||
17 | contributors may be used to endorse or promote products derived from this | ||
18 | software without specific prior written permission. | ||
19 | |||
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
30 | POSSIBILITY OF SUCH DAMAGE. | ||
31 | </copyright> --> | ||
32 | <html> | ||
33 | <head> | ||
34 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
35 | <link rel="stylesheet" type="text/css" href="menu.css"> | ||
36 | |||
37 | <script type="text/montage-serialization"> | ||
38 | { | ||
39 | "menudata": { | ||
40 | "prototype": "js/ui/menu/menu-controller", | ||
41 | "bindings": { | ||
42 | "currentDocument": {"<-": "@owner.currentDocument"} | ||
43 | } | ||
44 | }, | ||
45 | |||
46 | "menuController": { | ||
47 | "prototype": "montage/ui/controller/array-controller", | ||
48 | "bindings": { | ||
49 | "content": {"<-": "@menudata.topLevelMenu"} | ||
50 | } | ||
51 | }, | ||
52 | |||
53 | "repetition": { | ||
54 | "prototype": "montage/ui/repetition.reel", | ||
55 | "properties": { | ||
56 | "element": { "#": "topMenu" }, | ||
57 | "contentController": {"@": "menuController"} | ||
58 | } | ||
59 | }, | ||
60 | |||
61 | "menuEntry": { | ||
62 | "prototype": "js/ui/menu/menu-entry.reel", | ||
63 | "properties": { | ||
64 | "element": { "#": "menuItem" } | ||
65 | }, | ||
66 | "bindings": { | ||
67 | "label": {"<-": "@repetition.objectAtCurrentIteration.label"}, | ||
68 | "entries": {"<-": "@repetition.objectAtCurrentIteration.entries"}, | ||
69 | "menuIsActive": {"<-": "@owner.active"} | ||
70 | } | ||
71 | }, | ||
72 | |||
73 | "owner": { | ||
74 | "prototype": "js/ui/menu/menu.reel", | ||
75 | "properties": { | ||
76 | "element": {"#": "mainMenuBar"}, | ||
77 | "menudata": {"@": "menudata"} | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | </script> | ||
82 | |||
83 | </head> | ||
84 | <body> | ||
85 | |||
86 | <nav data-montage-id="mainMenuBar" class="mainMenuBar unselectable"> | ||
87 | <ul data-montage-id="topMenu" class="horizontal-menu"> | ||
88 | <li data-montage-id="menuItem"></li> | ||
89 | </ul> | ||
90 | </nav> | ||
91 | |||
92 | |||
93 | </body> | ||
94 | </html> | ||
diff --git a/js/ui/menu/menu.reel/menu.js b/js/ui/menu/menu.reel/menu.js new file mode 100755 index 00000000..62534d0e --- /dev/null +++ b/js/ui/menu/menu.reel/menu.js | |||
@@ -0,0 +1,183 @@ | |||
1 | /* <copyright> | ||
2 | Copyright (c) 2012, Motorola Mobility LLC. | ||
3 | All Rights Reserved. | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without | ||
6 | modification, 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 | |||
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
29 | POSSIBILITY OF SUCH DAMAGE. | ||
30 | </copyright> */ | ||
31 | |||
32 | var Montage = require("montage/core/core").Montage, | ||
33 | Component = require("montage/ui/component").Component; | ||
34 | |||
35 | exports.Menu = 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 | this._currentDocument = value; | ||
51 | } | ||
52 | }, | ||
53 | |||
54 | menudata: { | ||
55 | value: null | ||
56 | }, | ||
57 | |||
58 | _active: { | ||
59 | value: false | ||
60 | }, | ||
61 | |||
62 | active: { | ||
63 | get: function() { | ||
64 | return this._active; | ||
65 | }, | ||
66 | set: function(value) { | ||
67 | if(this._active !== value) { | ||
68 | this._active = value; | ||
69 | } | ||
70 | |||
71 | if(this._active) { | ||
72 | document.addEventListener("mousedown", this, false); | ||
73 | document.addEventListener("keydown", this, true); | ||
74 | } else { | ||
75 | document.removeEventListener("mousedown", this, false); | ||
76 | document.removeEventListener("keydown", this, true); | ||
77 | this.activeEntry = null; | ||
78 | } | ||
79 | |||
80 | } | ||
81 | }, | ||
82 | |||
83 | _activeEntry: { | ||
84 | value: null | ||
85 | }, | ||
86 | |||
87 | activeEntry: { | ||
88 | get: function() { | ||
89 | return this._activeEntry; | ||
90 | }, | ||
91 | set: function(value) { | ||
92 | if(this._activeEntry === value) return; | ||
93 |