From 3bd60f4df7775a58491dd86a5f39046d8ae12bfa Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Fri, 8 Mar 2013 10:15:38 +0100 Subject: [PATCH] tap-and-hold a portal on a smartphone to switch directly to it (fixes #406) --- code/smartphone.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/code/smartphone.js b/code/smartphone.js index 599c8468..37c89a4a 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -49,13 +49,6 @@ window.runOnSmartphonesBeforeBoot = function() { $('#chatcontrols').append(smartphone.mapButton).append(smartphone.sideButton); - // add event to portals that allows long press to switch to sidebar - window.addHook('portalAdded', function(data) { - data.portal.on('dblclick', function() { - window.lastClickedPortal = this.options.guid; - }); - }); - window.addHook('portalDetailsUpdated', function(data) { var x = $('.imgpreview img').removeClass('hide'); @@ -87,4 +80,19 @@ window.runOnSmartphonesAfterBoot = function() { // make buttons in action bar flexible var l = $('#chatcontrols a:visible'); l.css('width', 100/l.length + '%'); + + // add event to portals that allows long press to switch to sidebar + window.addHook('portalAdded', function(data) { + data.portal.on('add', function() { + if(!this._container || this.options.addedTapHoldHandler) return; + this.options.addedTapHoldHandler = true; + var guid = this.options.guid; + + // this is a hack, accessing Leaflet’s private _container is evil + $(this._container).on('taphold', function() { + window.renderPortalDetails(guid); + window.smartphone.sideButton.click(); + }); + }); + }); }