-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
109 lines (96 loc) · 2.99 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @jsx React.DOM*/
/**
* Created by laiff on 03.09.14.
*/
'use strict';
var React = require('react/addons');
var dom = React.DOM;
function createIcon(type) {
var iconType = type;
return React.createClass({
render: function () {
var type = iconType || this.props.type;
var cs = React.addons.classSet;
var classes = {
'fa': true,
'fa-spin': this.props.spin,
'fa-fw': this.props.fixedWidth,
'fa-li': this.props.li,
'fa-border': this.props.border
};
classes['fa-' + type] = type;
classes['fa-' + this.props.size] = this.props.size;
classes['fa-rotate-' + this.props.rotate] = this.props.rotate;
classes['fa-flip-' + this.props.flip] = this.props.flip;
classes['fa-stack-' + this.props.stack] = this.props.stack;
classes['fa-align-' + this.props.align] = this.props.align;
var className = cs(classes) + " " + (this.props.className || '');
return this.transferPropsTo(
dom.i({className: className}, this.props.children)
);
}
});
}
var IconStack = React.createClass({
render: function () {
var cs = React.addons.classSet;
var classes = {
'fa-stack': true
}
classes['fa-' + this.props.size] = this.props.size;
var className = cs(classes) + " " + (this.props.className || '');
return this.transferPropsTo(
dom.span({className: className}, this.props.children)
);
}
});
var Ul = React.createClass({
render: function () {
var cs = React.addons.classSet;
var classes = {
'fa-ul': true
}
var className = cs(classes) + " " + (this.props.className || '');
return this.transferPropsTo(
dom.ul({className: className}, this.props.children)
);
}
});
var Icon = createIcon();
var Animate = React.createClass({
getInitialState: function () {
return {
childCount: 0,
child: (dom.span({}, null))
};
},
componentWillMount: function () {
if (this.props.children) {
this.timer = setInterval(function () {
var newChild = this.state.childCount + 1;
if (this.props.children.length <= newChild) {
newChild = 0;
}
this.setState({
childCount: newChild,
child: this.props.children[newChild]
});
}.bind(this), this.props.interval || 1000);
this.setState({
child: this.props.children[0]
});
}
},
componentWillUnmount: function () {
clearInterval(this.timer);
},
render: function () {
return this.state.child;
}
});
module.exports = {
Icon: Icon,
Ul: Ul,
IconStack: IconStack,
Animate: Animate
};