Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panoramax: Adopt "copy id" feature from mapillary #10856

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion css/60_photos.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ li.list-item-photos.active:after {
border-radius: 0;
padding: 5px;
position: absolute;
right: 5px;
top: 5px;
z-index: 50;
width: fit-content;
}

.photoviewer button.thumb-hide.right {
right: 5px;
}

.photoviewer button.thumb-hide.left {
left: 5px;
}

.photoviewer button.set-photo-from-viewer {
Expand Down
37 changes: 25 additions & 12 deletions modules/ui/photoviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function uiPhotoviewer(context) {
function photoviewer(selection) {
selection
.append('button')
.attr('class', 'thumb-hide')
.attr('class', 'thumb-hide right')
.attr('title', t('icons.close'))
.on('click', function () {
if (services.streetside) { services.streetside.hideViewer(context); }
Expand All @@ -34,6 +34,17 @@ export function uiPhotoviewer(context) {
.append('div')
.call(svgIcon('#iD-icon-close'));

selection
.append('button')
.attr('class', 'thumb-hide left')
.attr('title', t('icons.copy'))
.on('click', async (e) => {
preventDefault(e);
await window.navigator.clipboard.writeText(getPhotoData().photoId);
})
.append('div')
.call(svgIcon('#iD-operation-copy'));

function preventDefault(d3_event) {
d3_event.preventDefault();
}
Expand Down Expand Up @@ -76,7 +87,7 @@ export function uiPhotoviewer(context) {

function setPhotoFromViewerButton() {
if (services.mapillary.isViewerOpen()) {
if (context.mode().id !== 'select' || !(layerStatus('mapillary') && getServiceId() === 'mapillary')) {
if (context.mode().id !== 'select' || !(layerStatus('mapillary') && getPhotoData()?.serviceId === 'mapillary')) {
buttonRemove();
} else {
if (selection.select('.set-photo-from-viewer').empty()) {
Expand Down Expand Up @@ -113,16 +124,6 @@ export function uiPhotoviewer(context) {
return layer.enabled();
}

function getServiceId() {
const hash = utilStringQs(window.location.hash);
let serviceId;
if (hash.photo) {
let result = hash.photo.split('/');
serviceId = result[0];
}
return serviceId;
}

function buttonCreate() {
const button = selection.selectAll('.set-photo-from-viewer').data([0]);
const buttonEnter = button.enter()
Expand Down Expand Up @@ -189,6 +190,18 @@ export function uiPhotoviewer(context) {
}
}

function getPhotoData() {
const hash = utilStringQs(window.location.hash);
let serviceId;
let photoId;
if (hash.photo) {
let result = hash.photo.split('/');
serviceId = result[0];
photoId = result.slice(1).join('/');
}
return { serviceId, photoId };
}

function buildResizeListener(target, eventName, dispatch, options) {

var resizeOnX = !!options.resizeOnX;
Expand Down