trippo/ResponsiveFilemanager — pull request #99 by mpryvkin (2014-06-19 20:02:13+00:00)
Title: Added support for cross-domain file selection

To enable cross-domain file selector, where files are hosted on one server (for example, ```serverA.com```) and URL is being sent to another (for example, ```serverB.com```), include ```crossdomain=1``` in the URL.

For example, to instantiate image picker, use the following URL:
```http://serverA.com/[path to filemanager]/filemanager/dialog.php?type=1&field_id=fieldID&crossdomain=1```

Then on ```serverB.com```, the following code can be used to retrieve the URL after file selection is made. Please note that the code is written for jQuery with FancyBox plug-in.
```
// Handler for a message from ResponsiveFilemanager
$(window).on('message', function(e) {
var event = e.originalEvent;

// Make sure the sender of the event is trusted
if(event.origin === 'http://serverA.com'){
if(event.data.sender === 'filemanager'){
$('#' + event.data.field_id).val(event.data.url).trigger('change');

// FancyBox: close ResponsiveFilemanager window
$.fancybox.close();
}
}
});

```