From a037418faab33f768f707f3ae99da206a4d7c1f0 Mon Sep 17 00:00:00 2001 From: Eric Chaves Date: Thu, 14 Feb 2013 16:32:11 -0200 Subject: [PATCH 1/2] fixed optional geoprogress --- geo.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/geo.js b/geo.js index b2548b4..029ae6e 100644 --- a/geo.js +++ b/geo.js @@ -2,6 +2,10 @@ navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, var lastCheckedPosition; var locationEventCount = 0; + if (geoprogress && geoprogress.constructor.name !== 'Function' && options === undefined){ + options = geoprogress; + geoprogress = function(){}; + }; options = options || {}; var checkLocation = function (position) { From 6dad66c722b2f4471571db064810452fbdbcc167 Mon Sep 17 00:00:00 2001 From: Eric Chaves Date: Tue, 19 Feb 2013 10:17:17 -0300 Subject: [PATCH 2/2] added context in options for callback calls --- geo.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/geo.js b/geo.js index 029ae6e..5c4e382 100644 --- a/geo.js +++ b/geo.js @@ -7,6 +7,7 @@ navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, geoprogress = function(){}; }; options = options || {}; + options.context = options.context || this; var checkLocation = function (position) { lastCheckedPosition = position; @@ -18,7 +19,7 @@ navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, navigator.geolocation.clearWatch(watchID); foundPosition(position); } else { - geoprogress(position); + geoprogress.call(options.context, position); } } @@ -30,11 +31,11 @@ navigator.geolocation.getAccurateCurrentPosition = function (geolocationSuccess, var onError = function (error) { clearTimeout(timerID); navigator.geolocation.clearWatch(watchID); - geolocationError(error); + geolocationError.call(options.context, error); } var foundPosition = function (position) { - geolocationSuccess(position); + geolocationSuccess.call(options.context, position); } if (!options.maxWait) options.maxWait = 10000; // Default 10 seconds