aboutsummaryrefslogtreecommitdiff
path: root/js/components/layout/tool-button.reel/tool-button.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/layout/tool-button.reel/tool-button.js')
-rw-r--r--js/components/layout/tool-button.reel/tool-button.js112
1 files changed, 112 insertions, 0 deletions
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>
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;
8var Component = require("montage/ui/component").Component;
9var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager;
10
11
12exports.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