Skip to content

Commit

Permalink
style: eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-mm committed Nov 7, 2017
1 parent f9b992a commit 153007b
Show file tree
Hide file tree
Showing 11 changed files with 1,206 additions and 1,182 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
73 changes: 35 additions & 38 deletions src/DefaultFileItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,52 +61,49 @@ export default class DefaultFileItem extends React.Component {
</a> : undefined}
</div>
</div>);
} else {
return (<div className={readOnlyStyle}>
<div className="field-image-info">
<a className="field-image-preview" href={previewUrl} target="_blank">
<img src={previewUrl} />
</a>
</div>
<div className="field-status">
{previewUrl ? <a className="kuma-upload-action preview-action" onClick={me.onShowFile.bind(this, file, previewUrl)} target="_blank" href={previewUrl}><Icon name="fangda" /></a> : null}
{response.canRemove !== false && !readOnly ? <a className="remove-action" onClick={this.onCancel.bind(this, file)}>
<Icon name="biaodanlei-tongyongqingchu" />
</a> : undefined}
</div>
</div>);
}
} else {
return (<div className={readOnlyStyle}>
<label className="field-icon">
<i className="kuma-upload-fileicon" data-ext={file.ext} data-type={file.fileType} />
</label>
<div className="field-line" />
<div className="field-info-wrap">
<label className="field-info">
<span className="filename" title={file.name}>{file.name}</span>
</label>
<div className="field-status">
{previewUrl ? <a className="kuma-upload-action preview-action" onClick={me.onShowFile.bind(this, file, previewUrl)} target="_blank" href={previewUrl}><Icon name="fangda" /></a> : null}
{downloadUrl && !readOnly ? <a className="kuma-upload-action download-action" target="_blank" download href={downloadUrl}><Icon name="xiazai" /></a> : null}
{response.canRemove !== false && !readOnly ? <a className="kuma-upload-action remove-action" onClick={this.onCancel.bind(this, file)}><Icon name="shanchu" /></a> : null}
</div>
<div className="field-image-info">
<a className="field-image-preview" href={previewUrl} target="_blank">
<img src={previewUrl} />
</a>
</div>
<div className="field-status">
{previewUrl ? <a className="kuma-upload-action preview-action" onClick={me.onShowFile.bind(this, file, previewUrl)} target="_blank" href={previewUrl}><Icon name="fangda" /></a> : null}
{response.canRemove !== false && !readOnly ? <a className="remove-action" onClick={this.onCancel.bind(this, file)}>
<Icon name="biaodanlei-tongyongqingchu" />
</a> : undefined}
</div>
</div>);
}
} else {
return (<div className={'kuma-upload-fileitem'}>
<label className="field-info">
return (<div className={readOnlyStyle}>
<label className="field-icon">
<i className="kuma-upload-fileicon" data-ext={file.ext} data-type={file.fileType} />
<span className="filename" title={file.name}>{util.natcut(response.name, 12)}</span>
</label>
<label className="field-status">
<a className="kuma-upload-status status-success"><i className="kuma-icon kuma-icon-choose" /></a>
{!readOnly ? <a className="kuma-upload-action remove-action" onClick={this.onCancel.bind(this, file)} title={i18n[locale].remove}>
<Icon name="shanchu" />
</a> : null}
</label>
<div className="field-line" />
<div className="field-info-wrap">
<label className="field-info">
<span className="filename" title={file.name}>{file.name}</span>
</label>
<div className="field-status">
{previewUrl ? <a className="kuma-upload-action preview-action" onClick={me.onShowFile.bind(this, file, previewUrl)} target="_blank" href={previewUrl}><Icon name="fangda" /></a> : null}
{downloadUrl && !readOnly ? <a className="kuma-upload-action download-action" target="_blank" download href={downloadUrl}><Icon name="xiazai" /></a> : null}
{response.canRemove !== false && !readOnly ? <a className="kuma-upload-action remove-action" onClick={this.onCancel.bind(this, file)}><Icon name="shanchu" /></a> : null}
</div>
</div>
</div>);
}
return (<div className={'kuma-upload-fileitem'}>
<label className="field-info">
<i className="kuma-upload-fileicon" data-ext={file.ext} data-type={file.fileType} />
<span className="filename" title={file.name}>{util.natcut(response.name, 12)}</span>
</label>
<label className="field-status">
<a className="kuma-upload-status status-success"><i className="kuma-icon kuma-icon-choose" /></a>
{!readOnly ? <a className="kuma-upload-action remove-action" onClick={this.onCancel.bind(this, file)} title={i18n[locale].remove}>
<Icon name="shanchu" />
</a> : null}
</label>
</div>);
}
}
136 changes: 68 additions & 68 deletions src/Dropzoom.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {Events} from 'uploadcore';
import util from "./util";
import FileList from "./FileList";
import Picker from "./Picker";
import { Events } from 'uploadcore';
import util from './util';
import FileList from './FileList';
import Picker from './Picker';

export default class Dropzoom extends React.Component {
static displayName = "Dropzoom";
static displayName = 'Dropzoom';

constructor(props) {
super(props);
constructor(props) {
super(props);

this.core = util.getCoreInstance(props);
this.core = util.getCoreInstance(props);

this.state = {
blink: 0,
highlight: 0,
total: this.core.getTotal()
};
this.state = {
blink: 0,
highlight: 0,
total: this.core.getTotal(),
};

const statchange = (stat) => {
const total = stat.getTotal();
if (total !== this.state.total) {
this.setState({total:total});
}
};
this.core.on(Events.QUEUE_STAT_CHANGE, statchange);
this.stopListen = () => {
this.core.off(Events.QUEUE_STAT_CHANGE, statchange);
};
}
const statchange = (stat) => {
const total = stat.getTotal();
if (total !== this.state.total) {
this.setState({ total });
}
};
this.core.on(Events.QUEUE_STAT_CHANGE, statchange);
this.stopListen = () => {
this.core.off(Events.QUEUE_STAT_CHANGE, statchange);
};
}

reset() {
this.core.getFiles().forEach((file) => {
file.cancel();
});
}
reset() {
this.core.getFiles().forEach((file) => {
file.cancel();
});
}

componentDidMount() {
const areaNode = ReactDOM.findDOMNode(this);
componentDidMount() {
const areaNode = ReactDOM.findDOMNode(this);

const dndArea = this.core.getDndCollector().addArea(areaNode);
dndArea.on('start', () => {
this.setState({blink:1})
}).on('response', (e) => {
if (areaNode.contains(e.target)) {
this.setState({highlight:1});
} else {
this.setState({highlight:0});
}
}).on('end', () => {
this.setState({blink:0,highlight:0});
});
this.dndArea = dndArea;
const dndArea = this.core.getDndCollector().addArea(areaNode);
dndArea.on('start', () => {
this.setState({ blink: 1 });
}).on('response', (e) => {
if (areaNode.contains(e.target)) {
this.setState({ highlight: 1 });
} else {
this.setState({ highlight: 0 });
}
}).on('end', () => {
this.setState({ blink: 0, highlight: 0 });
});
this.dndArea = dndArea;
}
componentWillUnmount() {
this.dndArea && this.dndArea.destroy();
this.stopListen && this.stopListen();
}
render() {
let className = 'kuma-uploader kuma-upload-dropzoom';
if (this.props.className) {
className += ` ${this.props.className}`;
}
componentWillUnmount() {
this.dndArea && this.dndArea.destroy();
this.stopListen && this.stopListen();
if (this.state.blink) {
className += ' blink';
}
render() {
let className = "kuma-uploader kuma-upload-dropzoom";
if (this.props.className) {
className += ' ' + this.props.className;
}
if (this.state.blink) {
className += ' blink';
}
if (this.state.highlight) {
className += ' enter';
}
let children = this.props.children;
if (!children || children.length < 1) {
children = <i className="kuma-icon kuma-icon-add" />;
}
return <div className={className}>
{this.state.total > 0
? <FileList locale={this.props.locale} core={this.core} mode="nw" fileList={this.props.fileList}/>
: <Picker core={this.core}>{children}</Picker>}
<div className="kuma-upload-responser" />
</div>;
if (this.state.highlight) {
className += ' enter';
}
let children = this.props.children;
if (!children || children.length < 1) {
children = <i className="kuma-icon kuma-icon-add" />;
}
return (<div className={className}>
{this.state.total > 0
? <FileList locale={this.props.locale} core={this.core} mode="nw" fileList={this.props.fileList} />
: <Picker core={this.core}>{children}</Picker>}
<div className="kuma-upload-responser" />
</div>);
}
}
Loading

0 comments on commit 153007b

Please sign in to comment.