5 | | if you drop file you will get two items, both of them are "file", so they are two part of data, |
6 | | if you drop html you can get also two items, both of them are strings: one in text/html type, second one in text/plain, so this is the same data in two format (this is what we get in Chrome). |
7 | | Specification does not said if data should be thread as a one piece of data in multiple format of multiple pieces of data. It depend on data. The only information we get is: "The drag data store item list is ordered in the order that the items were added to the list; most recently added last.". |
| 7 | DataTransfer object support both old and new API. |
11 | | There are also a lot of cool features like drag icon or droparea which allows only defined types to be drop. One more good new is that there are both asynchronous and synchronous FileReader to read dropped file. |
| 11 | Basically it a list of items (`dataTransfer.items`). Every item can be a file or a string data in certain type. Data type might be MIME types but it is not necessary. Theoretically it is possible to have mixed files and string data. I wrote "theoretically", because it is not defined how such data should be thread: |
| 12 | - if you drop file you will get two items, both of them are "file", so they are two part of data, |
| 13 | - if you drop html you can get also two items, both of them are strings: one in text/html type, second one in text/plain, so this is the same data in two format (this is what we get in Blink). |
| 14 | Specification does not said if data should be thread as a one piece of data in multiple formats of multiple pieces of data. It depend on data. The only information we get is: "The drag data store item list is ordered in the order that the items were added to the list; most recently added last.". |
| 15 | |
| 16 | Blink is now the only engine which support new API for now. |
| 17 | |
| 18 | == Old API == |
| 19 | |
| 20 | Old API is move complex. DataTransfer contains: |
| 21 | |
| 22 | - `types` - array of string ex. ['plain/text','plain/html'] or ['Files'], |
| 23 | - `files` - array of files, if files array contains any element then `types` contains 'Files' element, |
| 24 | - `getData(format)` - get string data, format is a string type from `types` array, |
| 25 | - `setData(format, data)` - set data by format. |
| 26 | - `clearData(optional format)` - remove data. |
| 27 | |
| 28 | Old API works together with the new one so there are two ways to get data from DataTransfer object. |
| 29 | |
| 30 | [http://msdn.microsoft.com/en-us/library/ie/ms535861(v=vs.85).aspx IE support only "Text" and "URL" types]. |