Merge pull request #659 from metamaps/feature/js-fiddling

simplify js
This commit is contained in:
Devin Howard 2016-09-24 23:35:50 +08:00 committed by GitHub
commit 82b7c7e5ac
9 changed files with 31 additions and 51 deletions

View file

@ -186,7 +186,7 @@ const Filter = {
$('#filter_by_' + listToModify + ' li[data-id="' + identifier + '"]').fadeOut('fast', function () {
$(this).remove()
})
index = self.visible[filtersToUse].indexOf(identifier)
const index = self.visible[filtersToUse].indexOf(identifier)
self.visible[filtersToUse].splice(index, 1)
})

View file

@ -1,17 +1,19 @@
/* global $ */
/*
* Metamaps.Backbone
* Dependencies:
* Metamaps.Backbone
*/
const Mapper = {
// this function is to retrieve a mapper JSON object from the database
// @param id = the id of the mapper to retrieve
get: function (id, callback) {
return fetch(`/users/${id}.json`, {
}).then(response => {
if (!response.ok) throw response
return response.json()
}).then(payload => {
callback(new Metamaps.Backbone.Mapper(payload))
$.ajax({
url: `/users/${id}.json`,
success: data => {
callback(new Metamaps.Backbone.Mapper(data))
}
})
}
}

View file

@ -1,7 +0,0 @@
import Maps from '../components/Maps'
const ReactComponents = {
Maps
}
export default ReactComponents

View file

@ -4,7 +4,7 @@ import React from 'react'
import ReactDOM from 'react-dom' // TODO ensure this isn't a double import
import Active from '../Active'
import ReactComponents from '../ReactComponents'
import Maps from '../../components/Maps'
/*
* - Metamaps.Loading
@ -42,7 +42,7 @@ const ExploreMaps = {
loadMore: self.loadMore
}
ReactDOM.render(
React.createElement(ReactComponents.Maps, exploreObj),
React.createElement(Maps, exploreObj),
document.getElementById('explore')
)

View file

@ -30,7 +30,6 @@ import TopicCard from './TopicCard'
import Util from './Util'
import Views from './Views'
import Visualize from './Visualize'
import ReactComponents from './ReactComponents'
Metamaps.Account = Account
Metamaps.Active = Active
@ -55,7 +54,6 @@ Metamaps.Mouse = Mouse
Metamaps.Organize = Organize
Metamaps.PasteInput = PasteInput
Metamaps.Realtime = Realtime
Metamaps.ReactComponents = ReactComponents
Metamaps.Router = Router
Metamaps.Selected = Selected
Metamaps.Settings = Settings

View file

@ -1,9 +1,9 @@
import React, { Component, PropTypes } from 'react'
import { objectWithoutProperties } from '../utils'
import _ from 'lodash'
const MapLink = props => {
const { show, text, href, linkClass } = props
const otherProps = objectWithoutProperties(props, ['show', 'text', 'href', 'linkClass'])
const otherProps = _.omit(props, ['show', 'text', 'href', 'linkClass'])
if (!show) {
return null
}

View file

@ -1,8 +1,6 @@
// create global references to some utility libraries
import ReactDOM from 'react-dom'
// create global references
import _ from 'underscore'
window.ReactDOM = ReactDOM
window._ = _
import Metamaps from './Metamaps'
window._ = _
window.Metamaps = Metamaps

View file

@ -1,9 +0,0 @@
export const objectWithoutProperties = (obj, keys) => {
const target = {}
for (let i in obj) {
if (keys.indexOf(i) !== -1) continue
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue
target[i] = obj[i]
}
return target
}

View file

@ -18,26 +18,24 @@
},
"homepage": "https://github.com/metamaps/metamaps#readme",
"dependencies": {
"autolinker": "^0.17.1",
"babel-cli": "^6.11.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-class-properties": "^6.11.5",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"backbone": "^1.0.0",
"chai": "^3.5.0",
"jquery": "1.12.1",
"mocha": "^3.0.2",
"mocha-jsdom": "^1.1.0",
"autolinker": "0.17.1",
"babel-cli": "6.11.4",
"babel-loader": "6.2.4",
"babel-plugin-transform-class-properties": "6.11.5",
"babel-preset-es2015": "6.9.0",
"babel-preset-react": "6.11.1",
"backbone": "1.0.0",
"node-uuid": "1.2.0",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"requirejs": "^2.1.1",
"react": "15.3.0",
"react-dom": "15.3.0",
"requirejs": "2.1.1",
"socket.io": "0.9.12",
"underscore": "^1.4.4",
"webpack": "^1.13.1"
"underscore": "1.4.4",
"webpack": "1.13.1"
},
"devDependencies": {
"chai": "^3.5.0",
"mocha": "^3.0.2",
"babel-eslint": "^6.1.2",
"eslint": "^3.5.0",
"eslint-config-standard": "^6.0.1",