From 9cf2dd391e055c87be74847b65cb5c4e35218d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Sj=C3=B6berg?= Date: Tue, 9 Jul 2013 17:03:19 -0500 Subject: [PATCH] Add cover photo submitter, cover photo votes, and portal details to large portal display dialog. --- code/boot.js | 24 ++++++++++++------- code/portal_detail_display.js | 36 +++++++++++++++++++++++++++- code/portal_detail_display_tools.js | 37 +++++++++++++++++++++++++++++ style.css | 15 ++++++++++++ 4 files changed, 103 insertions(+), 9 deletions(-) diff --git a/code/boot.js b/code/boot.js index 2a4eb924..4b257942 100644 --- a/code/boot.js +++ b/code/boot.js @@ -10,15 +10,23 @@ window.showLayerChooser = true; window.setupLargeImagePreview = function() { $('#portaldetails').on('click', '.imgpreview', function() { var img = $(this).find('img')[0]; + var details = $(this).find('div.portalDetails')[0]; //dialogs have 12px padding around the content - var dlgWidth = Math.max(img.naturalWidth+24,400); - dialog({ - html: '
' + img.outerHTML + '
', - title: $(this).parent().find('h3.title').text(), - width: dlgWidth, - }); - - }); + var dlgWidth = Math.max(img.naturalWidth+24,500); + if (details) { + dialog({ + html: '
' + img.outerHTML + '
' + details.outerHTML, + title: $(this).parent().find('h3.title').text(), + width: dlgWidth, + }); + } else { + dialog({ + html: '
' + img.outerHTML + '
', + title: $(this).parent().find('h3.title').text(), + width: dlgWidth, + }); + } + }); } // adds listeners to the layer chooser such that a long press hides diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index a46e4313..8ace8f9a 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -50,6 +50,39 @@ window.renderPortalDetails = function(guid) { var perma = '/intel?ll='+lat+','+lng+'&z=17&pll='+lat+','+lng; var imgTitle = 'title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."'; var poslinks = 'window.showPortalPosLinks('+lat+','+lng+',\''+escapeJavascriptString(d.portalV2.descriptiveText.TITLE)+'\')'; + var portalDetailObj = window.getPortalDescriptionFromDetailsExtended(d); + + + var portalDetailedDescription = ''; + + if(portalDetailObj) { + portalDetailedDescription = ''; + if(portalDetailObj.submitter.name.length > 0) { + if(portalDetailObj.submitter.team) { + submitterSpan = ''; + } else { + submitterSpan = ''; + } + portalDetailedDescription += ''; + } + + if(d.portalV2.descriptiveText.ADDRESS) { + portalDetailedDescription += ''; + } + + if(portalDetailObj.description) { + portalDetailedDescription += ''; + } + + if(portalDetailObj.submitter.link.length > 0) { + portalDetailedDescription += ''; + } + + portalDetailedDescription += '
Photo submitted by:' + submitterSpan + + portalDetailObj.submitter.name + ' (' + portalDetailObj.submitter.voteCount + ' votes)
Address:' + d.portalV2.descriptiveText.ADDRESS + '
Description:' + portalDetailObj.description + '
Link to original:' + portalDetailObj.submitter.link + '
'; + } + $('#portaldetails') .attr('class', TEAM_TO_CSS[getTeam(d)]) @@ -58,7 +91,8 @@ window.renderPortalDetails = function(guid) { + 'X' // help cursor via ".imgpreview img" + '
' - + '' + + '
'+ portalDetailedDescription + '
' + + '
' + ''+Math.floor(getPortalLevel(d))+'' + '' + '
'+getModDetails(d)+'
' diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index f9886389..085887cc 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -23,6 +23,43 @@ window.getPortalDescriptionFromDetails = function(details) { return desc; } +// Grabs more info, including the submitter name for the current main +// portal image +window.getPortalDescriptionFromDetailsExtended = function(details) { + var descObj = details.portalV2.descriptiveText; + var photoStreamObj = details.photoStreamInfo; + + var submitterObj = new Object(); + submitterObj.type = ""; + submitterObj.name = "Unknown"; + submitterObj.team = ""; + submitterObj.link = ""; + submitterObj.voteCount = 0; + + if(photoStreamObj && photoStreamObj.hasOwnProperty("coverPhoto") && photoStreamObj.coverPhoto.hasOwnProperty("attributionMarkup")) { + var attribution = photoStreamObj.coverPhoto.attributionMarkup; + submitterObj.type = attribution[0]; + if(attribution[1].hasOwnProperty("plain")) + submitterObj.name = attribution[1].plain; + if(attribution[1].hasOwnProperty("team")) + submitterObj.team = attribution[1].team; + if(attribution[1].hasOwnProperty("attributionLink")) + submitterObj.link = attribution[1].attributionLink; + if(photoStreamObj.coverPhoto.hasOwnProperty("voteCount")) + submitterObj.voteCount = photoStreamObj.coverPhoto.voteCount; + } + + + var portalDetails = { + title: descObj.TITLE, + description: descObj.DESCRIPTION, + address: descObj.ADDRESS, + submitter: submitterObj + }; + + return portalDetails; +} + // given portal details, returns html code to display mod details. window.getModDetails = function(d) { diff --git a/style.css b/style.css index ea62cedc..ad7cf9bd 100644 --- a/style.css +++ b/style.css @@ -514,6 +514,10 @@ h3 { display: none; } +.imgpreview .portalDetails { + display: none; +} + #level { font-size: 40px; text-shadow: -1px -1px #000, 1px -1px #000, -1px 1px #000, 1px 1px #000, 0 0 5px #fff; @@ -939,3 +943,14 @@ td + td { } +.portal_details tr { + padding-bottom: 1em; +} + + +.portal_details td:first-of-type { + min-width: 10em; + vertical-align: top; +} + +