aboutsummaryrefslogtreecommitdiff
path: root/js/components/menu/menu.reel
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/components/menu/menu.reel
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/components/menu/menu.reel')
-rw-r--r--js/components/menu/menu.reel/menu.css14
-rw-r--r--js/components/menu/menu.reel/menu.html89
-rw-r--r--js/components/menu/menu.reel/menu.js108
3 files changed, 211 insertions, 0 deletions
diff --git a/js/components/menu/menu.reel/menu.css b/js/components/menu/menu.reel/menu.css
new file mode 100644
index 00000000..557ffc71
--- /dev/null
+++ b/js/components/menu/menu.reel/menu.css
@@ -0,0 +1,14 @@
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.horizontal-menu {
8 list-style: none;
9 margin: 0px;
10 padding: 5px;
11 float: left;
12 cursor: default;
13 display: block;
14} \ No newline at end of file
diff --git a/js/components/menu/menu.reel/menu.html b/js/components/menu/menu.reel/menu.html
new file mode 100644
index 00000000..2cc6bf9b
--- /dev/null
+++ b/js/components/menu/menu.reel/menu.html
@@ -0,0 +1,89 @@
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 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 <link rel="stylesheet" type="text/css" href="menu.css">
11
12 <script type="text/montage-serialization">
13 {
14 "menudata": {
15 "name": "MenuData",
16 "module": "js/data/menu-data"
17 },
18
19 "menuController": {
20 "name": "ArrayController",
21 "module": "montage/ui/controller/array-controller",
22 "properties": {
23 "automaticallyOrganizeObjects": false
24 },
25 "bindings": {
26 "content": {
27 "boundObject": {"@": "menudata"},
28 "boundObjectPropertyPath": "topLevelMenu",
29 "oneway": true
30 }
31 }
32 },
33
34 "repetition": {
35 "module": "montage/ui/repetition.reel",
36 "name": "Repetition",
37 "properties": {
38 "element": { "#": "topMenu" },
39 "contentController": {"@": "menuController"},
40 "menuComponent": {"@": "owner"}
41 }
42 },
43
44 "menuEntry": {
45 "module": "js/components/menu/menu-entry.reel",
46 "name": "MenuEntry",
47 "properties": {
48 "element": { "#": "menuItem" }
49 },
50 "bindings": {
51 "data": {
52 "boundObject": {"@": "repetition"},
53 "boundObjectPropertyPath": "objectAtCurrentIteration",
54 "oneway": true
55 },
56 "_menu": {
57 "boundObject": {"@": "repetition"},
58 "boundObjectPropertyPath": "menuComponent",
59 "oneway": true
60 }
61
62
63 }
64 },
65
66 "owner": {
67 "module": "js/components/menu/menu.reel",
68 "name": "Menu",
69 "properties": {
70 "element": {"#": "mainMenuBar"},
71 "controller": {"@": "menuController"},
72 "rep": {"@": "repetition"}
73 }
74 }
75 }
76 </script>
77
78</head>
79<body>
80
81 <nav id="mainMenuBar" class="mainMenuBar unselectable">
82 <ul id="topMenu" class="horizontal-menu">
83 <li id="menuItem"></li>
84 </ul>
85 </nav>
86
87
88</body>
89</html>
diff --git a/js/components/menu/menu.reel/menu.js b/js/components/menu/menu.reel/menu.js
new file mode 100644
index 00000000..fb221640
--- /dev/null
+++ b/js/components/menu/menu.reel/menu.js
@@ -0,0 +1,108 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.Menu = Montage.create(Component, {
11
12 _active: {
13 value: false
14 },
15
16 active: {
17 get: function() {
18 return this._active;
19 },
20 set: function(value) {
21 this._active = value;
22 }
23 },
24
25 _activeEntry: {
26 value: null
27 },
28
29 activeEntry: {
30 get: function() {
31 return this._activeEntry;
32 },
33 set: function(value) {
34 if(this.active) {
35
36 if(this._activeEntry) this._activeEntry.deselect();
37
38 this._activeEntry = value;
39
40 this._activeEntry.select();
41
42 }
43 }
44 },
45
46 toggleActivation: {
47 value: function(item) {
48 if(this.active) {
49 this._activeEntry.deselect();
50 this._activeEntry = null;
51 this.active = false;
52 this.element.ownerDocument.removeEventListener('mousedown', this, false);
53 } else {
54 this.active = true;
55 this.activeEntry = item;
56 this.element.ownerDocument.addEventListener('mousedown', this, false);
57 }
58 }
59 },
60
61 prepareForDraw: {
62 value: function() {
63
64 }
65 },
66
67 handleMousedown: {
68 value: function(evt) {
69
70 if(this.active && (this.getZIndex(evt.target) < 9000 || evt.target.id === "topMenu")) {
71 this._activeEntry.deselect();
72 this._activeEntry = null;
73 this.active = false;
74
75 //console.log(this.rep.objects[1]);
76 //this.controller.content[1].header = "BLAH";
77 }
78
79// console.log(evt.target.style['z-index']);
80// console.log(this.getZIndex(evt.target));
81
82 }
83 },
84
85 getZIndex: {
86 value: function(elem) {
87
88 var position, value, zIndex;
89 while (elem && elem !== document) {
90// position = elem.style.position;
91 position = document.defaultView.getComputedStyle(elem, "").getPropertyValue("position");
92
93 if (position === "absolute" || position === "relative" || position === "fixed") {
94 // webkit returns a string for zindex value and "" if zindex is not available
95// zIndex = elem.style['z-index'];
96 zIndex = document.defaultView.getComputedStyle(elem, "").getPropertyValue("z-index");
97 value = parseInt(zIndex, 10);
98 if (!isNaN(value) && value !== 0) {
99 return value;
100 }
101 }
102 elem = elem.parentNode;
103 }
104 return 0;
105 }
106 }
107
108}); \ No newline at end of file