trippo/ResponsiveFilemanager — pull request #100 by mpryvkin (2014-06-21 02:34:03+00:00)
Title: Added support for cross-domain file selection

**STAND-ALONE FILE MANAGER**

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();
}
}
});
```

**FILE MANAGER AS TINYMCE PLUG-IN**

There is extra parameter needed ```filemanager_crossdomain``` when calling ```tinymce.init()```, please see below.
```
tinymce.init({
...
filemanager_crossdomain: true,
...
});
```