You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.1 KiB

10 years ago
'use strict';
var React = require('react');
var Dialog = require('rc-dialog');
function noop() {
}
var div;
module.exports = function (props) {
var d;
10 years ago
props = props || {};
props.animation = 'zoom';
props.maskAnimation = 'fade';
10 years ago
props.width = props.width || 500;
10 years ago
props.onClose = props.onCancel || noop;
function close() {
d.setState({
visible: false
});
}
10 years ago
function onCancel() {
if (props.onCancel) {
props.onCancel();
}
10 years ago
close();
}
10 years ago
function onOk() {
if (props.onOk) {
props.onOk(close);
10 years ago
} else {
close();
10 years ago
}
}
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;
10 years ago
props.footer = props.footer || footer;
10 years ago
props.renderToBody = false;
10 years ago
React.render(<Dialog {...props}/>, div, function () {
d = this;
});
10 years ago
};