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 React = require('react');
var Dialog = require('rc-dialog'); var Dialog = require('rc-dialog');
var div; var div;
@ -17,26 +19,38 @@ module.exports = function (props) {
} }
function onCancel() { function onCancel() {
if (props.onCancel) { var cancelFn = props.onCancel;
props.onCancel(close); if (cancelFn) {
if(cancelFn.length){
cancelFn(close);
}else {
cancelFn();
close();
}
} else { } else {
close(); close();
} }
} }
function onOk() { function onOk() {
if (props.onOk) { var okFn = props.onOk;
props.onOk(close); if (okFn) {
if(okFn.length){
okFn(close);
}else {
okFn();
close();
}
} else { } else {
close(); close();
} }
} }
var body = <div className="ant-confirm-body"> 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> <span className="ant-confirm-title">{props.title}</span>
<div className="ant-confirm-content">{props.content}</div> <div className="ant-confirm-content">{props.content}</div>
</div> </div>;
var footer = <div className="ant-confirm-btns"> 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-default ant-btn ant-btn-lg" onClick={onCancel}> </button>
<button type="button" className="ant-btn-primary ant-btn ant-btn-lg" onClick={onOk}> </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}> 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 () { </Dialog>, div, function () {
d = this; d = this;

View File

@ -2,18 +2,19 @@
var React = require('react'); var React = require('react');
var Dialog = require('rc-dialog'); var Dialog = require('rc-dialog');
function noop(){} function noop() {
}
var Modal = React.createClass({ var Modal = React.createClass({
handleCancel() { handleCancel() {
this.refs.d.requestClose(); this.refs.d.requestClose();
}, },
getDefaultProps(){ getDefaultProps() {
return { return {
onOk:noop, onOk: noop,
onCancel:noop, onCancel: noop,
onBeforeClose:noop onBeforeClose: noop
}; };
}, },
@ -27,8 +28,8 @@ var Modal = React.createClass({
<button type="button" className="ant-btn-default ant-btn" onClick={this.handleCancel}> </button>, <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> <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"/>;
} }
}); });
module.exports = Modal; module.exports = Modal;

View File

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

View File

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