Этот код проверит, покидает ли мышь div элемента datepicker, а затем закроет его, если мышь действительно ушла. Код проверяет это, проверяя, был ли элемент, который получил событие, календарем.
//el is set above or below, call is set globally in the document.ready
while (true){ //this will loop forever until a return
if (el == cal) { //is the receiving element the calender
return true; //we return true (no ideo why true and not null or 'yaadada'
} else if (el == document) { //we check if the target el is the document
$this.dpClose(); //close the element
return false; //return to leave loop
} else { //el is neither the call or the document
el = $(el).parent()[0]; //set el to the imidiate parent of the current el and reloop
}
}
Вы должны поместить этот код в заголовок вашего документа.
Проще было бы этот код:
$('.date-pick')
.datePicker()
.bind(
'dpDisplayed',
function(event, datePickerDiv)
{
cal = datePickerDiv; //datepickerdiv should somehow hold the the datpicker div , something like: $('.date-pick')[0];
$this = $(this);
$(cal).mouseleave( function() { $(this).dpClose(); });
}
}
Лучший вопрос может быть: почему вы не хотите включать код, который вы не знаете, что он делает?
ПРИМЕЧАНИЕ: этот код очень уродливый, и вам стоит подумать о его переписывании.