pass lint

This commit is contained in:
yiminghe 2015-06-11 16:35:36 +08:00
parent 81d61868b2
commit 3690b2888d
4 changed files with 36 additions and 16 deletions

View File

@ -1,3 +1,5 @@
'use strict';
var React = require('react');
var Dialog = require('rc-dialog');
var div;
@ -17,26 +19,38 @@ module.exports = function (props) {
}
function onCancel() {
if (props.onCancel) {
props.onCancel(close);
var cancelFn = props.onCancel;
if (cancelFn) {
if(cancelFn.length){
cancelFn(close);
}else {
cancelFn();
close();
}
} else {
close();
}
}
function onOk() {
if (props.onOk) {
props.onOk(close);
var okFn = props.onOk;
if (okFn) {
if(okFn.length){
okFn(close);
}else {
okFn();
close();
}
} else {
close();
}
}
var body = <div className="ant-confirm-body">
<i className={"anticon " + props.iconClassName}></i>
<i className={'anticon ' + props.iconClassName}></i>
<span className="ant-confirm-title">{props.title}</span>
<div className="ant-confirm-content">{props.content}</div>
</div>
</div>;
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>
@ -48,7 +62,7 @@ module.exports = function (props) {
}
React.render(<Dialog className="ant-confirm" renderToBody={false} visible={true} closable={false} title="" animation="zoom" maskAnimation="fade" width={width}>
<div style={{zoom:1,overflow:'hidden'}}>{body} {footer}</div>
<div style={{zoom: 1, overflow: 'hidden'}}>{body} {footer}</div>
</Dialog>, div, function () {
d = this;

View File

@ -2,18 +2,19 @@
var React = require('react');
var Dialog = require('rc-dialog');
function noop(){}
function noop() {
}
var Modal = React.createClass({
handleCancel() {
this.refs.d.requestClose();
},
getDefaultProps(){
getDefaultProps() {
return {
onOk:noop,
onCancel:noop,
onBeforeClose:noop
onOk: noop,
onCancel: noop,
onBeforeClose: noop
};
},
@ -27,7 +28,7 @@ var Modal = React.createClass({
<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" maskAnimation="fade" width="500" footer={footer} {...props} ref="d"/>
return <Dialog animation="zoom" maskAnimation="fade" width="500" footer={footer} {...props} ref="d"/>;
}
});

View File

@ -9,7 +9,7 @@ var antd = {
Dropdown: require('./components/dropdown'),
Progress: require('./components/progress'),
Select: require('./components/select'),
confirm:require('./components/confirm')
confirm: require('./components/confirm')
};
module.exports = window.antd = antd;

View File

@ -32,11 +32,13 @@
"eslint-plugin-react": "~2.5.0",
"extract-text-webpack-plugin": "~0.8.1",
"gh-pages-cli": "~0.2.0",
"jshint": "~2.8.0",
"json-loader": "~0.5.1",
"less": "~2.5.1",
"less-loader": "~2.2.0",
"lodash": "~3.8.0",
"nico-jsx": "~0.5.8",
"precommit-hook": "~1.0.7",
"style-loader": "~0.12.2",
"webpack": "~1.9.7"
},
@ -47,5 +49,8 @@
"deploy": "npm run build && gh-pages -d _site -b gh-pages",
"lint": "eslint components index.js --ext '.js,.jsx'",
"test": "webpack && npm run lint"
}
},
"precommit": [
"lint"
]
}