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.

71 lines
1.7 KiB

10 years ago
'use strict';
10 years ago
var React = require('react');
var Dialog = require('rc-dialog');
var div;
module.exports = function (props) {
var d;
props = props || {};
props.iconClassName = props.iconClassName || 'anticon-exclamation-circle';
10 years ago
props.transitionName = 'zoom';
10 years ago
props.maskAnimation = 'fade';
var width = props.width || 375;
function close() {
d.setState({
visible: false
});
}
function onCancel() {
10 years ago
var cancelFn = props.onCancel;
if (cancelFn) {
10 years ago
if(cancelFn.length) {
10 years ago
cancelFn(close);
}else {
cancelFn();
close();
}
10 years ago
} else {
close();
}
}
function onOk() {
10 years ago
var okFn = props.onOk;
if (okFn) {
10 years ago
if(okFn.length) {
10 years ago
okFn(close);
}else {
okFn();
close();
}
10 years ago
} else {
close();
}
}
var body = <div className="ant-confirm-body">
10 years ago
<i className={'anticon ' + props.iconClassName}></i>
10 years ago
<span className="ant-confirm-title">{props.title}</span>
<div className="ant-confirm-content">{props.content}</div>
10 years ago
</div>;
10 years ago
var footer = <div className="ant-confirm-btns">
<button type="button" className="ant-btn-default ant-btn ant-btn-lg" onClick={onCancel}> </button>
<button type="button" className="ant-btn-primary ant-btn ant-btn-lg" onClick={onOk}> </button>
</div>;
if (!div) {
div = document.createElement('div');
document.body.appendChild(div);
}
10 years ago
React.render(<Dialog prefixCls="ant-modal" className="ant-confirm" renderToBody={false} visible={true} closable={false} title="" animation="zoom" maskAnimation="fade" width={width}>
10 years ago
<div style={{zoom: 1, overflow: 'hidden'}}>{body} {footer}</div>
10 years ago
</Dialog>, div, function () {
d = this;
});
};