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.

86 lines
1.9 KiB

import React from 'react';
import Dialog from './index';
let div;
10 years ago
export default function (props) {
let d;
10 years ago
props = props || {};
props.iconClassName = props.iconClassName || 'anticon-exclamation-circle';
let width = props.width || 375;
10 years ago
function close() {
d.setState({
visible: false
});
}
function onCancel() {
let cancelFn = props.onCancel;
10 years ago
if (cancelFn) {
let ret;
10 years ago
if (cancelFn.length) {
ret = cancelFn(close);
10 years ago
} else {
ret = cancelFn();
if (!ret) {
close();
}
}
if (ret && ret.then) {
ret.then(close);
10 years ago
}
10 years ago
} else {
close();
}
}
function onOk() {
let okFn = props.onOk;
10 years ago
if (okFn) {
let ret;
10 years ago
if (okFn.length) {
ret = okFn(close);
10 years ago
} else {
ret = okFn();
if (!ret) {
close();
}
}
if (ret && ret.then) {
ret.then(close);
10 years ago
}
10 years ago
} else {
close();
}
}
let 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>;
let footer = <div className="ant-confirm-btns">
10 years ago
<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"
visible={true}
closable={false}
title=""
transitionName="zoom"
footer=""
10 years ago
maskTransitionName="fade" width={width}>
10 years ago
<div style={{zoom: 1, overflow: 'hidden'}}>{body} {footer}</div>
10 years ago
</Dialog>, div, function () {
d = this;
});
}