/
Ti.UI.Tab.js
executable file
·48 lines (41 loc) · 1.19 KB
/
Ti.UI.Tab.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var _ = require('../../../lib/alloy/underscore')._,
styler = require('../styler'),
U = require('../../../utils'),
CU = require('../compilerUtils');
exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
};
function parse(node, state, args) {
var children = U.XML.getElementsFromNodes(node.childNodes),
err = ['Tab must have only one child element, which must be a Window'];
code = '';
// Tab must have 1 window as a child
if (children.length !== 1) {
U.die(err);
}
var child = children[0],
childArgs = CU.getParserArgs(child),
theNode = CU.validateNodeName(child, 'Ti.UI.Window'),
windowSymbol;
// generate the code for the Window first
if (theNode) {
code += CU.generateNodeExtended(child, state, {
parent: {},
post: function(node, state, args) {
windowSymbol = state.parent.symbol;
}
});
} else {
err.unshift('Invalid Tab child "' + childArgs.fullname + '"');
U.die(err);
}
// create tab with window
state.extraStyle = styler.createVariableStyle('window', windowSymbol);
code += require('./default').parse(node, state).code;
// Update the parsing state
return {
parent: {},
styles: state.styles,
code: code
}
}