aboutsummaryrefslogtreecommitdiff
path: root/js/components/menu/menu.reel/menu.js
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/menu.js
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/menu.js')
-rw-r--r--js/components/menu/menu.reel/menu.js108
1 files changed, 108 insertions, 0 deletions
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