-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRTL.js
56 lines (48 loc) · 1.57 KB
/
RTL.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
49
50
51
52
53
54
55
56
var rtl = function() {
this.rightAlign = function(view) {
if (view) {
if (view.toString() === '[object TiUITextField]' || view.toString() === '[object TiUILabel]') {
view.textAlign = 'right';
}
}
};
this.rightAlignChildren = function(view) {
if (view) {
for(var i=0,j=view.children.length; i<j; i++){
if (view.children[i].toString() === '[object TiUITextField]' || view.children[i].toString() === '[object TiUILabel]') {
view.children[i].textAlign = 'right';
} else if (view.children[i].toString() === '[object TiUIView]') {
if (view.children[i].children && view.children[i].children.length > 0) {
if (view.children[i].children[0].toString() === '[object TiUITextField]' || view.children[i].children[0].toString() === '[object TiUILabel]') {
view.children[i].children[0].textAlign = 'right';
}
}
}
};
}
};
this.swapAlignment = function(view) {
if (view.left) {
view.right = view.left;
view.left = null;
} else if (view.right) {
view.left = view.right;
view.right = null;
}
view.textAlign = 'right';
};
this.swapAlignmentOfChildren = function(view) {
for (var i = 0, j = view.children.length; i < j; i++) {
if (view.children[i].left) {
view.children[i].right = view.children[i].left;
view.children[i].left = null;
view.children[i].textAlign = 'right';
} else if (view.children[i].right) {
view.children[i].left = view.children[i].right;
view.children[i].right = null;
view.children[i].textAlign = 'right';
}
};
};
};
module.exports = rtl;