added notifications

This commit is contained in:
DennisSchiefer 2012-07-04 09:00:11 +01:00
parent c07f87edca
commit c38c0b6f03
4 changed files with 75 additions and 4 deletions

View File

@ -99,6 +99,7 @@ onDrag: function(e) {
OSRM.Geocoder.updateLocation( this.parent.label );
},
onDragStart: function(e) {
OSRM.GUI.clear_timeout(0);
OSRM.G.dragging = true;
this.switchIcon(this.options.dragicon);

View File

@ -0,0 +1,56 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM Timers
// [handles notification timers]
OSRM.GUI.extend( {
// notifications
notifications: [
{ time:30000,
header: "[Tooltip] Clicking and Dragging",
body: "You can simply click on the map to set source and target markers. " +
"Then you can continue and drag the markers over the map or create. " +
"<br/><br/>" +
"You can even create additional markers by dragging them off of the main route." +
"Markers can be simply deleted by clicking on them."
}
],
// init
init: function() {
// init variables
var notifications = OSRM.GUI.notifications;
OSRM.G.notification_timers = new Array( notifications.length );
// init timers
for( var i=0, iEnd=notifications.length; i<iEnd; ++i)
OSRM.G.notification_timers[i] = setTimeout( function(id){ return function(){ OSRM.GUI.timeout(id);}; }(i), notifications[i].time);
},
//
timeout: function(id) {
OSRM.notify( OSRM.GUI.notifications[id].header, OSRM.GUI.notifications[id].body, true );
},
clear_timeout: function(id) {
clearTimeout( OSRM.G.notification_timers[id] );
}
});

View File

@ -64,6 +64,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
<script src="gui/OSRM.GUIBoxHandle.js" type="text/javascript"></script>
<script src="gui/OSRM.Selector.js" type="text/javascript"></script>
<script src="gui/OSRM.MainGUI.js" type="text/javascript"></script>
<script src="gui/OSRM.Timers.js" type="text/javascript"></script>
<script src="routing/OSRM.Routing.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingDescription.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingGeometry.js" type="text/javascript"></script>

View File

@ -270,14 +270,27 @@ OSRM.parseParameters = function(){
// check whether to activate maintenance mode
OSRM.inMaintenance = function(){
if( OSRM.DEFAULTS.MAINTENANCE == true ) {
document.getElementById('notification-blanket').style.display = "block";
document.getElementById('notification-label').innerHTML = OSRM.DEFAULTS.MAINTENANCE_HEADER;
document.getElementById('notification-box').innerHTML = OSRM.DEFAULTS.MAINTENANCE_TEXT;
document.getElementById('notification-toggle').style.display = "none";
OSRM.notify( OSRM.DEFAULTS.MAINTENANCE_HEADER, OSRM.DEFAULTS.MAINTENANCE_TEXT, false);
return true;
}
return false;
};
//general notification box
OSRM.notify = function( header, text, closable ){
document.getElementById('notification-blanket').style.display = "block";
document.getElementById('notification-label').innerHTML = header;
document.getElementById('notification-box').innerHTML = text;
if( closable )
document.getElementById('notification-toggle').onclick = OSRM.denotify;
else
document.getElementById('notification-toggle').style.display = "none";
},
OSRM.denotify = function() {
document.getElementById('notification-blanket').style.display = "none";
};
// onload event
OSRM.Browser.onLoadHandler( OSRM.init );