ant-design/components/modal/index.jsx
2015-06-12 17:37:39 +08:00

57 lines
1.1 KiB
JavaScript

'use strict';
var React = require('react');
var Dialog = require('rc-dialog');
function noop() {
}
var Modal = React.createClass({
getInitialState() {
return {
visible: false
};
},
handleCancel() {
this.props.onCancel();
this.hide();
},
getDefaultProps() {
return {
prefixCls: 'ant-modal',
onOk: noop,
onCancel: noop,
onBeforeClose: noop
};
},
show() {
this.setState({
visible: true
});
},
hide() {
this.setState({
visible: false
});
},
handleOk() {
this.props.onOk();
},
render() {
var props = this.props;
console.log(props);
var footer = props.footer || [
<button type="button" className="ant-btn-default ant-btn" onClick={this.handleCancel}> </button>,
<button type="button" className="ant-btn-primary ant-btn" onClick={this.handleOk}> </button>
];
return <Dialog animation="zoom" visible={this.state.visible} maskAnimation="fade" width="500" footer={footer} {...props} ref="d"/>;
}
});
module.exports = Modal;