Skip to content

Commit

Permalink
[CLEANUP] ‘use strict’ and remove _ from fn names
Browse files Browse the repository at this point in the history
  • Loading branch information
dhartunian committed May 3, 2016
1 parent 713eb80 commit cc03aec
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 27 deletions.
1 change: 0 additions & 1 deletion sources/js/about.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

import React from 'react';
import { Header} from './header.js';


module.exports.About = React.createClass({
Expand Down
2 changes: 2 additions & 0 deletions sources/js/guidelines.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import React from 'react';

module.exports.ContentGuidelines = React.createClass({
Expand Down
2 changes: 2 additions & 0 deletions sources/js/header.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import React from 'react';
import { Link } from 'react-router';

Expand Down
4 changes: 3 additions & 1 deletion sources/js/locationForm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import React from 'react';
import { Location } from './models.js';

Expand Down Expand Up @@ -116,4 +118,4 @@ module.exports.LocationForm = React.createClass({
</div>
)
}
});
});
2 changes: 2 additions & 0 deletions sources/js/locationInformation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import React from 'react';
import moment from 'moment';
import { Comment, Likes, Comments, Location } from './models.js';
Expand Down
38 changes: 19 additions & 19 deletions sources/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports.Map = React.createClass({
var url = this._getVizJSONURL();
var options = this.state.mapOptions;

cartodb.createVis('map', url, options).done(this._onVisLoaded);
cartodb.createVis('map', url, options).done(this.onVisLoaded);
},

isMobile() {
Expand All @@ -117,7 +117,7 @@ module.exports.Map = React.createClass({
}
},

_onVisLoaded(vis, layers) {
onVisLoaded(vis, layers) {
var layer = layers[1];
layer.setInteraction(true);
var query = "SELECT l.*, string_agg(o.name, ', ') as offerings " +
Expand All @@ -127,9 +127,9 @@ module.exports.Map = React.createClass({
"GROUP BY l.cartodb_id";
layer.setQuery(query);

layer.on('mouseover', this._onMouseOver);
layer.on('mouseout', this._onMouseOut);
layer.on('featureClick', this._onFeatureClick);
layer.on('mouseover', this.onMouseOver);
layer.on('mouseout', this.onMouseOut);
layer.on('featureClick', this.onFeatureClick);

var sublayer = layer.getSubLayer(0);
sublayer.setInteraction(true);
Expand Down Expand Up @@ -157,18 +157,18 @@ module.exports.Map = React.createClass({

this.map = vis.getNativeMap();

this.map.on('click', this._onClickMap);
this.map.on('click', this.onClickMap);
},

_onMouseOut: function() {
onMouseOut: function() {
$('.leaflet-container').css('cursor', 'auto');
},

_onMouseOver: function() {
onMouseOver: function() {
$('.leaflet-container').css('cursor', 'pointer');
},

_onFeatureClick: function(e, latlng, pos, data) {
onFeatureClick: function(e, latlng, pos, data) {
e.preventDefault();
e.stopPropagation();

Expand All @@ -184,20 +184,20 @@ module.exports.Map = React.createClass({
},


_onClickMap: function(e) {
onClickMap: function(e) {
var geocoder = this.state.geocoder;
var _onFinishedGeocoding = this._onFinishedGeocoding;
var onFinishedGeocoding = this.onFinishedGeocoding;
this.t = setTimeout(function() {
var coordinates = [e.latlng.lat, e.latlng.lng];
var latLng = new google.maps.LatLng(coordinates[0], coordinates[1]);

geocoder.geocode({ 'latLng': latLng }, function(results, status) {
_onFinishedGeocoding(coordinates, null, results, status);
onFinishedGeocoding(coordinates, null, results, status);
});
}, 250);
},

_onFinishedGeocoding: function(coordinates, place, results, status) {
onFinishedGeocoding: function(coordinates, place, results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results && results.length > 0) {
var address = results[0].formatted_address;
Expand Down Expand Up @@ -246,10 +246,10 @@ module.exports.Map = React.createClass({
* This element is INSIDE the content of the popup generated from the template. No better
* ideas on how to attach the handler to it. Hopefully React/leaflet thing can help here.
*/
$('.js-add-location').click(this._onClickAddLocation);
$('.js-add-location').click(this.onClickAddLocation);
},

_onClickAddLocation: function(e) {
onClickAddLocation: function(e) {
this._killEvent(e);
this.map.removeLayer(this.popup);

Expand All @@ -270,13 +270,13 @@ module.exports.Map = React.createClass({
}
},

_onKeyUp: function(e) {
onKeyUp: function(e) {
if (e.keyCode === 27) {
this.map.closePopup();
}
},

_onAddLocation: function() {
onAddLocation: function() {
var marker = L.circleMarker(this.state.model.get('coordinates'), this.state.style.marker);

marker.on('click', function() {
Expand Down Expand Up @@ -367,7 +367,7 @@ module.exports.Map = React.createClass({
renderLocationForm() {
if (this.state.locationForm) {
return (
<LocationForm onAddLocation={this._onAddLocation}
<LocationForm onAddLocation={this.onAddLocation}
onClickCancel={this.removeLocationForm}
offerings={this.state.offerings}
name={this.state.model.get('name')}
Expand Down Expand Up @@ -402,7 +402,7 @@ module.exports.Map = React.createClass({

render() {
return (
<div onkeyup={this._onKeyUp}>
<div onkeyup={this.onKeyUp}>
<div id="map" className="Map">
<Search gotoPlace={this._gotoPlace}/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions sources/js/models.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import Backbone from 'backbone';

module.exports.Comment = Backbone.Model.extend({
Expand Down
14 changes: 8 additions & 6 deletions sources/js/search.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
'use strict';

import React from 'react';

import '../scss/search.scss';

module.exports.Search = React.createClass({
_focus: function() {
focus: function() {
var self = this;

setTimeout(function() {
self.refs.searchBar.focus();
}, 500);
},

_initAutoComplete: function() {
initAutoComplete: function() {
var input = this.refs.searchBar;
this.autocomplete = new google.maps.places.Autocomplete(input, {
componentRestrictions: { country: 'USA' }
});

google.maps.event.addListener(this.autocomplete, 'place_changed', this._onPlaceChange);
google.maps.event.addListener(this.autocomplete, 'place_changed', this.onPlaceChange);
},

_onPlaceChange: function() {
onPlaceChange: function() {

var place = this.autocomplete.getPlace();

Expand All @@ -32,8 +34,8 @@ module.exports.Search = React.createClass({
},

componentDidMount: function() {
this._initAutoComplete();
this._focus();
this.initAutoComplete();
this.focus();
},

render: function() {
Expand Down
2 changes: 2 additions & 0 deletions sources/js/tos.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

import React from 'react';

module.exports.TermsOfService = React.createClass({
Expand Down

0 comments on commit cc03aec

Please sign in to comment.