myfaces.html5.dnd.dragEnterOrOver = function()

in myfaces-html5-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/dnd.js [60:94]


myfaces.html5.dnd.dragEnterOrOver = function(event, allowedEffect, dropTargetTypes, acceptedMimeTypes) {
	//check allowed mime types first. if its "*", then accept all (do not check it)
    if(acceptedMimeTypes.length!=1 || acceptedMimeTypes[0]!=myfaces.html5.dnd.ACCEPT_ALL_MIME_TYPES){
        var foundMimeTypes = acceptedMimeTypes.filter(function (mimeType){return event.dataTransfer.types.contains(mimeType)});
        //if even one of the event mime types are not allowed, stop DnD
        if(foundMimeTypes == null || foundMimeTypes.length == 0)
        {
            return true; //don't cancel the event, thus stop DnD
        }
    }

    
    //if allowed effect is specified, set it. so the browser can decide whether continue or stop dnd operation.
    if(allowedEffect){
    	event.dataTransfer.effectAllowed = allowedEffect;
    }
    
    //check drop target type
    var strAcceptedDropTargetTypesOfDragSource = event.dataTransfer.getData(myfaces.html5.dnd.DROP_TARGETS_MIME_TYPE);
    if(strAcceptedDropTargetTypesOfDragSource){		//if drag source defines a drop target type
    	//then, let's check this drop target's type matches with that
    	var acceptedDropTargetTypesFromDragSource = myfaces.html5.common.convertStringToArray(event.dataTransfer.getData(myfaces.html5.dnd.DROP_TARGETS_MIME_TYPE));
    	var foundDropTargetTypes = acceptedDropTargetTypesFromDragSource.filter(function (dropTargetType){return myfaces.html5.common.contains(dropTargetTypes, dropTargetType)});
    	
    	//if even one of the drop target types are not allowed, stop DnD 
    	if(foundDropTargetTypes.length == 0)
    		return true; //don't cancel the event, thus stop DnD
    }

    //cancel the event, so effect on screen is updated
    if (event.preventDefault)
        event.preventDefault();
 
    return false;
}