[gnome-maps/wip/mlundblad/es6: 3/5] Use ES6 arrow notation
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/es6: 3/5] Use ES6 arrow notation
- Date: Thu, 18 Jan 2018 21:00:26 +0000 (UTC)
commit 38c892d82c1800529c5cfd4aca2c192b7f68940c
Author: Marcus Lundblad <ml update uu se>
Date: Fri Nov 10 23:45:20 2017 +0100
Use ES6 arrow notation
Use the arrow notation to bind "this"
to anonymous functions.
https://bugzilla.gnome.org/show_bug.cgi?id=722758
src/accountListBox.js | 11 +--
src/application.js | 34 ++++-----
src/checkIn.js | 4 +-
src/checkInDialog.js | 32 ++++-----
src/contextMenu.js | 26 +++----
src/exportViewDialog.js | 23 ++----
src/favoritesPopover.js | 22 +++---
src/geoJSONSource.js | 40 +++++------
src/geoclue.js | 10 ++--
src/geocodeService.js | 10 +--
src/graphHopper.js | 22 +++---
src/layersPopover.js | 24 +++---
src/locationServiceNotification.js | 9 +--
src/longPrintLayout.js | 2 +-
src/mainWindow.js | 101 ++++++++++++--------------
src/mapBubble.js | 18 ++---
src/mapMarker.js | 49 ++++++-------
src/mapSource.js | 9 +--
src/mapView.js | 75 +++++++++-----------
src/mapWalker.js | 12 ++--
src/notification.js | 4 +-
src/notificationManager.js | 8 +-
src/openTripPlanner.js | 141 +++++++++++++++++-------------------
src/osmConnection.js | 60 +++++++--------
src/osmEdit.js | 20 +++---
src/osmEditDialog.js | 70 ++++++++----------
src/osmTypePopover.js | 12 +--
src/osmTypeSearchEntry.js | 4 +-
src/overpass.js | 4 +-
src/placeBubble.js | 40 ++++------
src/placeEntry.js | 20 +++---
src/placeFormatter.js | 12 ++--
src/placePopover.js | 50 +++++++------
src/placeStore.js | 42 ++++++------
src/printLayout.js | 22 +++---
src/printOperation.js | 8 +-
src/routeQuery.js | 4 +-
src/searchPopover.js | 4 +-
src/sendToDialog.js | 12 ++--
src/serviceBackend.js | 8 +-
src/settings.js | 4 +-
src/shortPrintLayout.js | 4 +-
src/sidebar.js | 70 +++++++++----------
src/socialPlaceListBox.js | 4 +-
src/storedRoute.js | 12 ++--
src/transitArrivalRow.js | 4 +-
src/transitBoardMarker.js | 4 +-
src/transitItineraryRow.js | 4 +-
src/transitLegRow.js | 8 +-
src/transitPrintLayout.js | 14 ++--
src/turnPointMarker.js | 8 +--
src/wikipedia.js | 4 +-
src/zoomInNotification.js | 2 +-
53 files changed, 554 insertions(+), 666 deletions(-)
---
diff --git a/src/accountListBox.js b/src/accountListBox.js
index df5eb4c..c261678 100644
--- a/src/accountListBox.js
+++ b/src/accountListBox.js
@@ -61,11 +61,10 @@ var AccountListBox = new Lang.Class({
params.activate_on_single_click = true;
this.parent(params);
- Application.checkInManager.connect('accounts-refreshed', this.refresh.bind(this));
+ Application.checkInManager.connect('accounts-refreshed', () => this.refresh());
- this.connect('row-activated', (function(list, row) {
- this.emit('account-selected', row.account);
- }).bind(this));
+ this.connect('row-activated',
+ (list, row) => this.emit('account-selected', row.account));
this.refresh();
},
@@ -77,8 +76,6 @@ var AccountListBox = new Lang.Class({
row.destroy();
});
- accounts.forEach((function(account) {
- this.add(new AccountRow({ account: account }));
- }).bind(this));
+ accounts.forEach((account) => this.add(new AccountRow({ account: account })));
}
});
diff --git a/src/application.js b/src/application.js
index 9cc5888..63bc62f 100644
--- a/src/application.js
+++ b/src/application.js
@@ -87,9 +87,7 @@ var Application = new Lang.Class({
GLib.set_application_name(_("Maps"));
/* Needed to be able to use in UI files */
- _ensuredTypes.forEach(function(type) {
- GObject.type_ensure(type);
- });
+ _ensuredTypes.forEach((type) => GObject.type_ensure(type));
this.parent({ application_id: 'org.gnome.Maps',
flags: Gio.ApplicationFlags.HANDLES_OPEN });
@@ -105,7 +103,7 @@ var Application = new Lang.Class({
this.add_main_option('version', 'v'.charCodeAt(0), GLib.OptionFlags.NONE, GLib.OptionArg.NONE,
_("Show the version of the program"), null);
- this.connect('handle-local-options', (function(app, options) {
+ this.connect('handle-local-options', (app, options) => {
if (options.contains('local')) {
let variant = options.lookup_value('local', null);
this.local_tile_path = variant.deep_unpack();
@@ -119,7 +117,7 @@ var Application = new Lang.Class({
}
return -1;
- }).bind(this));
+ });
},
_checkNetwork: function() {
@@ -127,17 +125,17 @@ var Application = new Lang.Class({
},
_showContact: function(id) {
- contactStore.lookup(id, (function(contact) {
+ contactStore.lookup(id, (contact) => {
this._mainWindow.markBusy();
if (!contact) {
this._mainWindow.unmarkBusy();
return;
}
- contact.geocode((function() {
+ contact.geocode(() => {
this._mainWindow.unmarkBusy();
this._mainWindow.mapView.showContact(contact);
- }).bind(this));
- }).bind(this));
+ });
+ });
},
_onShowContactActivate: function(action, parameter) {
@@ -150,10 +148,10 @@ var Application = new Lang.Class({
if (contactStore.state === Maps.ContactStoreState.LOADED) {
this. _showContact(id);
} else {
- Utils.once(contactStore, 'notify::state', (function() {
+ Utils.once(contactStore, 'notify::state', () => {
if (contactStore.state === Maps.ContactStoreState.LOADED)
this._showContact(id);
- }).bind(this));
+ });
}
},
@@ -165,13 +163,13 @@ var Application = new Lang.Class({
let dialog = osmEdit.createAccountDialog(this._mainWindow, false);
dialog.show();
- dialog.connect('response', dialog.destroy.bind(dialog));
+ dialog.connect('response', () => dialog.destroy());
},
_addContacts: function() {
- contactStore.get_contacts().forEach(function(contact) {
+ contactStore.get_contacts().forEach((contact) => {
contact.geocode(function() {
- contact.get_places().forEach(function(p) {
+ contact.get_places().forEach((p) => {
if (!p.location)
return;
@@ -199,10 +197,10 @@ var Application = new Lang.Class({
if (contactStore.state === Maps.ContactStoreState.LOADED) {
this._addContacts();
} else {
- Utils.once(contactStore, 'notify::state', (function() {
+ Utils.once(contactStore, 'notify::state', () => {
if (contactStore.state === Maps.ContactStoreState.LOADED)
this._addContacts();
- }).bind(this));
+ });
}
},
@@ -264,9 +262,9 @@ var Application = new Lang.Class({
notificationManager = new NotificationManager.NotificationManager(overlay);
this._mainWindow = new MainWindow.MainWindow({ application: this,
overlay: overlay });
- this._mainWindow.connect('destroy', this._onWindowDestroy.bind(this));
+ this._mainWindow.connect('destroy', () => this._onWindowDestroy());
if (GLib.getenv('MAPS_DEBUG') === 'focus') {
- this._mainWindow.connect('set-focus', function(window, widget) {
+ this._mainWindow.connect('set-focus', (window, widget) => {
log('* focus widget: %s'.format(widget));
});
}
diff --git a/src/checkIn.js b/src/checkIn.js
index d6849c5..d75d492 100644
--- a/src/checkIn.js
+++ b/src/checkIn.js
@@ -84,7 +84,7 @@ var CheckInManager = new Lang.Class({
this._accountsCount = 0;
this._authorizers = {};
- accounts.forEach((function(object) {
+ accounts.forEach((object) => {
if (!object.get_account())
return;
@@ -95,7 +95,7 @@ var CheckInManager = new Lang.Class({
this._accounts.push(object);
this._authorizers[accountId] = this._getBackend(object).createAuthorizer(object);
- }).bind(this));
+ });
this.emit('accounts-refreshed');
this.notify('hasCheckIn');
diff --git a/src/checkInDialog.js b/src/checkInDialog.js
index 9b0b700..1a86b4d 100644
--- a/src/checkInDialog.js
+++ b/src/checkInDialog.js
@@ -77,28 +77,22 @@ var CheckInDialog = new Lang.Class({
this.error = null;
this._cancellable = new Gio.Cancellable();
- this._cancellable.connect((function() {
- this.response(Response.CANCELLED);
- }).bind(this));
+ this._cancellable.connect(() => this.response(Response.CANCELLED));
- this.connect('delete-event', (function() {
- this._cancellable.cancel();
- }).bind(this));
+ this.connect('delete-event', () => this._cancellable.cancel());
- Application.checkInManager.connect('accounts-refreshed', this._onAccountRefreshed.bind(this));
+ Application.checkInManager.connect('accounts-refreshed',
+ () => this._onAccountRefreshed());
this._initHeaderBar();
this._initWidgets();
},
_initHeaderBar: function() {
- this._cancelButton.connect('clicked', (function() {
- this._cancellable.cancel();
- }).bind(this));
+ this._cancelButton.connect('clicked',
+ () => this._cancellable.cancel());
- this._okButton.connect('clicked', (function() {
- this._startCheckInStep();
- }).bind(this));
+ this._okButton.connect('clicked', () => this._startCheckInStep());
},
_initWidgets: function() {
@@ -125,15 +119,15 @@ var CheckInDialog = new Lang.Class({
this._foursquareOptionsBroadcastTwitterCheckButton,
'active', Gio.SettingsBindFlags.DEFAULT);
- this._accountListBox.connect('account-selected', (function(list, account) {
+ this._accountListBox.connect('account-selected', (list, account) => {
this._account = account;
this._startPlaceStep();
- }).bind(this));
+ });
- this._placeListBox.connect('place-selected', (function(list, place) {
+ this._placeListBox.connect('place-selected', (list, place) => {
this._checkIn.place = place;
this._startMessageStep();
- }).bind(this));
+ });
},
vfunc_show: function() {
@@ -150,9 +144,9 @@ var CheckInDialog = new Lang.Class({
this._account = Application.checkInManager.accounts[0];
this._startPlaceStep();
} else {
- Mainloop.idle_add((function() {
+ Mainloop.idle_add(() => {
this.response(Response.FAILURE_CHECKIN_DISABLED);
- }).bind(this));
+ });
}
},
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 5306093..65910f0 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -81,10 +81,8 @@ var ContextMenu = new Lang.Class({
this._latitude = this._mapView.view.y_to_latitude(y);
if (button === Gdk.BUTTON_SECONDARY) {
- Mainloop.idle_add((function() {
- // Need idle to avoid Clutter dead-lock on re-entrance
- this.popup_at_pointer(event);
- }).bind(this));
+ // Need idle to avoid Clutter dead-lock on re-entrance
+ Mainloop.idle_add(() => this.popup_at_pointer(event));
}
},
@@ -125,14 +123,14 @@ var ContextMenu = new Lang.Class({
longitude: this._longitude,
accuracy: 0 });
- Application.geocodeService.reverse(location, null, (function(place) {
+ Application.geocodeService.reverse(location, null, (place) => {
if (place) {
this._mapView.showPlace(place, false);
} else {
let msg = _("Nothing found here!");
Application.notificationManager.showMessage(msg);
}
- }).bind(this));
+ });
},
_onGeoURIActivated: function() {
@@ -153,11 +151,11 @@ var ContextMenu = new Lang.Class({
let dialog = osmEdit.createAccountDialog(this._mainWindow, true);
dialog.show();
- dialog.connect('response', (function(dialog, response) {
+ dialog.connect('response', (dialog, response) => {
dialog.destroy();
if (response === OSMAccountDialog.Response.SIGNED_IN)
this._addOSMLocation();
- }).bind(this));
+ });
return;
}
@@ -182,13 +180,13 @@ var ContextMenu = new Lang.Class({
this._latitude, this._longitude);
dialog.show();
- dialog.connect('response', (function(dialog, response) {
+ dialog.connect('response', (dialog, response) => {
dialog.destroy();
if (response === OSMEditDialog.Response.UPLOADED) {
Application.notificationManager.showMessage(
_("Location was added to the map, note that it may take a while before it shows on the
map and in search results."));
}
- }).bind(this));
+ });
},
_activateExport: function() {
@@ -206,9 +204,7 @@ var ContextMenu = new Lang.Class({
mapView: this._mapView
});
- dialog.connect('response', function() {
- dialog.destroy();
- });
+ dialog.connect('response', () => dialog.destroy());
dialog.show_all();
},
@@ -216,12 +212,12 @@ var ContextMenu = new Lang.Class({
if (this._mapView.view.state === Champlain.State.DONE) {
this._activateExport();
} else {
- let notifyId = this._mapView.view.connect('notify::state', (function() {
+ let notifyId = this._mapView.view.connect('notify::state', () => {
if (this._mapView.view.state === Champlain.State.DONE) {
this._mapView.view.disconnect(notifyId);
this._activateExport();
}
- }).bind(this));
+ });
}
}
});
diff --git a/src/exportViewDialog.js b/src/exportViewDialog.js
index 243e48b..96662a1 100644
--- a/src/exportViewDialog.js
+++ b/src/exportViewDialog.js
@@ -60,17 +60,11 @@ var ExportViewDialog = new Lang.Class({
params.use_header_bar = true;
this.parent(params);
- this._cancelButton.connect('clicked', (function() {
- this.response(Response.CANCEL);
- }).bind(this));
- this._exportButton.connect('clicked', this._exportView.bind(this));
- this._filenameEntry.connect('changed',
- this._onFileNameChanged.bind(this));
- this._fileChooserButton.connect('file-set',
- this._onFolderChanged.bind(this));
-
- this._layersCheckButton.connect('toggled',
- this._includeLayersChanged.bind(this));
+ this._cancelButton.connect('clicked', () => this.response(Response.CANCEL));
+ this._exportButton.connect('clicked', () => this._exportView());
+ this._filenameEntry.connect('changed', () => this._onFileNameChanged());
+ this._fileChooserButton.connect('file-set', () => this._onFolderChanged());
+ this._layersCheckButton.connect('toggled', () => this._includeLayersChanged());
this._folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
@@ -99,7 +93,8 @@ var ExportViewDialog = new Lang.Class({
let height = surfaceHeight * this._scaleFactor;
this._previewArea.set_size_request(width, height);
- this._previewArea.connect('draw', this._drawPreview.bind(this));
+ this._previewArea.connect('draw',
+ (w, cr) => this._drawPreview(w, cr));
},
_drawPreview: function(widget, cr) {
@@ -176,9 +171,7 @@ var ExportViewDialog = new Lang.Class({
secondary_text: details
});
- dialog.connect('response', function() {
- dialog.destroy();
- });
+ dialog.connect('response', () => dialog.destroy());
dialog.show_all();
}
},
diff --git a/src/favoritesPopover.js b/src/favoritesPopover.js
index b6df29a..a1b6d85 100644
--- a/src/favoritesPopover.js
+++ b/src/favoritesPopover.js
@@ -70,26 +70,26 @@ var FavoritesPopover = new Lang.Class({
row.set_header(header);
});
- this.connect('notify::rows', (function() {
+ this.connect('notify::rows', () => {
let visible = Math.min(this._rows, _N_VISIBLE);
let separators = visible - 1; // separators are 1px
let height = (PlaceListRow.ROW_HEIGHT + 6) * visible + separators;
this._scrolledWindow.min_content_height = height;
this._revealer.reveal_child = this._rows > _N_VISIBLE;
- }).bind(this));
+ });
this._entry.connect('changed',
- this._list.invalidate_filter.bind(this._list));
+ () => this._list.invalidate_filter(this._list));
- this._list.connect('row-activated', (function(list, row) {
+ this._list.connect('row-activated', (list, row) => {
this.hide();
this._mapView.showPlace(row.place, true);
- }).bind(this));
+ });
- this._list.set_filter_func((function(row) {
+ this._list.set_filter_func((row) => {
return row.place.match(this._entry.text);
- }).bind(this));
+ });
this._updateList();
},
@@ -106,12 +106,10 @@ var FavoritesPopover = new Lang.Class({
},
_updateList: function() {
- this._list.forall(function(row) {
- row.destroy();
- });
+ this._list.forall((row) => row.destroy());
let rows = 0;
- this._model.foreach((function(model, path, iter) {
+ this._model.foreach((model, path, iter) => {
let place = model.get_value(iter, PlaceStore.Columns.PLACE);
let row = new PlaceListRow.PlaceListRow({ place: place,
@@ -119,7 +117,7 @@ var FavoritesPopover = new Lang.Class({
can_focus: true });
this._list.add(row);
rows++;
- }).bind(this));
+ });
this.rows = rows;
}
diff --git a/src/geoJSONSource.js b/src/geoJSONSource.js
index 09e66a3..4fb0357 100644
--- a/src/geoJSONSource.js
+++ b/src/geoJSONSource.js
@@ -78,15 +78,15 @@ var GeoJSONSource = new Lang.Class({
if (tile.get_state() === Champlain.State.DONE)
return;
- tile.connect('render-complete', (function(tile, data, size, error) {
+ tile.connect('render-complete', (tile, data, size, error) => {
if(!error) {
tile.set_state(Champlain.State.DONE);
tile.display_content();
} else if(this.next_source)
this.next_source.fill_tile(tile);
- }).bind(this));
+ });
- Mainloop.idle_add(this._renderTile.bind(this, tile));
+ Mainloop.idle_add(() => this._renderTile(tile));
},
_validate: function([lon, lat]) {
@@ -99,10 +99,10 @@ var GeoJSONSource = new Lang.Class({
},
_compose: function(coordinates) {
- coordinates.forEach((function(coordinate) {
+ coordinates.forEach((coordinate) => {
this._validate(coordinate);
this._bbox.extend(coordinate[1], coordinate[0]);
- }).bind(this));
+ });
},
_clampBBox: function() {
@@ -117,9 +117,7 @@ var GeoJSONSource = new Lang.Class({
},
_parsePolygon: function(coordinates) {
- coordinates.forEach((function(coordinate) {
- this._compose(coordinate);
- }).bind(this));
+ coordinates.forEach((coordinate) => this._compose(coordinate));
},
_parsePoint: function(coordinates, properties) {
@@ -154,9 +152,9 @@ var GeoJSONSource = new Lang.Class({
break;
case 'MultiLineString':
- geometry.coordinates.forEach((function(coordinate) {
+ geometry.coordinates.forEach((coordinate) => {
this._parseLineString(coordinate);
- }).bind(this));
+ });
break;
case 'Polygon':
@@ -164,9 +162,9 @@ var GeoJSONSource = new Lang.Class({
break;
case 'MultiPolygon':
- geometry.coordinates.forEach((function(coordinate) {
+ geometry.coordinates.forEach((coordinate) => {
this._parsePolygon(coordinate);
- }).bind(this));
+ });
break;
case 'Point':
@@ -174,9 +172,9 @@ var GeoJSONSource = new Lang.Class({
break;
case 'MultiPoint':
- geometry.coordinates.forEach((function(coordinate, properties) {
+ geometry.coordinates.forEach((coordinate, properties) => {
this._parsePoint(coordinate,properties);
- }).bind(this));
+ });
break;
default:
@@ -190,9 +188,9 @@ var GeoJSONSource = new Lang.Class({
switch(root.type) {
case 'FeatureCollection':
- root.features.forEach((function(feature) {
+ root.features.forEach((feature) => {
this._parseGeometry(feature.geometry, feature.properties);
- }).bind(this));
+ });
break;
case 'Feature':
@@ -203,7 +201,7 @@ var GeoJSONSource = new Lang.Class({
if (!root.geometries)
throw new Error(_("parse error"));
- root.geometries.forEach(this._parseGeometry.bind(this));
+ root.geometries.forEach((g) => this._parseGeometry(g));
break;
default:
@@ -226,7 +224,7 @@ var GeoJSONSource = new Lang.Class({
height: TILE_SIZE,
content: content });
- content.connect('draw', (function(canvas, cr) {
+ content.connect('draw', (canvas, cr) => {
tile.set_surface(cr.getTarget());
cr.setOperator(Cairo.Operator.CLEAR);
cr.paint();
@@ -238,13 +236,13 @@ var GeoJSONSource = new Lang.Class({
return;
}
- tileJSON.features.forEach(function(feature) {
+ tileJSON.features.forEach((feature) => {
if (feature.type === TileFeature.POINT)
return;
let geoJSONStyleObj = GeoJSONStyle.GeoJSONStyle.parseSimpleStyle(feature.tags);
- feature.geometry.forEach(function(geometry) {
+ feature.geometry.forEach((geometry) => {
let first = true;
cr.moveTo(0, 0);
cr.setLineWidth(geoJSONStyleObj.lineWidth);
@@ -276,7 +274,7 @@ var GeoJSONSource = new Lang.Class({
});
tile.emit('render-complete', null, 0, false);
- }).bind(this));
+ });
content.invalidate();
}
diff --git a/src/geoclue.js b/src/geoclue.js
index 74e962b..f319456 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -75,7 +75,7 @@ var Geoclue = new Lang.Class({
let id = 'org.gnome.Maps';
let level = GClue.AccuracyLevel.EXACT;
- GClue.Simple.new(id, level, null, (function(object, result) {
+ GClue.Simple.new(id, level, null, (object, result) => {
try {
this._simple = GClue.Simple.new_finish(result);
}
@@ -91,16 +91,16 @@ var Geoclue = new Lang.Class({
}
this._simple.connect('notify::location',
- this._onLocationNotify.bind(this));
- this._simple.client.connect('notify::active', (function() {
+ () => this._onLocationNotify(this._simple));
+ this._simple.client.connect('notify::active', () => {
this.state = this._simple.client.active ? State.ON : State.DENIED;
- }).bind(this));
+ });
this.state = State.ON;
this._onLocationNotify(this._simple);
if (callback)
callback(true);
- }).bind(this));
+ });
},
_onLocationNotify: function(simple) {
diff --git a/src/geocodeService.js b/src/geocodeService.js
index 38a60c1..30fa2be 100644
--- a/src/geocodeService.js
+++ b/src/geocodeService.js
@@ -47,14 +47,12 @@ var GeocodeService = new Lang.Class({
}
forward.bounded = false;
forward.set_answer_count(answerCount);
- forward.search_async(cancellable, function(forward, res) {
+ forward.search_async(cancellable, (forward, res) => {
try {
let places = forward.search_finish(res);
if (places !== null) {
- places = places.map(function(p) {
- return new Place.Place({ place: p });
- });
+ places = places.map((p) => new Place.Place({ place: p }));
}
callback(places);
@@ -68,7 +66,7 @@ var GeocodeService = new Lang.Class({
let reverse = Geocode.Reverse.new_for_location(location);
Application.application.mark_busy();
- reverse.resolve_async(cancellable, (function(reverse, res) {
+ reverse.resolve_async(cancellable, (reverse, res) => {
Application.application.unmark_busy();
try {
let place = new Place.Place({ place: reverse.resolve_finish(res) });
@@ -80,6 +78,6 @@ var GeocodeService = new Lang.Class({
e.message);
callback(null);
}
- }).bind(this));
+ });
}
});
diff --git a/src/graphHopper.js b/src/graphHopper.js
index afb049e..bd1281d 100644
--- a/src/graphHopper.js
+++ b/src/graphHopper.js
@@ -52,7 +52,7 @@ var GraphHopper = new Lang.Class({
},
_updateFromStored: function() {
- Mainloop.idle_add((function() {
+ Mainloop.idle_add(() => {
if (!this.storedRoute)
return;
@@ -62,13 +62,13 @@ var GraphHopper = new Lang.Class({
time: this.storedRoute.time,
bbox: this.storedRoute.bbox });
this.storedRoute = null;
- }).bind(this));
+ });
},
_queryGraphHopper: function(points, transportationType, callback) {
let url = this._buildURL(points, transportationType);
let msg = Soup.Message.new('GET', url);
- this._session.queue_message(msg, (function(session, message) {
+ this._session.queue_message(msg, (session, message) => {
try {
let result = this._parseMessage(message);
if (!result)
@@ -78,7 +78,7 @@ var GraphHopper = new Lang.Class({
} catch (e) {
callback(null, e);
}
- }).bind(this));
+ });
},
fetchRoute: function(points, transportationType) {
@@ -88,7 +88,7 @@ var GraphHopper = new Lang.Class({
}
this._queryGraphHopper(points, transportationType,
- (function(result, exception) {
+ (result, exception) => {
if (exception) {
Application.notificationManager.showMessage(_("Route request failed."));
Utils.debug(e);
@@ -108,19 +108,19 @@ var GraphHopper = new Lang.Class({
this.route.update(route);
}
}
- }).bind(this));
+ });
},
fetchRouteAsync: function(points, transportationType, callback) {
this._queryGraphHopper(points, transportationType,
- (function(result, exception) {
+ (result, exception) => {
if (result) {
let route = this._createRoute(result.paths[0]);
callback(route, exception);
} else {
callback(null, exception);
}
- }).bind(this));
+ });
},
_buildURL: function(points, transportation) {
@@ -157,7 +157,7 @@ var GraphHopper = new Lang.Class({
if (!Array.isArray(result.paths)) {
Utils.debug("No route found");
if (result.info && Array.isArray(result.info.errors)) {
- result.info.errors.forEach(function({ message, details }) {
+ result.info.errors.forEach(({ message, details }) => {
Utils.debug("Message: " + message);
Utils.debug("Details: " + details);
});
@@ -194,7 +194,7 @@ var GraphHopper = new Lang.Class({
time: 0,
turnAngle: 0
});
- let rest = instructions.map((function(instr) {
+ let rest = instructions.map((instr) => {
let type = this._createTurnPointType(instr.sign);
let text = instr.text;
if (type === Route.TurnPointType.VIA) {
@@ -210,7 +210,7 @@ var GraphHopper = new Lang.Class({
time: instr.time,
turnAngle: instr.turn_angle
});
- }).bind(this));
+ });
return [startPoint].concat(rest);
},
diff --git a/src/layersPopover.js b/src/layersPopover.js
index a5c7fa3..9e6d09d 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -39,7 +39,7 @@ var ShapeLayerRow = new Lang.Class({
this._layerLabel.label = this.shapeLayer.getName();
this._layerLabel.tooltip_text = this.shapeLayer.file.get_parse_name();
- this._visibleButton.connect('clicked', (function() {
+ this._visibleButton.connect('clicked', () => {
let image = this._visibleButton.get_child();
this.shapeLayer.visible = !this.shapeLayer.visible;
@@ -48,7 +48,7 @@ var ShapeLayerRow = new Lang.Class({
image.icon_name = 'layer-visible-symbolic';
else
image.icon_name = 'layer-not-visible-symbolic';
- }).bind(this));
+ });
}
});
@@ -75,23 +75,23 @@ var LayersPopover = new Lang.Class({
this.get_style_context().add_class('maps-popover');
this._layersListBox.bind_model(this._mapView.shapeLayerStore,
- this._listBoxCreateWidget.bind(this));
- this._layersListBox.connect('row-activated', (function(lb, row) {
+ () => this._listBoxCreateWidget());
+ this._layersListBox.connect('row-activated', (lb, row) => {
this._mapView.gotoBBox(row.shapeLayer.bbox);
- }).bind(this));
+ });
- this._layersListBox.set_header_func(function(row, before) {
+ this._layersListBox.set_header_func((row, before) => {
let header = before ? new Gtk.Separator() : null;
row.set_header(header);
});
- this._streetLayerButton.connect('clicked', (function () {
+ this._streetLayerButton.connect('clicked', () => {
this._mapView.setMapType(MapView.MapType.STREET);
- }).bind(this));
+ });
- this._aerialLayerButton.connect('clicked', (function () {
+ this._aerialLayerButton.connect('clicked', () => {
this._mapView.setMapType(MapView.MapType.AERIAL);
- }).bind(this));
+ });
},
setMapType: function(mapType) {
@@ -101,7 +101,7 @@ var LayersPopover = new Lang.Class({
this._aerialLayerButton.active = true;
},
- _onRemoveClicked: function(row, button) {
+ _onRemoveClicked: function(row) {
this._mapView.removeShapeLayer(row.shapeLayer);
if (this._layersListBox.get_children().length <= 0)
this._layersListBox.hide();
@@ -110,7 +110,7 @@ var LayersPopover = new Lang.Class({
_listBoxCreateWidget: function(shapeLayer) {
let row = new ShapeLayerRow({ shapeLayer: shapeLayer });
row.closeButton.connect('clicked',
- this._onRemoveClicked.bind(this, row));
+ () => this._onRemoveClicked(row));
this._layersListBox.show();
return row;
}
diff --git a/src/locationServiceNotification.js b/src/locationServiceNotification.js
index acb8cf4..9cf6219 100644
--- a/src/locationServiceNotification.js
+++ b/src/locationServiceNotification.js
@@ -40,7 +40,7 @@ var LocationServiceNotification = new Lang.Class({
let ui = Utils.getUIObject('location-service-notification',
[ 'button', 'grid' ]);
- ui.button.connect('clicked', (function() {
+ ui.button.connect('clicked', () => {
let privacyInfo = Gio.DesktopAppInfo.new(_PRIVACY_PANEL);
try {
@@ -51,15 +51,14 @@ var LocationServiceNotification = new Lang.Class({
Utils.debug('launching privacy panel failed: ' + e);
}
- Application.geoclue.connect('notify::state', (function() {
+ Application.geoclue.connect('notify::state', () => {
if (!this.parent)
return;
if (Application.geoclue.state == Geoclue.State.ON)
this.dismiss();
- }).bind(this));
-
- }).bind(this));
+ });
+ });
this._ui.body.add(ui.grid);
}
diff --git a/src/longPrintLayout.js b/src/longPrintLayout.js
index 8f274e1..956a76e 100644
--- a/src/longPrintLayout.js
+++ b/src/longPrintLayout.js
@@ -49,7 +49,7 @@ var LongPrintLayout = new Lang.Class({
let totalSurfaces = 4 + this._route.turnPoints.length;
/* Plus via points */
- this._route.turnPoints.forEach(function(turnPoint) {
+ this._route.turnPoints.forEach((turnPoint) => {
if (turnPoint.type === Route.TurnPointType.VIA)
totalSurfaces++;
});
diff --git a/src/mainWindow.js b/src/mainWindow.js
index b6b0bf8..e418d7e 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -60,16 +60,16 @@ var ShapeLayerFileChooser = new Lang.Class({
this.add_filter(allFilter);
this.set_filter(allFilter);
- ShapeLayer.SUPPORTED_TYPES.forEach((function(layerClass) {
+ ShapeLayer.SUPPORTED_TYPES.forEach((layerClass) => {
let filter = new Gtk.FileFilter();
- [filter, allFilter].forEach(function(f) {
- layerClass.mimeTypes.forEach(function(type) {
+ [filter, allFilter].forEach((f) => {
+ layerClass.mimeTypes.forEach((type) => {
f.add_mime_type(type);
});
});
filter.set_name(layerClass.displayName);
this.add_filter(filter);
- }).bind(this));
+ });
}
});
@@ -146,27 +146,22 @@ var MainWindow = new Lang.Class({
loupe: true,
matchRoute: true
});
- placeEntry.connect('notify::place', (function() {
+ placeEntry.connect('notify::place', () => {
if (placeEntry.place) {
this._mapView.showPlace(placeEntry.place, true);
}
- }).bind(this));
+ });
let popover = placeEntry.popover;
- popover.connect('selected', (function() {
- this._mapView.grab_focus();
- }).bind(this));
- this._mapView.view.connect('button-press-event', (function () {
- popover.hide();
- }));
+ popover.connect('selected', () => this._mapView.grab_focus());
+ this._mapView.view.connect('button-press-event', () => popover.hide());
return placeEntry;
},
_createSidebar: function() {
let sidebar = new Sidebar.Sidebar(this._mapView);
- Application.routeQuery.connect('notify',
- this._setRevealSidebar.bind(this, true));
+ Application.routeQuery.connect('notify', () => this._setRevealSidebar(true));
this._toggleSidebarButton.bind_property('active',
this._mapView, 'routingOpen',
GObject.BindingFlags.BIDIRECTIONAL);
@@ -180,72 +175,72 @@ var MainWindow = new Lang.Class({
this.drag_dest_set(Gtk.DestDefaults.DROP, null, 0);
this.drag_dest_add_uri_targets();
- this.connect('drag-motion', (function(widget, ctx, x, y, time) {
+ this.connect('drag-motion', (widget, ctx, x, y, time) => {
Gdk.drag_status(ctx, Gdk.DragAction.COPY, time);
return true;
- }).bind(this));
+ });
- this.connect('drag-data-received', (function(widget, ctx, x, y, data, info, time) {
+ this.connect('drag-data-received', (widget, ctx, x, y, data, info, time) => {
let files = data.get_uris().map(Gio.file_new_for_uri);
if (this._mapView.openShapeLayers(files))
Gtk.drag_finish(ctx, true, false, time);
else
Gtk.drag_finish(ctx, false, false, time);
- }).bind(this));
+ });
},
_initActions: function() {
Utils.addActions(this, {
'close': {
- onActivate: this.close.bind(this)
+ onActivate: () => this.close()
},
'about': {
- onActivate: this._onAboutActivate.bind(this)
+ onActivate: () => this._onAboutActivate()
},
'map-type-menu': {
state: ['b', false],
- onActivate: this._onMapTypeMenuActivate.bind(this)
+ onActivate: () => this._onMapTypeMenuActivate()
},
'switch-to-street-view': {
accels: ['<Primary>1', '<Primary>KP_1'],
- onActivate: this._onStreetViewActivate.bind(this)
+ onActivate: () => this._onStreetViewActivate()
},
'switch-to-aearial-view': {
accels: ['<Primary>2', '<Primary>KP_2'],
- onActivate: this._onAerialViewActivate.bind(this)
+ onActivate: () => this._onAerialViewActivate()
},
'goto-user-location': {
accels: ['<Primary>L'],
- onActivate: this._onGotoUserLocationActivate.bind(this)
+ onActivate: () => this._onGotoUserLocationActivate()
},
'toggle-sidebar': {
accels: ['<Primary>D'],
state: ['b', false],
- onChangeState: this._onToggleSidebarChangeState.bind(this)
+ onChangeState: (a, v) => this._onToggleSidebarChangeState(a, v)
},
'zoom-in': {
accels: ['plus', '<Primary>plus', 'KP_Add', '<Primary>KP_Add', 'equal', '<Primary>equal'],
- onActivate: this._mapView.view.zoom_in.bind(this._mapView.view)
+ onActivate: () => this._mapView.view.zoom_in()
},
'zoom-out': {
accels: ['minus', '<Primary>minus', 'KP_Subtract', '<Primary>KP_Subtract'],
- onActivate: this._mapView.view.zoom_out.bind(this._mapView.view)
+ onActivate: () => this._mapView.view.zoom_out()
},
'toggle-scale': {
accels: ['<Primary>S'],
- onActivate: this._mapView.toggleScale.bind(this._mapView)
+ onActivate: () => this._mapView.toggleScale()
},
'find': {
accels: ['<Primary>F'],
- onActivate: this._placeEntry.grab_focus.bind(this._placeEntry)
+ onActivate: () => this._placeEntry.grab_focus()
},
'print-route': {
accels: ['<Primary>P'],
- onActivate: this._printRouteActivate.bind(this)
+ onActivate: () => this._printRouteActivate()
},
'open-shape-layer': {
accels: ['<Primary>O'],
- onActivate: this._onOpenShapeLayer.bind(this)
+ onActivate: () => this._onOpenShapeLayer()
}
});
},
@@ -257,27 +252,25 @@ var MainWindow = new Lang.Class({
this.connect('window-state-event',
this._onWindowStateEvent.bind(this));
- this._mapView.view.connect('button-press-event', (function() {
+ this._mapView.view.connect('button-press-event', () => {
// Can not call something that will generate clutter events
// from a clutter event-handler. So use an idle.
- Mainloop.idle_add((function() {
- this._mapView.grab_focus();
- }).bind(this));
- }).bind(this));
+ Mainloop.idle_add(() => this._mapView.grab_focus());
+ });
- this.application.connect('notify::connected', (function() {
+ this.application.connect('notify::connected', () => {
if (this.application.connected || this.application.local_tile_path)
this._mainStack.visible_child = this._overlay;
else
this._mainStack.visible_child = this._noNetworkView;
- }).bind(this));
+ });
/*
* If the currently focused widget is an entry then we will
* hijack the key-press to the main window and make sure that
* they reach the entry before they can be swallowed as accelerator.
*/
- this.connect('key-press-event', (function(window, event) {
+ this.connect('key-press-event', (window, event) => {
let focusWidget = window.get_focus();
let keyval = event.get_keyval()[1];
let keys = [Gdk.KEY_plus, Gdk.KEY_KP_Add,
@@ -304,7 +297,7 @@ var MainWindow = new Lang.Class({
return focusWidget.event(event);
return false;
- }).bind(this));
+ });
this._mapView.view.connect('notify::zoom-level',
this._updateZoomButtonsSensitivity.bind(this));
@@ -344,16 +337,16 @@ var MainWindow = new Lang.Class({
let favoritesPopover = this._favoritesButton.popover;
this._favoritesButton.sensitive = favoritesPopover.rows > 0;
- favoritesPopover.connect('notify::rows', (function() {
+ favoritesPopover.connect('notify::rows', () => {
this._favoritesButton.sensitive = favoritesPopover.rows > 0;
- }).bind(this));
+ });
this._mapView.bind_property('routeShowing', this._printRouteButton,
'visible', GObject.BindingFlags.DEFAULT);
Application.geoclue.connect('notify::state',
this._updateLocationSensitivity.bind(this));
- this.application.connect('notify::connected', (function() {
+ this.application.connect('notify::connected', () => {
let app = this.application;
this._updateLocationSensitivity();
@@ -363,7 +356,7 @@ var MainWindow = new Lang.Class({
favoritesPopover.rows > 0);
this._placeEntry.sensitive = app.connected;
this._printRouteButton.sensitive = app.connected;
- }).bind(this));
+ });
},
_saveWindowGeometry: function() {
@@ -405,11 +398,11 @@ var MainWindow = new Lang.Class({
this._configureId = 0;
}
- this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, (function() {
+ this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, () => {
this._saveWindowGeometry();
this._configureId = 0;
return false;
- }).bind(this));
+ });
},
_onWindowStateEvent: function(widget, event) {
@@ -453,7 +446,7 @@ var MainWindow = new Lang.Class({
return;
}
- Application.geoclue.start((function() {
+ Application.geoclue.start(() => {
switch(Application.geoclue.state) {
case Geoclue.State.FAILED:
message = _("Failed to connect to location service");
@@ -469,7 +462,7 @@ var MainWindow = new Lang.Class({
this._mapView.gotoUserLocation(true);
break;
}
- }).bind(this));
+ });
},
_printRouteActivate: function() {
@@ -541,9 +534,7 @@ var MainWindow = new Lang.Class({
copyrightLabel.show();
aboutDialog.show();
- aboutDialog.connect('response', (function() {
- aboutDialog.destroy();
- }));
+ aboutDialog.connect('response', () => aboutDialog.destroy());
},
_getAttribution: function() {
@@ -575,13 +566,13 @@ var MainWindow = new Lang.Class({
transient_for: this,
});
- fileChooser.connect('response', (function(widget, response) {
+ fileChooser.connect('response', (widget, response) => {
if (response === Gtk.ResponseType.ACCEPT) {
this._mapView.openShapeLayers(fileChooser.get_files());
this.layersPopover.popdown();
}
fileChooser.destroy();
- }).bind(this));
+ });
fileChooser.show();
},
@@ -592,9 +583,7 @@ var MainWindow = new Lang.Class({
this._busy.show();
let stage = this._mapView.view.get_stage();
- this._busySignalId = stage.connect('captured-event', function() {
- return true;
- });
+ this._busySignalId = stage.connect('captured-event', () => true);
},
unmarkBusy: function() {
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 238920e..d4e055f 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -131,7 +131,7 @@ var MapBubble = new Lang.Class({
image.icon_name = 'non-starred-symbolic';
}
- button.connect('clicked', (function() {
+ button.connect('clicked', () => {
if (placeStore.exists(this._place,
PlaceStore.PlaceType.FAVORITE)) {
image.icon_name = 'non-starred-symbolic';
@@ -142,7 +142,7 @@ var MapBubble = new Lang.Class({
placeStore.addPlace(this._place,
PlaceStore.PlaceType.FAVORITE);
}
- }).bind(this));
+ });
},
_initSendToButton: function(button) {
@@ -154,10 +154,8 @@ var MapBubble = new Lang.Class({
return;
button.visible = true;
- button.connect('clicked', function() {
- dialog.connect('response', function() {
- dialog.hide();
- });
+ button.connect('clicked', () => {
+ dialog.connect('response', () => dialog.hide());
dialog.show_all();
});
},
@@ -169,7 +167,7 @@ var MapBubble = new Lang.Class({
button.visible = true;
- button.connect('clicked', (function() {
+ button.connect('clicked', () => {
query.freeze_notify();
query.reset();
Application.routingDelegator.reset();
@@ -182,7 +180,7 @@ var MapBubble = new Lang.Class({
}
this.destroy();
query.thaw_notify();
- }).bind(this));
+ });
},
_initCheckInButton: function(button, matchPlace) {
@@ -191,10 +189,10 @@ var MapBubble = new Lang.Class({
GObject.BindingFlags.DEFAULT |
GObject.BindingFlags.SYNC_CREATE);
- button.connect('clicked', (function() {
+ button.connect('clicked', () => {
Application.checkInManager.showCheckInDialog(this.get_toplevel(),
this.place,
matchPlace);
- }).bind(this));
+ });
}
});
diff --git a/src/mapMarker.js b/src/mapMarker.js
index 328281e..16ac12d 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -109,7 +109,7 @@ var MapMarker = new Lang.Class({
let canvas = new Clutter.Canvas({ width: pixbuf.get_width(),
height: pixbuf.get_height() });
- canvas.connect('draw', (function(canvas, cr) {
+ canvas.connect('draw', (canvas, cr) => {
cr.setOperator(Cairo.Operator.CLEAR);
cr.paint();
cr.setOperator(Cairo.Operator.OVER);
@@ -118,7 +118,7 @@ var MapMarker = new Lang.Class({
cr.paint();
this._surface = cr.getTarget();
- }).bind(this));
+ });
let actor = new Clutter.Actor();
actor.set_content(canvas);
@@ -204,7 +204,7 @@ var MapMarker = new Lang.Class({
_hideBubbleOn: function(signal, duration) {
let sourceId = null;
- let signalId = this._view.connect(signal, (function() {
+ let signalId = this._view.connect(signal, () => {
if (sourceId)
Mainloop.source_remove(sourceId);
else
@@ -219,23 +219,23 @@ var MapMarker = new Lang.Class({
sourceId = Mainloop.timeout_add(duration, callback);
else
sourceId = Mainloop.idle_add(callback);
- }).bind(this));
+ });
- Utils.once(this.bubble, 'closed', (function() {
+ Utils.once(this.bubble, 'closed', () => {
// We still listening for the signal to refresh
// the existent timeout
if (!sourceId)
this._view.disconnect(signalId);
- }).bind(this));
+ });
- Utils.once(this, 'notify::selected', (function() {
+ Utils.once(this, 'notify::selected', () => {
// When the marker gets deselected, we need to ensure
// that the timeout callback is not called anymore.
if (sourceId) {
Mainloop.source_remove(sourceId);
this._view.disconnect(signalId);
}
- }).bind(this));
+ });
},
_initBubbleSignals: function() {
@@ -249,26 +249,26 @@ var MapMarker = new Lang.Class({
// does the job.
this._mapView.onSetMarkerSelected(this);
- let markerSelectedSignalId = this._mapView.connect('marker-selected', (function(mapView,
selectedMarker) {
+ let markerSelectedSignalId = this._mapView.connect('marker-selected', (mapView, selectedMarker) => {
if (this.get_parent() !== selectedMarker.get_parent())
this.selected = false;
- }).bind(this));
+ });
- let goingToSignalId = this._mapView.connect('going-to', (function() {
+ let goingToSignalId = this._mapView.connect('going-to', () => {
this.set_selected(false);
- }).bind(this));
+ });
let buttonPressSignalId =
- this._view.connect('button-press-event', (function() {
+ this._view.connect('button-press-event', () => {
this.set_selected(false);
- }).bind(this));
+ });
// Destroy the bubble when the marker is destroyed o removed from a layer
- let parentSetSignalId = this.connect('parent-set', (function() {
+ let parentSetSignalId = this.connect('parent-set', () => {
this.set_selected(false);
- }).bind(this));
- let dragMotionSignalId = this.connect('drag-motion', (function() {
+ });
+ let dragMotionSignalId = this.connect('drag-motion', () => {
this.set_selected(false);
- }).bind(this));
- Utils.once(this.bubble, 'closed', (function() {
+ });
+ Utils.once(this.bubble, 'closed', () => {
this._mapView.disconnect(markerSelectedSignalId);
this._mapView.disconnect(goingToSignalId);
this._view.disconnect(buttonPressSignalId);
@@ -277,7 +277,7 @@ var MapMarker = new Lang.Class({
this._bubble.destroy();
delete this._bubble;
- }).bind(this));
+ });
},
_isInsideView: function() {
@@ -324,17 +324,12 @@ var MapMarker = new Lang.Class({
},
goTo: function(animate) {
- Utils.once(this.walker, 'gone-to', (function() {
- this.emit('gone-to');
- }).bind(this));
-
+ Utils.once(this.walker, 'gone-to', () => this.emit('gone-to'));
this.walker.goTo(animate);
},
goToAndSelect: function(animate) {
- Utils.once(this, 'gone-to', (function() {
- this.selected = true;
- }).bind(this));
+ Utils.once(this, 'gone-to', () => this.selected = true);
this.goTo(animate);
},
diff --git a/src/mapSource.js b/src/mapSource.js
index 9f4c97b..ecb8154 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -50,13 +50,8 @@ var AttributionLogo = new Lang.Class({
else
return;
- view.connect('notify::width', (function() {
- this._updatePosition(view);
- }).bind(this));
-
- view.connect('notify::height', (function() {
- this._updatePosition(view);
- }).bind(this));
+ view.connect('notify::width', () => this._updatePosition(view));
+ view.connect('notify::height', () => this._updatePosition(view));
this._updatePosition(view);
},
diff --git a/src/mapView.js b/src/mapView.js
index 2249889..2c5cce5 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -122,9 +122,7 @@ var MapView = new Lang.Class({
let isValid = Application.routeQuery.isValid();
this._routingOpen = value && isValid;
- this._routeLayers.forEach((function(routeLayer) {
- routeLayer.visible = value && isValid;
- }).bind(this));
+ this._routeLayers.forEach((routeLayer) => routeLayer.visible = value && isValid);
this._instructionMarkerLayer.visible = value && isValid;
if (!value)
this.routeShowing = false;
@@ -153,7 +151,6 @@ var MapView = new Lang.Class({
this.shapeLayerStore = new Gio.ListStore(GObject.TYPE_OBJECT);
- this._updateUserLocation();
Application.geoclue.connect('location-changed',
this._updateUserLocation.bind(this));
Application.geoclue.connect('notify::state',
@@ -191,11 +188,11 @@ var MapView = new Lang.Class({
view.connect('notify::realized', this._goToStoredLocation.bind(this));
view.connect('notify::latitude', this._onViewMoved.bind(this));
// switching map type will set view min-zoom-level from map source
- view.connect('notify::min-zoom-level', (function() {
+ view.connect('notify::min-zoom-level', () => {
if (view.min_zoom_level < MapMinZoom) {
view.min_zoom_level = MapMinZoom;
}
- }).bind(this));
+ });
this._initScale(view);
return view;
@@ -224,11 +221,11 @@ var MapView = new Lang.Class({
},
_clearRouteLayers: function() {
- this._routeLayers.forEach((function(routeLayer) {
+ this._routeLayers.forEach((routeLayer) => {
routeLayer.remove_all();
routeLayer.visible = false;
this.view.remove_layer(routeLayer);
- }).bind(this));
+ });
this._routeLayers = [];
},
@@ -265,34 +262,33 @@ var MapView = new Lang.Class({
let transitPlan = Application.routingDelegator.openTripPlanner.plan;
let query = Application.routeQuery;
- route.connect('update', (function() {
+ route.connect('update', () => {
this.showRoute(route);
this.routeShowing = true;
- }).bind(this));
- route.connect('reset', (function() {
+ });
+ route.connect('reset', () => {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
this.routeShowing = false;
- }).bind(this));
- transitPlan.connect('update', this._showTransitPlan.bind(this, transitPlan));
- transitPlan.connect('reset', (function() {
+ });
+ transitPlan.connect('update', () => this._showTransitPlan(transitPlan));
+ transitPlan.connect('reset', () => {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
this.routeShowing = false;
- }).bind(this));
- transitPlan.connect('itinerary-selected', (function(obj, itinerary) {
+ });
+ transitPlan.connect('itinerary-selected', (obj, itinerary) => {
this._showTransitItinerary(itinerary);
this.routeShowing = true;
- }).bind(this));
- transitPlan.connect('itinerary-deselected', (function() {
+ });
+ transitPlan.connect('itinerary-deselected', () => {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
this.routeShowing = false;
- }).bind(this));
+ });
- query.connect('notify', (function() {
- this.routingOpen = query.isValid();
- }).bind(this));
+
+ query.connect('notify', () => this.routingOpen = query.isValid());
},
setMapType: function(mapType) {
@@ -334,9 +330,7 @@ var MapView = new Lang.Class({
}
}
- overlay_sources.forEach((function(source) {
- this.view.add_overlay_source(source, 255);
- }).bind(this));
+ overlay_sources.forEach((source) => this.view.add_overlay_source(source, 255));
},
toggleScale: function() {
@@ -346,7 +340,7 @@ var MapView = new Lang.Class({
openShapeLayers: function(files) {
let bbox = new Champlain.BoundingBox();
let ret = true;
- files.forEach((function(file){
+ files.forEach((file) => {
try {
let i = this._findShapeLayerIndex(file);
let layer = (i > -1) ? this.shapeLayerStore.get_item(i) : null;
@@ -364,7 +358,7 @@ var MapView = new Lang.Class({
Application.notificationManager.showMessage(msg);
ret = false;
}
- }).bind(this));
+ });
this.gotoBBox(bbox);
return ret;
@@ -407,9 +401,8 @@ var MapView = new Lang.Class({
return;
this.emit('going-to-user-location');
- Utils.once(this._userLocation, "gone-to", (function() {
- this.emit('gone-to-user-location');
- }).bind(this));
+ Utils.once(this._userLocation, "gone-to",
+ () => this.emit('gone-to-user-location'));
this._userLocation.goTo(animate);
},
@@ -511,13 +504,13 @@ var MapView = new Lang.Class({
return;
this._placeLayer.remove_all();
- places.forEach((function(p) {
+ places.forEach((p) => {
let place = new ContactPlace.ContactPlace({ place: p,
contact: contact });
let marker = new PlaceMarker.PlaceMarker({ place: place,
mapView: this });
this._placeLayer.add_marker(marker);
- }).bind(this));
+ });
if (places.length > 1)
this.gotoBBox(contact.bounding_box);
@@ -574,9 +567,7 @@ var MapView = new Lang.Class({
routeLayer = this._createRouteLayer(false, TURN_BY_TURN_ROUTE_COLOR,
ROUTE_LINE_WIDTH);
- route.path.forEach((function (polyline) {
- routeLayer.add_node(polyline);
- }).bind(this));
+ route.path.forEach((polyline) => routeLayer.add_node(polyline));
this.routingOpen = true;
this._ensureInstructionLayerAboveRouteLayers();
@@ -591,7 +582,7 @@ var MapView = new Lang.Class({
let pointIndex = 0;
this._instructionMarkerLayer.remove_all();
- route.turnPoints.forEach(function(turnPoint) {
+ route.turnPoints.forEach((turnPoint) => {
if (turnPoint.isStop()) {
let queryPoint = query.filledPoints[pointIndex];
let destinationMarker = new TurnPointMarker.TurnPointMarker({ turnPoint: turnPoint,
@@ -609,7 +600,7 @@ var MapView = new Lang.Class({
this._placeLayer.remove_all();
this._instructionMarkerLayer.remove_all();
- itinerary.legs.forEach((function (leg, index) {
+ itinerary.legs.forEach((leg, index) => {
let dashed = !leg.transit;
let color = leg.color;
let outlineColor = leg.textColor;
@@ -653,11 +644,11 @@ var MapView = new Lang.Class({
routeLayer.add_node(firstPoint);
}
- }).bind(this));
+ });
this._ensureInstructionLayerAboveRouteLayers();
- itinerary.legs.forEach((function (leg, index) {
+ itinerary.legs.forEach((leg, index) => {
let previousLeg = index === 0 ? null : itinerary.legs[index - 1];
/* add start marker */
@@ -672,7 +663,7 @@ var MapView = new Lang.Class({
}
this._instructionMarkerLayer.add_marker(start);
- }).bind(this));
+ });
/* add arrival marker */
let lastLeg = itinerary.legs.last();
@@ -692,10 +683,10 @@ var MapView = new Lang.Class({
if (this._storeId !== 0)
return;
- this._storeId = Mainloop.timeout_add(_LOCATION_STORE_TIMEOUT,(function(){
+ this._storeId = Mainloop.timeout_add(_LOCATION_STORE_TIMEOUT, () => {
this._storeId = 0;
this._storeLocation();
- }).bind(this));
+ });
},
onSetMarkerSelected: function(selectedMarker) {
diff --git a/src/mapWalker.js b/src/mapWalker.js
index 0cd3340..06a03ec 100644
--- a/src/mapWalker.js
+++ b/src/mapWalker.js
@@ -117,19 +117,17 @@ var MapWalker = new Lang.Class({
this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_CUBIC;
this._ensureVisible(fromLocation);
- Utils.once(this._view, 'animation-completed', (function() {
+ Utils.once(this._view, 'animation-completed', () => {
this._view.goto_animation_mode = Clutter.AnimationMode.EASE_OUT_CUBIC;
this._view.go_to(this.place.location.latitude,
this.place.location.longitude);
- Utils.once(this._view, 'animation-completed::go-to', (function() {
+ Utils.once(this._view, 'animation-completed::go-to', () => {
this.zoomToFit();
this._view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
this.emit('gone-to');
- }).bind(this));
-
- }).bind(this));
-
+ });
+ });
}
},
@@ -146,7 +144,7 @@ var MapWalker = new Lang.Class({
bottom: 90,
top: -90 });
- [fromLocation, this.place.location].forEach(function(location) {
+ [fromLocation, this.place.location].forEach((location) => {
visibleBox.left = Math.min(visibleBox.left, location.longitude);
visibleBox.right = Math.max(visibleBox.right, location.longitude);
visibleBox.bottom = Math.min(visibleBox.bottom, location.latitude);
diff --git a/src/notification.js b/src/notification.js
index 3eb64cc..e78a331 100644
--- a/src/notification.js
+++ b/src/notification.js
@@ -60,10 +60,10 @@ var Notification = new Lang.Class({
// if there is an actual change in revealed state.
if (state !== this.child_revealed) {
this.set_reveal_child(state);
- Mainloop.timeout_add(this.transition_duration, (function() {
+ Mainloop.timeout_add(this.transition_duration, () => {
this.emit(signal);
return false;
- }).bind(this));
+ });
}
}
});
diff --git a/src/notificationManager.js b/src/notificationManager.js
index ed622ac..ba2fae1 100644
--- a/src/notificationManager.js
+++ b/src/notificationManager.js
@@ -37,11 +37,11 @@ var NotificationManager = new Lang.Class({
_add: function(notification) {
this._current = notification;
if (!(notification instanceof Notification.Plain)) {
- let dismissId = notification.connect('dismissed', (function() {
+ let dismissId = notification.connect('dismissed', () => {
this._overlay.remove(notification);
notification.disconnect(dismissId);
this._current = null;
- }).bind(this));
+ });
}
this._overlay.add_overlay(notification);
Mainloop.timeout_add(_TIMEOUT, notification.dismiss.bind(notification));
@@ -50,10 +50,10 @@ var NotificationManager = new Lang.Class({
showMessage: function (msg) {
let notification = new Notification.Plain(msg);
- notification.connect('dismissed', (function() {
+ notification.connect('dismissed', () => {
this._current = null;
notification.destroy();
- }).bind(this));
+ });
this.showNotification(notification);
},
diff --git a/src/openTripPlanner.js b/src/openTripPlanner.js
index e0d209b..a827c38 100644
--- a/src/openTripPlanner.js
+++ b/src/openTripPlanner.js
@@ -195,7 +195,7 @@ var OpenTripPlanner = new Lang.Class({
let request = new Soup.Message({ method: 'GET', uri: uri });
request.request_headers.append('Accept', 'application/json');
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.Status.OK) {
callback(false);
return;
@@ -209,14 +209,14 @@ var OpenTripPlanner = new Lang.Class({
Utils.debug('Failed to parse router information');
callback(false);
}
- }).bind(this));
+ });
}
},
_getRoutersForPlace: function(place) {
let routers = [];
- this._routers.routerInfo.forEach((function(routerInfo) {
+ this._routers.routerInfo.forEach((routerInfo) => {
/* TODO: only check bounding rectangle for now
* should we try to do a finer-grained check using the bounding
* polygon (if OTP gives one for the routers).
@@ -228,7 +228,7 @@ var OpenTripPlanner = new Lang.Class({
place.location.longitude >= routerInfo.lowerLeftLongitude &&
place.location.longitude <= routerInfo.upperRightLongitude)
routers.push(routerInfo.routerId);
- }));
+ });
return routers;
},
@@ -261,9 +261,9 @@ var OpenTripPlanner = new Lang.Class({
},
_getModes: function(options) {
- let modes = options.transitTypes.map((function(transitType) {
+ let modes = options.transitTypes.map((transitType) => {
return this._getMode(transitType);
- }).bind(this));
+ });
return modes.join(',');
},
@@ -282,21 +282,21 @@ var OpenTripPlanner = new Lang.Class({
callback);
} else if (stopIndex === 0) {
this._fetchWalkingRoute([points[0], stopPoint],
- (function(route) {
+ (route) => {
/* if we couldn't find an exact walking route, go with the
* "as the crow flies" distance */
if (route)
stop.dist = route.distance;
this._selectBestStopRecursive(stops, index + 1, stopIndex,
callback);
- }).bind(this));
+ });
} else if (stopIndex === points.length - 1) {
- this._fetchWalkingRoute([stopPoint, points.last()], (function(route) {
+ this._fetchWalkingRoute([stopPoint, points.last()], (route) => {
if (route)
stop.dist = route.distance;
this._selectBestStopRecursive(stops, index + 1, stopIndex,
callback);
- }).bind(this));
+ });
} else {
/* for intermediate stops just return the one geographically
* closest */
@@ -308,9 +308,7 @@ var OpenTripPlanner = new Lang.Class({
* distances */
stops.sort(this._sortTransitStops);
Utils.debug('refined stops: ');
- stops.forEach(function(stop) {
- Utils.debug(JSON.stringify(stop, '', 2));
- });
+ stops.forEach((stop) => Utils.debug(JSON.stringify(stop, '', 2)));
callback(stops[0]);
}
},
@@ -333,7 +331,7 @@ var OpenTripPlanner = new Lang.Class({
let request = new Soup.Message({ method: 'GET', uri: uri });
request.request_headers.append('Accept', 'application/json');
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.Status.OK) {
Utils.debug('Failed to get routes for stop');
this._reset();
@@ -343,7 +341,7 @@ var OpenTripPlanner = new Lang.Class({
Utils.debug('Routes for stop: ' + stop + ': ' + JSON.stringify(routes));
callback(routes);
}
- }).bind(this));
+ });
},
_routeMatchesSelectedModes: function(route) {
@@ -372,7 +370,7 @@ var OpenTripPlanner = new Lang.Class({
if (index < stops.length) {
let stop = stops[index];
- this._fetchRoutesForStop(router, stop, (function(routes) {
+ this._fetchRoutesForStop(router, stop, (routes) => {
for (let i = 0; i < routes.length; i++) {
let route = routes[i];
@@ -383,7 +381,7 @@ var OpenTripPlanner = new Lang.Class({
}
this._filterStopsRecursive(router, stops, index + 1,
filteredStops, callback);
- }).bind(this));
+ });
} else {
callback(filteredStops);
}
@@ -407,7 +405,7 @@ var OpenTripPlanner = new Lang.Class({
let request = new Soup.Message({ method: 'GET', uri: uri });
request.request_headers.append('Accept', 'application/json');
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.Status.OK) {
Utils.debug('Failed to get stop for search point ' + point);
this._reset();
@@ -425,13 +423,13 @@ var OpenTripPlanner = new Lang.Class({
stops = stops.splice(0, NUM_STOPS_TO_TRY);
Utils.debug('stops: ' + JSON.stringify(stops, '', 2));
- this._selectBestStop(stops, index, (function(stop) {
+ this._selectBestStop(stops, index, (stop) => {
result.push(stop);
this._fetchTransitStopsRecursive(router, index + 1,
result, callback);
- }).bind(this));
+ });
} else {
- this._filterStops(router, stops, (function(filteredStops) {
+ this._filterStops(router, stops, (filteredStops) => {
filteredStops.sort(this._sortTransitStops);
filteredStops = filteredStops.splice(0, NUM_STOPS_TO_TRY);
@@ -441,15 +439,15 @@ var OpenTripPlanner = new Lang.Class({
return;
}
- this._selectBestStop(filteredStops, index, (function(stop) {
+ this._selectBestStop(filteredStops, index, (stop) => {
result.push(stop);
this._fetchTransitStopsRecursive(router, index + 1,
result, callback);
- }).bind(this));
- }).bind(this));
+ });
+ });
}
}
- }).bind(this));
+ });
} else {
callback(result);
}
@@ -544,7 +542,7 @@ var OpenTripPlanner = new Lang.Class({
},
_fetchRoutesForRouter: function(router, callback) {
- this._fetchTransitStops(router, (function(stops) {
+ this._fetchTransitStops(router, (stops) => {
let points = this._query.filledPoints;
if (!stops) {
@@ -570,7 +568,7 @@ var OpenTripPlanner = new Lang.Class({
let request = new Soup.Message({ method: 'GET', uri: uri });
request.request_headers.append('Accept', 'application/json');
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.Status.OK) {
Utils.debug('Failed to get route plan from router ' +
routers[index] + ' ' + message);
@@ -578,22 +576,22 @@ var OpenTripPlanner = new Lang.Class({
} else {
callback(JSON.parse(message.response_body.data));
}
- }).bind(this));
- }).bind(this));
+ });
+ });
},
_fetchRoutesRecursive: function(routers, index, result, callback) {
if (index < routers.length) {
let router = routers[index];
- this._fetchRoutesForRouter(router, (function(response) {
+ this._fetchRoutesForRouter(router, (response) => {
if (response) {
Utils.debug('plan: ' + JSON.stringify(response, '', 2));
result.push(response);
}
this._fetchRoutesRecursive(routers, index + 1, result, callback);
- }).bind(this));
+ });
} else {
callback(result);
}
@@ -631,21 +629,21 @@ var OpenTripPlanner = new Lang.Class({
},
_fetchRoute: function() {
- this._fetchRouters((function(success) {
+ this._fetchRouters((success) => {
if (success) {
let points = this._query.filledPoints;
let routers = this._getRoutersForPoints(points);
if (routers.length > 0) {
- this._fetchRoutes(routers, (function(routes) {
+ this._fetchRoutes(routers, (routes) => {
let itineraries = [];
- routes.forEach((function(plan) {
+ routes.forEach((plan) => {
if (plan.plan && plan.plan.itineraries) {
itineraries =
itineraries.concat(
this._createItineraries(plan.plan.itineraries));
}
- }).bind(this));
+ });
if (itineraries.length === 0) {
/* don't reset query points, unlike for turn-based
@@ -655,7 +653,7 @@ var OpenTripPlanner = new Lang.Class({
} else {
this._recalculateItineraries(itineraries);
}
- }).bind(this));
+ });
} else {
Application.notificationManager.showMessage(_("No timetable data found for this
route."));
@@ -665,7 +663,7 @@ var OpenTripPlanner = new Lang.Class({
Application.notificationManager.showMessage(_("Route request failed."));
this._reset();
}
- }).bind(this));
+ });
},
_isOnlyWalkingItinerary: function(itinerary) {
@@ -676,10 +674,10 @@ var OpenTripPlanner = new Lang.Class({
// filter out itineraries with only walking
let newItineraries = [];
- itineraries.forEach((function(itinerary) {
+ itineraries.forEach((itinerary) => {
if (!this._isOnlyWalkingItinerary(itinerary))
newItineraries.push(itinerary);
- }).bind(this));
+ });
/* TODO: should we always calculate a walking itinerary to put at the
* top if the total distance is below some threashhold?
@@ -717,10 +715,10 @@ var OpenTripPlanner = new Lang.Class({
_recalculateItinerariesRecursive: function(itineraries, index) {
if (index < itineraries.length) {
- this._recalculateItinerary(itineraries[index], (function(itinerary) {
+ this._recalculateItinerary(itineraries[index], (itinerary) => {
itineraries[index] = itinerary;
this._recalculateItinerariesRecursive(itineraries, index + 1);
- }).bind(this));
+ });
} else {
/* filter out itineraries where there are intermediate walking legs
* that are too narrow time-wise, this is nessesary since running
@@ -732,16 +730,14 @@ var OpenTripPlanner = new Lang.Class({
*/
let filteredItineraries = [];
- itineraries.forEach((function(itinerary) {
+ itineraries.forEach((itinerary) => {
if (this._isItineraryRealistic(itinerary) &&
!this._isOnlyWalkingItinerary(itinerary))
filteredItineraries.push(itinerary);
- }).bind(this));
+ });
if (filteredItineraries.length > 0) {
- filteredItineraries.forEach((function(itinerary) {
- itinerary.adjustTimings();
- }).bind(this));
+ filteredItineraries.forEach((itinerary) => itinerary.adjustTimings());
/* sort itineraries, by departure time ascending if querying
* by leaving time, by arrival time descending when querying
@@ -815,11 +811,10 @@ var OpenTripPlanner = new Lang.Class({
if (!route) {
this._graphHopper.fetchRouteAsync(points,
RouteQuery.Transportation.PEDESTRIAN,
- (function(newRoute)
- {
+ (newRoute) => {
this._walkingRoutes[index] = newRoute;
callback(newRoute);
- }).bind(this));
+ });
} else {
callback(route);
}
@@ -834,7 +829,7 @@ var OpenTripPlanner = new Lang.Class({
* leg is a non-transit (walking), recalculate the route in its entire
* using walking
*/
- this._fetchWalkingRoute(this._query.filledPoints, (function(route) {
+ this._fetchWalkingRoute(this._query.filledPoints, (route) => {
let leg = this._createWalkingLeg(from, to, from.place.name,
to.place.name, route);
let newItinerary =
@@ -842,7 +837,7 @@ var OpenTripPlanner = new Lang.Class({
duration: route.time / 1000,
legs: [leg]});
callback(newItinerary);
- }).bind(this));
+ });
} else if (itinerary.legs.length === 1 && itinerary.legs[0].transit) {
// special case if there is extactly one transit leg
let leg = itinerary.legs[0];
@@ -860,28 +855,28 @@ var OpenTripPlanner = new Lang.Class({
/* add an extra walking leg to both the beginning and end of the
* itinerary
*/
- this._fetchWalkingRoute([from, startLeg], (function(firstRoute) {
+ this._fetchWalkingRoute([from, startLeg], (firstRoute) => {
let firstLeg =
this._createWalkingLeg(from, startLeg, from.place.name,
leg.from, firstRoute);
- this._fetchWalkingRoute([endLeg, to], (function(lastRoute) {
+ this._fetchWalkingRoute([endLeg, to], (lastRoute) => {
let lastLeg = this._createWalkingLeg(endLeg, to, leg.to,
to.place.name,
lastRoute);
itinerary.legs.unshift(firstLeg);
itinerary.legs.push(lastLeg);
callback(itinerary);
- }).bind(this));
- }).bind(this));
+ });
+ });
} else if (endWalkDistance >= MIN_WALK_ROUTING_DISTANCE) {
// add an extra walking leg to the end of the itinerary
- this._fetchWalkingRoute([endLeg, to], (function(lastRoute) {
+ this._fetchWalkingRoute([endLeg, to], (lastRoute) => {
let lastLeg =
this._createWalkingLeg(endLeg, to, leg.to,
to.place.name, lastRoute);
itinerary.legs.push(lastLeg);
callback(itinerary);
- }).bind(this));
+ });
} else {
/* if only there's only a walking leg to be added to the start
* let the recursive routine dealing with multi-leg itineraries
@@ -955,14 +950,14 @@ var OpenTripPlanner = new Lang.Class({
itinerary.legs.splice(index + 1, index + 1);
}
- this._fetchWalkingRoute([from, to], (function(route) {
+ this._fetchWalkingRoute([from, to], (route) => {
let newLeg =
this._createWalkingLeg(from, to, from.place.name,
toName, route);
itinerary.legs[index] = newLeg;
this._recalculateItineraryRecursive(itinerary, index + 1,
callback);
- }).bind(this));
+ });
} else {
/* introduce an additional walking leg calculated
* by GH in case the OTP starting point as far enough from
@@ -974,7 +969,7 @@ var OpenTripPlanner = new Lang.Class({
let distance = fromLoc.get_distance_from(toLoc) * 1000;
if (distance >= MIN_WALK_ROUTING_DISTANCE) {
- this._fetchWalkingRoute([from, to], (function(route) {
+ this._fetchWalkingRoute([from, to], (route) => {
let newLeg =
this._createWalkingLeg(from, to, from.place.name,
leg.from, route);
@@ -985,7 +980,7 @@ var OpenTripPlanner = new Lang.Class({
this._recalculateItineraryRecursive(itinerary,
index + 2,
callback);
- }).bind(this));
+ });
} else {
this._recalculateItineraryRecursive(itinerary, index + 1,
callback);
@@ -1035,7 +1030,7 @@ var OpenTripPlanner = new Lang.Class({
insertIndex = index;
}
let from = this._createQueryPointForCoord(finalTransitLeg.fromCoordinate);
- this._fetchWalkingRoute([from, to], (function(route) {
+ this._fetchWalkingRoute([from, to], (route) => {
let newLeg =
this._createWalkingLeg(from, to,
finalTransitLeg.from,
@@ -1044,7 +1039,7 @@ var OpenTripPlanner = new Lang.Class({
this._recalculateItineraryRecursive(itinerary,
insertIndex + 1,
callback);
- }).bind(this));
+ });
} else {
/* introduce an additional walking leg calculated by GH in
* case the OTP end point as far enough from the original
@@ -1056,7 +1051,7 @@ var OpenTripPlanner = new Lang.Class({
let distance = fromLoc.get_distance_from(toLoc) * 1000;
if (distance >= MIN_WALK_ROUTING_DISTANCE) {
- this._fetchWalkingRoute([from, to], (function(route) {
+ this._fetchWalkingRoute([from, to], (route) => {
let newLeg =
this._createWalkingLeg(from, to, leg.to,
to.place.name, route);
@@ -1067,7 +1062,7 @@ var OpenTripPlanner = new Lang.Class({
this._recalculateItineraryRecursive(itinerary,
index + 2,
callback);
- }).bind(this));
+ });
} else {
this._recalculateItineraryRecursive(itinerary, index + 1,
callback);
@@ -1092,14 +1087,14 @@ var OpenTripPlanner = new Lang.Class({
itinerary.legs.splice(index + 1, index + 1);
}
- this._fetchWalkingRoute([from, to], (function(route) {
+ this._fetchWalkingRoute([from, to], (route) => {
let newLeg = this._createWalkingLeg(from, to, leg.from,
leg.to, route);
itinerary.legs[index] = newLeg;
this._recalculateItineraryRecursive(itinerary,
index + 1,
callback);
- }).bind(this));
+ });
} else {
this._recalculateItineraryRecursive(itinerary, index + 1,
callback);
@@ -1122,9 +1117,7 @@ var OpenTripPlanner = new Lang.Class({
},
_createItineraries: function(itineraries) {
- return itineraries.map((function(itinerary) {
- return this._createItinerary(itinerary);
- }).bind(this));
+ return itineraries.map((itinerary) => this._createItinerary(itinerary));
},
_createItinerary: function(itinerary) {
@@ -1137,9 +1130,7 @@ var OpenTripPlanner = new Lang.Class({
},
_createLegs: function(legs) {
- return legs.map((function(leg) {
- return this._createLeg(leg);
- }).bind(this));
+ return legs.map((leg) => this._createLeg(leg));
},
/* check if a string is a valid hex RGB string */
@@ -1197,9 +1188,7 @@ var OpenTripPlanner = new Lang.Class({
_createIntermediateStops: function(leg) {
let stops = leg.intermediateStops;
- return stops.map((function(stop) {
- return this._createIntermediateStop(stop, leg);
- }).bind(this));
+ return stops.map((stop) => this._createIntermediateStop(stop, leg));
},
_createIntermediateStop: function(stop, leg) {
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 630ce42..d858ceb 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -63,11 +63,11 @@ var OSMConnection = new Lang.Class({
let uri = new Soup.URI(url);
let request = new Soup.Message({ method: 'GET', uri: uri });
- cancellable.connect((function() {
+ cancellable.connect(() => {
this._session.cancel_message(request, Soup.STATUS_CANCELLED);
- }).bind(this));
+ });
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.Status.OK) {
callback(false, message.status_code, null, type, null);
return;
@@ -81,7 +81,7 @@ var OSMConnection = new Lang.Class({
Utils.debug(e);
callback(false, message.status_code, null, type, e);
}
- }).bind(this));
+ });
},
_getQueryUrl: function(type, id) {
@@ -94,11 +94,11 @@ var OSMConnection = new Lang.Class({
proxy instance doesn't have a token set, we could safely count on
it being present in the keyring */
if (this._callProxy.get_token() === null) {
- Secret.password_lookup(SECRET_SCHEMA, {}, null, function(s, res) {
+ Secret.password_lookup(SECRET_SCHEMA, {}, null, (s, res) => {
this._onPasswordLookedUp(res,
comment,
callback);
- }.bind(this));
+ });
} else {
this._doOpenChangeset(comment, callback);
}
@@ -128,9 +128,8 @@ var OSMConnection = new Lang.Class({
call.set_method('PUT');
call.set_function('/changeset/create');
- call.invoke_async(null, (function(call, res, userdata) {
- this._onChangesetOpened(call, callback);
- }).bind(this));
+ call.invoke_async(null, (call, res, userdata) =>
+ { this._onChangesetOpened(call, callback); });
},
_onChangesetOpened: function(call, callback) {
@@ -152,9 +151,8 @@ var OSMConnection = new Lang.Class({
call.set_method('PUT');
call.set_function(this._getCreateOrUpdateFunction(object, type));
- call.invoke_async(null, (function(call, res, userdata) {
- this._onObjectUploaded(call, callback);
- }).bind(this));
+ call.invoke_async(null, (call, res, userdata) =>
+ { this._onObjectUploaded(call, callback); });
},
_onObjectUploaded: function(call, callback) {
@@ -175,9 +173,8 @@ var OSMConnection = new Lang.Class({
call.set_method('DELETE');
call.set_function(this._getDeleteFunction(object, type));
- call.invoke_async(null, (function(call, res, userdata) {
- this._onObjectDeleted(call, callback);
- }).bind(this));
+ call.invoke_async(null, (call, res, userdata) =>
+ { this._onObjectDeleted(call, callback); });
},
_onObjectDeleted: function(call, callback) {
@@ -194,9 +191,8 @@ var OSMConnection = new Lang.Class({
call.set_method('PUT');
call.set_function(this._getCloseChangesetFunction(changesetId));
- call.invoke_async(null, (function(call, res, userdata) {
- this._onChangesetClosed(call, callback);
- }).bind(this));
+ call.invoke_async(null, (call, res, userdata) =>
+ { this._onChangesetClosed(call, callback); });
},
_onChangesetClosed: function(call, callback) {
@@ -227,9 +223,9 @@ var OSMConnection = new Lang.Class({
/* OAuth proxy used for enrolling access tokens */
this._oauthProxy = Rest.OAuthProxy.new(CONSUMER_KEY, CONSUMER_SECRET,
OAUTH_ENDPOINT_URL, false);
- this._oauthProxy.request_token_async('request_token', 'oob', function(p, error, w, u) {
+ this._oauthProxy.request_token_async('request_token', 'oob', (p, error, w, u) => {
this._onRequestOAuthToken(error, callback);
- }.bind(this), this._oauthProxy, callback);
+ }, this._oauthProxy, callback);
},
_onRequestOAuthToken: function(error, callback) {
@@ -250,9 +246,9 @@ var OSMConnection = new Lang.Class({
let uri = new Soup.URI(loginUrl);
let msg = new Soup.Message({method: 'GET', uri: uri});
- this._session.queue_message(msg, (function(obj, message) {
+ this._session.queue_message(msg, (obj, message) => {
this._onLoginFormReceived(message, username, password, callback);
- }).bind(this));
+ });
},
_onLoginFormReceived: function(message, username, password, callback) {
@@ -289,12 +285,12 @@ var OSMConnection = new Lang.Class({
requestHeaders.append('Cookie', '_osm_session=' + sessionId);
msg.flags |= Soup.MessageFlags.NO_REDIRECT;
- this._session.queue_message(msg, (function(obj, message) {
+ this._session.queue_message(msg, (obj, message) => {
if (message.status_code === Soup.Status.MOVED_TEMPORARILY)
this._fetchAuthorizeForm(username, sessionId, callback);
else
callback(false, null);
- }).bind(this));
+ });
},
@@ -307,14 +303,14 @@ var OSMConnection = new Lang.Class({
msg.request_headers.append('Cookie',
'_osm_session=' + sessionId +
'; _osm_username=' + username);
- this._session.queue_message(msg, (function(obj, message) {
+ this._session.queue_message(msg, (obj, message) => {
if (message.status_code === Soup.Status.OK) {
let token = this._extractToken(message.response_body.data);
this._postAuthorizeForm(username, sessionId, token, callback);
} else {
callback(false, null);
}
- }).bind(this));
+ });
},
_postAuthorizeForm: function(username, sessionId, token, callback) {
@@ -334,18 +330,18 @@ var OSMConnection = new Lang.Class({
'_osm_session=' + sessionId +
'; _osm_username=' + username);
- this._session.queue_message(msg, (function(obj, message) {
+ this._session.queue_message(msg, (obj, message) => {
if (msg.status_code === Soup.Status.OK) {
callback(true, message.response_body.data);
} else
callback(false, null);
- }).bind(this));
+ });
},
requestOAuthAccessToken: function(code, callback) {
- this._oauthProxy.access_token_async('access_token', code, function(p, error, w, data) {
+ this._oauthProxy.access_token_async('access_token', code, (p, error, w, data) => {
this._onAccessOAuthToken(error, callback);
- }.bind(this), this._oauthProxy, callback);
+ }, this._oauthProxy, callback);
},
_onAccessOAuthToken: function(error, callback) {
@@ -363,9 +359,9 @@ var OSMConnection = new Lang.Class({
"OSM OAuth access token and secret",
this._oauthProxy.token + ":" +
this._oauthProxy.token_secret, null,
- function(source, result, userData) {
+ (source, result, userData) => {
this._onPasswordStored(result, callback);
- }.bind(this));
+ });
},
_onPasswordStored: function(result, callback) {
diff --git a/src/osmEdit.js b/src/osmEdit.js
index 6ea82e7..d74209b 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -106,9 +106,9 @@ var OSMEdit = new Lang.Class({
},
_openChangeset: function(object, type, comment, action, callback) {
- this._osmConnection.openChangeset(comment, (function(success, status, changesetId) {
+ this._osmConnection.openChangeset(comment, (success, status, changesetId) => {
this._onChangesetOpened(success, status, changesetId, object, type, action, callback);
- }).bind(this));
+ });
},
_onObjectUploaded: function(success, status, response, changesetId, callback) {
@@ -120,9 +120,9 @@ var OSMEdit = new Lang.Class({
_uploadObject: function(object, type, changesetId, callback) {
this._osmObject = object;
- this._osmConnection.uploadObject(object, type, changesetId, (function(success, status, response) {
+ this._osmConnection.uploadObject(object, type, changesetId, (success, status, response) => {
this._onObjectUploaded(success, status, response, changesetId, callback);
- }).bind(this));
+ });
},
deleteObject: function(object, type, comment, callback) {
@@ -139,9 +139,9 @@ var OSMEdit = new Lang.Class({
_deleteObject: function(object, type, changesetId, callback) {
this._osmObject = object;
- this._osmConnection.deleteObject(object, type, changesetId, (function(success, status, response) {
+ this._osmConnection.deleteObject(object, type, changesetId, (success, status, response) => {
this._onObjectDeleted(success, status, response, changesetId, callback);
- }).bind(this));
+ });
},
_closeChangeset: function(changesetId, callback) {
@@ -149,12 +149,12 @@ var OSMEdit = new Lang.Class({
},
performOAuthSignIn: function(username, password, callback) {
- this._osmConnection.requestOAuthToken(function(success) {
+ this._osmConnection.requestOAuthToken((success) => {
if (success)
this._onOAuthTokenRequested(username, password, callback);
else
callback(false, null);
- }.bind(this));
+ });
},
_onOAuthTokenRequested: function(username, password, callback) {
@@ -164,9 +164,9 @@ var OSMEdit = new Lang.Class({
},
requestOAuthAccessToken: function(code, callback) {
- this._osmConnection.requestOAuthAccessToken(code, (function(success, token) {
+ this._osmConnection.requestOAuthAccessToken(code, (success, token) => {
this._onOAuthAccessTokenRequested(success, callback);
- }).bind(this));
+ });
},
_onOAuthAccessTokenRequested: function(success, callback) {
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 18fcd23..cbbd3f3 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -308,22 +308,18 @@ var OSMEditDialog = new Lang.Class({
this._typeSearch.can_focus = true;
let typeSearchPopover = this._typeSearch.popover;
- typeSearchPopover.connect('selected', this._onTypeSelected.bind(this));
+ typeSearchPopover.connect('selected', () => this._onTypeSelected());
this._cancellable = new Gio.Cancellable();
- this._cancellable.connect((function() {
- this.response(Response.CANCELLED);
- }).bind(this));
+ this._cancellable.connect(() => this.response(Response.CANCELLED));
- this.connect('delete-event', (function() {
- this._cancellable.cancel();
- }).bind(this));
+ this.connect('delete-event', () => this._cancellable.cancel());
this._isEditing = false;
- this._nextButton.connect('clicked', this._onNextClicked.bind(this));
- this._cancelButton.connect('clicked', this._onCancelClicked.bind(this));
- this._backButton.connect('clicked', this._onBackClicked.bind(this));
- this._typeButton.connect('clicked', this._onTypeClicked.bind(this));
+ this._nextButton.connect('clicked', () => this._onNextClicked());
+ this._cancelButton.connect('clicked', () => this._onCancelClicked());
+ this._backButton.connect('clicked', () => this._onBackClicked());
+ this._typeButton.connect('clicked', () => this._onTypeClicked());
if (this._addLocation) {
this._headerBar.title = C_("dialog title", "Add to OpenStreetMap");
@@ -351,14 +347,14 @@ var OSMEditDialog = new Lang.Class({
this._originalTitle = this._headerBar.title;
this._updateRecentTypesList();
- this._recentTypesListBox.set_header_func(function (row, previous) {
+ this._recentTypesListBox.set_header_func((row, previous) => {
if (previous)
row.set_header(new Gtk.Separator());
});
- this._recentTypesListBox.connect('row-activated', (function(listbox, row) {
+ this._recentTypesListBox.connect('row-activated', (listbox, row) => {
this._onTypeSelected(null, row._key, row._value, row._title);
- }).bind(this));
+ });
},
_onNextClicked: function() {
@@ -413,9 +409,7 @@ var OSMEditDialog = new Lang.Class({
_updateType: function(key, value) {
/* clear out any previous type-related OSM tags */
- OSMTypes.OSM_TYPE_TAGS.forEach((function (tag) {
- this._osmObject.delete_tag(tag);
- }).bind(this));
+ OSMTypes.OSM_TYPE_TAGS.forEach((tag) => this._osmObject.delete_tag(tag));
this._osmObject.set_tag(key, value);
},
@@ -582,11 +576,9 @@ var OSMEditDialog = new Lang.Class({
styleContext.add_class('flat');
this._editorGrid.attach(deleteButton, 2, this._currentRow, 1, 1);
- deleteButton.connect('clicked', (function() {
+ deleteButton.connect('clicked', () => {
if (fieldSpec.subtags) {
- fieldSpec.subtags.forEach((function(key) {
- this._osmObject.delete_tag(key);
- }).bind(this));
+ fieldSpec.subtags.forEach((key) => this._osmObject.delete_tag(key));
} else {
this._osmObject.delete_tag(fieldSpec.tag);
}
@@ -598,7 +590,7 @@ var OSMEditDialog = new Lang.Class({
}
this._nextButton.sensitive = true;
this._updateAddFieldMenu();
- }).bind(this));
+ });
deleteButton.show();
},
@@ -636,18 +628,18 @@ var OSMEditDialog = new Lang.Class({
if (fieldSpec.placeHolder)
entry.placeholder_text = fieldSpec.placeHolder;
- entry.connect('changed', (function() {
+ entry.connect('changed', () => {
if (fieldSpec.rewriteFunc)
entry.text = fieldSpec.rewriteFunc(entry.text);
this._osmObject.set_tag(fieldSpec.tag, entry.text);
this._nextButton.sensitive = true;
- }).bind(this));
+ });
if (fieldSpec.hint) {
entry.secondary_icon_name = 'dialog-information-symbolic';
- entry.connect('icon-press', (function(entry, iconPos, event) {
+ entry.connect('icon-press', (entry, iconPos, event) => {
this._showHintPopover(entry, fieldSpec.hint);
- }).bind(this));
+ });
}
this._editorGrid.attach(entry, 1, this._currentRow, 1, 1);
@@ -667,16 +659,16 @@ var OSMEditDialog = new Lang.Class({
spinbutton.value = value;
spinbutton.numeric = true;
spinbutton.hexpand = true;
- spinbutton.connect('changed', (function() {
+ spinbutton.connect('changed', () => {
this._osmObject.set_tag(fieldSpec.tag, spinbutton.text);
this._nextButton.sensitive = true;
- }).bind(this, fieldSpec.tag, spinbutton));
+ });
if (fieldSpec.hint) {
spinbutton.secondary_icon_name = 'dialog-information-symbolic';
- spinbutton.connect('icon-press', (function(iconPos, event) {
+ spinbutton.connect('icon-press', (iconPos, event) => {
this._showHintPopover(spinbutton, fieldSpec.hint);
- }).bind(this));
+ });
}
this._editorGrid.attach(spinbutton, 1, this._currentRow, 1, 1);
@@ -697,10 +689,10 @@ var OSMEditDialog = new Lang.Class({
});
combobox.active_id = value;
combobox.hexpand = true;
- combobox.connect('changed', (function() {
- this._osmObject.set_tag(fieldSpec.tag, combobox.active_id);
+ combobox.connect('changed', () => {
+ this._osmObject.set_tag(fieldSpec.tag, combobox.active_id);
this._nextButton.sensitive = true;
- }).bind(this, fieldSpec.tag, combobox));
+ });
this._editorGrid.attach(combobox, 1, this._currentRow, 1, 1);
combobox.show();
@@ -751,10 +743,10 @@ var OSMEditDialog = new Lang.Class({
let hasValue = false;
if (fieldSpec.subtags) {
- fieldSpec.subtags.forEach((function(tag) {
+ fieldSpec.subtags.forEach((tag) => {
if (this._osmObject.get_tag(tag) !== null)
hasValue = true;
- }).bind(this));
+ });
} else {
hasValue = this._osmObject.get_tag(fieldSpec.tag) !== null;
}
@@ -769,21 +761,21 @@ var OSMEditDialog = new Lang.Class({
button.get_style_context().add_class('flat');
button.get_child().halign = Gtk.Align.START;
- button.connect('clicked', (function() {
+ button.connect('clicked', () => {
this._addFieldButton.active = false;
this._addOSMField(fieldSpec, '');
/* add a "placeholder" empty OSM tag to keep the add field
* menu updated, these tags will be filtered out if nothing
* is entered */
if (fieldSpec.subtags) {
- fieldSpec.subtags.forEach((function(tag) {
+ fieldSpec.subtags.forEach((tag) => {
this._osmObject.set_tag(tag, '');
- }).bind(this));
+ });
} else {
this._osmObject.set_tag(fieldSpec.tag, '');
}
this._updateAddFieldMenu();
- }).bind(this));
+ });
hasAllFields = false;
this._addFieldPopoverGrid.add(button);
diff --git a/src/osmTypePopover.js b/src/osmTypePopover.js
index d53fcf5..540700f 100644
--- a/src/osmTypePopover.js
+++ b/src/osmTypePopover.js
@@ -42,20 +42,16 @@ var OSMTypePopover = new Lang.Class({
_init: function(props) {
this.parent(props);
- this._list.connect('row-activated', (function(list, row) {
+ this._list.connect('row-activated', (list, row) => {
if (row)
this.emit('selected', row.key, row.value, row.title);
- }).bind(this));
+ });
},
showMatches: function(matches) {
- this._list.forall(function(row) {
- row.destroy();
- });
+ this._list.forall((row) => row.destroy());
- matches.forEach((function(type) {
- this._addRow(type);
- }).bind(this));
+ matches.forEach((type) => this._addRow(type));
this.show();
},
diff --git a/src/osmTypeSearchEntry.js b/src/osmTypeSearchEntry.js
index d9b9eeb..af6a1c3 100644
--- a/src/osmTypeSearchEntry.js
+++ b/src/osmTypeSearchEntry.js
@@ -39,11 +39,11 @@ var OSMTypeSearchEntry = new Lang.Class({
this._popover =
new OSMTypePopover.OSMTypePopover({relative_to: this});
- this.connect('size-allocate', (function(widget, allocation) {
+ this.connect('size-allocate', (widget, allocation) => {
/* Magic number to make the alignment pixel perfect. */
let width_request = allocation.width + 20;
this._popover.width_request = width_request;
- }).bind(this));
+ });
this.connect('search-changed', this._onSearchChanged.bind(this));
this.connect('activate', this._onSearchChanged.bind(this));
diff --git a/src/overpass.js b/src/overpass.js
index a872219..c8c0851 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -68,7 +68,7 @@ var Overpass = new Lang.Class({
let request = new Soup.Message({ method: 'GET',
uri: uri });
- this._session.queue_message(request, (function(obj, message) {
+ this._session.queue_message(request, (obj, message) => {
if (message.status_code !== Soup.KnownStatusCode.OK) {
callback(false, message.status_code, null);
return;
@@ -81,7 +81,7 @@ var Overpass = new Lang.Class({
} catch(e) {
callback(false, message.status_code);
}
- }).bind(this));
+ });
},
_populatePlace: function(place, overpassData) {
diff --git a/src/placeBubble.js b/src/placeBubble.js
index a402e69..780d10a 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -64,9 +64,7 @@ var PlaceBubble = new Lang.Class({
this.parent(params);
- Utils.load_icon(this.place.icon, 48, (function(pixbuf) {
- this.image.pixbuf = pixbuf;
- }).bind(this));
+ Utils.load_icon(this.place.icon, 48, (pixbuf) => this.image.pixbuf = pixbuf);
this._stack = ui.stack;
this._title = ui.labelTitle;
@@ -82,20 +80,20 @@ var PlaceBubble = new Lang.Class({
// If the place is stale, update from Overpass.
if (Application.placeStore.isStale(this.place)) {
- overpass.addInfo(this.place, (function(status, code) {
+ overpass.addInfo(this.place, (status, code) => {
this._populate(this.place);
Application.placeStore.updatePlace(this.place);
- }).bind(this));
+ });
} else {
let place = Application.placeStore.get(this.place);
this._populate(place);
}
} else if (this.place.store) {
- overpass.addInfo(this.place, (function(status, code) {
+ overpass.addInfo(this.place, (status, code) => {
this._populate(this.place);
Application.placeStore.addPlace(this.place,
PlaceStore.PlaceType.RECENT);
- }).bind(this));
+ });
} else {
this._populate(this.place);
}
@@ -181,16 +179,15 @@ var PlaceBubble = new Lang.Class({
},
_attachContent: function(content, expandedContent) {
- content.forEach((function(info) {
+ content.forEach((info) => {
let label = new Gtk.Label({ label: info,
visible: true,
use_markup: true,
halign: Gtk.Align.START });
this._boxContent.pack_start(label, false, true, 0);
- }).bind(this));
+ });
- expandedContent.forEach((function({ label, linkUrl, linkText, info },
- row) {
+ expandedContent.forEach(({ label, linkUrl, linkText, info }, row) => {
let widget;
if (label) {
@@ -223,13 +220,13 @@ var PlaceBubble = new Lang.Class({
else
// Expand over both columns if this row has no label
this._expandedContent.attach(widget, 0, row, 2, 1);
- }).bind(this));
+ });
},
_populate: function(place) {
let formatter = new PlaceFormatter.PlaceFormatter(place);
- let content = formatter.rows.map(function(row) {
+ let content = formatter.rows.map((row) => {
row = row.map(function(prop) {
return GLib.markup_escape_text(place[prop], -1);
});
@@ -286,13 +283,8 @@ var PlaceBubble = new Lang.Class({
// clear the view widgets to be able to re-populate an updated place
_clearView: function() {
- this._boxContent.get_children().forEach(function(child) {
- child.destroy();
- });
-
- this._expandedContent.get_children().forEach(function(child) {
- child.destroy();
- });
+ this._boxContent.get_children().forEach((child) => child.destroy());
+ this._expandedContent.get_children().forEach((child) => child.destroy());
},
_initEditButton: function() {
@@ -315,11 +307,11 @@ var PlaceBubble = new Lang.Class({
let dialog = osmEdit.createAccountDialog(this.get_toplevel(), true);
dialog.show();
- dialog.connect('response', (function(dialog, response) {
+ dialog.connect('response', (dialog, response) => {
dialog.destroy();
if (response === OSMAccountDialog.Response.SIGNED_IN)
this._edit();
- }).bind(this));
+ });
return;
}
@@ -332,7 +324,7 @@ var PlaceBubble = new Lang.Class({
let dialog = osmEdit.createEditDialog(this.get_toplevel(), this._place);
dialog.show();
- dialog.connect('response', (function(dialog, response) {
+ dialog.connect('response', (dialog, response) => {
dialog.destroy();
switch (response) {
@@ -347,6 +339,6 @@ var PlaceBubble = new Lang.Class({
default:
break;
}
- }).bind(this));
+ });
}
});
diff --git a/src/placeEntry.js b/src/placeEntry.js
index aa9429a..83eb454 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -100,7 +100,7 @@ var PlaceEntry = new Lang.Class({
this._popover = this._createPopover(numVisible, maxChars);
this.connect('activate', this._onActivate.bind(this));
- this.connect('search-changed', (function() {
+ this.connect('search-changed', () => {
if (this._cancellable)
this._cancellable.cancel();
@@ -116,13 +116,13 @@ var PlaceEntry = new Lang.Class({
this._popover.showCompletion();
else
this._popover.hide();
- }).bind(this));
+ });
if (parseOnFocusOut) {
- this.connect('focus-out-event', (function() {
+ this.connect('focus-out-event', () => {
this._parse();
return false;
- }).bind(this));
+ });
}
},
@@ -139,16 +139,16 @@ var PlaceEntry = new Lang.Class({
relative_to: this,
maxChars: maxChars});
- this.connect('size-allocate', (function(widget, allocation) {
+ this.connect('size-allocate', (widget, allocation) => {
// Magic number to make the alignment pixel perfect.
let width_request = allocation.width + 20;
popover.width_request = width_request;
- }).bind(this));
+ });
- popover.connect('selected', (function(widget, place) {
+ popover.connect('selected', (widget, place) => {
this.place = place;
popover.hide();
- }).bind(this));
+ });
return popover;
},
@@ -209,7 +209,7 @@ var PlaceEntry = new Lang.Class({
this._popover.showSpinner();
this._cancellable = new Gio.Cancellable();
- Application.geocodeService.search(this.text, bbox, this._cancellable, (function(places) {
+ Application.geocodeService.search(this.text, bbox, this._cancellable, (places) => {
if (!places) {
this.place = null;
this._popover.showNoResult();
@@ -217,6 +217,6 @@ var PlaceEntry = new Lang.Class({
}
this._popover.updateResult(places, this.text);
this._popover.showResult();
- }).bind(this));
+ });
}
});
diff --git a/src/placeFormatter.js b/src/placeFormatter.js
index 35870b8..71dadf6 100644
--- a/src/placeFormatter.js
+++ b/src/placeFormatter.js
@@ -60,11 +60,11 @@ var PlaceFormatter = new Lang.Class({
if (this._place instanceof StoredRoute.StoredRoute)
return this._place.viaString;
- return this.rows.map((function(row) {
- return row.map((function(prop) {
+ return this.rows.map((row) => {
+ return row.map((prop) => {
return this._place[prop];
- }).bind(this)).join(', ');
- }).bind(this)).join(', ');
+ }).join(', ');
+ }).join(', ');
},
_update: function() {
@@ -111,9 +111,7 @@ var PlaceFormatter = new Lang.Class({
},
_addRow: function(properties) {
- properties = properties.filter((function(prop) {
- return this._place[prop] ? true : false;
- }).bind(this));
+ properties = properties.filter((prop) => this._place[prop] ? true : false);
if (properties.length > 0)
this._rows.push(properties);
diff --git a/src/placePopover.js b/src/placePopover.js
index 5773b34..7ee7dfa 100644
--- a/src/placePopover.js
+++ b/src/placePopover.js
@@ -60,30 +60,26 @@ var PlacePopover = new Lang.Class({
this.parent(props);
this._entry = this.relative_to;
- this._entry.connect('notify::place', (function() {
- this._mode = Mode.ACTIVATED;
- }).bind(this));
+ this._entry.connect('notify::place', () => this._mode = Mode.ACTIVATED);
- Application.routingDelegator.graphHopper.route.connect('updated', (function() {
+ Application.routingDelegator.graphHopper.route.connect('updated', () => {
this._mode = Mode.ACTIVATED;
- }).bind(this));
+ });
- this._list.connect('row-activated', (function(list, row) {
- if (row)
- this.emit('selected', row.place);
- }).bind(this));
+ this._list.connect('row-activated', (list, row) => {
+ if (row)
+ this.emit('selected', row.place);
+ });
// Make sure we clear all selected rows when the search string change
- this._entry.connect('changed', (function() {
- this._list.unselect_all();
- }).bind(this));
+ this._entry.connect('changed', () => this._list.unselect_all());
// Do not show 'press enter to search' when we have
// selected rows in completion mode.
this._list.connect('selected-rows-changed',
this._updateHint.bind(this));
- this._list.set_header_func(function(row, before) {
+ this._list.set_header_func((row, before) => {
let header = new Gtk.Separator();
if (before)
row.set_header(header);
@@ -96,7 +92,7 @@ var PlacePopover = new Lang.Class({
// This silents warning at Maps exit about this widget being
// visible but not mapped.
- this.connect('unmap', function(popover) { popover.hide(); });
+ this.connect('unmap', (popover) => popover.hide());
},
showSpinner: function() {
@@ -152,29 +148,35 @@ var PlacePopover = new Lang.Class({
this.parent();
},
+<<<<<<< HEAD
updateResult: function(places, searchString) {
- this._list.forall(function(row) {
- row.destroy();
- });
+ this._list.forall((row) => { row.destroy(); });
+=======
+ updateResult(places, searchString) {
+ this._list.forall((row) => row.destroy());
+>>>>>>> 336ab5c6... fixup! WIP: Use ES6 arrow notation
- places.forEach((function(place) {
+ places.forEach((place) => {
if (!place.location)
return;
this._addRow(place, null, searchString);
- }).bind(this));
+ });
},
+<<<<<<< HEAD
updateCompletion: function(filter, searchString) {
- this._list.forall(function(row) {
- row.destroy();
- });
+ this._list.forall((row) => { row.destroy(); });
+=======
+ updateCompletion(filter, searchString) {
+ this._list.forall((row) => row.destroy());
+>>>>>>> 336ab5c6... fixup! WIP: Use ES6 arrow notation
- filter.foreach((function(model, path, iter) {
+ filter.foreach((model, path, iter) => {
let place = model.get_value(iter, PlaceStore.Columns.PLACE);
let type = model.get_value(iter, PlaceStore.Columns.TYPE);
this._addRow(place, type, searchString);
- }).bind(this));
+ });
},
_addRow: function(place, type, searchString) {
diff --git a/src/placeStore.js b/src/placeStore.js
index 9650b47..77577d7 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -99,10 +99,10 @@ var PlaceStore = new Lang.Class({
}
if (this.exists(place, PlaceType.RECENT)) {
- this._removeIf((function(model, iter) {
+ this._removeIf((model, iter) => {
let p = model.get_value(iter, Columns.PLACE);
return p.uniqueID === place.uniqueID;
- }).bind(this), true);
+ }, true);
}
this._addPlace(place, PlaceType.FAVORITE);
},
@@ -119,7 +119,7 @@ var PlaceStore = new Lang.Class({
if (this._numRecentPlaces === this._recentPlacesLimit) {
// Since we sort by added, the oldest recent will be
// the first one we encounter.
- this._removeIf((function(model, iter) {
+ this._removeIf((model, iter) => {
let type = model.get_value(iter, Columns.TYPE);
if (type === PlaceType.RECENT) {
@@ -129,7 +129,7 @@ var PlaceStore = new Lang.Class({
return true;
}
return false;
- }).bind(this), true);
+ }, true);
}
this._addPlace(place, PlaceType.RECENT);
this._numRecentPlaces++;
@@ -143,7 +143,7 @@ var PlaceStore = new Lang.Class({
return;
if (this._numRecentRoutes >= this._recentRoutesLimit) {
- this._removeIf((function(model, iter) {
+ this._removeIf((model, iter) => {
let type = model.get_value(iter, Columns.TYPE);
if (type === PlaceType.RECENT_ROUTE) {
@@ -153,7 +153,7 @@ var PlaceStore = new Lang.Class({
return true;
}
return false;
- }).bind(this), true);
+ }, true);
}
this._addPlace(stored, PlaceType.RECENT_ROUTE);
this._numRecentRoutes++;
@@ -168,7 +168,7 @@ var PlaceStore = new Lang.Class({
return;
try {
let jsonArray = JSON.parse(buffer);
- jsonArray.forEach((function({ place, type, added }) {
+ jsonArray.forEach(({ place, type, added }) => {
// We expect exception to be thrown in this line when parsing
// gnome-maps 3.14 or below place stores since the "place"
// key is not present.
@@ -187,7 +187,7 @@ var PlaceStore = new Lang.Class({
this._numRecentPlaces++;
}
this._setPlace(this.append(), p, type, added);
- }).bind(this));
+ });
} catch (e) {
throw new Error('failed to parse places file');
}
@@ -208,21 +208,21 @@ var PlaceStore = new Lang.Class({
if (!this.exists(place, placeType))
return;
- this._removeIf((function(model, iter) {
+ this._removeIf((model, iter) => {
let p = model.get_value(iter, Columns.PLACE);
if (p.uniqueID === place.uniqueID) {
this._typeTable[place.uniqueID] = null;
return true;
}
return false;
- }).bind(this), true);
+ }, true);
this._store();
},
getModelForPlaceType: function(placeType) {
let filter = new Gtk.TreeModelFilter({ child_model: this });
- filter.set_visible_func(function(model, iter) {
+ filter.set_visible_func((model, iter) => {
let type = model.get_value(iter, Columns.TYPE);
return (type === placeType);
});
@@ -232,7 +232,7 @@ var PlaceStore = new Lang.Class({
_store: function() {
let jsonArray = [];
- this.foreach(function(model, path, iter) {
+ this.foreach((model, path, iter) => {
let place = model.get_value(iter, Columns.PLACE);
let type = model.get_value(iter, Columns.TYPE);
let added = model.get_value(iter, Columns.ADDED);
@@ -263,9 +263,9 @@ var PlaceStore = new Lang.Class({
added]);
if (place.icon !== null) {
- Utils.load_icon(place.icon, _ICON_SIZE, (function(pixbuf) {
+ Utils.load_icon(place.icon, _ICON_SIZE, (pixbuf) => {
this.set(iter, [Columns.ICON], [pixbuf]);
- }).bind(this));
+ });
}
this._typeTable[place.uniqueID] = type;
},
@@ -273,14 +273,14 @@ var PlaceStore = new Lang.Class({
get: function(place) {
let storedPlace = null;
- this.foreach((function(model, path, iter) {
+ this.foreach((model, path, iter) => {
let p = model.get_value(iter, Columns.PLACE);
if (p.uniqueID === place.uniqueID) {
storedPlace = p;
return true;
}
return false;
- }).bind(this));
+ });
return storedPlace;
},
@@ -289,7 +289,7 @@ var PlaceStore = new Lang.Class({
return false;
let added = null;
- this.foreach(function(model, path, iter) {
+ this.foreach((model, path, iter) => {
let p = model.get_value(iter, Columns.PLACE);
if (p.uniqueID === place.uniqueID) {
@@ -312,18 +312,18 @@ var PlaceStore = new Lang.Class({
},
_removeIf: function(evalFunc, stop) {
- this.foreach((function(model, path, iter) {
+ this.foreach((model, path, iter) => {
if (evalFunc(model, iter)) {
this.remove(iter);
if (stop)
return true;
}
return false;
- }).bind(this));
+ });
},
updatePlace: function(place) {
- this.foreach((function(model, path, iter) {
+ this.foreach((model, path, iter) => {
let p = model.get_value(iter, Columns.PLACE);
if (p.uniqueID === place.uniqueID) {
@@ -332,6 +332,6 @@ var PlaceStore = new Lang.Class({
this._store();
return;
}
- }).bind(this));
+ });
}
});
diff --git a/src/printLayout.js b/src/printLayout.js
index 22db108..94e6a92 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -133,9 +133,7 @@ var PrintLayout = new Lang.Class({
},
_initSignals: function() {
- this.connect('render-complete', (function() {
- this.renderFinished = true;
- }).bind(this));
+ this.connect('render-complete', () => this.renderFinished = true);
},
_createMarker: function(turnPoint) {
@@ -160,23 +158,23 @@ var PrintLayout = new Lang.Class({
this._addRouteLayer(view);
- turnPoints.forEach((function(turnPoint) {
+ turnPoints.forEach((turnPoint) => {
locations.push(turnPoint.coordinate);
if (turnPoint.isStop()) {
markerLayer.add_marker(this._createMarker(turnPoint));
}
- }).bind(this));
+ });
view.ensure_visible(this._route.createBBox(locations), false);
if (view.state !== Champlain.State.DONE) {
- let notifyId = view.connect('notify::state', (function() {
+ let notifyId = view.connect('notify::state', () => {
if (view.state === Champlain.State.DONE) {
view.disconnect(notifyId);
let surface = view.to_surface(true);
if (surface)
this._addSurface(surface, x, y, pageNum);
}
- }).bind(this));
+ });
} else {
let surface = view.to_surface(true);
if (surface)
@@ -196,7 +194,7 @@ var PrintLayout = new Lang.Class({
let routeLayer = new Champlain.PathLayer({ stroke_width: _STROKE_WIDTH,
stroke_color: _STROKE_COLOR });
view.add_layer(routeLayer);
- this._route.path.forEach(function(node) { routeLayer.add_node(node); });
+ this._route.path.forEach((node) => routeLayer.add_node(node));
},
_drawInstruction: function(width, height, turnPoint) {
@@ -216,20 +214,20 @@ var PrintLayout = new Lang.Class({
instructionWidget.height_request = height;
/* Paint the background of the entry to be transparent */
- instructionEntry.connect('draw', (function(widget, cr) {
+ instructionEntry.connect('draw', (widget, cr) => {
cr.setSourceRGBA(0.0, 0.0, 0.0, 0.0);
cr.setOperator(Cairo.Operator.SOURCE);
cr.paint();
cr.setOperator(Cairo.Operator.OVER);
- }).bind(this));
+ });
instructionEntry.queue_draw();
instructionWidget.add(instructionEntry);
instructionWidget.set_valign(Gtk.Align.START);
- instructionWidget.connect('damage-event', (function(widget) {
+ instructionWidget.connect('damage-event', (widget) => {
let surface = widget.get_surface();
this._addSurface(surface, x, y, pageNum);
- }).bind(this));
+ });
},
_drawHeader: function(width, height) {
diff --git a/src/printOperation.js b/src/printOperation.js
index 640e2bb..7b89c2f 100644
--- a/src/printOperation.js
+++ b/src/printOperation.js
@@ -63,12 +63,12 @@ var PrintOperation = new Lang.Class({
let width = context.get_width();
let height = context.get_height();
- Mainloop.timeout_add(_MIN_TIME_TO_ABORT, (function() {
+ Mainloop.timeout_add(_MIN_TIME_TO_ABORT, () => {
if (this._operation.get_status() !== Gtk.PrintStatus.FINISHED) {
this._abortDialog.show();
}
return false;
- }).bind(this), null);
+ }, null);
if (selectedTransitItinerary) {
this._layout =
@@ -100,10 +100,10 @@ var PrintOperation = new Lang.Class({
_drawPage: function(operation, context, page_num, data) {
let cr = context.get_cairo_context();
- this._layout.surfaceObjects[page_num].forEach((function(so) {
+ this._layout.surfaceObjects[page_num].forEach((so) => {
cr.setSourceSurface(so.surface, so.x, so.y);
cr.paint();
- }).bind(this));
+ });
},
_runPrintOperation: function() {
diff --git a/src/routeQuery.js b/src/routeQuery.js
index a70d904..cd3b4b2 100644
--- a/src/routeQuery.js
+++ b/src/routeQuery.js
@@ -185,7 +185,7 @@ var RouteQuery = new Lang.Class({
index = this.points.length - 1;
this._points.splice(index, 0, point);
- point.connect('notify::place', (function() {
+ point.connect('notify::place', () => {
let placeStore = Application.placeStore;
if (point.place) {
if (!placeStore.exists(point.place, null)) {
@@ -195,7 +195,7 @@ var RouteQuery = new Lang.Class({
}
this.notify('points');
this._latest = point;
- }).bind(this));
+ });
this._latest = point;
this.notify('points');
this.emit('point-added', point, index);
diff --git a/src/searchPopover.js b/src/searchPopover.js
index 1860a39..0ae20c1 100644
--- a/src/searchPopover.js
+++ b/src/searchPopover.js
@@ -42,9 +42,7 @@ var SearchPopover = new Lang.Class({
// propagate the 'enter' key press if there is a selection.
this._entry.connect('key-press-event',
this._propagateKeys.bind(this));
- this._entry.connect('button-press-event', (function() {
- this._list.unselect_all();
- }).bind(this));
+ this._entry.connect('button-press-event', () => this._list.unselect_all());
},
_propagateKeys: function(entry, event) {
diff --git a/src/sendToDialog.js b/src/sendToDialog.js
index 18c7cf5..06a55f6 100644
--- a/src/sendToDialog.js
+++ b/src/sendToDialog.js
@@ -70,18 +70,16 @@ var SendToDialog = new Lang.Class({
this._headerBar.subtitle = this._place.name;
this._cancelButton.connect('clicked',
- this.response.bind(this, Response.CANCEL));
+ () => this.response(Response.CANCEL));
- this._chooseButton.connect('clicked', (function() {
+ this._chooseButton.connect('clicked', () => {
let row = this._list.get_selected_row();
this._activateRow(row);
- }).bind(this));
+ });
- this._list.connect('row-activated', (function(list, row) {
- this._activateRow(row);
- }).bind(this));
+ this._list.connect('row-activated', (list, row) => this._activateRow(row));
- this._list.set_header_func(function(row, before) {
+ this._list.set_header_func((row, before) => {
let horizontal = Gtk.Orientation.HORIZONTAL;
if (before)
diff --git a/src/serviceBackend.js b/src/serviceBackend.js
index f87e122..bbe7165 100644
--- a/src/serviceBackend.js
+++ b/src/serviceBackend.js
@@ -70,7 +70,7 @@ var ServiceBackend = new Lang.Class({
Utils.debug(this.name + ': ' + func);
- restCall.invoke_async(cancellable, (function(call, result) {
+ restCall.invoke_async(cancellable, (call, result) => {
let data = JSON.parse(call.get_payload());
let account = this.getAuthorizerAccount(authorizer);
@@ -93,7 +93,7 @@ var ServiceBackend = new Lang.Class({
message: this.getCallResultMessage(call, data) });
else
callback(account, data, null);
- }).bind(this));
+ });
},
performCheckIn: function(authorizer, checkIn, callback, cancellable) {
@@ -110,12 +110,12 @@ var ServiceBackend = new Lang.Class({
latitude,
longitude,
distance,
- (function(account, data, error) {
+ (account, data, error) => {
if (!error)
callback(account, this.createPlaces(data), error);
else
callback(account, [], error);
- }).bind(this),
+ },
cancellable);
},
diff --git a/src/settings.js b/src/settings.js
index d3dbc78..10827c3 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -33,11 +33,11 @@ var Settings = new Lang.Class({
_init: function(params) {
this.parent(params);
- this.list_keys().forEach((function(key) {
+ this.list_keys().forEach((key) => {
this._keyTypes[key] = this.get_value(key)
.get_type()
.dup_string();
- }).bind(this));
+ });
},
get: function(name) {
diff --git a/src/shortPrintLayout.js b/src/shortPrintLayout.js
index 5ee77fb..35010b9 100644
--- a/src/shortPrintLayout.js
+++ b/src/shortPrintLayout.js
@@ -51,11 +51,11 @@ var ShortPrintLayout = new Lang.Class({
let instructionMargin = _Instruction.SCALE_MARGIN * this._pageHeight;
let dy = 0;
- this._route.turnPoints.forEach(function(turnPoint) {
+ this._route.turnPoints.forEach((turnPoint) => {
dy = instructionHeight + instructionMargin;
this._adjustPage(dy);
this._drawInstruction(instructionWidth, instructionHeight, turnPoint);
this._cursorY += dy;
- }.bind(this));
+ });
}
});
diff --git a/src/sidebar.js b/src/sidebar.js
index d338422..01811af 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -161,14 +161,14 @@ var Sidebar = new Lang.Class({
},
_initQuerySignals: function() {
- this._query.connect('point-added', (function(obj, point, index) {
+ this._query.connect('point-added', (obj, point, index) => {
this._createRouteEntry(index, point);
- }).bind(this));
+ });
- this._query.connect('point-removed', (function(obj, point, index) {
+ this._query.connect('point-removed', (obj, point, index) => {
let row = this._entryList.get_row_at_index(index);
row.destroy();
- }).bind(this));
+ });
},
_cancelStore: function() {
@@ -191,19 +191,19 @@ var Sidebar = new Lang.Class({
this._entryList.insert(routeEntry, index);
if (type === RouteEntry.Type.FROM) {
- routeEntry.button.connect('clicked', (function() {
+ routeEntry.button.connect('clicked', () => {
let lastIndex = this._entryList.get_children().length;
this._query.addPoint(lastIndex - 1);
- }).bind(this));
+ });
this.bind_property('child-revealed',
routeEntry.entry, 'has_focus',
GObject.BindingFlags.DEFAULT);
} else if (type === RouteEntry.Type.VIA) {
- routeEntry.button.connect('clicked', (function() {
+ routeEntry.button.connect('clicked', () => {
let row = routeEntry.get_parent();
this._query.removePoint(row.get_index());
- }).bind(this));
+ });
} else if (type === RouteEntry.Type.TO) {
routeEntry.button.connect('clicked',
this._reverseRoutePoints.bind(this));
@@ -216,32 +216,32 @@ var Sidebar = new Lang.Class({
let route = Application.routingDelegator.graphHopper.route;
let transitPlan = Application.routingDelegator.openTripPlanner.plan;
- route.connect('reset', (function() {
+ route.connect('reset', () => {
this._clearInstructions();
let length = this._entryList.get_children().length;
for (let index = 1; index < (length - 1); index++) {
this._query.removePoint(index);
}
- }).bind(this));
+ });
- transitPlan.connect('reset', (function() {
+ transitPlan.connect('reset', () => {
this._clearTransitOverview();
this._showTransitOverview();
this._instructionStack.visible_child = this._transitWindow;
/* don't remove query points as with the turn-based routing,
* since we might get "no route" because of the time selected
* and so on */
- }).bind(this));
+ });
- transitPlan.connect('no-more-results', (function() {
+ transitPlan.connect('no-more-results', () => {
// remove the "load more" row, keep the empty row since it gives the separator
let numRows = this._transitOverviewListBox.get_children().length;
let loadMoreRow = this._transitOverviewListBox.get_row_at_index(numRows - 2);
this._transitOverviewListBox.remove(loadMoreRow);
- }).bind(this));
+ });
- this._query.connect('notify', (function() {
+ this._query.connect('notify', () => {
if (this._query.isValid()) {
this._instructionStack.visible_child = this._instructionSpinner;
} else {
@@ -256,15 +256,15 @@ var Sidebar = new Lang.Class({
if (this._storeRouteTimeoutId)
this._cancelStore();
- }).bind(this));
+ });
- route.connect('update', (function() {
+ route.connect('update', () => {
this._clearInstructions();
if (this._storeRouteTimeoutId)
this._cancelStore();
- this._storeRouteTimeoutId = Mainloop.timeout_add(5000, (function() {
+ this._storeRouteTimeoutId = Mainloop.timeout_add(5000, () => {
let placeStore = Application.placeStore;
let places = this._query.filledPoints.map(function(point) {
return point.place;
@@ -281,32 +281,32 @@ var Sidebar = new Lang.Class({
PlaceStore.PlaceType.RECENT_ROUTE);
}
this._storeRouteTimeoutId = 0;
- }).bind(this));
+ });
- route.turnPoints.forEach((function(turnPoint) {
+ route.turnPoints.forEach((turnPoint) => {
let row = new InstructionRow.InstructionRow({ visible: true,
turnPoint: turnPoint });
this._instructionList.add(row);
- }).bind(this));
+ });
/* Translators: %s is a time expression with the format "%f h" or "%f min" */
this._timeInfo.label = _("Estimated time: %s").format(Utils.prettyTime(route.time));
this._distanceInfo.label = Utils.prettyDistance(route.distance);
- }).bind(this));
+ });
- this._instructionList.connect('row-selected',(function(listbox, row) {
+ this._instructionList.connect('row-selected', (listbox, row) => {
if (row)
this._mapView.showTurnPoint(row.turnPoint);
- }).bind(this));
+ });
- transitPlan.connect('update', (function() {
+ transitPlan.connect('update', () => {
this._clearTransitOverview();
this._showTransitOverview();
this._populateTransitItineraryOverview();
- }).bind(this));
+ });
/* use list separators for the transit itinerary overview list */
- this._transitOverviewListBox.set_header_func(function(row, prev) {
+ this._transitOverviewListBox.set_header_func((row, prev) => {
if (prev)
row.set_header(new Gtk.Separator());
});
@@ -348,12 +348,12 @@ var Sidebar = new Lang.Class({
_populateTransitItineraryOverview: function() {
let plan = Application.routingDelegator.openTripPlanner.plan;
- plan.itineraries.forEach((function(itinerary) {
+ plan.itineraries.forEach((itinerary) => {
let row =
new TransitItineraryRow.TransitItineraryRow({ visible: true,
itinerary: itinerary });
this._transitOverviewListBox.add(row);
- }).bind(this));
+ });
/* add the "load more" row */
this._transitOverviewListBox.add(
new TransitMoreRow.TransitMoreRow({ visible: true }));
@@ -520,12 +520,12 @@ var Sidebar = new Lang.Class({
app_paintable: true });
this._dragWidget = new Gtk.OffscreenWindow({ visible: true });
- dragEntry.connect('draw', (function(widget, cr) {
+ dragEntry.connect('draw', (widget, cr) => {
cr.setSourceRGBA(0.0, 0.0, 0.0, 0.0);
cr.setOperator(Cairo.Operator.SOURCE);
cr.paint();
cr.setOperator(Cairo.Operator.OVER);
- }).bind(this));
+ });
this._dragWidget.add(dragEntry);
},
@@ -547,12 +547,8 @@ var Sidebar = new Lang.Class({
Gdk.DragAction.MOVE);
row.drag_dest_add_image_targets();
- dragIcon.connect('drag-begin', (function(icon, context) {
- this._onDragBegin(context, row);
- }).bind(this));
- dragIcon.connect('drag-end', (function(icon, context) {
- this._onDragEnd(context, row);
- }).bind(this));
+ dragIcon.connect('drag-begin', (icon, context) => this._onDragBegin(context, row));
+ dragIcon.connect('drag-end', (icon, context) => this._onDragEnd(context, row));
row.connect('drag-leave', this._dragUnhighlightRow.bind(this, row));
row.connect('drag-motion', this._onDragMotion.bind(this));
diff --git a/src/socialPlaceListBox.js b/src/socialPlaceListBox.js
index 9bcfb0f..13514fb 100644
--- a/src/socialPlaceListBox.js
+++ b/src/socialPlaceListBox.js
@@ -62,14 +62,14 @@ var SocialPlaceListBox = new Lang.Class({
params.activate_on_single_click = true;
this.parent(params);
- this.connect('row-activated', (function(list, row) {
+ this.connect('row-activated', (list, row) => {
if (!row.place) {
// "Show more results" row activated
row.destroy();
this._showBadMatches();
} else
this.emit('place-selected', row.place);
- }).bind(this));
+ });
},
get matches() {
diff --git a/src/storedRoute.js b/src/storedRoute.js
index ca3b870..96b3ad1 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -71,12 +71,12 @@ var StoredRoute = new Lang.Class({
if (geoclue)
currentLocation = geoclue.place;
- places.forEach((function(place) {
+ places.forEach((place) => {
if (currentLocation && place === currentLocation)
this._containsCurrentLocation = true;
this.places.push(new Place.Place({ place: place }));
- }).bind(this));
+ });
this.parent(params);
},
@@ -185,13 +185,13 @@ StoredRoute.fromJSON = function(obj) {
case 'route':
route = new Route.Route();
- prop.path = prop.path.map(function(coordinate) {
+ prop.path = prop.path.map((coordinate) => {
let lat = coordinate.latitude;
let lon = coordinate.longitude;
return new Champlain.Coordinate({ latitude: lat,
longitude: lon });
});
- prop.turnPoints = prop.turnPoints.map(function(turnPoint) {
+ prop.turnPoints = prop.turnPoints.map((turnPoint) => {
let lat = turnPoint.coordinate.latitude;
let lon = turnPoint.coordinate.longitude;
@@ -209,9 +209,7 @@ StoredRoute.fromJSON = function(obj) {
break;
case 'places':
- prop.forEach(function(p) {
- places.push(Place.Place.fromJSON(p));
- });
+ prop.forEach((p) => places.push(Place.Place.fromJSON(p)));
break;
}
}
diff --git a/src/transitArrivalRow.js b/src/transitArrivalRow.js
index e24e3b1..b2b903a 100644
--- a/src/transitArrivalRow.js
+++ b/src/transitArrivalRow.js
@@ -65,10 +65,10 @@ var TransitArrivalRow = new Lang.Class({
if (this._print)
this._arrivalLabel.max_width_chars = -1;
- this._eventBox.connect('event', (function(widget, event) {
+ this._eventBox.connect('event', (widget, event) => {
this._onEvent(event, lastLeg.toCoordinate);
return true;
- }).bind(this));
+ });
},
_onEvent: function(event, coord) {
diff --git a/src/transitBoardMarker.js b/src/transitBoardMarker.js
index fc6459b..cb5483b 100644
--- a/src/transitBoardMarker.js
+++ b/src/transitBoardMarker.js
@@ -96,7 +96,7 @@ var TransitBoardMarker = new Lang.Class({
height: ACTOR_SIZE });
- canvas.connect('draw', (function(canvas, cr) {
+ canvas.connect('draw', (canvas, cr) => {
cr.setOperator(Cairo.Operator.CLEAR);
cr.paint();
cr.setOperator(Cairo.Operator.OVER);
@@ -118,7 +118,7 @@ var TransitBoardMarker = new Lang.Class({
}
this._surface = cr.getTarget();
- }).bind(this));
+ });
let actor = new Clutter.Actor();
diff --git a/src/transitItineraryRow.js b/src/transitItineraryRow.js
index e4356fd..16acfae 100644
--- a/src/transitItineraryRow.js
+++ b/src/transitItineraryRow.js
@@ -61,13 +61,13 @@ var TransitItineraryRow = new Lang.Class({
let estimatedSpace = this._calculateEstimatedSpace();
let useContractedLabels = estimatedSpace > 28;
- this._itinerary.legs.forEach((function(leg, i) {
+ this._itinerary.legs.forEach((leg, i) => {
this._summaryGrid.add(this._createLeg(leg, useCompact,
useContractedLabels));
if (i !== length - 1)
this._summaryGrid.add(new Gtk.Label({ visible: true,
label: '-' }));
- }).bind(this));
+ });
},
/* calculate an estimated relative space-consuption for rendering,
diff --git a/src/transitLegRow.js b/src/transitLegRow.js
index 83cf6cb..9b8530d 100644
--- a/src/transitLegRow.js
+++ b/src/transitLegRow.js
@@ -150,19 +150,19 @@ var TransitLegRow = new Lang.Class({
this._expandButton.connect('clicked', this._expand.bind(this));
this._collapsButton.connect('clicked', this._collaps.bind(this));
- this._instructionList.connect('row-selected', (function(listbox, row) {
+ this._instructionList.connect('row-selected', (listbox, row) => {
if (row) {
if (row.turnPoint)
this._mapView.showTurnPoint(row.turnPoint);
else
this._mapView.showTransitStop(row.stop, this._leg);
}
- }).bind(this));
+ });
- this._eventBox.connect('event', (function(widget, event) {
+ this._eventBox.connect('event', (widget, event) => {
this._handleEventBox(event);
return true;
- }).bind(this));
+ });
this._isExpanded = false;
diff --git a/src/transitPrintLayout.js b/src/transitPrintLayout.js
index 947e38c..f397b6c 100644
--- a/src/transitPrintLayout.js
+++ b/src/transitPrintLayout.js
@@ -125,14 +125,14 @@ var TransitPrintLayout = new Lang.Class({
else
view.ensure_visible(leg.bbox, false);
if (view.state !== Champlain.State.DONE) {
- let notifyId = view.connect('notify::state', (function() {
+ let notifyId = view.connect('notify::state', () => {
if (view.state === Champlain.State.DONE) {
view.disconnect(notifyId);
let surface = view.to_surface(true);
if (surface)
this._addSurface(surface, x, y, pageNum);
}
- }).bind(this));
+ });
} else {
let surface = view.to_surface(true);
if (surface)
@@ -173,7 +173,7 @@ var TransitPrintLayout = new Lang.Class({
routeLayer.add_node(lastPoint);
}
- leg.polyline.forEach(function(node) { routeLayer.add_node(node) });
+ leg.polyline.forEach((node) => routeLayer.add_node(node));
/* like above, "stitch" the route segment with the next one if it's
* a walking leg, and not the last one
@@ -199,20 +199,20 @@ var TransitPrintLayout = new Lang.Class({
widget.get_style_context().add_class('printing-text');
// Paint the background of the row to be transparent
- widget.connect('draw', (function(widget, cr) {
+ widget.connect('draw', (widget, cr) => {
cr.setSourceRGBA(0.0, 0.0, 0.0, 0.0);
cr.setOperator(Cairo.Operator.SOURCE);
cr.paint();
cr.setOperator(Cairo.Operator.OVER);
- }).bind(this));
+ });
widget.queue_draw();
offscreenWindow.add(widget);
offscreenWindow.set_valign(Gtk.Align.START);
- offscreenWindow.connect('damage-event', (function (widget) {
+ offscreenWindow.connect('damage-event', (widget) => {
let surface = widget.get_surface();
this._addSurface(surface, x, y, pageNum);
- }).bind(this));
+ });
},
_drawInstruction: function(width, height, leg, start) {
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index d6732b5..1e31c65 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -67,9 +67,7 @@ var TurnPointMarker = new Lang.Class({
let actor;
if (this._queryPoint) {
this.draggable = true;
- this.connect('drag-finish', (function() {
- this._onMarkerDrag();
- }).bind(this));
+ this.connect('drag-finish', () => this._onMarkerDrag());
actor = this._actorFromIconName(this._turnPoint.iconName, 0);
} else {
let color = this._getColor();
@@ -105,11 +103,11 @@ var TurnPointMarker = new Lang.Class({
view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
view.goto_duration = 0;
- Utils.once(view, 'animation-completed', (function() {
+ Utils.once(view, 'animation-completed', () => {
view.zoom_level = turnPointZoomLevel;
view.center_on(this.latitude,
this.longitude);
- }).bind(this));
+ });
view.go_to(this.latitude, this.longitude);
},
diff --git a/src/wikipedia.js b/src/wikipedia.js
index 39caf2f..52c567d 100644
--- a/src/wikipedia.js
+++ b/src/wikipedia.js
@@ -68,7 +68,7 @@ function fetchArticleThumbnail(wiki, size, callback) {
return;
}
- session.queue_message(msg, function (session, msg) {
+ session.queue_message(msg, (session, msg) => {
if (msg.status_code !== Soup.KnownStatusCode.OK) {
log("Failed to request thumbnail: " + msg.reason_phrase);
callback(null);
@@ -106,7 +106,7 @@ function _fetchThumbnailImage(wiki, size, source, callback) {
let msg = new Soup.Message({ method: 'GET', uri: uri });
let session = _getSoupSession();
- session.queue_message(msg, function (session, msg) {
+ session.queue_message(msg, (session, msg) => {
if (msg.status_code !== Soup.KnownStatusCode.OK) {
log("Failed to download thumbnail: " + msg.reason_phrase);
callback(null);
diff --git a/src/zoomInNotification.js b/src/zoomInNotification.js
index 382ecf3..3b947c8 100644
--- a/src/zoomInNotification.js
+++ b/src/zoomInNotification.js
@@ -39,7 +39,7 @@ var ZoomInNotification = Lang.Class({
let ui = Utils.getUIObject('zoom-in-notification', [ 'grid',
'okButton' ]);
- ui.okButton.connect('clicked', this._onZoomIn.bind(this));
+ ui.okButton.connect('clicked', () => this._onZoomIn());
this._ui.body.add(ui.grid);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]