Skip to content

Commit

Permalink
added jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiapezzotti committed Aug 22, 2024
1 parent a773d0a commit 2bd38e0
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 15 deletions.
53 changes: 53 additions & 0 deletions modules/renderer/photos.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,30 @@ export function rendererPhotos(context) {
window.location.replace('#' + utilQsString(hash, true));
}

/**
* @returns The layer ID
*/
photos.overlayLayerIDs = function() {
return _layerIDs;
};

/**
* @returns All the photo types
*/
photos.allPhotoTypes = function() {
return _allPhotoTypes;
};

/**
* @returns The date filters value
*/
photos.dateFilters = function() {
return _dateFilters;
};

/**
* @returns The year date filter value
*/
photos.yearSliderValue = function() {
return _yearSliderValue;
};
Expand All @@ -55,6 +67,12 @@ export function rendererPhotos(context) {
return val === _dateFilters[0] ? _fromDate : _toDate;
};

/**
* Sets the date filter (min/max date)
* @param {*} type Either 'fromDate' or 'toDate'
* @param {*} val The actual Date
* @param {boolean} updateUrl Whether the URL should update or not
*/
photos.setDateFilter = function(type, val, updateUrl) {
// validate the date
var date = val && new Date(val);
Expand Down Expand Up @@ -85,6 +103,11 @@ export function rendererPhotos(context) {
}
};

/**
* Sets the username filter
* @param {string} val The username
* @param {boolean} updateUrl Whether the URL should update or not
*/
photos.setUsernameFilter = function(val, updateUrl) {
if (val && typeof val === 'string') val = val.replace(/;/g, ',').split(',');
if (val) {
Expand All @@ -104,6 +127,11 @@ export function rendererPhotos(context) {
}
};

/**
* Util function to set the slider date filter
* @param {*} year The slider value
* @param {boolean} updateUrl whether the URL should update or not
*/
photos.setFromYearFilter = function(year, updateUrl){

_yearSliderValue = year;
Expand All @@ -127,6 +155,11 @@ export function rendererPhotos(context) {
}
};

/**
* Util function to set the slider date filter
* @param {*} val Either 'panoramic' or 'flat'
* @param {boolean} updateUrl Whether the URL should update or not
*/
photos.togglePhotoType = function(val, updateUrl) {
var index = _shownPhotoTypes.indexOf(val);
if (index !== -1) {
Expand All @@ -147,6 +180,11 @@ export function rendererPhotos(context) {
return photos;
};

/**
* Updates the URL with new values
* @param {*} val value to save
* @param {string} property Name of the value
*/
function setUrlFilterValue(property, val) {
if (!window.mocha) {
var hash = utilStringQs(window.location.hash);
Expand All @@ -166,20 +204,32 @@ export function rendererPhotos(context) {
return layer && layer.supported() && layer.enabled();
}

/**
* @returns If the Date filter should be drawn
*/
photos.shouldFilterByDate = function() {
return false;
};

/**
* @returns If the Date Slider filter should be drawn
*/
photos.shouldFilterDateBySlider = function(){
return showsLayer('mapillary') || showsLayer('kartaview') || showsLayer('mapilio')
|| showsLayer('streetside') || showsLayer('vegbilder') || showsLayer('panoramax');
};

/**
* @returns If the Photo Type filter should be drawn
*/
photos.shouldFilterByPhotoType = function() {
return showsLayer('mapillary') ||
(showsLayer('streetside') && showsLayer('kartaview')) || showsLayer('vegbilder') || showsLayer('panoramax');
};

/**
* @returns If the Username filter should be drawn
*/
photos.shouldFilterByUsername = function() {
return !showsLayer('mapillary') && showsLayer('kartaview') && !showsLayer('streetside') || showsLayer('panoramax');
};
Expand Down Expand Up @@ -210,6 +260,9 @@ export function rendererPhotos(context) {
return _usernames;
};

/**
* Inits the streetlevel layer given the saved values in the URL
*/
photos.init = function() {
var hash = utilStringQs(window.location.hash);
var parts;
Expand Down
15 changes: 14 additions & 1 deletion modules/services/pannellum_photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export default {
]);
},

/**
* Shows the photo frame if hidden
* @param {*} context the HTML wrap of the frame
*/
showPhotoFrame: function (context) {
const isHidden = context.selectAll('.photo-frame.pannellum-frame.hide').size();

Expand All @@ -105,8 +109,12 @@ export default {
}

return this;
},
},

/**
* Hides the photo frame if shown
* @param {*} context the HTML wrap of the frame
*/
hidePhotoFrame: function (viewerContext) {
viewerContext
.select('photo-frame.pannellum-frame')
Expand All @@ -115,6 +123,11 @@ export default {
return this;
},

/**
* Renders an image inside the frame
* @param {*} data the image data, it should contain an image_path attribute, a link to the actual image.
* @param {boolean} keepOrientation if true, HFOV, pitch and yaw will be kept between images
*/
selectPhoto: function (data, keepOrientation) {
const {key} = data;
if ( !(key in _currScenes) ) {
Expand Down
Loading

0 comments on commit 2bd38e0

Please sign in to comment.