This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Popover.js
58 lines (48 loc) · 1.68 KB
/
Popover.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
var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var BootstrapMixin = require('./BootstrapMixin');
var Popover = React.createClass({displayName: "Popover",
mixins: [BootstrapMixin],
propTypes: {
placement: React.PropTypes.oneOf(['top','right', 'bottom', 'left']),
positionLeft: React.PropTypes.number,
positionTop: React.PropTypes.number,
arrowOffsetLeft: React.PropTypes.number,
arrowOffsetTop: React.PropTypes.number,
title: React.PropTypes.node
},
getDefaultProps: function () {
return {
placement: 'right'
};
},
render: function () {
var classes = {};
classes['popover'] = true;
classes[this.props.placement] = true;
classes['in'] = this.props.positionLeft != null || this.props.positionTop != null;
var style = {};
style['left'] = this.props.positionLeft;
style['top'] = this.props.positionTop;
style['display'] = 'block';
var arrowStyle = {};
arrowStyle['left'] = this.props.arrowOffsetLeft;
arrowStyle['top'] = this.props.arrowOffsetTop;
return (
React.createElement("div", React.__spread({}, this.props, {className: joinClasses(this.props.className, classSet(classes)), style: style, title: null}),
React.createElement("div", {className: "arrow", style: arrowStyle}),
this.props.title ? this.renderTitle() : null,
React.createElement("div", {className: "popover-content"},
this.props.children
)
)
);
},
renderTitle: function() {
return (
React.createElement("h3", {className: "popover-title"}, this.props.title)
);
}
});
module.exports = Popover;