2015-06-24 19:20:47 +08:00
|
|
|
import React from 'react';
|
|
|
|
import Tooltip from 'rc-tooltip';
|
|
|
|
const prefixCls = 'ant-popover';
|
|
|
|
|
|
|
|
export default React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
visible: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
getDefaultProps() {
|
|
|
|
return {
|
|
|
|
transitionName: '',
|
|
|
|
placement: 'top',
|
|
|
|
trigger: 'click',
|
2015-08-19 20:12:34 +08:00
|
|
|
overlayStyle: {},
|
|
|
|
onConfirm: function () {
|
|
|
|
},
|
|
|
|
onCancel: function () {
|
|
|
|
}
|
2015-06-24 19:20:47 +08:00
|
|
|
};
|
|
|
|
},
|
2015-08-18 14:02:55 +08:00
|
|
|
confirm() {
|
2015-06-24 19:20:47 +08:00
|
|
|
this.props.onConfirm.call(this);
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
2015-08-18 14:02:55 +08:00
|
|
|
cancel() {
|
2015-06-24 19:20:47 +08:00
|
|
|
this.props.onCancel.call(this);
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
2015-08-18 14:02:55 +08:00
|
|
|
onVisibleChange(v) {
|
2015-08-07 19:21:02 +08:00
|
|
|
this.setState({
|
|
|
|
visible: v
|
|
|
|
});
|
|
|
|
},
|
2015-06-24 19:20:47 +08:00
|
|
|
render() {
|
|
|
|
const overlay = <div>
|
|
|
|
<div className={prefixCls + '-content'}>
|
|
|
|
<p className={prefixCls + '-message'}>
|
|
|
|
<i className="anticon anticon-exclamation-circle"></i>
|
|
|
|
{this.props.title}
|
|
|
|
</p>
|
2015-08-19 20:12:34 +08:00
|
|
|
|
2015-06-24 19:20:47 +08:00
|
|
|
<div className={prefixCls + '-buttons'}>
|
|
|
|
<button onClick={this.cancel} className="ant-btn ant-btn-sm">取 消</button>
|
2015-07-16 11:50:36 +08:00
|
|
|
<button onClick={this.confirm} className="ant-btn ant-btn-primary ant-btn-sm">确 定</button>
|
2015-06-24 19:20:47 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
|
|
|
|
const transitionName = ({
|
|
|
|
top: 'zoom-down',
|
|
|
|
bottom: 'zoom-up',
|
|
|
|
left: 'zoom-right',
|
|
|
|
right: 'zoom-left'
|
|
|
|
})[this.props.placement];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Tooltip placement={this.props.placement}
|
2015-08-19 20:12:34 +08:00
|
|
|
overlayStyle={this.props.overlayStyle}
|
2015-08-07 19:21:02 +08:00
|
|
|
prefixCls={prefixCls}
|
|
|
|
onVisibleChange={this.onVisibleChange}
|
|
|
|
transitionName={transitionName}
|
|
|
|
visible={this.state.visible}
|
|
|
|
trigger={this.props.trigger}
|
|
|
|
overlay={overlay}>
|
2015-06-24 19:20:47 +08:00
|
|
|
{this.props.children}
|
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|