aboutsummaryrefslogtreecommitdiff
path: root/js/components/toolbar.reel/toolbar.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/toolbar.reel/toolbar.js')
-rw-r--r--js/components/toolbar.reel/toolbar.js112
1 files changed, 112 insertions, 0 deletions
diff --git a/js/components/toolbar.reel/toolbar.js b/js/components/toolbar.reel/toolbar.js
new file mode 100644
index 00000000..dbff2db6
--- /dev/null
+++ b/js/components/toolbar.reel/toolbar.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
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.Toolbar = Montage.create(Component, {
11 _needsButtonProperties : {
12 value: null
13 },
14 leftAlignClass : { value: "left-button" },
15 hideButtonClass : { value: "hide-button" },
16 _buttons : { value: null },
17 buttons : {
18 get: function() {
19 return this._buttons;
20 },
21 set: function(btns) {
22 this._buttons = btns;
23 this._needsButtonProperties = true;
24 console.log("buttons set");
25 }
26 },
27
28 _buttonToHide : {
29 value: null
30 },
31 _buttonToShow : {
32 value: null
33 },
34 getButton : {
35 value: function(identifier) {
36 var buttons = this.repetition.childComponents,
37 buttonIds = buttons.map(function(component) {
38 return component.sourceObject.identifier;
39 });
40
41 return buttons[buttonIds.indexOf(identifier)];
42 }
43 },
44 hideButton : {
45 value: function(identifier) {
46 var button = this.getButton(identifier);
47
48 if(button) {
49 this._buttonToHide = button;
50 this.needsDraw = true;
51 }
52 }
53 },
54 showButton : {
55 value: function(identifier) {
56 var button = this.getButton(identifier);
57
58 if(button) {
59 this._buttonToShow = button;
60 this.needsDraw = true;
61 }
62 }
63 },
64
65 prepareForDraw : {
66 value: function() {
67 console.log("toolbar - prepare for draw");
68 if(this._needsButtonProperties) {
69 this.repetition.childComponents.forEach(function(button) {
70 button.identifier = button.sourceObject.identifier;
71 button.addEventListener('action', this.delegate, false);
72 }, this);
73 }
74 }
75 },
76 draw : {
77 value: function() {
78 console.log("toolbar - draw - repetition ", this.repetition);
79 if(this._needsClass) {
80
81 this.repetition.childComponents.forEach(function(button) {
82 button.element.classList.add('toolbar-' + button.sourceObject.identifier + '-button');
83
84 ///// add left align class if specified in serialization
85 if(button.sourceObject.leftAlign) {
86 button.element.parentElement.classList.add(this.leftAlignClass);
87 }
88 }, this);
89
90 this._needsClass = false;
91 }
92
93 if(this._needsButtonProperties) {
94 this._needsClass = this.needsDraw = true;
95 this._needsButtonProperties = false;
96 }
97
98 if(this._buttonToHide) {
99 this._buttonToHide.element.classList.add(this.hideButtonClass);
100 this._buttonToHide = null;
101 }
102 if(this._buttonToShow) {
103 this._buttonToShow.element.classList.remove(this.hideButtonClass);
104 this._buttonToShow = null;
105 }
106
107 }
108 },
109 _needsClass : {
110 value: null
111 }
112}); \ No newline at end of file