* elFinder client options and main script for RequireJS
* Rename "main.default.js" to "main.js" and edit it if you need configure elFInder options or any things. And use that in elfinder.html.
* e.g. `<script data-main="./main.js" src="./require.js"></script>`
var // jQuery and jQueryUI version
// Detect language (optional)
var locq = window.location.search,
if (locq && (locm = locq.match(/lang=([a-zA-Z_-]+)/))) {
// detection by url query (?lang=xx)
// detection by browser language
fullLang = (navigator.browserLanguage || navigator.language || navigator.userLanguage || '');
fullLang = fullLang.replace('-', '_').substr(0,5).toLowerCase();
lang = (fullLang || 'en').substr(0,2);
// Start elFinder (REQUIRED)
start = function(elFinder, editors, config) {
elFinder.prototype.loadCss('//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/themes/smoothness/jquery-ui.css');
editors: Array.isArray(editors)? editors : []
// Interpretation of "elFinderConfig"
if (config && config.managers) {
$.each(config.managers, function(id, mOpts) {
opts = Object.assign(opts, config.defaultOpts || {});
// editors marges to opts.commandOptions.edit
mOpts.commandsOptions.edit.editors = mOpts.commandsOptions.edit.editors.concat(editors || []);
Object.assign(mOpts, optEditors);
$.extend(true, { lang: lang }, opts, mOpts || {}),
// 2nd Arg - before boot up function
// `init` event callback function
fm.bind('init', function() {
// Optional for Japanese decoder "encoding-japanese"
if (Encoding && Encoding.convert) {
fm.registRawStringDecoder(function(s) {
return Encoding.convert(s, {to:'UNICODE',type:'string'});
alert('"elFinderConfig" object is wrong.');
// JavaScript loader (REQUIRED)
, 'extras/editors.default.min' // load text, image editors
// , 'extras/quicklook.googledocs.min' // optional preview for GoogleApps contents on the GoogleDrive volume
// is IE8 or :? for determine the jQuery version to use (optional)
old = (typeof window.addEventListener === 'undefined' && typeof document.getElementsByClassName === 'undefined')
(!window.chrome && !document.unqueID && !window.opera && !window.sidebar && 'WebkitAppearance' in document.documentElement.style && document.body.style && typeof document.body.style.webkitFilter === 'undefined');
// config of RequireJS (REQUIRED)
'jquery' : '//cdnjs.cloudflare.com/ajax/libs/jquery/'+(old? '1.12.4' : jqver)+'/jquery.min',
'jquery-ui': '//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/jquery-ui.min',
'elfinder' : 'elfinder.min',
'encoding-japanese': '//cdn.rawgit.com/polygonplanet/encoding.js/1.0.26/encoding.min'
waitSeconds : 10 // optional
// check elFinderConfig and fallback
// This part don't used if you are using elfinder.html, see elfinder.html
if (! require.defined('elFinderConfig')) {
define('elFinderConfig', {
// elFinder options (REQUIRED)
// Documentation for client options:
// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
url : 'php/connector.minimal.php' // connector URL (REQUIRED)
// set API key to enable Creative Cloud image editor
// see https://console.adobe.io/
creativeCloudApiKey : '',
// browsing manager URL for CKEditor, TinyMCE
// uses self location with the empty value
// to enable CAD-Files and 3D-Models preview with sharecad.org
sharecadMimes : ['image/vnd.dwg', 'image/vnd.dxf', 'model/vnd.dwf', 'application/vnd.hp-hpgl', 'application/plt', 'application/step', 'model/iges', 'application/vnd.ms-pki.stl', 'application/sat', 'image/cgm', 'application/x-msmetafile'],
// to enable preview with Google Docs Viewer
googleDocsMimes : ['application/pdf', 'image/tiff', 'application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/postscript', 'application/rtf'],
// to enable preview with Microsoft Office Online Viewer
// these MIME types override "googleDocsMimes"
officeOnlineMimes : ['application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.presentation']
// load JavaScripts (REQUIRED)