diff --git a/WebContent/OSRM.config.js b/WebContent/OSRM.config.js
index f52c7737d..4d4f67b7a 100644
--- a/WebContent/OSRM.config.js
+++ b/WebContent/OSRM.config.js
@@ -91,8 +91,14 @@ OSRM.DEFAULTS = {
bing:true,
}
],
-
- MAINTENANCE: false,
- MAINTENANCE_HEADER: "Scheduled Maintenance",
- MAINTENANCE_TEXT: "The OSRM Website is down for a scheduled maintenance. Please be patient while required updates are performed. The site will be back online shortly.
In the meantime you may want to go out an map a friendly neighborhood near you...
[OSRM]",
+
+ NOTIFICATIONS: {
+ LOCALIZATION: 1800000, // 30min
+ CLICKING: 60000, // 1min
+ DRAGGING: 120000, // 2min
+ MAINTENANCE: false
+ },
+
+ OVERRIDE_MAINTENANCE_HEADER: undefined,
+ OVERRIDE_MAINTENANCE_BODY: undefined
};
diff --git a/WebContent/base/OSRM.Map.js b/WebContent/base/OSRM.Map.js
index ca2c53708..98e95962f 100644
--- a/WebContent/base/OSRM.Map.js
+++ b/WebContent/base/OSRM.Map.js
@@ -86,7 +86,7 @@ zoomed: function(e) {
contextmenu: function(e) {;},
mousemove: function(e) { OSRM.Via.drawDragMarker(e); },
click: function(e) {
- OSRM.GUI.deactivateTooltip( "clicking" );
+ OSRM.GUI.deactivateTooltip( "CLICKING" );
if( !OSRM.G.markers.hasSource() ) {
var index = OSRM.G.markers.setSource( e.latlng );
OSRM.Geocoder.updateAddress( OSRM.C.SOURCE_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
diff --git a/WebContent/base/osrm/OSRM.Marker.js b/WebContent/base/osrm/OSRM.Marker.js
index aa7560330..f143ec409 100644
--- a/WebContent/base/osrm/OSRM.Marker.js
+++ b/WebContent/base/osrm/OSRM.Marker.js
@@ -99,7 +99,7 @@ onDrag: function(e) {
OSRM.Geocoder.updateLocation( this.parent.label );
},
onDragStart: function(e) {
- OSRM.GUI.deactivateTooltip( "dragging" );
+ OSRM.GUI.deactivateTooltip( "DRAGGING" );
OSRM.G.dragging = true;
this.switchIcon(this.options.dragicon);
diff --git a/WebContent/gui/OSRM.MainGUI.js b/WebContent/gui/OSRM.MainGUI.js
index 8fc8a512c..405b1b44b 100644
--- a/WebContent/gui/OSRM.MainGUI.js
+++ b/WebContent/gui/OSRM.MainGUI.js
@@ -74,6 +74,7 @@ setLabels: function() {
document.getElementById("gui-units-toggle").getElementsByTagName("option")[0].innerHTML = OSRM.loc("GUI_KILOMETERS");
document.getElementById("gui-units-toggle").getElementsByTagName("option")[1].innerHTML = OSRM.loc("GUI_MILES");
OSRM.GUI.selectorOnChange( document.getElementById("gui-units-toggle") );
+ OSRM.GUI.updateNotifications();
},
// clear output area
diff --git a/WebContent/gui/OSRM.Notifications.js b/WebContent/gui/OSRM.Notifications.js
index 6c41d961d..cb2a0681e 100644
--- a/WebContent/gui/OSRM.Notifications.js
+++ b/WebContent/gui/OSRM.Notifications.js
@@ -22,51 +22,40 @@ or see http://www.gnu.org/licenses/agpl.txt.
OSRM.GUI.extend( {
// tooltips
-tooltips: {
- // triggered in OSRM.Localization.setLanguageWrapper
- localization:
- { timeout: 1800000, // 30min
- header: "Did you know? You can change the display language.",
- body: "You can use the pulldown menu in the upper left corner to select your favorite language. " +
- "
" +
- "Don't despair if you cannot find your language of choice. " +
- "If you want, you can help to provide additional translations! " +
- "Visit here for more information."
- },
- // triggered in OSRM.Map.click
- clicking:
- { timeout: 60000, // 1min
- header: "Did you know? You can click on the map to set route markers.",
- body: "You can click on the map with the left mouse button to set a source marker (green) or a target marker (red), " +
- "if the source marker already exists. " +
- "The address of the selected location will be displayed in the boxes to the left. " +
- "
" +
- "You can delete a marker by clicking on it again with the left mouse button."
- },
- // triggered in OSRM.Routing.getRoute_Dragging
- dragging:
- { timeout: 120000, // 2min
- header: "Did you know? You can drag each route marker on the map.",
- body: "You can drag a marker by clicking on it with the left mouse button and holding the button pressed. " +
- "Then you can move the marker around the map and the route will be updated instantaneously. " +
- "
" +
- "You can even create intermediate markers by dragging them off of the main route! "
- }
-},
+activeExclusive: undefined,
+activeTooltip: undefined,
+tooltips: {},
+ // LOCALIZATION: deactivation triggered in OSRM.Localization.setLanguageWrapper
+ // CLICKING: deactivation triggered in OSRM.Map.click
+ // DRAGGING: deactivation triggered in OSRM.Routing.getRoute_Dragging
+ // MAINTENANCE: deactivation only by config
// initialize notifications and tooltip timers
init: function() {
- // notifications
- // [nothing to be done at the moment]
+ // exclusive notifications
+ var config = OSRM.DEFAULTS.NOTIFICATIONS;
+ if( config["MAINTENANCE"] == true ) {
+ var header = OSRM.DEFAULTS.OVERRIDE_MAINTENANCE_HEADER || OSRM.loc("NOTIFICATION_MAINTENANCE_HEADER");
+ var body = OSRM.DEFAULTS.OVERRIDE_MAINTENANCE_BODY || OSRM.loc("NOTIFICATION_MAINTENANCE_BODY");
+ OSRM.GUI.exclusiveNotify( header, body, false);
+ OSRM.GUI.activeExclusive = "MAINTENANCE";
+ return;
+ }
// tooltip timers
+ var config = OSRM.DEFAULTS.NOTIFICATIONS;
var tooltips = OSRM.GUI.tooltips;
- for( id in tooltips ) {
+ for( id in config ) {
+ // skip notification?
+ if( !OSRM.Utils.isNumber( config[id] ) )
+ continue;
+ // create structure to hold timer data
+ tooltips[id] = {};
// start timer
tooltips[id]._timer = setTimeout(
function(_id){ return function(){OSRM.GUI._showTooltip(_id);}; }(id),
- tooltips[id].timeout
+ config[id]
);
// mark tooltip as pending
@@ -87,6 +76,7 @@ deactivateTooltip: function(id) {
// show tooltip after timer expired
_showTooltip: function(id) {
var tooltips = OSRM.GUI.tooltips;
+ // only show tooltip if it exists
if(tooltips[id] == undefined)
return;
@@ -96,16 +86,18 @@ _showTooltip: function(id) {
}
// if a notification is currently shown, restart timer
+ var config = OSRM.DEFAULTS.NOTIFICATIONS;
if( OSRM.GUI.isTooltipVisible() ) {
tooltips[id]._timer = setTimeout(
function(_id){ return function(){OSRM.GUI._showTooltip(_id);}; }(id),
- tooltips[id].timeout
+ config[id]
);
return;
}
// show notification
- OSRM.GUI.tooltipNotify( tooltips[id].header, tooltips[id].body );
+ OSRM.GUI.tooltipNotify( OSRM.loc("NOTIFICATION_"+id+"_HEADER"), OSRM.loc("NOTIFICATION_"+id+"_BODY") );
+ OSRM.GUI.activeTooltip = id;
// mark tooltip as no longer pending
tooltips[id]._pending = false;
@@ -121,11 +113,32 @@ exclusiveNotify: function( header, text, closable ){
document.getElementById('exclusive-notification-toggle').onclick = OSRM.GUI.exclusiveDenotify;
else
document.getElementById('exclusive-notification-toggle').style.display = "none";
+ OSRM.GUI.exclusiveResize();
},
exclusiveDenotify: function() {
document.getElementById('exclusive-notification-blanket').style.display = "none";
+ OSRM.GUI.activeExclusive = undefined;
+},
+exclusiveUpdate: function() {
+ if( OSRM.GUI.activeExclusive == undefined )
+ return;
+
+ // override mainly intended for maintenance mode
+ var header = OSRM.DEFAULTS["OVERRIDE_"+OSRM.GUI.activeExclusive+"_HEADER"] || OSRM.loc("NOTIFICATION_MAINTENANCE_HEADER");
+ var body = OSRM.DEFAULTS["OVERRIDE_"+OSRM.GUI.activeExclusive+"_BODY"] || OSRM.loc("NOTIFICATION_MAINTENANCE_BODY");
+
+ document.getElementById('exclusive-notification-label').innerHTML = header;
+ document.getElementById('exclusive-notification-box').innerHTML = body;
+ OSRM.GUI.exclusiveResize();
+},
+exclusiveResize: function() {
+ var height = document.getElementById('exclusive-notification-box').clientHeight;
+ document.getElementById('exclusive-notification-content').style.height = (height + 28) + "px";
+ document.getElementById('exclusive-notification-wrapper').style.height = (height + 48) + "px";
+},
+inMaintenance: function() {
+ return OSRM.GUI.activeExclusive == "MAINTENANCE";
},
-
// tooltip notification
tooltipNotify: function( header, text ){
@@ -138,6 +151,18 @@ tooltipNotify: function( header, text ){
document.getElementById('tooltip-notification-toggle').onclick = OSRM.GUI.tooltipDenotify;
document.getElementById('tooltip-notification-resize').onclick = OSRM.GUI.tooltipResize;
},
+tooltipDenotify: function() {
+ document.getElementById('tooltip-notification-wrapper').style.display = "none";
+ OSRM.GUI.activeTooltip = undefined;
+},
+tooltipUpdate: function() {
+ if( OSRM.GUI.activeTooltip == undefined )
+ return;
+ document.getElementById('tooltip-notification-label').innerHTML = OSRM.loc("NOTIFICATION_"+OSRM.GUI.activeTooltip+"_HEADER");
+ document.getElementById('tooltip-notification-box').innerHTML = OSRM.loc("NOTIFICATION_"+OSRM.GUI.activeTooltip+"_BODY");
+ OSRM.GUI.tooltipResize();
+ OSRM.GUI.tooltipResize(); // simple trick to retain opened/closed state of tooltip
+},
tooltipResize: function() {
if( document.getElementById('tooltip-notification-box').style.display == "none" ) {
document.getElementById('tooltip-notification-box').style.display = "block";
@@ -152,11 +177,15 @@ tooltipResize: function() {
document.getElementById('tooltip-notification-resize').className = "iconic-button down-marker top-right-button";
}
},
-tooltipDenotify: function() {
- document.getElementById('tooltip-notification-wrapper').style.display = "none";
-},
isTooltipVisible: function() {
return document.getElementById('tooltip-notification-wrapper').style.display == "block";
+},
+
+
+// update language of any notification
+updateNotifications: function() {
+ OSRM.GUI.exclusiveUpdate();
+ OSRM.GUI.tooltipUpdate();
}
});
diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js
index bfd1f12a8..c8f7bb7a8 100644
--- a/WebContent/localization/OSRM.Locale.en.js
+++ b/WebContent/localization/OSRM.Locale.en.js
@@ -98,7 +98,32 @@ OSRM.Localization["en"] = {
"DIRECTION_11-8":"Enter roundabout and leave at eighth exit[ onto %s]",
"DIRECTION_11-9":"Enter roundabout and leave at nineth exit[ onto %s]",
"DIRECTION_11-x":"Enter roundabout and leave at one of the too many exits[ onto %s]",
-"DIRECTION_15":"You have reached your destination"
+"DIRECTION_15":"You have reached your destination",
+// notifications
+"NOTIFICATION_MAINTENANCE_HEADER": "Scheduled Maintenance",
+"NOTIFICATION_MAINTENANCE_BODY": "The OSRM Website is down for a scheduled maintenance. " +
+ "Please be patient while required updates are performed. " +
+ "The site will be back online shortly." +
+ "
" +
+ "In the meantime you may want to go out an map a friendly neighborhood near you..." +
+ "
[OSRM]",
+"NOTIFICATION_LOCALIZATION_HEADER": "Did you know? You can change the display language.",
+"NOTIFICATION_LOCALIZATION_BODY": "You can use the pulldown menu in the upper left corner to select your favorite language. " +
+ "
" +
+ "Don't despair if you cannot find your language of choice. " +
+ "If you want, you can help to provide additional translations! " +
+ "Visit here for more information.",
+"NOTIFICATION_CLICKING_HEADER": "Did you know? You can click on the map to set route markers.",
+"NOTIFICATION_CLICKING_BODY": "You can click on the map with the left mouse button to set a source marker (green) or a target marker (red), " +
+ "if the source marker already exists. " +
+ "The address of the selected location will be displayed in the boxes to the left. " +
+ "
" +
+ "You can delete a marker by clicking on it again with the left mouse button.",
+"NOTIFICATION_DRAGGING_HEADER": "Did you know? You can drag each route marker on the map.",
+"NOTIFICATION_DRAGGING_BODY": "You can drag a marker by clicking on it with the left mouse button and holding the button pressed. " +
+ "Then you can move the marker around the map and the route will be updated instantaneously. " +
+ "
" +
+ "You can even create intermediate markers by dragging them off of the main route! "
};
// set GUI language on load
diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js
index 226a128b9..29681ee43 100644
--- a/WebContent/localization/OSRM.Localization.js
+++ b/WebContent/localization/OSRM.Localization.js
@@ -49,7 +49,7 @@ init: function() {
OSRM.Localization.setLanguage( OSRM.DEFAULTS.LANGUAGE );
},
setLanguageWrapper: function(language) { // wrapping required to correctly prevent localization tooltip from showing
- OSRM.GUI.deactivateTooltip( "localization" );
+ OSRM.GUI.deactivateTooltip( "LOCALIZATION" );
OSRM.Localization.setLanguage(language);
},
setLanguage: function(language) {
diff --git a/WebContent/main.js b/WebContent/main.js
index f2a327386..01917d8a4 100644
--- a/WebContent/main.js
+++ b/WebContent/main.js
@@ -33,7 +33,7 @@ OSRM.init = function() {
OSRM.Localization.init();
// stop if in maintenance mode
- if( OSRM.inMaintenance() == true )
+ if( OSRM.GUI.inMaintenance() == true )
return;
// check if the URL contains some GET parameter, e.g. for showing a route
@@ -291,15 +291,5 @@ OSRM.parseParameters = function(){
};
-// check whether to activate maintenance mode
-OSRM.inMaintenance = function(){
- if( OSRM.DEFAULTS.MAINTENANCE == true ) {
- OSRM.GUI.exclusiveNotify( OSRM.DEFAULTS.MAINTENANCE_HEADER, OSRM.DEFAULTS.MAINTENANCE_TEXT, false);
- return true;
- }
- return false;
-};
-
-
// onload event
OSRM.Browser.onLoadHandler( OSRM.init );