aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-10-30 17:18:02 +0000
committerStruan Donald <struan@exo.org.uk>2012-10-30 17:18:02 +0000
commit24cbac3d7f0cc2a23c90ce064bb95111c4478bc9 (patch)
tree1523467a7d09350338c5967bdeec42f25b0be171 /www/js
parent778c3cb21c00d2c9522cdcc63f55cf6201675853 (diff)
display contents of saved reports
Diffstat (limited to 'www/js')
-rw-r--r--www/js/fixmystreet.js23
-rw-r--r--www/js/map-OpenLayers.js9
-rw-r--r--www/js/mobile.js32
3 files changed, 43 insertions, 21 deletions
diff --git a/www/js/fixmystreet.js b/www/js/fixmystreet.js
index 8ca2705..1e283db 100644
--- a/www/js/fixmystreet.js
+++ b/www/js/fixmystreet.js
@@ -79,7 +79,6 @@ 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>');
@@ -92,7 +91,6 @@ $(document).bind('pageshow', function(){
$html.removeClass('no-js').addClass('js');
-
// Preload the new report pin
document.createElement('img').src = '../i/pin-green.png';
@@ -112,6 +110,13 @@ $(document).bind('pageshow', function(){
margin: 0
});
$('#fms_pan_zoom').css({ top: '2.75em !important' });
+ } else {
+ $('#map_box').css({
+ zIndex: '', position: '',
+ top: '', left: '', right: '', bottom: '',
+ width: '', height: '10em',
+ margin: ''
+ });
}
});
@@ -506,17 +511,3 @@ $.fn.drawer = function(id, ajax) {
}
}
});
-
-/*
-XXX Disabled because jerky on Android and makes map URL bar height too small on iPhone.
-// Hide URL bar
-$(window).load(function(){
- window.setTimeout(function(){
- var s = window.pageYOffset || document.compatMode === "CSS1Compat" && document.documentElement.scrollTop || document.body.scrollTop || 0;
- if (s < 20 && !location.hash) {
- window.scrollTo(0, 1);
- }
- }, 0);
-});
-*/
-
diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js
index caa326d..3c136cf 100644
--- a/www/js/map-OpenLayers.js
+++ b/www/js/map-OpenLayers.js
@@ -259,7 +259,7 @@ $(document).delegate('#submit-problem', 'pageshow', function(event) {
});
});
-$(document).delegate('#around-page', 'pageshow', function(event) {
+function show_map(event) {
ensureNonZeroHeight();
set_map_config();
@@ -293,6 +293,7 @@ $(document).delegate('#around-page', 'pageshow', function(event) {
}
if (fixmystreet.state_map && fixmystreet.state_map == 'full') {
+ console.log('full page');
// TODO Work better with window resizing, this is pretty 'set up' only at present
var $content = $('.content'),
q = ( $content.offset().left + $content.width() ) / 2;
@@ -362,7 +363,11 @@ $(document).delegate('#around-page', 'pageshow', function(event) {
fixmystreet_onload();
}
fixContentHeight(fixmystreet.map);
-});
+}
+
+$(document).delegate('#around-page', 'pageshow', show_map );
+$(document).delegate('#report-page', 'pageshow', show_map );
+
/* Overridding the buttonDown function of PanZoom so that it does
zoomTo(0) rather than zoomToMaxExtent()
diff --git a/www/js/mobile.js b/www/js/mobile.js
index fda1c3a..f902baa 100644
--- a/www/js/mobile.js
+++ b/www/js/mobile.js
@@ -485,13 +485,15 @@ function save_report() {
function display_saved_reports() {
if ( localStorage.getObject( 'reports' ) ) {
var r = localStorage.getObject('reports');
- var list = $('<ul></ul>');
+ var list = $('<ul id="current" class="issue-list-a tab open"></ul>');
for ( i = 0; i < r.length; i++ ) {
if ( r[i] && r[i].title ) {
- var item = $('<li id="' + i + '">' + r[i].title + '</li>');
+ var item = $('<li class="saved-report" id="' + i + '"></li>');
+ var content = $('<a class="text"><h4>' + r[i].title + '</h4></a>');
if ( r[i].file ) {
- $('<img src="' + r[i].file + '" width="100">').appendTo(item);
+ $('<img class="img" src="' + r[i].file + '" height="60" width="90">').prependTo(content);
}
+ content.appendTo(item);
item.appendTo(list);
}
}
@@ -501,6 +503,28 @@ function display_saved_reports() {
}
}
+function open_saved_report_page(e) {
+ localStorage.currentReport = this.id;
+ $.mobile.changePage('report.html');
+}
+
+function display_saved_report() {
+ var r = localStorage.getObject('reports')[localStorage.currentReport];
+ fixmystreet.latitude = r.lat;
+ fixmystreet.longitude = r.lon;
+ fixmystreet.pins = [ [ r.lat, r.lon, 'yellow', '', "", 'big' ] ];
+
+ $('#title').text(r.title);
+ $('#details').text(r.detail);
+ if ( r.file ) {
+ $('#photo').attr('src', r.file);
+ $('#photo_link').attr('href', r.file);
+ $('#report-img').show();
+ } else {
+ $('#report-img').hide();
+ }
+}
+
$(document).bind('pageinit', function() {
$('#postcodeForm').submit(locate);
$('#mapForm').submit(postReport);
@@ -521,3 +545,5 @@ $(document).delegate('#report-created', 'pageshow',function() {
$(document).delegate('#account-page', 'pageshow', display_account_page);
$(document).delegate('#my-reports-page', 'pageshow', display_saved_reports);
+$(document).delegate('#report-page', 'pageshow', display_saved_report);
+$(document).delegate('.saved-report', 'click', open_saved_report_page);