@@ -207,23 +207,33 @@ MmtMap.clickInteractions = {
207
207
208
208
popupHtmlTemplate : '<div class="popup_header"><img src="<%= image %>" alt="Image of <%= name %>" /><p class="text-center feature_title"><%= name %></p><br /></div>' ,
209
209
210
+ noThumbPopupHtmlTemplate : '<div class="popup_header" style="margin-top: 10px;"><p class="text-center feature_title"><%= name %></p><br /></div>' ,
211
+
210
212
popupAudioFileHtmlTemplate : '<div class="player popup_player <%= playerId %>" id="<%= playerId %>"><div id="play_button_container"><a href="#" class="play" data-audio="<%= url %>"><img src="/static/img/play.svg" alt="play" class="play_button" /></a></div><div class="player_display"><span class="player_timer">--:--</span><div class="progress_bar_container"><div class="progress_bar_fill"></div></div></div></div><p class="text-center player_title"><strong>Listen: </strong><%= playerTitle %></p><hr />' ,
211
213
212
214
213
215
clickFeature : function ( source , sourceLayer , feature , id , coords ) {
214
216
// Loads the feature from the server and adds a large click popup with an audio player (if there is an audio file related to it)
215
217
218
+
219
+
216
220
$ . get ( 'api/1.0/features/' + sourceLayer + '/' + id , function ( data ) {
217
221
// Construct the HTML for the popup and add it to the map
218
-
219
222
let popupPlayerId = undefined ;
220
- let popupHtml = _ . template ( MmtMap . clickInteractions . popupHtmlTemplate ) ;
221
-
222
- popupHtml = popupHtml ( {
223
- image : data . properties . popup_image ,
224
- name : data . properties . name
225
- } ) ;
226
-
223
+ let popupHtml = undefined ;
224
+
225
+ if ( data . properties . popup_image . length > 0 ) {
226
+ popupHtml = _ . template ( MmtMap . clickInteractions . popupHtmlTemplate ) ;
227
+ popupHtml = popupHtml ( {
228
+ image : data . properties . popup_image ,
229
+ name : data . properties . name
230
+ } ) ;
231
+ } else {
232
+ popupHtml = _ . template ( MmtMap . clickInteractions . noThumbPopupHtmlTemplate ) ;
233
+ popupHtml = popupHtml ( {
234
+ name : data . properties . name
235
+ } ) ;
236
+ }
227
237
228
238
// If there is an audio file attached to the feature, add a player
229
239
if ( data . properties . popup_audio_file != null ) {
@@ -235,12 +245,10 @@ MmtMap.clickInteractions = {
235
245
playerId : popupPlayerId ,
236
246
url : data . properties . popup_audio_file . url ,
237
247
playerTitle : data . properties . popup_audio_title
238
- } ) ;
239
- popupHtml = popupHtml + popupAudioFileHtml ;
248
+ } ) ;
240
249
}
241
250
242
251
243
-
244
252
let buttonHtml = '<div class="text-center"><br /><button type="button" class="btn btn-sm btn-light read_more" href="#">Read More</button> <button type="button" class="btn btn-sm btn-light close_popup">Close</button></div>' ;
245
253
246
254
popupHtml = popupHtml + buttonHtml ;
0 commit comments