modified notification markers, so that a trigger function can be named

that will prevent the notification from happening
This commit is contained in:
DennisSchiefer 2012-07-04 12:36:43 +01:00
parent c38c0b6f03
commit f385ea4e97
2 changed files with 26 additions and 10 deletions

View File

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

View File

@ -23,34 +23,50 @@ OSRM.GUI.extend( {
// notifications // notifications
notifications: [ notifications: [
{ time:30000, { time: 30000,
header: "[Tooltip] Clicking and Dragging", header: "[Tooltip] Clicking and Dragging",
body: "You can simply click on the map to set source and target markers. " + 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. " + "Then you can continue and drag the markers over the map or create. " +
"<br/><br/>" + "<br/><br/>" +
"You can even create additional markers by dragging them off of the main route." + "You can even create additional markers by dragging them off of the main route." +
"Markers can be simply deleted by clicking on them." "Markers can be simply deleted by clicking on them.",
_class: "Routing",
_func: "getRoute_Dragging"
} }
], ],
// init // initialize notification timers
init: function() { init: function() {
// init variables // init variables
var notifications = OSRM.GUI.notifications; var notifications = OSRM.GUI.notifications;
OSRM.G.notification_timers = new Array( notifications.length ); OSRM.G.notification_timers = new Array( notifications.length );
// init timers // init timers
for( var i=0, iEnd=notifications.length; i<iEnd; ++i) 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); notifications[i].timer = setTimeout( function(id){ return function(){ OSRM.GUI.notification_timeout(id);}; }(i), notifications[i].time);
notifications[i].old_function = OSRM[notifications[i]._class][notifications[i]._func];
OSRM[notifications[i]._class][notifications[i]._func] = function(id){ return function(){ OSRM.GUI.notification_wrapper(id);}; }(i);
}
}, },
// // wrapper function to clear timeouts
timeout: function(id) { notification_wrapper: function(id) {
var notifications = OSRM.GUI.notifications;
clearTimeout( notifications[id].timer );
notifications[id].old_function();
OSRM[notifications[id]._class][notifications[id]._func] = notifications[id].old_function;
},
// show notification message after timeout expired
notification_timeout: function(id) {
OSRM.notify( OSRM.GUI.notifications[id].header, OSRM.GUI.notifications[id].body, true ); OSRM.notify( OSRM.GUI.notifications[id].header, OSRM.GUI.notifications[id].body, true );
}, },
clear_timeout: function(id) { // clear notification timeout
clearTimeout( OSRM.G.notification_timers[id] ); notification_clear: function(id) {
clearTimeout( OSRM.GUI.notifications[id].timer );
} }
}); });