Skip to content

Commit

Permalink
Add resize buttons to report pages
Browse files Browse the repository at this point in the history
  • Loading branch information
pezholio committed Mar 2, 2017
1 parent ca8a8d1 commit a38b5d7
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 12 deletions.
2 changes: 1 addition & 1 deletion templates/web/base/common_header_tags.html
Expand Up @@ -12,7 +12,7 @@
<script nonce="[% csp_nonce %]">
window.Modernizr=function(e,t,n){function r(e){p.cssText=e}function o(e,t){return typeof e===t}var a,i,c,l="2.8.3",s={},u=t.documentElement,d="modernizr",f=t.createElement(d),p=f.style,m=({}.toString,{}),h=[],y=h.slice,v=function(e,n,r,o){var a,i,c,l,s=t.createElement("div"),f=t.body,p=f||t.createElement("body");if(parseInt(r,10))for(;r--;)c=t.createElement("div"),c.id=o?o[r]:d+(r+1),s.appendChild(c);return a=["&#173;",'<style id="s',d,'">',e,"</style>"].join(""),s.id=d,(f?s:p).innerHTML+=a,p.appendChild(s),f||(p.style.background="",p.style.overflow="hidden",l=u.style.overflow,u.style.overflow="hidden",u.appendChild(p)),i=n(s,e),f?s.parentNode.removeChild(s):(p.parentNode.removeChild(p),u.style.overflow=l),!!i},g=function(t){var n=e.matchMedia||e.msMatchMedia;if(n)return n(t)&&n(t).matches||!1;var r;return v("@media "+t+" { #"+d+" { position: absolute; } }",function(t){r="absolute"==(e.getComputedStyle?getComputedStyle(t,null):t.currentStyle).position}),r},b={}.hasOwnProperty;c=o(b,"undefined")||o(b.call,"undefined")?function(e,t){return t in e&&o(e.constructor.prototype[t],"undefined")}:function(e,t){return b.call(e,t)};for(var E in m)c(m,E)&&(i=E.toLowerCase(),s[i]=m[E](),h.push((s[i]?"":"no-")+i));return r(""),f=a=null,s._version=l,s.mq=g,s.testStyles=v,s}(this,this.document);
var fixmystreet=fixmystreet||{};
(function(b){var a=b.documentElement;a.className=a.className.replace(/\bno-js\b/,"js");var c=-1<a.className.indexOf("iel8"),c=Modernizr.mq("(min-width: 48em)")||c?"desktop":"mobile";b=b.getElementById("js-meta-data");fixmystreet.page=b.getAttribute("data-page");fixmystreet.cobrand=b.getAttribute("data-cobrand");"mobile"==c&&(a.className+=" mobile","around"==fixmystreet.page&&(a.className+=" mobile-reporting-map only-map"))})(document);
(function(b){var a=b.documentElement;a.className=a.className.replace(/\bno-js\b/,"js");var c=-1<a.className.indexOf("iel8"),c=Modernizr.mq("(min-width: 48em)")||c?"desktop":"mobile";b=b.getElementById("js-meta-data");fixmystreet.page=b.getAttribute("data-page");fixmystreet.cobrand=b.getAttribute("data-cobrand");"mobile"==c&&(a.className+=" mobile","around"==fixmystreet.page&&(a.className+=" map-fullscreen only-map map-reporting"))})(document);
</script>

[% IF admin %]
Expand Down
3 changes: 3 additions & 0 deletions templates/web/base/js/translation_strings.html
Expand Up @@ -46,6 +46,9 @@
map_map: '[% loc('Map') | replace("'", "\\'") %]',
map_satellite: '[% loc('Satellite') | replace("'", "\\'") %]',

expand_map: '[% loc('Expand map') | replace("'", "\\'") %]',
collapse_map: '[% loc('Collapse map') | replace("'", "\\'") %]',

permalink: '[% loc('Permalink') | replace("'", "\\'") %]',

upload_max_files_exceeded: '[% loc ('Whoa there Testino! Three photos are enough.') | replace("'", "\\'") %]',
Expand Down
17 changes: 15 additions & 2 deletions web/cobrands/fixmystreet/fixmystreet.js
Expand Up @@ -118,15 +118,15 @@ fixmystreet.mobile_reporting = {
apply_ui: function() {
// Creates the "app-like" mobile reporting UI with full screen map
// and special "OK/Cancel" buttons etc.
$('html').addClass('mobile-reporting-map only-map');
$('html').addClass('map-fullscreen only-map map-reporting');
$('.mobile-map-banner span').text(translation_strings.place_pin_on_map);
$('html, body').scrollTop(0);
},

remove_ui: function() {
// Removes the "app-like" mobile reporting UI, reverting all the
// changes made by fixmystreet.mobile_reporting.apply_ui().
$('html').removeClass('mobile-reporting-map only-map');
$('html').removeClass('map-fullscreen only-map map-reporting');
$('#map_box').css({ width: "", height: "", position: "" });
$('#mob_sub_map_links').remove();
}
Expand Down Expand Up @@ -869,6 +869,9 @@ $.extend(fixmystreet.set_up, {
}
$('#key-tools li:empty').remove();
$('#report-updates-data').insertAfter($('#map_box'));
if (fixmystreet.page === 'report' || fixmystreet.page === 'reports') {
$('#sub_map_links').append('<a href="#" id="toggle-fullscreen" class="expand" data-expand-text="'+ translation_strings.expand_map +'" data-compress-text="'+ translation_strings.collapse_map +'" >'+ translation_strings.expand_map +'</span>');
}
}

// Show/hide depending on whether it has any children to show
Expand Down Expand Up @@ -897,6 +900,16 @@ $.extend(fixmystreet.set_up, {
})
.prependTo('#sub_map_links');
}

$('#toggle-fullscreen').click(function() {
var btnClass = $('html').hasClass('map-fullscreen') ? 'expand' : 'compress';
var text = $(this).data(btnClass + '-text');

$('html').toggleClass('map-fullscreen only-map');
$(this).html(text).attr('class', btnClass);

fixmystreet.map.updateSize();
});
},

map_sidebar_key_tools: function() {
Expand Down
2 changes: 1 addition & 1 deletion web/cobrands/fixmystreet/header.js
Expand Up @@ -13,7 +13,7 @@ var fixmystreet = fixmystreet || {};
if (type == 'mobile') {
E.className += ' mobile';
if (fixmystreet.page == 'around') {
E.className += ' mobile-reporting-map only-map';
E.className += ' map-fullscreen only-map map-reporting';
}
}
})(document);
Binary file added web/cobrands/fixmystreet/images/compress.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions web/cobrands/fixmystreet/images/compress.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/cobrands/fixmystreet/images/compress@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/cobrands/fixmystreet/images/expand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions web/cobrands/fixmystreet/images/expand.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/cobrands/fixmystreet/images/expand@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 45 additions & 8 deletions web/cobrands/sass/_base.scss
Expand Up @@ -620,6 +620,7 @@ body.mappage .wrapper {
background-image: url($image-sprite);
background-position: center -2563px;
}

&.share {
background-image: url('/cobrands/fixmystreet/images/share.png');
background-position: center 25%;
Expand Down Expand Up @@ -1496,6 +1497,40 @@ html.js #map .noscript {
background-image:url($image-sprite);
background-position: flip(right, -341px) -3936px;
}
&#toggle-fullscreen {
padding: 0.6em 1em 0.5em 1em;
&:after {
content: "";
display: inline-block;
width: 16px;
height: 16px;
background-size: 16px 16px;
vertical-align: middle;
margin-#{$left}: 8px;
}
&.expand:after {
background-image: url(/cobrands/fixmystreet/images/expand.png);

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
background-image: url(/cobrands/fixmystreet/images/expand@2x.png);
}

@media all {
background-image: url(/cobrands/fixmystreet/images/expand.svg), none;
}
}
&.compress:after {
background-image: url(/cobrands/fixmystreet/images/compress.png);

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
background-image: url(/cobrands/fixmystreet/images/compress@2x.png);
}

@media all {
background-image: url(/cobrands/fixmystreet/images/compress.svg), none;
}
}
}
&:hover {
background-color:#000;
text-decoration:none;
Expand Down Expand Up @@ -1559,14 +1594,14 @@ html.js #map .noscript {
text-transform: uppercase;
text-align: center;
font-size: 0.875em;
.mobile-reporting-map & {
.map-fullscreen & {
display: none;
}
}

.mobile-map-banner {
display: none;
.mobile-reporting-map & {
.map-fullscreen & {
display: block;
}
text-transform: uppercase;
Expand Down Expand Up @@ -1656,7 +1691,7 @@ a:hover.rap-notes-trigger {
// and make the map full screen to reduce distractions. JavaScript also
// tweaks the text content of some of the map-related elements, to make
// it more "app-like".
.mobile-reporting-map {
.map-fullscreen {
#site-header {
display: none;
}
Expand All @@ -1672,10 +1707,6 @@ a:hover.rap-notes-trigger {
z-index: 1; // stack above positioned elements later on the page (eg: .report-list-filters)
}

#fms_pan_zoom {
top: 2.75em; // make space for the semi-transparent "Place pin on map" bar
}

.container {
padding: 0; // map_box needs to be full width, so remove page gutter
}
Expand All @@ -1685,7 +1716,13 @@ a:hover.rap-notes-trigger {
}
}

.mobile-reporting-map.only-map {
.map-reporting {
#fms_pan_zoom {
top: 2.75em; // make space for the semi-transparent "Place pin on map" bar
}
}

.only-map {
height: 100%;
body {
height: 100%;
Expand Down

0 comments on commit a38b5d7

Please sign in to comment.