diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/components/layout/tool-button.reel | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/components/layout/tool-button.reel')
-rw-r--r-- | js/components/layout/tool-button.reel/tool-button.css | 24 | ||||
-rw-r--r-- | js/components/layout/tool-button.reel/tool-button.html | 35 | ||||
-rw-r--r-- | js/components/layout/tool-button.reel/tool-button.js | 112 |
3 files changed, 171 insertions, 0 deletions
diff --git a/js/components/layout/tool-button.reel/tool-button.css b/js/components/layout/tool-button.reel/tool-button.css new file mode 100644 index 00000000..46152424 --- /dev/null +++ b/js/components/layout/tool-button.reel/tool-button.css | |||
@@ -0,0 +1,24 @@ | |||
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 | .buttonBackground { | ||
8 | height: 23px; | ||
9 | width: 26px; | ||
10 | margin: auto; | ||
11 | } | ||
12 | |||
13 | .buttonSelected { | ||
14 | background: #B2B2B2; | ||
15 | } | ||
16 | |||
17 | #toolBarButton { | ||
18 | border: 3px; | ||
19 | float: left; | ||
20 | } | ||
21 | |||
22 | #toolBarButton:hover { | ||
23 | opacity: 1; | ||
24 | } | ||
diff --git a/js/components/layout/tool-button.reel/tool-button.html b/js/components/layout/tool-button.reel/tool-button.html new file mode 100644 index 00000000..81a9b927 --- /dev/null +++ b/js/components/layout/tool-button.reel/tool-button.html | |||
@@ -0,0 +1,35 @@ | |||
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 | |||
11 | <link rel="stylesheet" type="text/css" href="tool-button.css"> | ||
12 | |||
13 | <script type="text/montage-serialization"> | ||
14 | { | ||
15 | "owner": { | ||
16 | "module": "js/components/layout/tool-button.reel", | ||
17 | "name": "ToolButton", | ||
18 | "properties": { | ||
19 | "element": {"#": "buttonBackground"}, | ||
20 | "button": {"#": "toolBarButton"} | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | </script> | ||
25 | |||
26 | |||
27 | </head> | ||
28 | |||
29 | <body> | ||
30 | <div id="buttonBackground" class="buttonBackground"> | ||
31 | <div id="toolBarButton" class="toolBarButton"></div> | ||
32 | </div> | ||
33 | </body> | ||
34 | |||
35 | </html> | ||
diff --git a/js/components/layout/tool-button.reel/tool-button.js b/js/components/layout/tool-button.reel/tool-button.js new file mode 100644 index 00000000..509512d0 --- /dev/null +++ b/js/components/layout/tool-button.reel/tool-button.js | |||
@@ -0,0 +1,112 @@ | |||
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 | var Montage = require("montage/core/core").Montage; | ||
8 | var Component = require("montage/ui/component").Component; | ||
9 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; | ||
10 | |||
11 | |||
12 | exports.ToolButton = Montage.create(Component, { | ||
13 | |||
14 | button: { value: null }, | ||
15 | |||
16 | data: { value: null }, | ||
17 | |||
18 | _selected: { value: null }, | ||
19 | |||
20 | selected: { | ||
21 | get: function() { return this._selected; }, | ||
22 | set: function(value) { | ||
23 | this._selected = value; | ||
24 | this.needsDraw = true; | ||
25 | } | ||
26 | }, | ||
27 | |||
28 | _subselected: { value: 1 }, | ||
29 | |||
30 | subselected: { | ||
31 | get: function() { return this._subselected; }, | ||
32 | set: function(value) { | ||
33 | |||
34 | var len = value.length; | ||
35 | for(var i=0; i < len; i++) { | ||
36 | if(value[i]) { | ||
37 | this._subselected = i; | ||
38 | this.needsDraw = true; | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | }, | ||
43 | |||
44 | _currentSubSelected: { value: 0}, | ||
45 | |||
46 | prepareForDraw: { | ||
47 | enumerable: false, | ||
48 | value: function() { | ||
49 | this.element.title = this.data.toolTip; | ||
50 | this.element.addEventListener("mousedown", this, false); | ||
51 | this.element.addEventListener("dblclick", this, false); | ||
52 | |||
53 | Object.defineBinding(this, "selected", { | ||
54 | boundObject: this.data, | ||
55 | boundObjectPropertyPath: "selected", | ||
56 | oneway: false | ||
57 | }); | ||
58 | |||
59 | if(this.data.container) { | ||
60 | this.element.title = this.data.subtools[this._subselected].toolTip; | ||
61 | Object.defineBinding(this, "subselected", { | ||
62 | boundObject: this.data.subtools, | ||
63 | boundObjectPropertyPath: "selected", | ||
64 | oneway: true | ||
65 | }); | ||
66 | } | ||
67 | } | ||
68 | }, | ||
69 | |||
70 | draw: { | ||
71 | enumerable: false, | ||
72 | value: function() { | ||
73 | var buttonid; | ||
74 | |||
75 | if(this.data.container) { | ||
76 | buttonid = this.data.subtools[this._subselected].id; | ||
77 | this.element.title = this.data.subtools[this._subselected].toolTip; | ||
78 | this.button.classList.remove( this.data.subtools[this._currentSubSelected].id + "Unpressed" ); | ||
79 | this.button.classList.remove( this.data.subtools[this._currentSubSelected].id + "Pressed" ); | ||
80 | this._currentSubSelected = this._subselected; | ||
81 | } else { | ||
82 | buttonid = this.data.id; | ||
83 | } | ||
84 | |||
85 | if(this._selected) { | ||
86 | this.element.classList.add( "buttonSelected" ); | ||
87 | this.button.classList.remove( buttonid + "Unpressed" ); | ||
88 | this.button.classList.add( buttonid + "Pressed" ); | ||
89 | } else { | ||
90 | this.element.classList.remove( "buttonSelected" ); | ||
91 | this.button.classList.remove( buttonid + "Pressed" ); | ||
92 | this.button.classList.add( buttonid + "Unpressed" ); | ||
93 | } | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | handleMousedown: { | ||
98 | value: function(event) { | ||
99 | if(!this._selected) { | ||
100 | NJevent("selectTool", this.data); | ||
101 | } | ||
102 | } | ||
103 | }, | ||
104 | |||
105 | handleDblclick: { | ||
106 | value: function(event) { | ||
107 | NJevent("toolDoubleClick", this.data); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | |||
112 | }); \ No newline at end of file | ||