if (typeof mapbox === 'undefined') mapbox = {}; mapbox.share = function() { var share = {}, map; tj = {}; var l = window.location; tj.webpage = l.href; tj.embed = (l.hash) ? l.href + '?embed' : l.href + '#/?embed'; var link = document.createElement('a'); var close = document.createElement('a'); var embed = document.createElement('textarea'); var share = document.createElement('div'); var popup = document.createElement('div'); var elements = [link, close, embed, share, popup]; for (var i = 0; i < elements.length; i++) { MM.addEvent(elements[i], 'mousedown', MM.cancelEvent); MM.addEvent(elements[i], 'dblclick', MM.cancelEvent); } link.innerHTML = 'Share +'; link.href = '#'; link.className = 'share'; link.onclick = link.ontouchstart = function() { popup.style.display = popup.style.display === 'block' ? 'none' : 'block'; $('body').toggleClass('sharing'); return false; }; close.innerHTML = 'Close'; close.href = '#'; close.className = 'close'; close.onclick = close.ontouchstart = function() { popup.style.display = popup.style.display === 'block' ? 'none' : 'block'; $('body').toggleClass('sharing'); return false; }; embed.className = 'embed'; embed.rows = 4; embed.setAttribute('readonly', 'readonly'); embed.value = '' .replace('{{embed}}', tj.embed); embed.onclick = function() { embed.focus(); embed.select(); return false; }; var twitter = 'http://twitter.com/intent/tweet?status=' + encodeURIComponent(document.title + ' (' + tj.webpage + ')'); var facebook = 'https://www.facebook.com/sharer.php?u=' + encodeURIComponent(tj.webpage) + '&t=' + encodeURIComponent(document.title); share.innerHTML = ('