I would like add the username to a line added in a field in the lightbox when this user press “Enter”.
Like this:
Refaire la penderie (Walter)
Équilibrer les comptes (Alain)
-Retour sur la fiesse (Diane)
I’m using this code to accept “Enterkey” key and identify it but I don’t find the way to add the username by replacing “Enterkey” by “(Username)Enterkey”…
[code]
scheduler.getLightbox().onkeydown=function(e){
switch((e||event).keyCode){
case scheduler.keys.edit_save:
// Ajoute prenom user
if (event.keyCode)==‘13’){
"Code should be here..."
}
if (!(e||event).shiftKey) return;
scheduler.save_lightbox();
break;
case scheduler.keys.edit_cancel:
scheduler.cancel_lightbox();
break;
default:
break;
}
};[/code]
Each lightbox section has id. When enter is pressed you could get event target and try to find its id. You could go higher to parents (target.parentNode …) until find element with class “dhx_wrap_section”. It’s lightbox section wrapper. You could get its first child this id is the section id. Then you could iterate over sections and find section with this id.
Possibly something like this:
switch((e||event).keyCode){
case 13:
var target = e.target || event.srcElement;
while(target && target.className != "dhx_wrap_section")
target = target.parentNode;
var sectId = target.firstChild.id;
var sections = scheduler.config.lightbox.sections;
var section = null;
for(var i = 0; i < sections.length; i++){
if(sections[i].id == sectId) {
section = sections[i];
break;
}
}
if(section){
//Do Stafff!..
if(section.name == "description"){
var descr = scheduler.formSection('description');
var oldVal = descr.getValue();
descr.setValue(oldVal + " (New text)");
return false;
}
}
break;
default:
break;
}