mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 05:29:37 +08:00
58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
var React = require('react');
|
|
var Dialog = require('rc-dialog');
|
|
|
|
function noop() {
|
|
}
|
|
|
|
var div;
|
|
|
|
module.exports = function (props) {
|
|
var d;
|
|
props = props || {};
|
|
|
|
props.animation = 'zoom';
|
|
props.maskAnimation = 'fade';
|
|
props.width = props.width || 500;
|
|
|
|
props.onClose = props.onCancel || noop;
|
|
|
|
function close() {
|
|
d.setState({
|
|
visible: false
|
|
});
|
|
}
|
|
|
|
function onCancel() {
|
|
if (props.onCancel) {
|
|
props.onCancel();
|
|
}
|
|
close();
|
|
}
|
|
|
|
function onOk() {
|
|
if (props.onOk) {
|
|
props.onOk(close);
|
|
} else {
|
|
close();
|
|
}
|
|
}
|
|
|
|
var footer = [
|
|
<button type="button" className="ant-btn-default ant-btn" onClick={onCancel}>取 消</button>,
|
|
<button type="button" className="ant-btn-primary ant-btn" onClick={onOk}>确 定</button>
|
|
];
|
|
if (!div) {
|
|
div = document.createElement('div');
|
|
document.body.appendChild(div);
|
|
}
|
|
props.visible = true;
|
|
props.children = props.content;
|
|
props.footer = props.footer || footer;
|
|
props.renderToBody = false;
|
|
React.render(<Dialog {...props}/>, div, function () {
|
|
d = this;
|
|
});
|
|
};
|