Skip to content

Commit

Permalink
eslinting mindmap
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Apr 1, 2015
1 parent e21139d commit 26e459b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
10 changes: 7 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
// To give you an idea how to override rule options:
"rules": {
"semi": 0,
"consistent-return": 1,
"strict": 1,
"new-cap": 1,
"strict": 0,
"no-shadow": 1,
"no-comma-dangle": 0,
"curly": 0,
"yoda": 0,
Expand All @@ -20,6 +19,11 @@
"eol-last": 0,
"no-mixed-requires": 0,
"no-underscore-dangle": 0,
"no-unused-expressions": 0,
"no-return-assign": 1,
"no-use-before-define": 1,
"no-extra-semi": 0,
"consistent-return": 0,
"comma-spacing": 1
},
"globals": {
Expand Down
6 changes: 5 additions & 1 deletion views/body/default-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ marked.setOptions({
})

var DefaultRenderer = React.createClass({
_onClick(e) {
if (e.target.nodeName === 'A') return
this.props.onClick(e)
},
render: function () {
return <span className="treed_body_rendered"
onClick={this.props.onClick}
onClick={this._onClick}
dangerouslySetInnerHTML={{
__html: this.props.content ? marked(this.props.content + '') : ''
}}/>
Expand Down
39 changes: 26 additions & 13 deletions views/mindmap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ var React = require('react/addons')
, Listener = require('../../listener')

var MindmapNode = React.createClass({
propTypes: {
id: PT.string,
isRoot: PT.bool,
store: PT.object,
reCalc: PT.func,
onHeight: PT.func,
positions: PT.object,
px: PT.number,
py: PT.number,
plutins: PT.object,
bodies: PT.object,
},

mixins: [
Listener({
storeAttrs: function (getters, props) {
Expand Down Expand Up @@ -86,7 +99,7 @@ var MindmapNode = React.createClass({
, length = Math.sqrt(x*x + y*y)
, ang = length ? Math.atan2(y, x) : Math.PI
if (ang < 0) ang += Math.PI*2
style = {
const style = {
width: length,
transform: `rotate(${ang}rad)`,
}
Expand All @@ -97,7 +110,7 @@ var MindmapNode = React.createClass({
var box
if (this.state.ticked) {
box = this.props.positions[this.props.id]
}
}
if (!box) {
box = {x: this.props.px, y: this.props.py}
}
Expand All @@ -113,27 +126,27 @@ var MindmapNode = React.createClass({
'MindmapNode-parent': this.state.node.children && this.state.node.children.length,
'MindmapNode-collapsed': !this.props.isRoot && this.state.node.children && this.state.node.children.length && this.state.node.collapsed,
})
var body = this.props.bodies[this.state.node.type] || this.props.bodies['default']
var body = this.props.bodies[this.state.node.type] || this.props.bodies.default
return <div style={style} className={cls}>
{this.makeLine()}
<div onClick={this._onClick} className='MindmapNode_main'>
<div className='MindmapNode_collapser' onClick={this._toggleCollapse}/>
{SimpleBody({
editor: body.editor,
renderer: body.renderer,
node: this.state.node,
isActive: this.state.isActive,
editState: this.state.editState,
actions: this.props.store.actions,
store: this.props.store,
})}
<SimpleBody
editor={body.editor}
renderer={body.renderer}
node={this.state.node}
isActive={this.state.isActive}
editState={this.state.editState}
actions={this.props.store.actions}
store={this.props.store}
/>
</div>
{this.state.node.children.length ? <div className='MindmapNode_children'>
{!this.state.lazyChildren && this.state.node.children.map((id, i) =>
<MindmapNode
px={box.x}
py={box.y}
hiding={!this.props.isRoot && (this.props.hiding || this.state.node.collapsed)}
hiding={!this.props.isRoot && (this.props.hiding || this.state.node.collapsed)}
onHeight={this.props.onHeight}
reCalc={this.props.reCalc}
positions={this.props.positions}
Expand Down

0 comments on commit 26e459b

Please sign in to comment.