2015-06-04 21:17:52 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var React = require('react');
|
|
|
|
var Dialog = require('rc-dialog');
|
2015-06-11 16:35:36 +08:00
|
|
|
function noop() {
|
|
|
|
}
|
2015-06-10 22:02:13 +08:00
|
|
|
|
|
|
|
var Modal = React.createClass({
|
2015-06-12 17:11:32 +08:00
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
visible: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-06-10 22:02:13 +08:00
|
|
|
handleCancel() {
|
2015-06-25 15:29:56 +08:00
|
|
|
var d = this.refs.d;
|
|
|
|
d.requestClose();
|
2015-06-10 22:02:13 +08:00
|
|
|
},
|
|
|
|
|
2015-06-11 16:35:36 +08:00
|
|
|
getDefaultProps() {
|
2015-06-10 22:02:13 +08:00
|
|
|
return {
|
2015-06-12 12:01:02 +08:00
|
|
|
prefixCls: 'ant-modal',
|
2015-06-11 16:35:36 +08:00
|
|
|
onOk: noop,
|
2015-06-12 23:46:04 +08:00
|
|
|
onCancel: noop
|
2015-06-10 22:02:13 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-06-12 17:11:32 +08:00
|
|
|
show() {
|
|
|
|
this.setState({
|
|
|
|
visible: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
hide() {
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-06-10 22:02:13 +08:00
|
|
|
handleOk() {
|
|
|
|
this.props.onOk();
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
var props = this.props;
|
2015-06-12 17:37:39 +08:00
|
|
|
var footer = props.footer || [
|
2015-07-08 20:53:11 +08:00
|
|
|
<button key="cancel" type="button" className="ant-btn-default ant-btn" onClick={this.handleCancel}>取 消</button>,
|
|
|
|
<button key="confirm" type="button" className="ant-btn-primary ant-btn" onClick={this.handleOk}>确 定</button>
|
2015-06-25 15:29:56 +08:00
|
|
|
];
|
2015-06-15 21:18:08 +08:00
|
|
|
return <Dialog transitionName="zoom" onBeforeClose={props.onCancel} visible={this.state.visible} maskAnimation="fade" width="500" footer={footer} {...props} ref="d"/>;
|
2015-06-10 17:59:32 +08:00
|
|
|
}
|
2015-06-10 22:02:13 +08:00
|
|
|
});
|
2015-06-10 17:59:32 +08:00
|
|
|
|
2015-06-11 16:35:36 +08:00
|
|
|
module.exports = Modal;
|