Browse Source

pass lint

pull/19/head
yiminghe 10 years ago
parent
commit
3690b2888d
  1. 28
      components/confirm/index.jsx
  2. 15
      components/modal/index.jsx
  3. 2
      index.js
  4. 7
      package.json

28
components/confirm/index.jsx

@ -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;

15
components/modal/index.jsx

@ -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,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-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;

2
index.js

@ -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;

7
package.json

@ -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"
]
}

Loading…
Cancel
Save