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.js109
1 files changed, 109 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..bc3cbd08
--- /dev/null
+++ b/js/components/toolbar.reel/toolbar.js
@@ -0,0 +1,109 @@
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 }
25 },
26
27 _buttonToHide : {
28 value: null
29 },
30 _buttonToShow : {
31 value: null
32 },
33 getButton : {
34 value: function(identifier) {
35 var buttons = this.repetition.childComponents,
36 buttonIds = buttons.map(function(component) {
37 return component.sourceObject.identifier;
38 });
39
40 return buttons[buttonIds.indexOf(identifier)];
41 }
42 },
43 hideButton : {
44 value: function(identifier) {
45 var button = this.getButton(identifier);
46
47 if(button) {
48 this._buttonToHide = button;
49 this.needsDraw = true;
50 }
51 }
52 },
53 showButton : {
54 value: function(identifier) {
55 var button = this.getButton(identifier);
56
57 if(button) {
58 this._buttonToShow = button;
59 this.needsDraw = true;
60 }
61 }
62 },
63
64 prepareForDraw : {
65 value: function() {
66 if(this._needsButtonProperties) {
67 this.repetition.childComponents.forEach(function(button) {
68 button.identifier = button.sourceObject.identifier;
69 button.addEventListener('action', this.delegate, false);
70 }, this);
71 }
72 }
73 },
74 draw : {
75 value: function() {
76 if(this._needsClass) {
77
78 this.repetition.childComponents.forEach(function(button) {
79 button.element.classList.add('toolbar-' + button.sourceObject.identifier + '-button');
80
81 ///// add left align class if specified in serialization
82 if(button.sourceObject.leftAlign) {
83 button.element.parentElement.classList.add(this.leftAlignClass);
84 }
85 }, this);
86
87 this._needsClass = false;
88 }
89
90 if(this._needsButtonProperties) {
91 this._needsClass = this.needsDraw = true;
92 this._needsButtonProperties = false;
93 }
94
95 if(this._buttonToHide) {
96 this._buttonToHide.element.classList.add(this.hideButtonClass);
97 this._buttonToHide = null;
98 }
99 if(this._buttonToShow) {
100 this._buttonToShow.element.classList.remove(this.hideButtonClass);
101 this._buttonToShow = null;
102 }
103
104 }
105 },
106 _needsClass : {
107 value: null
108 }
109}); \ No newline at end of file