Skip to content

Commit

Permalink
docs(examples): change to ES7 function bind syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Oct 11, 2015
1 parent 9d21fc5 commit 67895ab
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
20 changes: 10 additions & 10 deletions examples/gh-pages/scripts/components/GeojsonToComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,30 @@ export default class GeojsonToComponents extends Component {
0: {
ref: "map",
style: {height: "100%"},
onClick: this._handle_map_click,
onZoomChanged: this._handle_map_zoom_changed,
onClick: ::this._handle_map_click,
onZoomChanged: ::this._handle_map_zoom_changed,
},
1: {
ref: "centerMarker",
visible: true,
draggable: true,
onDragend: this._handle_marker_dragend,
onClick: this._handle_marker_click,
onDragend: ::this._handle_marker_dragend,
onClick: ::this._handle_marker_click,
child: {
content: "Bermuda Triangle",
owner: "centerMarker",
},
},
3: {
onRightclick: this._handle_polygon_rightclick,
onRightclick: ::this._handle_polygon_rightclick,
},
},
}

_handle_map_click = () => {
_handle_map_click () {
}

_handle_map_zoom_changed = () => {
_handle_map_zoom_changed () {
this.setState(update(this.state, {
geoStateBy: {
0: {
Expand All @@ -88,7 +88,7 @@ export default class GeojsonToComponents extends Component {
}));
}

_handle_marker_click = () => {
_handle_marker_click () {
this.setState(update(this.state, {
geoStateBy: {
0: {
Expand All @@ -100,7 +100,7 @@ export default class GeojsonToComponents extends Component {
}));
}

_handle_polygon_rightclick = () => {
_handle_polygon_rightclick () {
this.setState(update(this.state, {
geoStateBy: {
1: {
Expand All @@ -112,7 +112,7 @@ export default class GeojsonToComponents extends Component {
}));
}

_handle_marker_dragend = ({latLng}) => {
_handle_marker_dragend ({latLng}) {
const marker = this.state.geoJson.features[1],
originalCoordinates = marker.properties.originalCoordinates || marker.geometry.coordinates,
newCoordinates = [latLng.lng(), latLng.lat()];
Expand Down
4 changes: 2 additions & 2 deletions examples/gh-pages/scripts/components/GettingStarted.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class GettingStarted extends Component {
* This is called when you click on the map.
* Go and try click now.
*/
_handle_map_click = (event) => {
_handle_map_click (event) {
var {markers} = this.state;
markers = update(markers, {
$push: [
Expand Down Expand Up @@ -74,7 +74,7 @@ export default class GettingStarted extends Component {
ref="map"
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={this._handle_map_click}>
onClick={::this._handle_map_click}>
{this.state.markers.map((marker, index) => {
return (
<Marker
Expand Down
4 changes: 2 additions & 2 deletions examples/gh-pages/scripts/components/basics/OverlayView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class OverlayViewExample extends Component {
>
<div style={STYLES.overlayView}>
<h1>OverlayView</h1>
<button onClick={this.onClick}>
<button onClick={::this.onClick}>
I have been clicked {count} time{count === 1 ? '' : 's'}
</button>
</div>
Expand All @@ -58,7 +58,7 @@ export default class OverlayViewExample extends Component {
);
}

onClick = () => {
onClick () {
this.setState({count: this.state.count + 1});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class AccessingArguments extends Component {
center: new google.maps.LatLng(-25.363882, 131.044922),
}

_handle_map_click = (event) => {
_handle_map_click (event) {
const {markers} = this.state;
markers.push({
position: event.latLng
Expand All @@ -39,7 +39,7 @@ export default class AccessingArguments extends Component {
ref="map"
defaultZoom={4}
center={center}
onClick={this._handle_map_click}>
onClick={::this._handle_map_click}>
{markers.map((marker, index) =>
<Marker position={marker.position} key={index} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export default class ClosureListeners extends Component {
});
}

_handle_marker_click = (marker) => {
_handle_marker_click (marker) {
marker.showInfo = true;
this.setState(this.state);
}

_handle_closeclick = (marker) => {
_handle_closeclick (marker) {
marker.showInfo = false;
this.setState(this.state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class GettingProperties extends Component {
content: "Change the zoom level",
}

_handle_zoom_changed = () => {
_handle_zoom_changed () {
const zoomLevel = this.refs.map.getZoom();
if (zoomLevel !== this.state.zoomLevel) {
// Notice: Check zoomLevel equality here,
Expand All @@ -41,7 +41,7 @@ export default class GettingProperties extends Component {
ref="map"
defaultCenter={myLatLng}
zoom={zoomLevel}
onZoomChanged={this._handle_zoom_changed}>
onZoomChanged={::this._handle_zoom_changed}>
<InfoWindow
defaultPosition={myLatLng}
content={content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export default class SimpleClickEvent extends Component {
center: this.props.initialCenter,
}

_handle_marker_click = () => {
_handle_marker_click () {
this.setState({
zoom: 8,
});
}

_handle_map_center_changed = () => {
_handle_map_center_changed () {
const newPos = this.refs.map.getCenter();
if (newPos.equals(new google.maps.LatLng(this.props.initialCenter))) {
// Notice: Check newPos equality here,
Expand Down Expand Up @@ -62,11 +62,11 @@ export default class SimpleClickEvent extends Component {
ref="map"
zoom={zoom}
center={center}
onCenterChanged={this._handle_map_center_changed}>
onCenterChanged={::this._handle_map_center_changed}>
<Marker
defaultPosition={center}
title="Click to zoom"
onClick={this._handle_marker_click} />
onClick={::this._handle_marker_click} />
</GoogleMap>
);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/gh-pages/scripts/components/places/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export default class SearchBoxExample extends Component {
markers: []
}

_handle_bounds_changed = () => {
_handle_bounds_changed () {
this.setState({
bounds: this.refs.map.getBounds(),
center: this.refs.map.getCenter()
});
}

_handle_places_changed = () => {
_handle_places_changed () {
const places = this.refs.searchBox.getPlaces();
const markers = [];

Expand Down Expand Up @@ -78,13 +78,13 @@ export default class SearchBoxExample extends Component {
}
}}
defaultZoom={15}
onBoundsChanged={this._handle_bounds_changed}
onBoundsChanged={::this._handle_bounds_changed}
ref="map">

<SearchBox
bounds={this.state.bounds}
controlPosition={google.maps.ControlPosition.TOP_LEFT}
onPlacesChanged={this._handle_places_changed}
onPlacesChanged={::this._handle_places_changed}
ref="searchBox"
style={SearchBoxExample.inputStyle} />

Expand Down
2 changes: 1 addition & 1 deletion examples/gh-pages/scripts/containers/NavHeaderBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class NavHeaderBar extends Component {
<li><a href="https://github.com/tomchentw" target="_blank">by @tomchentw</a></li>
{props.actions.map(actionToMenuItem, this)}
<li className={cx(dropdownClassSet)}>
<a href="javascript:void(0);" className="dropdown-toggle" onClick={this._handle_click.bind(this)}>Samples <span className="caret"></span></a>
<a href="javascript:void(0);" className="dropdown-toggle" onClick={::this._handle_click}>Samples <span className="caret"></span></a>
<ul className="dropdown-menu" role="menu">
{props.dropdownActions.map(actionToMenuItem, this)}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions examples/simplemap/scripts/SimpleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class SimpleMap extends Component {
* This is called when you click on the map.
* Go and try click now.
*/
_handle_map_click = (event) => {
_handle_map_click (event) {
var {markers} = this.state;
markers = update(markers, {
$push: [
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class SimpleMap extends Component {
ref="map"
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={this._handle_map_click}>
onClick={::this._handle_map_click}>
{this.state.markers.map((marker, index) => {
return (
<Marker
Expand Down

0 comments on commit 67895ab

Please sign in to comment.