diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index 86c555fb6..b1dde0154 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -52,6 +52,7 @@ OSRM.Localization["de"] = { "NO_ROUTE_FOUND": "Keine Route hierher möglich", // printing "OVERVIEW_MAP": "Übersichtskarte", +"NO_ROUTE_SELECTED": "Keine Route ausgewählt", // directions "N": "Norden", "E": "Ost", diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js index 1210ce2e7..8f20a94ef 100644 --- a/WebContent/localization/OSRM.Locale.en.js +++ b/WebContent/localization/OSRM.Locale.en.js @@ -52,6 +52,7 @@ OSRM.Localization["en"] = { "NO_ROUTE_FOUND": "No route possible", //printing "OVERVIEW_MAP": "Overview Map", +"NO_ROUTE_SELECTED": "No route selected", // directions "N": "north", "E": "east", diff --git a/WebContent/localization/OSRM.Locale.fi.js b/WebContent/localization/OSRM.Locale.fi.js index a650fadab..ab63bc61f 100644 --- a/WebContent/localization/OSRM.Locale.fi.js +++ b/WebContent/localization/OSRM.Locale.fi.js @@ -52,6 +52,7 @@ OSRM.Localization["fi"] = { "NO_ROUTE_FOUND": "Reittiä ei löytynyt", //printing "OVERVIEW_MAP": "Yleiskuvakartta", +"NO_ROUTE_SELECTED": "Ei reitti valittu", // directions "N": "pohjoiseen", "E": "itään", diff --git a/WebContent/localization/OSRM.Locale.fr.js b/WebContent/localization/OSRM.Locale.fr.js index 3629455a2..783ecefac 100644 --- a/WebContent/localization/OSRM.Locale.fr.js +++ b/WebContent/localization/OSRM.Locale.fr.js @@ -52,6 +52,7 @@ OSRM.Localization["fr"] = { "NO_ROUTE_FOUND": "Pas d’itinéraire possible", //printing "OVERVIEW_MAP": "Overview Map", +"NO_ROUTE_SELECTED": "Pas d’itinéraire choisi", // directions "N": "nord", "E": "est", diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index b87861a53..383726589 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -35,6 +35,12 @@ init: function() { input_mask_header.appendChild(icon,input_mask_header.lastChild); document.getElementById("gui-printer-inactive").onclick = OSRM.Printing.openPrintWindow; + + OSRM.Browser.onUnloadHandler( OSRM.Printing.uninit ); +}, +uninit: function() { + if(OSRM.G.printwindow) + OSRM.G.printwindow.close(); }, @@ -128,14 +134,14 @@ show: function(response) { // draw map var positions = OSRM.G.route.getPositions(); var tile_server_id = OSRM.G.map.getActiveLayerId(); - var zoom = print_window.drawMap( OSRM.DEFAULTS.TILE_SERVERS[tile_server_id], new L.LatLngBounds( positions ) ); + var zoom = print_window.OSRM.drawMap( OSRM.DEFAULTS.TILE_SERVERS[tile_server_id], new L.LatLngBounds( positions ) ); // draw markers - print_window.prefetchIcons( OSRM.G.images ); - print_window.drawMarkers( OSRM.G.markers.route ); + print_window.OSRM.prefetchIcons( OSRM.G.images ); + print_window.OSRM.drawMarkers( OSRM.G.markers.route ); // draw route & query for better geometry - print_window.drawRoute( positions ); + print_window.OSRM.drawRoute( positions ); OSRM.JSONP.call(OSRM.Routing._buildCall()+'&z='+zoom+'&instructions=false', OSRM.Printing.drawRoute, OSRM.Printing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'print'); }, timeoutRoute: function() {}, @@ -143,13 +149,13 @@ drawRoute: function(response) { if(!response) return; var positions = OSRM.RoutingGeometry._decode(response.route_geometry, 5); - OSRM.G.printwindow.drawRoute( positions ); + OSRM.G.printwindow.OSRM.drawRoute( positions ); }, // opens the print window and closes old instances openPrintWindow: function() { - // do not open window if there is no route to draw + // do not open window if there is no route to draw (should never trigger!) if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() ) return; @@ -167,16 +173,21 @@ printWindowLoaded: function(){ var print_window = OSRM.G.printwindow; var print_document = print_window.document; - // add events - print_document.getElementById('gui-printer').onclick = print_window.printWindow; - // localization print_document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" ); - print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" ); - + print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" ); + if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() ) { // error message if no route available (can trigger if user refreshes print-window) + print_document.getElementById("description").innerHTML = OSRM.loc("NO_ROUTE_SELECTED"); + return; + } + // add routing content OSRM.Printing.show( OSRM.G.response ); + // add events + print_document.getElementById("gui-printer-inactive").id = "gui-printer"; + print_document.getElementById('gui-printer').onclick = print_window.printWindow; + // finally, focus on printwindow print_window.focus(); } diff --git a/WebContent/printing/printing.css b/WebContent/printing/printing.css index c09d75ea1..9002c7c17 100644 --- a/WebContent/printing/printing.css +++ b/WebContent/printing/printing.css @@ -135,6 +135,14 @@ div.label min-width:10px; min-height:10px; } +.not-selectable +{ + cursor:default; + -moz-user-select: -moz-none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; +} @media print { .pagebreak { @@ -217,6 +225,11 @@ div.label { background-image:url("../images/printer_active.png"); } +#gui-printer-inactive +{ + cursor:default; + background-image:url("../images/printer_inactive.png"); +} /* table */ diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html index 4e53a0cc3..0d4b0966a 100644 --- a/WebContent/printing/printing.html +++ b/WebContent/printing/printing.html @@ -45,22 +45,22 @@ or see http://www.gnu.org/licenses/agpl.txt. -
+ -