Skip to content

moxie.file.FileDrop

Davit Barbakadze edited this page Aug 6, 2017 · 3 revisions

Important! This page is auto-generated from the comments in the source files. All changes will be overwritten! If you are looking to contribute, modify the comment in the corresponding source file instead.

Module: moxie.file.FileDrop

Table of Contents

Constructor

Turn arbitrary DOM element to a drop zone accepting files. Converts selected files to File objects, to be used in conjunction with Image, preloaded in memory with FileReader or uploaded to a server through XMLHttpRequest.

Arguments

  • options Object|String
    If options has typeof string, argument is considered as options.drop_zone
    • drop_zone String|DOMElement
      DOM Element to turn into a drop zone
    • [accept] Array
      Array of mime types to accept. By default accepts all
    • [required_caps] Object|String
      Set of required capabilities, that chosen runtime must support

Example

	<div id="drop_zone">
		Drop files here
	</div>
	<br />
	<div id="filelist"></div>

	<script type="text/javascript">
		var fileDrop = new moxie.file.FileDrop('drop_zone'), fileList = moxie.utils.Dom.get('filelist');

		fileDrop.ondrop = function() {
			moxie.utils.Basic.each(this.files, function(file) {
				fileList.innerHTML += '<div>' + file.name + '</div>';
			});
		};

		fileDrop.init();
	</script>

Events

ready

Dispatched when runtime is connected and drop zone is ready to accept files.

Arguments

  • event Object

dragenter

Dispatched when dragging cursor enters the drop zone.

Arguments

  • event Object

dragleave

Dispatched when dragging cursor leaves the drop zone.

Arguments

  • event Object

drop

Dispatched when file is dropped onto the drop zone.

Arguments

  • event Object

error

Dispatched if error occurs.

Arguments

  • event Object