aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/tabs.reel/tabs.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 /node_modules/montage/ui/tabs.reel/tabs.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 'node_modules/montage/ui/tabs.reel/tabs.js')
-rwxr-xr-xnode_modules/montage/ui/tabs.reel/tabs.js177
1 files changed, 177 insertions, 0 deletions
diff --git a/node_modules/montage/ui/tabs.reel/tabs.js b/node_modules/montage/ui/tabs.reel/tabs.js
new file mode 100755
index 00000000..60b18480
--- /dev/null
+++ b/node_modules/montage/ui/tabs.reel/tabs.js
@@ -0,0 +1,177 @@
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 @module "montage/ui/tabs.reel"
8 @requires montage/core/core
9 @requires montage/ui/component
10 @requires "montage/ui/repetition.reel"
11 @requires "montage/ui/substitution.reel"
12 @requires "montage/ui/dynamic-text.reel"
13 @requires "montage/ui/image.reel"
14 @requires montage/core/uuid
15*/
16var Montage = require("montage").Montage,
17 Component = require("ui/component").Component,
18 Repetition = require("ui/repetition.reel").Repetition,
19 Substitution = require("ui/substitution.reel").Substitution,
20 DynamicText = require("ui/dynamic-text.reel").DynamicText,
21 Image = require("ui/image.reel").Image,
22 Uuid = require("core/uuid").Uuid;
23
24/**
25 @class module:"montage/ui/tabs.reel".Tabs
26*/
27
28var Tabs = exports.Tabs = Montage.create(Component, /** @lends module:"montage/ui/tabs.reel".Tabs# */ {
29
30 hasTemplate: {
31 value: true
32 },
33
34 _repetition: {
35 enumerable: false,
36 value: null
37 },
38/**
39 Description TODO
40 @type {Property}
41 @default {Array} []
42 */
43 tabs: {
44 enumerable: false,
45 distinct: true,
46 value: []
47 },
48
49 navController: {
50 value: null
51 },
52 // optional property. If provided, this will result in wiring tab clicks to switching components in content
53 /**
54 Description TODO
55 @type {Property}
56 @default null
57 */
58 content: {
59 enumerable: false,
60 value: null
61 },
62
63 // @private -
64 _selectedTabs: {value: null},
65 selectedTabs: {
66 get: function() {
67 return this._selectedTabs;
68 },
69 set: function(arr) {
70 if(arr && arr.length > 0) {
71 this._selectedTabs = arr;
72 this.selectedTab = arr[0];
73 }
74 }
75 },
76
77 // selectedTabValue is the value of the Tab, selectedTab returns the object representing the tab
78
79 _selectedTabValue: {value: null},
80 selectedTabValue: {
81 get: function() {
82 return this._selectedTabValue;
83 },
84 set: function(value) {
85 this._selectedTabValue = value;
86 if(this.navController) {
87 var index = this._indexOf(value);
88 this.navController.selectedIndexes = [index];
89 }
90 }
91 },
92
93
94 _selectedTab: {value: null},
95 selectedTab: {
96 distinct: true,
97 enumerable: false,
98 get: function() {
99 return this._selectedTab;
100 },
101 set: function(value) {
102 if(value && value !== this._selectedTab) {
103 this._selectedTab = value;
104 this.needsDraw = true;
105 }
106 }
107 },
108
109 _indexOf: {
110 value: function(value) {
111 var index = 0;
112 // get the index of the this value element in the tabs array
113 var i = 0, len = this.tabs.length;
114 for (; i < len; i++) {
115 if (this.tabs[i].value === value) {
116 index = i;
117 }
118 }
119 return index;
120
121 }
122 },
123
124 propertyChangeBindingListener: {
125 value: function(type, listener, useCapture, atSignIndex, bindingOrigin, bindingPropertyPath, bindingDescriptor) {
126 // kishore: same as in list.js
127 if (bindingDescriptor.boundObjectPropertyPath.match(/objectAtCurrentIteration/)) {
128 if (this._repetition) {
129 bindingDescriptor.boundObject = this._repetition;
130 return this._repetition.propertyChangeBindingListener.apply(this._repetition, arguments);
131 } else {
132 return null;
133 }
134 } else {
135 return Object.prototype.propertyChangeBindingListener.apply(this, arguments);
136 }
137 }
138 },
139
140 deserializedFromTemplate: {
141 value: function() {
142 this._orphanedChildren = this.childComponents;
143 this.childComponents = null;
144 }
145 },
146
147 templateDidLoad: {
148 value: function() {
149 var orphanedFragment,
150 currentContentRange = this.element.ownerDocument.createRange();
151 currentContentRange.selectNodeContents(this.element);
152 orphanedFragment = currentContentRange.extractContents();
153
154 this._repetition.element.querySelector('li').appendChild(orphanedFragment);
155 this._repetition.childComponents = this._orphanedChildren;
156 this._repetition.needsDraw = true;
157
158 if(this.content) {
159 // substitution
160 Object.defineBinding(this.content, "switchValue", {
161 boundObject: this,
162 boundObjectPropertyPath: 'selectedTab.value'
163 });
164 }
165 var index = (this.selectedTabValue ? this._indexOf(this.selectedTabValue) : 0);
166 this.navController.selectedIndexes = [index];
167
168 }
169 },
170
171 draw: {
172 value: function() {
173 //console.log("draw current tab = " + value);
174 }
175 }
176
177});