Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
Add Click
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrneDev committed Sep 25, 2018
1 parent 092bd43 commit 147b091
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^0.1.0-beta.7"
"flarum/core": "0.1.0-beta.7"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 9 additions & 2 deletions js/forum/dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ System.register('reflar/geotags/components/GeotagModal', ['flarum/components/Mod
value: function onready() {
var _this2 = this;

if (this.geotags.length > 1) {
if (m.route().includes('/t/') || this.geotags.length > 1) {
$('#modal').on('shown.bs.modal', function () {
_this2.loadMap();
});
Expand Down Expand Up @@ -448,7 +448,13 @@ System.register('reflar/geotags/components/GeotagModal', ['flarum/components/Mod
var latLong = new OpenLayers.LonLat(geotag.lng(), geotag.lat()).transform(new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
markers.addMarker(new OpenLayers.Marker(latLong, new OpenLayers.Icon(markerUrl, iconSize, new OpenLayers.Pixel(-(iconSize.w / 2), -iconSize.h))));
var marker = new OpenLayers.Marker(latLong, new OpenLayers.Icon(markerUrl, iconSize, new OpenLayers.Pixel(-(iconSize.w / 2), -iconSize.h)));

marker.events.register('click', marker, function () {
m.route(app.route.discussion(app.store.getById('discussions', geotag.discussionId())));
});

markers.addMarker(marker);
});
map.zoomToExtent(markers.getDataExtent());
this.geotags = null;
Expand Down Expand Up @@ -678,6 +684,7 @@ System.register('reflar/geotags/models/Geotag', ['flarum/Model', 'flarum/utils/m
lat: Model.attribute('lat'),
lng: Model.attribute('lng'),
tagSlug: Model.attribute('tag_slug'),
discussionId: Model.attribute('discussion_id'),
markerColor: Model.attribute('marker_color')
}));

Expand Down
10 changes: 8 additions & 2 deletions js/forum/src/components/GeotagModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class GeotagModal extends Modal {
}

onready() {
if (this.geotags.length > 1) {
if (m.route().includes('/t/') || this.geotags.length > 1) {
$('#modal').on('shown.bs.modal', () => {
this.loadMap()
})
Expand Down Expand Up @@ -66,7 +66,13 @@ export default class GeotagModal extends Modal {
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
markers.addMarker(new OpenLayers.Marker(latLong, new OpenLayers.Icon(markerUrl, iconSize, new OpenLayers.Pixel(-(iconSize.w / 2), -iconSize.h))));
var marker = new OpenLayers.Marker(latLong, new OpenLayers.Icon(markerUrl, iconSize, new OpenLayers.Pixel(-(iconSize.w / 2), -iconSize.h)));

marker.events.register('click', marker, () => {
m.route(app.route.discussion(app.store.getById('discussions', geotag.discussionId())));
});

markers.addMarker(marker);
});
map.zoomToExtent(markers.getDataExtent());
this.geotags = null;
Expand Down
1 change: 1 addition & 0 deletions js/lib/models/Geotag.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default class Geotag extends mixin(Model, {
lat: Model.attribute('lat'),
lng: Model.attribute('lng'),
tagSlug: Model.attribute('tag_slug'),
discussionId: Model.attribute('discussion_id'),
markerColor: Model.attribute('marker_color')
}) {}
1 change: 1 addition & 0 deletions src/Api/Serializer/GeotagBasicSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected function getDefaultAttributes($geotag)

if ($post) {
$attributes['post_id'] = $post->id;
$attributes['discussion_id'] = $post->discussion->id;
$tag = $post->discussion->tags[0];
if ($tag) {
$attributes['marker_color'] = $tag->color;
Expand Down

0 comments on commit 147b091

Please sign in to comment.