From 2e78b58678231a406fe2e8b116964945d95f69c5 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Wed, 18 Sep 2013 17:06:22 +0200 Subject: [PATCH] event for select boxes to disable androids JS calls --- code/portal_highlighter.js | 7 ------- code/smartphone.js | 12 ++++++++++++ plugins/layer-farms-find.user.js | 7 ------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/code/portal_highlighter.js b/code/portal_highlighter.js index e9de1edc..4554416e 100644 --- a/code/portal_highlighter.js +++ b/code/portal_highlighter.js @@ -32,13 +32,6 @@ window.portalHighlighterControl = function() { }); $("#portal_highlight_select").val(_current_highlighter); $("#portal_highlight_select").change(function(){ changePortalHighlights($(this).val());}); - // notify android that the select spinner is enabled. - // this disables javascript injection on android side. - // if android is not notified, the spinner closes on the next JS call - if (typeof android !== 'undefined' && android && android.spinnerEnabled) { - $("#portal_highlight_select").click(function(){ android.spinnerEnabled(true);}); - $("#portal_highlight_select").focus(function(){ android.spinnerEnabled(false);}); - } $(".leaflet-top.leaflet-left").css('padding-top', '20px'); $(".leaflet-control-scale-line").css('margin-top','25px'); } diff --git a/code/smartphone.js b/code/smartphone.js index f8cf7d4b..edaa1d8b 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -125,6 +125,18 @@ window.runOnSmartphonesAfterBoot = function() { var l = $('#chatcontrols a:visible'); l.css('width', 100/l.length + '%'); + // notify android that a select spinner is enabled. + // this disables javascript injection on android side. + // if android is not notified, the spinner closes on the next JS call + if (typeof android !== 'undefined' && android && android.spinnerEnabled) { + $("body").on("click", "select", function() { + android.spinnerEnabled(true); + }); + $("body").on("focus", "select", function() { + android.spinnerEnabled(false); + }); + } + // add event to portals that allows long press to switch to sidebar window.addHook('portalAdded', function(data) { data.portal.on('add', function() { diff --git a/plugins/layer-farms-find.user.js b/plugins/layer-farms-find.user.js index d2b80044..bd1ec897 100644 --- a/plugins/layer-farms-find.user.js +++ b/plugins/layer-farms-find.user.js @@ -340,13 +340,6 @@ var setup = function() { possibleFarmPortals = []; window.plugin.farmFind.levelLayerGroup = new L.LayerGroup(); $('body').append(''); - // notify android that the select spinner is enabled. - // this disables javascript injection on android side. - // if android is not notified, the spinner closes on the next JS call - if (typeof android !== 'undefined' && android && android.spinnerEnabled) { - $("#farm_level_select").click(function(){ android.spinnerEnabled(true);}); - $("#farm_level_select").focus(function(){ android.spinnerEnabled(false);}); - } var myselect = document.getElementById("farm_level_select"); myselect.options.selectedIndex = 6; window.addLayerGroup('Farms', window.plugin.farmFind.levelLayerGroup, true);