diff options
Diffstat (limited to 'www/js/app.js')
-rw-r--r-- | www/js/app.js | 84 |
1 files changed, 55 insertions, 29 deletions
diff --git a/www/js/app.js b/www/js/app.js index 282e921..8b7432c 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -100,6 +100,11 @@ var tpl = { printDebug: function(msg) { if ( CONFIG.DEBUG ) { console.log(msg); + + // Some messages get logged before we've had a chance to + // attach the debugger, so keep them all for later reference. + FMS.debug_messages = FMS.debug_messages || []; + FMS.debug_messages.push(msg); } }, @@ -113,21 +118,28 @@ var tpl = { }, checkLoggedInStatus: function() { + var p = $.Deferred(); + if ( FMS.isOffline ) { + p.resolve(); } else { $.ajax( { url: CONFIG.FMS_URL + '/auth/ajax/check_auth', type: 'GET', dataType: 'json', timeout: 30000, - success: function( data, status ) { - FMS.isLoggedIn = 1; - }, - error: function() { - FMS.isLoggedIn = 0; - } - } ); + }) + .done(function() { + FMS.isLoggedIn = 1; + p.resolve(); + }) + .fail(function() { + FMS.isLoggedIn = 0; + p.resolve(); + }) } + + return p; }, saveCurrentDraft: function(force) { @@ -151,12 +163,12 @@ var tpl = { removeDraft: function(draftID, removePhoto) { var draft = FMS.allDrafts.get(draftID); - var uri = draft.get('file'); + var files = draft.get('files'); FMS.allDrafts.remove(draft); draft.destroy(); - if ( removePhoto && uri ) { - return FMS.files.deleteURI( uri ); + if ( removePhoto && files.length ) { + return FMS.files.deleteURIs( files ); } var p = $.Deferred(); p.resolve(); @@ -266,6 +278,13 @@ var tpl = { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false); } $('#load-screen').height( $(window).height() ); + + // Rough-and-ready iPhone X detection so CSS can stop things + // obscuring the home indicator at the bottom of the screen. + if (window.screen.width == 375 && window.screen.height == 812) { + $("body").addClass("iphone-x"); + } + FMS.initialized = 1; if ( navigator && navigator.splashscreen ) { navigator.splashscreen.hide(); @@ -283,11 +302,7 @@ var tpl = { if ( typeof device !== 'undefined' && device.platform === 'iOS' ) { var model = parseInt(device.model.replace('iPhone',''), 10); FMS.iPhoneModel = model; - - // fix overlap of status bar in ios7 - if (parseFloat(window.device.version) >= 7.0) { - $('body').addClass('ios7'); - } + $('body').addClass('ios'); } _.extend(FMS, { @@ -306,9 +321,6 @@ var tpl = { } FMS.windowHeight = $(window).height(); - if ( $('body').hasClass('ios7') ) { - FMS.windowHeight -= 20; - } if ( localStorage.usedBefore ) { FMS.usedBefore = 1; @@ -327,23 +339,37 @@ var tpl = { $(document).on('ajaxStart', function() { $.mobile.loading('show'); } ); $(document).on('ajaxStop', function() { $.mobile.loading('hide'); } ); - $('#display-help').on('vclick', function(e) { FMS.helpShow(e); } ); + $('#display-help').on('vclick', function(e) { + // Avoid a problem with input cursors being visible through + // the help layer on Web View, by unfocusing the element + if (device.platform === 'iOS') { + $('input').blur(); + } + + FMS.helpShow(e); + }); + $('#dismiss').on('vclick', function(e) { FMS.helpHide(e); } ); FMS.allDrafts.comparator = function(a,b) { var a_date = a.get('created'), b_date = b.get('created'); return a_date === b_date ? 0 : a_date < b_date ? 1 : -1; }; FMS.allDrafts.fetch(); FMS.checkOnlineStatus(); FMS.loadCurrentDraft(); - FMS.checkLoggedInStatus(); - FMS.setupHelp(); - - Backbone.history.start(); - if ( navigator && navigator.splashscreen ) { - navigator.splashscreen.hide(); - } else { - $('#load-screen').hide(); - } - $('#display-help').show(); + FMS.checkLoggedInStatus().done(function() { + if (!CONFIG.HELP_DISABLED) { + FMS.setupHelp(); + } + + Backbone.history.start(); + if ( navigator && navigator.splashscreen ) { + navigator.splashscreen.hide(); + } else { + $('#load-screen').hide(); + } + if (!CONFIG.HELP_DISABLED) { + $('#display-help').show(); + } + }); }); } }); |