This commit is contained in:
Jon Atkins
2013-09-19 00:53:27 +01:00
19 changed files with 430 additions and 293 deletions

View File

@ -6,19 +6,37 @@ window._highlighters = null;
window._current_highlighter = localStorage.portal_highlighter;
window._no_highlighter = 'No Highlights';
if(window._current_highlighter !== undefined) {
if (typeof android !== 'undefined' && android && android.setActiveHighlighter)
android.setActiveHighlighter(window._current_highlighter);
}
window.addPortalHighlighter = function(name, callback) {
if(_highlighters === null) {
_highlighters = {};
}
_highlighters[name] = callback;
if (typeof android !== 'undefined' && android && android.addPortalHighlighter)
android.addPortalHighlighter(name);
if(localStorage.portal_highlighter === undefined) {
_current_highlighter = name;
if (typeof android !== 'undefined' && android && android.setActiveHighlighter)
android.setActiveHighlighter(name);
localStorage.portal_highlighter = name;
}
portalHighlighterControl();
}
window.portalHighlighterControl = function() {
if (typeof android !== 'undefined' && android && android.addPortalHighlighter) {
$('#portal_highlight_select').remove();
return;
}
if(_highlighters !== null) {
if($('#portal_highlight_select').length === 0) {
$("body").append("<select id='portal_highlight_select'></select>");
@ -32,13 +50,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');
}
@ -46,6 +57,8 @@ window.portalHighlighterControl = function() {
window.changePortalHighlights = function(name) {
_current_highlighter = name;
if (typeof android !== 'undefined' && android && android.setActiveHighlighter)
android.setActiveHighlighter(name);
resetHighlightedPortals();
localStorage.portal_highlighter = name;
}

View File

@ -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() {