aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/fixmystreet.js3
-rw-r--r--www/js/map-OpenLayers.js68
-rw-r--r--www/js/mobile.js7
-rw-r--r--www/js/mobile_config.js3
4 files changed, 74 insertions, 7 deletions
diff --git a/www/js/fixmystreet.js b/www/js/fixmystreet.js
index ce79214..a2551db 100644
--- a/www/js/fixmystreet.js
+++ b/www/js/fixmystreet.js
@@ -77,7 +77,7 @@ function tabs(elem, indirect) {
}
-$(function(){
+$(document).bind('pageinit', function(){
var $html = $('html');
$html.removeClass('no-js').addClass('js');
@@ -554,7 +554,6 @@ $.fn.drawer = function(id, ajax) {
heightFix(window, '.content', -176);
}
}
-
});
/*
diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js
index c462849..f6117ab 100644
--- a/www/js/map-OpenLayers.js
+++ b/www/js/map-OpenLayers.js
@@ -205,9 +205,61 @@ function fixmystreet_onload() {
});
}
+OpenLayers.Map.prototype.getCurrentSize = function() {
+ var mapDiv = $(this.div);
+ return new OpenLayers.Size(mapDiv.width(), mapDiv.height());
+};
+
+function fixContentHeight(olMap) {
+ var footer = $("div[data-role='footer']:visible"),
+ content = $("div[data-role='content']:visible:visible"),
+ viewHeight = $(window).height(),
+ contentHeight = viewHeight - footer.outerHeight();
+
+ if ((content.outerHeight() + footer.outerHeight()) !== viewHeight) {
+ contentHeight -= (content.outerHeight() - content.height() + 1);
+ content.height(contentHeight);
+ }
+ content.width($(window).width());
+ olMap.updateSize();
+}
+
+function ensureNonZeroHeight(containerid) {
+ var footer = $("div[id='" + containerid + "'] > div[data-role='footer']"),
+ header = $("div[id='" + containerid + "'] > div[data-role='header']"),
+ content = $("div[id='" + containerid + "'] > div[data-role='content']"),
+ viewHeight = $(window).height(),
+ contentHeight = viewHeight - footer.outerHeight() - header.outerHeight();
+
+ if ((content.outerHeight() + footer.outerHeight() + header.outerHeight()) !== viewHeight) {
+ contentHeight -= (content.outerHeight() - content.height() + 1);
+ content.height(contentHeight);
+ content.width($(window).width());
+ }
+ }
+
+$(document).delegate('#submit-problem', 'pageshow', function(event) {
+ $('#side-form, #site-logo').show();
+ $('#pc').val(localStorage.pc);
+ $('#fixmystreet\\.latitude').val(localStorage.latitude);
+ $('#fixmystreet\\.longitude').val(localStorage.longitude);
+ $.getJSON( CONFIG.FMS_URL + 'report/new/ajax', {
+ latitude: $('#fixmystreet\\.latitude').val(),
+ longitude: $('#fixmystreet\\.longitude').val()
+ }, function(data) {
+ if (data.error) {
+ // XXX If they then click back and click somewhere in the area, this error will still show.
+ $('#side-form').html('<h1>Reporting a problem</h1><p>' + data.error + '</p>');
+ return;
+ }
+ $('#councils_text').html(data.councils_text);
+ $('#form_category_row').html(data.category);
+ });
+});
-$(function(){
+$(document).delegate('#around-page', 'pageshow', function(event) {
+ ensureNonZeroHeight();
set_map_config();
fixmystreet.map = new OpenLayers.Map("map", {
@@ -219,6 +271,8 @@ $(function(){
$('#fms_pan_zoom').css({ top: '2.75em !important' });
}
+ fixContentHeight(fixmystreet.map);
+
fixmystreet.layer_options = OpenLayers.Util.extend({
zoomOffset: fixmystreet.zoomOffset,
transitionEffect: 'resize',
@@ -305,6 +359,7 @@ $(function(){
} else {
fixmystreet_onload();
}
+ fixContentHeight(fixmystreet.map);
});
/* Overridding the buttonDown function of PanZoom so that it does
@@ -447,13 +502,13 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
});
$('#side-form, #site-logo').show();
- fixmystreet.map.updateSize(); // might have done, and otherwise Firefox gets confused.
+ //fixmystreet.map.updateSize(); // might have done, and otherwise Firefox gets confused.
/* For some reason on IOS5 if you use the jQuery show method it
* doesn't display the JS validation error messages unless you do this
* or you cause a screen redraw by changing the phone orientation.
* NB: This has to happen after the call to show() */
if ( navigator.userAgent.match(/like Mac OS X/i)) {
- document.getElementById('side-form').style.display = 'block';
+ //document.getElementById('side-form').style.display = 'block';
}
$('#side').hide();
if (typeof heightFix !== 'undefined') {
@@ -499,6 +554,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
$('.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
@@ -513,6 +569,12 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
$('#mob_ok').text('OK');
});
});
+ */
+ $('#mob_ok').on('click', function(){
+ localStorage.latitude = $('#fixmystreet\\.latitude').val();
+ localStorage.longitude = $('#fixmystreet\\.longitude').val();
+ $.mobile.changePage('submit-problem.html')
+ });
}
fixmystreet.page = 'new';
diff --git a/www/js/mobile.js b/www/js/mobile.js
index c44501d..6d41956 100644
--- a/www/js/mobile.js
+++ b/www/js/mobile.js
@@ -41,7 +41,8 @@ function show_around( lat, long ) {
localStorage.longitude = long;
localStorage.pc = pc;
hideBusy();
- window.location='around.html';
+ //window.location='around.html';
+ $.mobile.changePage('around.html');
return false;
}
@@ -476,6 +477,8 @@ function onDeviceReady() {
navigator.network.connection.type == Connection.UNKNOWN ) ) {
document.location = 'no_connection.html';
}
+}
+$(document).bind('pageinit', function() {
$('#postcodeForm').submit(locate);
$('#mapForm').submit(postReport);
$('#signInForm').submit(sign_in);
@@ -484,6 +487,6 @@ function onDeviceReady() {
$('#mapForm :input[type=submit]').on('click', function() { submit_clicked = $(this); });
account();
hideBusy();
-}
+});
document.addEventListener("deviceready", onDeviceReady, false);
diff --git a/www/js/mobile_config.js b/www/js/mobile_config.js
new file mode 100644
index 0000000..ef96235
--- /dev/null
+++ b/www/js/mobile_config.js
@@ -0,0 +1,3 @@
+$(document).bind("mobileinit", function(){
+ $.mobile.ignoreContentEnabled = true;
+});