aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-10-26 16:22:24 +0100
committerStruan Donald <struan@exo.org.uk>2012-10-26 16:22:24 +0100
commitd95ce6686f422cce2cb2a0e26746ac67b4ae43e3 (patch)
tree32ccfa7cc7d09b7880e05fd748ff7703f693b728 /www/js
parent7315b8b2270db2751f983aa8679fe0d8685a94e3 (diff)
improve map display
Diffstat (limited to 'www/js')
-rw-r--r--www/js/fixmystreet.js79
-rw-r--r--www/js/map-OpenLayers.js65
2 files changed, 42 insertions, 102 deletions
diff --git a/www/js/fixmystreet.js b/www/js/fixmystreet.js
index dac2efb..8ca2705 100644
--- a/www/js/fixmystreet.js
+++ b/www/js/fixmystreet.js
@@ -79,13 +79,15 @@ function tabs(elem, indirect) {
$(document).delegate( '#front-page', 'pageshow', function(event, ui) {
// Geolocation
+ console.log('frontpage pageshow');
if (geo_position_js.init() && !$('#geolocate_link').length) {
+ console.log('adding thing');
$('#postcodeForm').after('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
$('#geolocate_link').click(getPosition);
}
});
-$(document).bind('pageinit', function(){
+$(document).bind('pageshow', function(){
var $html = $('html');
$html.removeClass('no-js').addClass('js');
@@ -96,79 +98,26 @@ $(document).bind('pageinit', function(){
var last_type;
$(window).resize(function(){
- var type = $('#site-header').css('borderTopWidth');
- if (type == '4px') { type = 'mobile'; }
- else if (type == '0px') { type = 'desktop'; }
- else { return; }
- if (last_type == type) { return; }
- if (type == 'mobile') {
- $html.addClass('mobile');
- $('#map_box').prependTo('.content').css({
- zIndex: '', position: '',
- top: '', left: '', right: '', bottom: '',
- width: '', height: '10em',
- margin: ''
- });
- if (typeof fixmystreet !== 'undefined') {
- fixmystreet.state_map = ''; // XXX
- }
- if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') {
- // Immediately go full screen map if on around page
- $('#site-header').hide();
- $('#map_box').prependTo('.wrapper').css({
- position: 'absolute',
- top: 0, left: 0, right: 0, bottom: 0,
- height: 'auto',
- margin: 0
- });
- $('#fms_pan_zoom').css({ top: '2.75em !important' });
- $('.big-green-banner')
- .addClass('mobile-map-banner')
- .appendTo('#map_box')
- .text('Place pin on map')
- .prepend('<a href="index.html">home</a>');
- }
- $('span.report-a-problem-btn').on('click.reportBtn', function(){
- $('html, body').animate({scrollTop:0}, 500);
- }).css({ cursor:'pointer' }).on('hover.reportBtn', function(){
- $(this).toggleClass('hover');
- });
- } else {
- // Make map full screen on non-mobile sizes.
- $html.removeClass('mobile');
- var map_pos = 'fixed', map_height = '100%';
- if ($html.hasClass('ie6')) {
- map_pos = 'absolute';
- map_height = $(window).height();
- }
- $('#map_box').prependTo('.wrapper').css({
- zIndex: 0, position: map_pos,
+ var footer = $("div[data-role='footer']:visible"),
+ content = $("div[data-role='content']:visible:visible"),
+ viewHeight = $(window).height(),
+ contentHeight = viewHeight - footer.outerHeight();
+ $html.addClass('mobile');
+ if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') {
+ // Immediately go full screen map if on around page
+ $('#map_box').css({
+ position: 'absolute',
top: 0, left: 0, right: 0, bottom: 0,
- width: '100%', height: map_height,
+ height: contentHeight,
margin: 0
});
- if (typeof fixmystreet !== 'undefined') {
- fixmystreet.state_map = 'full';
- }
- if (typeof fixmystreet !== 'undefined' && fixmystreet.page == 'around') {
- // Remove full-screen-ness
- $('#site-header').show();
- $('#fms_pan_zoom').css({ top: '4.75em !important' });
- $('.big-green-banner')
- .removeClass('mobile-map-banner')
- .prependTo('#side')
- .text('Click map to report a problem');
- }
- $('span.report-a-problem-btn').css({ cursor:'' }).off('.reportBtn');
+ $('#fms_pan_zoom').css({ top: '2.75em !important' });
}
- last_type = type;
});
//add mobile class if small screen
$(window).resize();
- $('#pc').focus();
-
$('input[type=submit]').removeAttr('disabled');
/*
$('#mapForm').submit(function() {
diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js
index 8f62e76..caa326d 100644
--- a/www/js/map-OpenLayers.js
+++ b/www/js/map-OpenLayers.js
@@ -541,43 +541,34 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
}
$('#sub_map_links').hide();
- if ($('html').hasClass('mobile')) {
- var $map_box = $('#map_box'),
- width = $map_box.width(),
- height = $map_box.height();
- $map_box.append(
- '<p id="mob_sub_map_links">' +
- '<a href="#" id="try_again">Try again</a>' +
- '<a href="#ok" id="mob_ok">OK</a>' +
- '</p>'
- ).css({ position: 'relative', width: width, height: height, marginBottom: '1em' });
- // Making it relative here makes it much easier to do the scrolling later
-
- $('.mobile-map-banner').text('Right place?').prepend('<a href="index.html">home</a>');
-
- // mobile user clicks 'ok' on map
- /*
- $('#mob_ok').toggle(function(){
- //scroll the height of the map box instead of the offset
- //of the #side-form or whatever as we will probably want
- //to do this on other pages where #side-form might not be
- $('html, body').animate({ scrollTop: height-60 }, 1000, function(){
- $('#mob_sub_map_links').addClass('map_complete');
- $('#mob_ok').text('MAP');
- });
- }, function(){
- $('html, body').animate({ scrollTop: 0 }, 1000, function(){
- $('#mob_sub_map_links').removeClass('map_complete');
- $('#mob_ok').text('OK');
- });
- });
- */
- $('#mob_ok').on('click', function(){
- localStorage.latitude = $('#fixmystreet\\.latitude').val();
- localStorage.longitude = $('#fixmystreet\\.longitude').val();
- $.mobile.changePage('submit-problem.html')
- });
- }
+ var $map_box = $('#map_box');
+ $map_box.append(
+ '<p id="mob_sub_map_links">' +
+ '<a href="#" id="try_again">Try again</a>' +
+ '<a href="#ok" id="mob_ok">OK</a>' +
+ '</p>'
+ );
+ // .css({ position: 'relative', width: width, height: height, marginBottom: '1em' });
+ // Making it relative here makes it much easier to do the scrolling later
+
+ $('.mobile-map-banner').text('Right place?').prepend('<a href="index.html">home</a>');
+
+ $('#try_again').on('click', function(){
+ fixmystreet.bbox_strategy.activate();
+ fixmystreet.markers.refresh( { force: true } );
+ if ( fixmystreet.state_pins_were_hidden ) {
+ // If we had pins hidden when we clicked map (which had to show the pin layer as I'm doing it in one layer), hide them again.
+ $('#hide_pins_link').click();
+ }
+ fixmystreet.drag.deactivate();
+ $('#sub_map_links').show();
+ $('#mob_sub_map_links').remove();
+ });
+ $('#mob_ok').on('click', function(){
+ localStorage.latitude = $('#fixmystreet\\.latitude').val();
+ localStorage.longitude = $('#fixmystreet\\.longitude').val();
+ $.mobile.changePage('submit-problem.html')
+ });
fixmystreet.page = 'new';
location.hash = 'report';