let farm_level_select work on mobile (fix for #548)

This commit is contained in:
Philipp Schaefer 2013-09-12 14:36:24 +02:00
parent aa219300f8
commit cc78717786
2 changed files with 34 additions and 14 deletions

View File

@ -24,6 +24,7 @@ window.show = function(id) {
case 'map': case 'map':
window.smartphone.mapButton.click(); window.smartphone.mapButton.click();
$('#portal_highlight_select').show(); $('#portal_highlight_select').show();
$('#farm_level_select').show();
break; break;
case 'info': case 'info':
window.smartphone.sideButton.click(); window.smartphone.sideButton.click();
@ -36,5 +37,6 @@ window.show = function(id) {
window.hideall = function() { window.hideall = function() {
$('#chatcontrols, #chat, #chatinput, #sidebartoggle, #scrollwrapper, #updatestatus, #portal_highlight_select').hide(); $('#chatcontrols, #chat, #chatinput, #sidebartoggle, #scrollwrapper, #updatestatus, #portal_highlight_select').hide();
$('#farm_level_select').hide();
$('#map').css('visibility', 'hidden'); $('#map').css('visibility', 'hidden');
} }

View File

@ -291,19 +291,26 @@ window.plugin.farmFind.drawCircle = function(farm)
}; };
window.plugin.farmFind.setupCSS = function() { window.plugin.farmFind.setupCSS = function() {
$("<style>").prop("type", "text/css").html( $('<style>').prop('type', 'text/css').html(''
"" + '#farm_level_select {'
+ "#farm_level_select {" + ' position: absolute;'
+ " position: absolute;" + ' top: 5px;'
+ " top: 5px;" + ' left:180px;'
+ " left:180px;" + ' z-index: 2500;'
+ " z-index: 2500;" + ' font-size:11px;'
+ " font-size:11px;" + ' font-family: "coda",arial,helvetica,sans-serif;'
+ ' font-family: "coda",arial,helvetica,sans-serif;' + ' background-color:#0E3C46;'
+ " background-color:#0E3C46;" + ' color:#ffce00;'
+ " color:#ffce00;" + '}\n').appendTo('head');
+ "}\n").appendTo("head");
}; };
window.plugin.farmFind.setupSmartCSS = function() {
$('<style>').prop('type', 'text/css').html(''
+ '#farm_level_select {'
+ ' top: 0px !important;'
+ '}\n').appendTo('head');
};
window.plugin.farmFind.changeLevel = function() window.plugin.farmFind.changeLevel = function()
{ {
var myselect = document.getElementById("farm_level_select"); var myselect = document.getElementById("farm_level_select");
@ -315,14 +322,25 @@ window.plugin.farmFind.changeLevel = function()
}; };
var setup = function() {window.plugin.farmFind.minLevel = 7; var setup = function() {
window.plugin.farmFind.minLevel = 7;
window.plugin.farmFind.minNearby = 5; window.plugin.farmFind.minNearby = 5;
window.plugin.farmFind.setupCSS(); window.plugin.farmFind.setupCSS();
if (window.isSmartphone()) {
window.plugin.farmFind.setupSmartCSS();
}
window.plugin.farmFind.Radius = 500; window.plugin.farmFind.Radius = 500;
$('#toolbox').append(' <a onclick="window.plugin.farmFind.checkPortals()" id="findFarmClick" title="Check portals in view for L' + window.plugin.farmFind.minLevel + ' farms">L' + window.plugin.farmFind.minLevel + ' Farms</a>'); $('#toolbox').append(' <a onclick="window.plugin.farmFind.checkPortals()" id="findFarmClick" title="Check portals in view for L' + window.plugin.farmFind.minLevel + ' farms">L' + window.plugin.farmFind.minLevel + ' Farms</a>');
possibleFarmPortals = []; possibleFarmPortals = [];
window.plugin.farmFind.levelLayerGroup = new L.LayerGroup(); window.plugin.farmFind.levelLayerGroup = new L.LayerGroup();
$('#dashboard').append('<select onchange="window.plugin.farmFind.changeLevel()" id="farm_level_select"><option value=1>Farm level 1</option><option value=2>Farm level 2</option><option value=3>Farm level 3</option><option value=4>Farm level 4</option><option value=5>Farm level 5</option><option value=6>Farm level 6</option><option value=7>Farm level 7</option><option value=8>Farm level 8</option></select>'); $('body').append('<select onchange="window.plugin.farmFind.changeLevel()" id="farm_level_select"><option value=1>Farm level 1</option><option value=2>Farm level 2</option><option value=3>Farm level 3</option><option value=4>Farm level 4</option><option value=5>Farm level 5</option><option value=6>Farm level 6</option><option value=7>Farm level 7</option><option value=8>Farm level 8</option></select>');
// 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"); var myselect = document.getElementById("farm_level_select");
myselect.options.selectedIndex = 6; myselect.options.selectedIndex = 6;
window.addLayerGroup('Farms', window.plugin.farmFind.levelLayerGroup, true); window.addLayerGroup('Farms', window.plugin.farmFind.levelLayerGroup, true);