From: Tom Hughes Date: Tue, 3 Dec 2013 00:23:16 +0000 (+0000) Subject: Merge remote-tracking branch 'jfirebaugh/562' X-Git-Tag: live~4676 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/691352136ab17e4a84394a5b80e758c8a1ce92a0?hp=c32fec1768c31044db82c06c99489c07930998cd Merge remote-tracking branch 'jfirebaugh/562' --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 273ce581a..c5532cfc4 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -287,8 +287,19 @@ $(document).ready(function () { OSM.router.load(); $(document).on("click", "a", function(e) { - if (e.isDefaultPrevented() || e.isPropagationStopped()) return; - if (this.host === window.location.host && OSM.router.route(this.pathname + this.search + this.hash)) e.preventDefault(); + if (e.isDefaultPrevented() || e.isPropagationStopped()) + return; + + // Open links in a new tab as normal. + if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) + return; + + // Ignore cross-protocol and cross-origin links. + if (location.protocol !== this.protocol || location.host !== this.host) + return; + + if (OSM.router.route(this.pathname + this.search + this.hash)) + e.preventDefault(); }); $(".search_form").on("submit", function(e) { diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index 04f7c0731..27774f05b 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -10,8 +10,9 @@ OSM.History = function(map) { unHighlightChangeset($(this).data("changeset").id); }) .on("click", "[data-changeset]", function (e) { - e.preventDefault(); - clickChangeset($(this).data("changeset").id); + if (!$(e.target).is('a')) { + clickChangeset($(this).data("changeset").id, e); + } }); var group = L.featureGroup() @@ -22,7 +23,7 @@ OSM.History = function(map) { unHighlightChangeset(e.layer.id); }) .on("click", function (e) { - clickChangeset(e.layer.id); + clickChangeset(e.layer.id, e); }); group.getLayerId = function(layer) { @@ -39,8 +40,31 @@ OSM.History = function(map) { $("#changeset_" + id).removeClass("selected"); } - function clickChangeset(id) { - OSM.router.route($("#changeset_" + id).find(".changeset_id").attr("href")); + function clickChangeset(id, e) { + var evt, el = $("#changeset_" + id).find("a.changeset_id")[0]; + if ('createEvent' in document) { + evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', + true, // canBubble + true, // cancelable + window, // 'AbstractView' + e.clicks, // click count + e.screenX, // screenX + e.screenY, // screenY + e.clientX, // clientX + e.clientY, // clientY + e.ctrlKey, // ctrl + e.altKey, // alt + e.shiftKey, // shift + e.metaKey, // meta + e.button, // mouse button + e.relatedTarget // relatedTarget + ); + el.dispatchEvent(evt); + } else { + evt = document.createEventObject(); + el.fireEvent('onclick', evt); + } } function loadData() {