From 418db706c2f49f48844a314252ad5565b827b2c8 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Fri, 16 Dec 2011 13:50:46 +0100 Subject: [PATCH] Handle repaging on rotate --- www/mobile/mobile_client.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/www/mobile/mobile_client.js b/www/mobile/mobile_client.js index 640b406..58da345 100644 --- a/www/mobile/mobile_client.js +++ b/www/mobile/mobile_client.js @@ -35,7 +35,7 @@ var tab = "recordview"; var triedPass = ""; var triedUser = ""; -var previousOrientation = 0; +var previousOrientation = window.orientation || 0; window.addEventListener("load",function() { @@ -47,27 +47,27 @@ window.addEventListener("load",function() { }); function calcRecPerPage() { - state.recPerPage = 5; state.width = window.innerWidth; state.height = window.innerHeight; - state.recPerPage = Math.max(Math.round((state.height - 88 - 40) / 60), 5) ; - + return Math.max(Math.round((state.height - 88 - 40) / 60), 5) ; } function checkOrientation() { - if(window.orientation && window.orientation !== previousOrientation){ - previousOrientation = window.orientation; - calcRecPerPage(); + if(state.height != window.innerHeight){ + var newPageSize = calcRecPerPage(); + //alert("orient change: Dimension " + state.width + " " + state.height + " Old Rec/page " + state.recPerPage + " New: " + newPageSize); + state.setRecPerPage(newPageSize); + my_paz.show(state.getStartWith(), state.getRecPerPage(), curSort); } }; -calcRecPerPage(); +state.setRecPerPage(calcRecPerPage()); window.addEventListener("resize", checkOrientation, false); window.addEventListener("orientationchange", checkOrientation, false); // (optional) Android doesn't always fire orientationChange on 180 degree turns -setInterval(checkOrientation, 2000); +//setInterval(checkOrientation, 2000); var imageHelper = new ImageHelper(); @@ -946,7 +946,7 @@ function showDetails (prefixRecId) { } // request the record displayLoading() - my_paz.record_with_query(recId); + my_paz.record_with_query(recId, state.simpleQuery); } function replaceHtml(el, html) { -- 1.7.10.4