diff options
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/fixmystreet.js | 141 | ||||
-rw-r--r-- | www/js/map-OpenLayers.js | 128 | ||||
-rw-r--r-- | www/js/map-OpenStreetMap.js | 5 | ||||
-rw-r--r-- | www/js/map-bing-ol.js | 3 | ||||
-rw-r--r-- | www/js/mobile.js | 210 | ||||
-rw-r--r-- | www/js/mobile_config.js | 3 |
6 files changed, 284 insertions, 206 deletions
diff --git a/www/js/fixmystreet.js b/www/js/fixmystreet.js index 9b8708f..71a4f96 100644 --- a/www/js/fixmystreet.js +++ b/www/js/fixmystreet.js @@ -77,21 +77,57 @@ function tabs(elem, indirect) { } -$(function(){ +$(document).delegate( '#front-page', 'pageshow', function(event, ui) { + // Geolocation + if (geo_position_js.init() && !$('#geolocate_link').length) { + console.log('adding thing'); + $('#postcodeForm').after('<a href="#" id="geolocate_link">… or locate me automatically</a>'); + $('#geolocate_link').click(getPosition); + } +}); + +$(document).bind('pageshow', function(){ var $html = $('html'); $html.removeClass('no-js').addClass('js'); - // Preload the new report pin document.createElement('img').src = '../i/pin-green.png'; var last_type; $(window).resize(function(){ + 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, + height: contentHeight, + margin: 0 + }); + $('#fms_pan_zoom').css({ top: '2.75em !important' }); + } else { + $('#map_box').css({ + zIndex: '', position: '', + top: '', left: '', right: '', bottom: '', + width: '', height: '10em', + margin: '' + }); + } + + $('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'); + }); var crosshairsControls, i, markHere, newX, newY; - if (typeof fixmystreet.map !== "undefined") { + if (typeof fixmystreet !== 'undefined' && typeof fixmystreet.map !== "undefined") { // Update the position of any crosshairs controls: crosshairsControls = fixmystreet.map.getControlsByClass( "OpenLayers.Control.Crosshairs"); @@ -99,6 +135,7 @@ $(function(){ crosshairsControls[i].reposition(); } // Also reposition the "Tap here to mark this point" button: + console.log('reposition mark-here'); markHere = $('#mark-here'); newX = $(window).width() / 2 - markHere.width() / 2; newY = $(window).height() * 4 / 5 - markHere.height() / 2; @@ -106,87 +143,13 @@ $(function(){ left: newX + "px", top: newY + "px" }); + console.log( newX + ', ' + newY ); } - - 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, - top: 0, left: 0, right: 0, bottom: 0, - width: '100%', height: map_height, - 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'); - } - last_type = type; }); //add mobile class if small screen $(window).resize(); - $('#pc').focus(); - $('input[type=submit]').removeAttr('disabled'); /* $('#mapForm').submit(function() { @@ -286,12 +249,6 @@ $(function(){ $('#form_category').change( form_category_onchange ); - // Geolocation - if (geo_position_js.init()) { - $('#postcodeForm').after('<a href="#" id="geolocate_link">… or locate me automatically</a>'); - $('#geolocate_link').click(getPosition); - } - /* * Report a problem page */ @@ -363,7 +320,6 @@ $(function(){ /* * Show stuff on input focus */ - $('.form-focus-hidden').hide(); $('.form-focus-trigger').on('focus', function(){ $('.form-focus-hidden').fadeIn(500); }); @@ -580,19 +536,4 @@ $.fn.drawer = function(id, ajax) { heightFix(window, '.content', -176); } } - -}); - -/* -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 c845978..7edcffa 100644 --- a/www/js/map-OpenLayers.js +++ b/www/js/map-OpenLayers.js @@ -208,9 +208,63 @@ function fixmystreet_onload() { fixmystreet.map.addControl( new OpenLayers.Control.Crosshairs(null) ); } +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) { + $('#mapForm').submit(postReport); + $('#mapForm :input[type=submit]').on('click', function() { submit_clicked = $(this); }); + $('#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(){ +function show_map(event) { + ensureNonZeroHeight(); set_map_config(); fixmystreet.map = new OpenLayers.Map("map", { @@ -222,6 +276,8 @@ $(function(){ $('#fms_pan_zoom').css({ top: '2.75em !important' }); } + fixContentHeight(fixmystreet.map); + fixmystreet.layer_options = OpenLayers.Util.extend({ zoomOffset: fixmystreet.zoomOffset, transitionEffect: 'resize', @@ -240,6 +296,7 @@ $(function(){ } 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; @@ -308,7 +365,12 @@ $(function(){ } else { fixmystreet_onload(); } -}); + fixContentHeight(fixmystreet.map); +} + +$(document).delegate('#around-page', 'pageshow', show_map ); +$(document).delegate('#report-page', 'pageshow', show_map ); + OpenLayers.Control.Crosshairs = OpenLayers.Class.create(); OpenLayers.Control.Crosshairs.CROSSHAIR_SIDE = 100; @@ -492,13 +554,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') { @@ -529,36 +591,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'); - }); - }); - } + 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'; diff --git a/www/js/map-OpenStreetMap.js b/www/js/map-OpenStreetMap.js index 50f1596..5ef2405 100644 --- a/www/js/map-OpenStreetMap.js +++ b/www/js/map-OpenStreetMap.js @@ -5,11 +5,8 @@ function set_map_config(perm) { } fixmystreet.controls = [ new OpenLayers.Control.ArgParser(), - //new OpenLayers.Control.LayerSwitcher(), - new OpenLayers.Control.Navigation(), new OpenLayers.Control.Permalink(permalink_id), - new OpenLayers.Control.PermalinkFMS('osm_link', 'http://www.openstreetmap.org/'), - new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + new OpenLayers.Control.PermalinkFMS('osm_link', 'http://www.openstreetmap.org/') ]; } diff --git a/www/js/map-bing-ol.js b/www/js/map-bing-ol.js index 9e9354d..8ded5b3 100644 --- a/www/js/map-bing-ol.js +++ b/www/js/map-bing-ol.js @@ -14,8 +14,7 @@ function set_map_config(perm) { new OpenLayers.Control.Attribution(), new OpenLayers.Control.ArgParser(), fixmystreet.nav_control, - new OpenLayers.Control.Permalink(permalink_id), - new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) + new OpenLayers.Control.Permalink(permalink_id) ]; fixmystreet.map_type = OpenLayers.Layer.Bing; } diff --git a/www/js/mobile.js b/www/js/mobile.js index c44501d..9da0ecb 100644 --- a/www/js/mobile.js +++ b/www/js/mobile.js @@ -1,38 +1,13 @@ -function touchmove(e) { - e.preventDefault(); -} - -function loadingSpinner(method){ - if (method == "on") { - //Adjust to screen size - var pHeight = window.innerHeight; - var pWidth = window.innerWidth; - var sH = parseInt($('#loadingSpinner').css('height'),10); - var sW = parseInt($('#loadingSpinner').css('width'),10); - $('#loadingSpinner').css('top',(pHeight-sH)/2+$('body').scrollTop()); - $('#loadingSpinner').css('left',(pWidth-sW)/2); - $('#loadingSpinner').css('z-index',1000); - //Show - $('#loadingSpinner').show(); - } else if (method == 'off'){ - $('#loadingSpinner').hide(); - } -} +Storage.prototype.setObject = function(key, value) { + this.setItem(key, JSON.stringify(value)); +}; -function showBusy( title, msg ) { - if ( navigator && navigator.notification && typeof navigator.notification.activityStart !== "undefined") { - navigator.notification.activityStart( title, msg ); - } else { - loadingSpinner('on'); - } -} +Storage.prototype.getObject = function(key) { + return JSON.parse(this.getItem(key)); +}; -function hideBusy() { - if ( navigator && navigator.notification && navigator.notification.activityStop) { - navigator.notification.activityStop(); - } else { - loadingSpinner('off'); - } +function touchmove(e) { + e.preventDefault(); } function show_around( lat, long ) { @@ -40,8 +15,7 @@ function show_around( lat, long ) { localStorage.latitude = lat; localStorage.longitude = long; localStorage.pc = pc; - hideBusy(); - window.location='around.html'; + $.mobile.changePage('around.html'); return false; } @@ -72,7 +46,6 @@ function use_lat_long( lat, long ) { } function location_error( msg ) { - hideBusy(); if ( msg === '' ) { $('#location_error').remove(); return; @@ -93,7 +66,6 @@ function lookup_string(q) { q = q.replace(/\s+/, ' '); if (!q) { - hideBusy(); location_error("Please enter location"); return false; } @@ -140,7 +112,6 @@ function lookup_string(q) { } else { location_error("Could not find your location"); } - hideBusy(); }); return false; } @@ -154,8 +125,6 @@ function locate() { return false; } - showBusy('Locating', 'Looking up location'); - if ( valid_postcode( pc ) ) { jQuery.get( CONFIG.MAPIT_URL + 'postcode/' + pc + '.json', function(data, status) { if ( status == 'success' ) { @@ -182,7 +151,6 @@ function foundLocation(myLocation) { function notFoundLocation() { location_error( 'Could not find location' ); } function getPosition() { - showBusy( 'Locating', 'Looking up location' ); navigator.geolocation.getCurrentPosition(foundLocation, notFoundLocation); } @@ -224,7 +192,11 @@ function check_name( name, msg ) { $('#form_name').val( name ); if ( msg ) { $('#form_name').focus(); - $('#form_name').before('<div class="form-error">' + msg + '</div>' ); + if ( $('#form_name_error').length ) { + $('#form_name_error').text(msg); + } else { + $('#form_name').before('<div class="form-error" id="form_name_error">' + msg + '</div>' ); + } } } @@ -240,11 +212,9 @@ function fileUploadSuccess(r) { if ( data.success ) { if ( data.report ) { localStorage.report = data.report; - hideBusy(); - window.location = 'report_created.html'; + $.mobile.changePage('report_created.html'); } else { - hideBusy(); - window.location = 'email_sent.html'; + $.mobile.changePage('email_sent.html'); } } else { if ( data.check_name ) { @@ -255,14 +225,12 @@ function fileUploadSuccess(r) { $('input[type=submit]').prop("disabled", false); } } else { - hideBusy(); alert('Could not submit report'); $('input[type=submit]').prop("disabled", false); } } function fileUploadFail() { - hideBusy(); alert('Could not submit report'); $('input[type=submit]').prop("disabled", false); } @@ -306,7 +274,6 @@ function postReport(e) { } } - showBusy( 'Sending Report', 'Please wait while your report is sent' ); if ( $('#form_photo').val() !== '' ) { fileURI = $('#form_photo').val(); @@ -332,11 +299,9 @@ function postReport(e) { localStorage.long = null; if ( data.report ) { localStorage.report = data.report; - hideBusy(); - window.location = 'report_created.html'; + $.mobile.changePage('report_created.html'); } else { - hideBusy(); - window.location = 'email_sent.html'; + $.mobile.changePage('email_sent.html'); } if ( !localStorage.name && $('#password_sign_in').val() ) { localStorage.name = $('#form_name').val(); @@ -348,11 +313,9 @@ function postReport(e) { check_name( data.check_name, data.errors.name ); } $('input[type=submit]').prop("disabled", false); - hideBusy(); } }, error: function (data, status, errorThrown ) { - hideBusy(); alert( 'There was a problem submitting your report, please try again (' + status + '): ' + JSON.stringify(data), function(){}, 'Submit report' ); $('input[type=submit]').prop("disabled", false); } @@ -362,7 +325,6 @@ function postReport(e) { } function sign_in() { - showBusy( 'Signing In', 'Please wait while you are signed in' ); $('#form_email').blur(); $('#password_sign_in').blur(); jQuery.ajax( { @@ -374,19 +336,16 @@ function sign_in() { remember_me: 1 }, success: function(data) { - console.log(data); if ( data.name ) { localStorage.name = data.name; localStorage.username = $('#form_email').val(); localStorage.password = $('#password_sign_in').val(); - hideBusy(); $('#user-meta').html('<p>You are signed in as ' + localStorage.username + '.</p>'); $('#form_sign_in_only').hide(); $('#forget_button').show(); $('#form_email').val(''); $('#password_sign_in').val(''); } else { - hideBusy(); $('#form_email').before('<div class="form-error">There was a problem with your email/password combination.</div>'); } } @@ -394,7 +353,7 @@ function sign_in() { } -function display_signed_out_msg() { +function display_account_page() { if ( localStorage.signed_out == 1 ) { $('#user-meta').html('<p>You’ve been signed out.</p>'); $('#form_sign_in_only').show(); @@ -418,8 +377,7 @@ function sign_out() { if ( data.signed_out ) { localStorage.signed_out = 1; localStorage.name = null; - hideBusy(); - document.location = 'sign_in.html'; + $.mobile.changePage('sign_in.html'); } } } ); @@ -466,7 +424,7 @@ function forget() { delete localStorage.username; delete localStorage.password; localStorage.signed_out = 1; - display_signed_out_msg(); + display_account_page(); } function onDeviceReady() { @@ -476,14 +434,134 @@ function onDeviceReady() { navigator.network.connection.type == Connection.UNKNOWN ) ) { document.location = 'no_connection.html'; } +} + +function get_report_params () { + var params = { + service: 'iphone', + title: $('#form_title').val(), + detail: $('#form_detail').val(), + may_show_name: $('#form_may_show_name').attr('checked') ? 1 : 0, + category: $('#form_category').val(), + lat: $('#fixmystreet\\.latitude').val(), + lon: $('#fixmystreet\\.longitude').val(), + phone: $('#form_phone').val(), + pc: $('#pc').val(), + time: new Date() + }; + + if ( localStorage.username && localStorage.password && localStorage.name ) { + params.name = localStorage.name; + params.email = localStorage.username; + params.password_sign_in = localStorage.password; + } else { + params.name = $('#form_name').val(); + params.email = $('#form_email').val(); + params.password_sign_in = $('#password_sign_in').val(); + } + + if ( $('#form_photo').val() !== '' ) { + fileURI = $('#form_photo').val(); + params.file = fileURI; + } + + return params; + +} + +function save_report() { + var params = get_report_params(); + + var r; + if ( localStorage.getObject( 'reports' ) ) { + r = localStorage.getObject( 'reports' ); + } else { + r = []; + } + r.push( params ); + localStorage.setObject('reports', r); + $.mobile.changePage('my_reports.html'); +} + +function display_saved_reports() { + if ( localStorage.getObject( 'reports' ) ) { + var r = localStorage.getObject('reports'); + 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 class="saved-report" id="' + i + '"></li>'); + var date; + if ( r[i].time ) { + var date = new Date( r[i].time ); + date = date.getDate() + '-' + ( date.getMonth() + 1 ) + '-' + date.getFullYear(); + date += ' ' + date.getHour() + ':' + date.getMinute(); + } else { + date = ''; + } + var content = $('<a class="text"><h4>' + r[i].title + '</h4><small>' + date + '</small></a>'); + if ( r[i].file ) { + $('<img class="img" src="' + r[i].file + '" height="60" width="90">').prependTo(content); + } + content.appendTo(item); + item.appendTo(list); + } + } + list.appendTo('#reports'); + } else { + $("#reports").innerHTML('No 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(); + } +} + +function submit_problem_show() { + if ( localStorage.name ) { + $('.form-focus-hidden').show(); + } else { + $('.form-focus-hidden').hide(); + } +} + +$(document).bind('pageinit', function() { $('#postcodeForm').submit(locate); $('#mapForm').submit(postReport); $('#signInForm').submit(sign_in); $('#ffo').click(getPosition); - $('#forget').click(forget); + $('#forget').on('click', forget); + $('#save_report').on('click', save_report); $('#mapForm :input[type=submit]').on('click', function() { submit_clicked = $(this); }); account(); - hideBusy(); -} +}); document.addEventListener("deviceready", onDeviceReady, false); + +$(document).delegate('#report-created', 'pageshow',function() { + var uri = CONFIG.FMS_URL + 'report/' + localStorage.report; + $('#report_url').html( '<a href="' + uri + '">' + uri + '</a>' ); +}); + +$(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('#submit-problem', 'pageshow', submit_problem_show); +$(document).delegate('.saved-report', 'click', open_saved_report_page); 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; +}); |