Categories | Question details Back To List | ||
Ligtbox open? Dear DHX-Team, just a little question: How can i check if lightbox is opened in scheduler? I need to check this because i want to log the keys pressed when it is opened for edit or create mode. Is there an argument i can use in a if-clause? Thanks, Steve MC Answer posted by Stanislav (support) on Oct 19, 2009 02:47 You can use onBeforeLightbox and onAfterLightbox events of the scheduler , which occurs before and after lightbox. >>Is there an argument i can use in a if-clause? if (scheduler._lightbox_id) do_something(); This is inner variable, so it can be changed in some future versions. ( above mentioned events a bit more complex way, but more stable as well ) Answer posted by Steve MC on Oct 19, 2009 03:34 Hey There! Yes, i tried the onBefore and onAfter use, but it is not useable wirth the document.onkeydown - Function i am using. So i THINK i need the second way, by if-Clause... but there i got a problem... what is my lightbox_id ??? Or have i got you right, the funciton is working or is it not working? <<< Bad english so not axactlyy got what you wanted to say Answer posted by Stanislav (support) on Oct 19, 2009 06:33 >>what is my lightbox_id this is just name of var, you can use it as is, without any changes scheduler._lightbox_id - contains the ID of item, for which form is shown, so it is empty if form is not shown >>Yes, i tried the onBefore and onAfter var my_flag = false; scheduler.attachEvent("onBeforeLightbox",function(){ my_flag = true; return true; }) scheduler.attachEvent("onAfterLightbox",function(){ my_flag = false; return true; }) .... if (my_flag) do_something(); Answer posted by Steve MC on Oct 19, 2009 08:50 Works perfectly, thank you! Can't find the Question where i had my question from so i post it here: FOR ALL WHO WANTS TO SWITCH THROUGH THE DAYS VIA ARROWKEYS (left + right) WITHOUT WHILE LIGHTBOX IS OPENED: var lightboxopen = false; scheduler.attachEvent("onBeforeLightbox",function(){ lightboxopen = true; return true; }) scheduler.attachEvent("onAfterLightbox",function(){ lightboxopen = false; return true; }) document.onkeydown = function(event) { if (event.keyCode == 37) { // Left-Arrow event.cancelBubble = true; event.returnValue = true; if (!lightboxopen) { var next = scheduler.date.add(scheduler._date,-1,scheduler._mode); scheduler.setCurrentView(next); } } if (event.keyCode == 39) { // Right-Arrow event.cancelBubble = true; event.returnValue = true; if (!lightboxopen) { var next = scheduler.date.add(scheduler._date,1,scheduler._mode); scheduler.setCurrentView(next); } } return event.returnValue; } |