diff --git a/akvo/rsr/static/rsr/v3/css/src/main.css b/akvo/rsr/static/rsr/v3/css/src/main.css index 3996f70d97..d09a621f63 100755 --- a/akvo/rsr/static/rsr/v3/css/src/main.css +++ b/akvo/rsr/static/rsr/v3/css/src/main.css @@ -1,7 +1,7 @@ @charset "UTF-8"; /*--------------------------------------------------------------------------------- - Title: Akvo RSR v3 + Title: Akvo RSR v3 Author: Loic Sans, loic@akvo.org /*---------------------------------------------------------------------------------*/ @@ -191,7 +191,7 @@ span.twitter-typeahead .tt-suggestion > p { padding: 3px 20px; clear: both; font-weight: normal; - line-height: 1.42857; + line-height: 1.42857143; color: #333333; white-space: nowrap; } @@ -1153,7 +1153,8 @@ div.textBlock { .organisationDetail .orgDescr { background-color: rgba(244, 116, 107, 0.1); } .organisationDetail .orgDescr p { - padding-left: 20px; } + padding-left: 20px; + color: rgba(32, 32, 36, 0.45); } .organisationDetail h1 { margin-top: 0; margin-bottom: 20px; @@ -1170,11 +1171,14 @@ div.textBlock { width: 35%; margin-left: 5px; } .organisationDetail .orgDetails { - background: rgba(255, 255, 255, 0.45); + background: rgba(255, 255, 255, 0.65); -moz-border-radius: 5px; -o-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } + @media only screen and (max-width: 768px) { + .organisationDetail .orgDetails { + padding: 10px 15px; } } /* Update Page */ .updateMain h1 { diff --git a/akvo/rsr/static/rsr/v3/css/src/main.scss b/akvo/rsr/static/rsr/v3/css/src/main.scss index 119f2d76a2..da63e41fde 100755 --- a/akvo/rsr/static/rsr/v3/css/src/main.scss +++ b/akvo/rsr/static/rsr/v3/css/src/main.scss @@ -1,6 +1,6 @@ /*--------------------------------------------------------------------------------- - Title: Akvo RSR v3 + Title: Akvo RSR v3 Author: Loic Sans, loic@akvo.org /*---------------------------------------------------------------------------------*/ @@ -53,7 +53,7 @@ a, a:link, a:visited { img { max-width: 100%; .gmnoprint & { - max-width: none; + max-width: none; } } @@ -743,8 +743,8 @@ h4.detailedInfo { color: $anchorLinkHover; } @include responsive(small-max-screens) { - padding-top:20px; - padding-bottom:20px; + padding-top:20px; + padding-bottom:20px; } } div#filter { @@ -1371,6 +1371,7 @@ div.textBlock { background-color: rgba(lighten($akvoTvRed,15%), 0.1); p { padding-left: 20px; + color: rgba($akvoBlack, 0.45); } } h1 { @@ -1393,8 +1394,11 @@ div.textBlock { } } .orgDetails { - background: rgba(white, 0.45); + background: rgba(white, 0.65); @include border-radius(5px); + @include responsive(small-max-screens) { + padding: 10px 15px; + } } } @@ -1454,4 +1458,4 @@ div.textBlock { div { padding: 5px 10px; } -} \ No newline at end of file +} diff --git a/akvo/rsr/static/rsr/v3/js/src/scripts.js b/akvo/rsr/static/rsr/v3/js/src/scripts.js index 283cf6038f..2525568061 100644 --- a/akvo/rsr/static/rsr/v3/js/src/scripts.js +++ b/akvo/rsr/static/rsr/v3/js/src/scripts.js @@ -68,11 +68,13 @@ $(document).ready(function() { // Find each element of class rsr_map (from the coll_map template tag) // and render map with data from related js object _.forEach(document.getElementsByClassName('rsr_map'), function( node ) { + var mapId = node.id, + mapConfig = window[mapId], disableDefaultUI = false, draggable = true; - if ( node.dynamic === false ) { + if ( !mapConfig.dynamic ) { disableDefaultUI = true; draggable = false; } @@ -120,9 +122,11 @@ $(document).ready(function() { infoWindow = new google.maps.InfoWindow({ content: infoWinTempl(location) }); - google.maps.event.addListener(marker, 'click', function() { - infoWindow.open(map, marker); - }); + if (mapConfig.dynamic) { + google.maps.event.addListener(marker, 'click', function() { + infoWindow.open(map, marker); + }); + } bounds.extend(marker.position); }); diff --git a/akvo/rsr/templatetags/maps.py b/akvo/rsr/templatetags/maps.py index 8cdb4edb79..25a2dedfbd 100644 --- a/akvo/rsr/templatetags/maps.py +++ b/akvo/rsr/templatetags/maps.py @@ -107,6 +107,84 @@ def coll_map(coll, width='100%', height='100%', dynamic='dynamic'): 'partnersite_widget': False} + +def get_location(item): + """...""" + try: + location = item.primary_location + + if location.latitude == 0 and location.longitude == 0: + raise ValueError('latitude or longitude is 0') + if location.latitude > 80 or location.latitude < -80: + raise ValueError('lat over 80 or lat less than -80') + + if isinstance(item, Project): + item_type = 'project' + icon = PROJECT_MARKER_ICON + text = item.title.encode('utf8') + + elif isinstance(item, Organisation): + item_type = 'organisation' + icon = ORGANISATION_MARKER_ICON + text = item.name.encode('utf8') + + elif isinstance(item, ProjectUpdate): + item_type = 'projectUpdate' + icon = PROJECT_UPDATE_MARKER_ICON + text = item.title.encode('utf8') + + return {'type': item_type, + 'image': avatar(item), + 'latitude': location.latitude, + 'longitude': location.longitude, + 'url': item.get_absolute_url(), + 'icon': icon, + 'pk': str(item.pk), + 'text': text} + except Exception, e: + print e + return [] + + +@register.inclusion_tag('inclusion_tags/map.html') +def primary_location_map(item, width='100%', height='100%', dynamic='dynamic'): + if dynamic != 'dynamic': + dynamic = False + map_id = 'akvo_map_{}'.format(os.urandom(8).encode('hex')) + + locations = [] + locations.append(get_location(item)) + + return { + 'map_id': map_id, + 'width': width, + 'height': height, + 'locations': locations, + 'dynamic': dynamic, + } + + +@register.inclusion_tag('inclusion_tags/map.html') +def locations_map(item, width='100%', height='100%', dynamic='dynamic'): + if dynamic != 'dynamic': + dynamic = False + map_id = 'akvo_map_{}'.format(os.urandom(8).encode('hex')) + + locations = [] + + if isinstance(item, Project): + locations.append(get_location(item)) + + + return { + 'map_id': map_id, + 'width': width, + 'height': height, + 'locations': locations, + 'dynamic': dynamic, + } + + @register.inclusion_tag('inclusion_tags/maps.html') def project_map(id, width, height, dynamic='dynamic'): """ @@ -183,8 +261,8 @@ def organisation_map(id, width, height, dynamic='dynamic'): map_id = 'akvo_map_%s' % os.urandom(8).encode('hex') locations = [] - for location in OrganisationLocation.objects.filter(location_target_id=id): + if location.latitude == 0 and location.longitude == 0: continue if location.latitude > 80 or location.latitude < -80: diff --git a/akvo/templates/base.html b/akvo/templates/base.html index efd3f28913..a94b240da3 100644 --- a/akvo/templates/base.html +++ b/akvo/templates/base.html @@ -51,6 +51,12 @@ {% compressed_css 'rsr_v3_style' %} {% if stylesheet %}{% endif %} + {% block head %}{% endblock head %} diff --git a/akvo/templates/inclusion_tags/maps.html b/akvo/templates/inclusion_tags/maps.html index 5b3b7f32ff..fbaf990f58 100644 --- a/akvo/templates/inclusion_tags/maps.html +++ b/akvo/templates/inclusion_tags/maps.html @@ -115,5 +115,5 @@ } }; - window.onload = function (){googleMap.load()}; - \ No newline at end of file + window.onload = function (){googleMap.load()}; + diff --git a/akvo/templates/organisation_main.html b/akvo/templates/organisation_main.html index 3c6ed838a6..d881c48028 100644 --- a/akvo/templates/organisation_main.html +++ b/akvo/templates/organisation_main.html @@ -3,7 +3,7 @@ {% block title %}{{organisation.name}}{% endblock %} {% block maincontent %}
- +
@@ -137,11 +137,17 @@

{% trans 'Funding' %}

-
-

- {% organisation_map organisation.id '100%' '300px' %} -

+
+ {% primary_location_map organisation '100%' '300px' 'dynamic' %} + {# org_map organisation '100%' '300px' 'static' #}
-{% endblock %} \ No newline at end of file +{% endblock %} + +{% block js %} + {{ block.super }} + + {# Google Maps #} + +{% endblock js %} diff --git a/akvo/templates/partials/project_header.html b/akvo/templates/partials/project_header.html index 977a208de5..2d42482b91 100644 --- a/akvo/templates/partials/project_header.html +++ b/akvo/templates/partials/project_header.html @@ -45,23 +45,24 @@

diff --git a/akvo/templates/project_directory.html b/akvo/templates/project_directory.html index 7a7c0d4b34..fcc8323a29 100644 --- a/akvo/templates/project_directory.html +++ b/akvo/templates/project_directory.html @@ -143,7 +143,7 @@

{% trans "Finance" %}

{% endblock %} {% block js %} {{ block.super }} - + {