code style
This commit is contained in:
parent
20da1ef39f
commit
7eacda2ae7
9 changed files with 49 additions and 42 deletions
|
@ -1,6 +1,11 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"parser": "babel-eslint",
|
"parser": "babel-eslint",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"extends": "standard",
|
"extends": "standard",
|
||||||
"installedESLint": true,
|
"installedESLint": true,
|
||||||
"env": {
|
"env": {
|
||||||
|
@ -13,6 +18,8 @@ module.exports = {
|
||||||
"react"
|
"react"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"react/jsx-uses-react": [2],
|
||||||
|
"react/jsx-uses-vars": [2],
|
||||||
"yoda": [2, "never", { "exceptRange": true }]
|
"yoda": [2, "never", { "exceptRange": true }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global $ */
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
|
@ -10,7 +12,7 @@ const ImportDialog = {
|
||||||
openLightbox: null,
|
openLightbox: null,
|
||||||
closeLightbox: null,
|
closeLightbox: null,
|
||||||
|
|
||||||
init: function(serverData, openLightbox, closeLightbox) {
|
init: function (serverData, openLightbox, closeLightbox) {
|
||||||
const self = ImportDialog
|
const self = ImportDialog
|
||||||
self.openLightbox = openLightbox
|
self.openLightbox = openLightbox
|
||||||
self.closeLightbox = closeLightbox
|
self.closeLightbox = closeLightbox
|
||||||
|
@ -22,14 +24,14 @@ const ImportDialog = {
|
||||||
`))
|
`))
|
||||||
ReactDOM.render(React.createElement(ImportDialogBox, {
|
ReactDOM.render(React.createElement(ImportDialogBox, {
|
||||||
onFileAdded: PasteInput.handleFile,
|
onFileAdded: PasteInput.handleFile,
|
||||||
exampleImageUrl: serverData['import-example.png'],
|
exampleImageUrl: serverData['import-example.png']
|
||||||
}), $('.importDialogWrapper').get(0))
|
}), $('.importDialogWrapper').get(0))
|
||||||
},
|
},
|
||||||
show: function() {
|
show: function () {
|
||||||
self.openLightbox('import-dialog')
|
ImportDialog.openLightbox('import-dialog')
|
||||||
},
|
},
|
||||||
hide: function() {
|
hide: function () {
|
||||||
self.closeLightbox('import-dialog')
|
ImportDialog.closeLightbox('import-dialog')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* global Metamaps, $ */
|
/* global Metamaps, $ */
|
||||||
|
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
import React from 'react'
|
|
||||||
import ReactDOM from 'react-dom'
|
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import AutoLayout from '../AutoLayout'
|
import AutoLayout from '../AutoLayout'
|
||||||
|
@ -47,7 +45,6 @@ const Map = {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
$('.starMap').click(function () {
|
$('.starMap').click(function () {
|
||||||
if ($(this).is('.starred')) self.unstar()
|
if ($(this).is('.starred')) self.unstar()
|
||||||
else self.star()
|
else self.star()
|
||||||
|
|
|
@ -45,7 +45,7 @@ const PasteInput = {
|
||||||
|
|
||||||
handleFile: (file, coords = null) => {
|
handleFile: (file, coords = null) => {
|
||||||
var self = PasteInput
|
var self = PasteInput
|
||||||
var fileReader = new FileReader()
|
var fileReader = new window.FileReader()
|
||||||
fileReader.readAsText(file)
|
fileReader.readAsText(file)
|
||||||
fileReader.onload = function(e) {
|
fileReader.onload = function(e) {
|
||||||
var text = e.currentTarget.result
|
var text = e.currentTarget.result
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React, { PropTypes, Component } from 'react'
|
||||||
import Dropzone from 'react-dropzone'
|
import Dropzone from 'react-dropzone'
|
||||||
|
|
||||||
class ImportDialogBox extends Component {
|
class ImportDialogBox extends Component {
|
||||||
constructor(props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -16,6 +16,7 @@ class ImportDialogBox extends Component {
|
||||||
|
|
||||||
handleFile = (files, e) => {
|
handleFile = (files, e) => {
|
||||||
// for some reason it uploads twice, so we need this debouncer
|
// for some reason it uploads twice, so we need this debouncer
|
||||||
|
// eslint-disable-next-line no-return-assign
|
||||||
this.debouncer = this.debouncer || window.setTimeout(() => this.debouncer = null, 10)
|
this.debouncer = this.debouncer || window.setTimeout(() => this.debouncer = null, 10)
|
||||||
if (!this.debouncer) {
|
if (!this.debouncer) {
|
||||||
this.props.onFileAdded(files[0])
|
this.props.onFileAdded(files[0])
|
||||||
|
|
|
@ -21,15 +21,15 @@ class Header extends Component {
|
||||||
const { signedIn, section } = this.props
|
const { signedIn, section } = this.props
|
||||||
|
|
||||||
const activeClass = (title) => {
|
const activeClass = (title) => {
|
||||||
let forClass = "exploreMapsButton"
|
let forClass = 'exploreMapsButton'
|
||||||
forClass += " " + title + "Maps"
|
forClass += ' ' + title + 'Maps'
|
||||||
if (title == "my" && section == "mine" ||
|
if (title === 'my' && section === 'mine' ||
|
||||||
title == section) forClass += " active"
|
title === section) forClass += ' active'
|
||||||
return forClass
|
return forClass
|
||||||
}
|
}
|
||||||
|
|
||||||
const explore = section == "mine" || section == "active" || section == "starred" || section == "shared" || section == "featured"
|
const explore = section === 'mine' || section === 'active' || section === 'starred' || section === 'shared' || section === 'featured'
|
||||||
const mapper = section == "mapper"
|
const mapper = section === 'mapper'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="exploreMapsHeader">
|
<div id="exploreMapsHeader">
|
||||||
|
@ -38,31 +38,31 @@ class Header extends Component {
|
||||||
<div className="exploreMapsCenter">
|
<div className="exploreMapsCenter">
|
||||||
<MapLink show={signedIn && explore}
|
<MapLink show={signedIn && explore}
|
||||||
href="/explore/mine"
|
href="/explore/mine"
|
||||||
linkClass={activeClass("my")}
|
linkClass={activeClass('my')}
|
||||||
data-router="true"
|
data-router="true"
|
||||||
text="My Maps"
|
text="My Maps"
|
||||||
/>
|
/>
|
||||||
<MapLink show={signedIn && explore}
|
<MapLink show={signedIn && explore}
|
||||||
href="/explore/shared"
|
href="/explore/shared"
|
||||||
linkClass={activeClass("shared")}
|
linkClass={activeClass('shared')}
|
||||||
data-router="true"
|
data-router="true"
|
||||||
text="Shared With Me"
|
text="Shared With Me"
|
||||||
/>
|
/>
|
||||||
<MapLink show={signedIn && explore}
|
<MapLink show={signedIn && explore}
|
||||||
href="/explore/starred"
|
href="/explore/starred"
|
||||||
linkClass={activeClass("starred")}
|
linkClass={activeClass('starred')}
|
||||||
data-router="true"
|
data-router="true"
|
||||||
text="Starred By Me"
|
text="Starred By Me"
|
||||||
/>
|
/>
|
||||||
<MapLink show={explore}
|
<MapLink show={explore}
|
||||||
href={signedIn ? "/" : "/explore/active"}
|
href={signedIn ? '/' : '/explore/active'}
|
||||||
linkClass={activeClass("active")}
|
linkClass={activeClass('active')}
|
||||||
data-router="true"
|
data-router="true"
|
||||||
text="Global"
|
text="Global"
|
||||||
/>
|
/>
|
||||||
<MapLink show={!signedIn && explore}
|
<MapLink show={!signedIn && explore}
|
||||||
href="/explore/featured"
|
href="/explore/featured"
|
||||||
linkClass={activeClass("featured")}
|
linkClass={activeClass('featured')}
|
||||||
data-router="true"
|
data-router="true"
|
||||||
text="Featured Maps"
|
text="Featured Maps"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -21,7 +21,7 @@ class MapCard extends Component {
|
||||||
<div className="map" id={ map.id }>
|
<div className="map" id={ map.id }>
|
||||||
<a href={ '/maps/' + map.id } data-router="true">
|
<a href={ '/maps/' + map.id } data-router="true">
|
||||||
<div className={ 'permission ' + editPermission }>
|
<div className={ 'permission ' + editPermission }>
|
||||||
<div className="mapCard">
|
<div className="mapCard">
|
||||||
<span className="title" title={ map.get('name') }>
|
<span className="title" title={ map.get('name') }>
|
||||||
{ truncatedName }
|
{ truncatedName }
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -9,12 +9,11 @@ class Maps extends Component {
|
||||||
const { maps, currentUser, section, displayStyle, user, moreToLoad, loadMore } = this.props
|
const { maps, currentUser, section, displayStyle, user, moreToLoad, loadMore } = this.props
|
||||||
let mapElements
|
let mapElements
|
||||||
|
|
||||||
if (displayStyle == 'grid') {
|
if (displayStyle === 'grid') {
|
||||||
mapElements = maps.models.map(function (map) {
|
mapElements = maps.models.map(function (map) {
|
||||||
return <MapCard key={ map.id } map={ map } currentUser={ currentUser } />
|
return <MapCard key={ map.id } map={ map } currentUser={ currentUser } />
|
||||||
})
|
})
|
||||||
}
|
} else if (displayStyle === 'list') {
|
||||||
else if (displayStyle == 'list') {
|
|
||||||
mapElements = maps.models.map(function (map) {
|
mapElements = maps.models.map(function (map) {
|
||||||
return <MapListItem key={ map.id } map={ map } />
|
return <MapListItem key={ map.id } map={ map } />
|
||||||
})
|
})
|
||||||
|
@ -28,9 +27,10 @@ class Maps extends Component {
|
||||||
{ currentUser && !user ? <div className="map newMap"><a href="/maps/new"><div className="newMapImage"></div><span>Create new map...</span></a></div> : null }
|
{ currentUser && !user ? <div className="map newMap"><a href="/maps/new"><div className="newMapImage"></div><span>Create new map...</span></a></div> : null }
|
||||||
{ mapElements }
|
{ mapElements }
|
||||||
<div className='clearfloat'></div>
|
<div className='clearfloat'></div>
|
||||||
{ moreToLoad ?
|
{!moreToLoad ? null : [
|
||||||
[<button className="button loadMore" onClick={ loadMore }>load more</button>, <div className='clearfloat'></div>]
|
<button className="button loadMore" onClick={ loadMore }>load more</button>,
|
||||||
: null }
|
<div className='clearfloat'></div>
|
||||||
|
]}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Header signedIn={ !!currentUser }
|
<Header signedIn={ !!currentUser }
|
||||||
|
|
Loading…
Add table
Reference in a new issue