printing icon can now deactivates when there is no route

This commit is contained in:
DennisSchiefer 2012-04-25 12:17:36 +01:00
parent ab1e5255eb
commit 94ca30c690
4 changed files with 25 additions and 2 deletions

View File

@ -49,12 +49,16 @@ OSRM.extend( OSRM.Route,{
hideRoute: function() {
this._current_route.hide();
this._unnamed_route.hide();
// activate printing
OSRM.Printing.deactivate();
},
hideAll: function() {
this._current_route.hide();
this._unnamed_route.hide();
this._old_route.hide();
this._noroute = OSRM.Route.ROUTE;
// activate printing
OSRM.Printing.deactivate();
},
showUnnamedRoute: function(positions) {

View File

@ -399,6 +399,11 @@ html, body {
{
background-image:url("images/printer.png");
}
#gui-printer-inactive
{
cursor:default;
background-image:url("images/printer_inactive.png");
}
#gui-printer:hover
{
background-image:url("images/printer_hover.png");

View File

@ -24,7 +24,7 @@ OSRM.Printing = {
// create UI for printing in mainwindow
init: function() {
var icon = document.createElement('div');
icon.id = "gui-printer";
icon.id = "gui-printer-inactive";
icon.className = "iconic-button top-right-button";
var spacer = document.createElement('div');
@ -34,7 +34,18 @@ init: function() {
input_mask_header.appendChild(spacer,input_mask_header.lastChild);
input_mask_header.appendChild(icon,input_mask_header.lastChild);
document.getElementById("gui-printer").onclick = OSRM.Printing.print;
document.getElementById("gui-printer-inactive").onclick = OSRM.Printing.print;
},
// switch printer button on/off
activate: function() { // use showing route description as trigger
if( document.getElementById("gui-printer-inactive") )
document.getElementById("gui-printer-inactive").id = "gui-printer";
},
deactivate: function() { // use hide route as trigger
if( document.getElementById("gui-printer") )
document.getElementById("gui-printer").id = "gui-printer-inactive";
},

View File

@ -46,6 +46,9 @@ showRouteLink_TimeOut: function(){
// handling of routing description
show: function(response) {
// activate printing
OSRM.Printing.activate();
// compute query string
var query_string = '?hl=' + OSRM.Localization.current_language;
for(var i=0; i<OSRM.G.markers.route.length; i++)