css
17 hours ago
files
17 hours ago
img
17 hours ago
jquery
17 hours ago
js
17 hours ago
php
17 hours ago
sounds
17 hours ago
themes
17 hours ago
Changelog
17 hours ago
LICENSE.md
17 hours ago
README.md
17 hours ago
bower.json
17 hours ago
composer.json
17 hours ago
main.default.js
17 hours ago
package.json
17 hours ago
main.default.js
171 lines
| 1 | /** |
| 2 | * elFinder client options and main script for RequireJS |
| 3 | * |
| 4 | * 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. |
| 5 | * e.g. `<script data-main="./main.js" src="./require.js"></script>` |
| 6 | **/ |
| 7 | (function(){ |
| 8 | "use strict"; |
| 9 | var // jQuery and jQueryUI version |
| 10 | jqver = '4.0.0', |
| 11 | uiver = '1.14.2', |
| 12 | |
| 13 | // Detect language (optional) |
| 14 | lang = (function() { |
| 15 | var locq = window.location.search, |
| 16 | map = { |
| 17 | 'pt' : 'pt_BR', |
| 18 | 'ug' : 'ug_CN', |
| 19 | 'zh' : 'zh_CN' |
| 20 | }, |
| 21 | full = { |
| 22 | 'zh_tw' : 'zh_TW', |
| 23 | 'zh_cn' : 'zh_CN', |
| 24 | 'fr_ca' : 'fr_CA' |
| 25 | }, |
| 26 | fullLang, locm, lang; |
| 27 | if (locq && (locm = locq.match(/lang=([a-zA-Z_-]+)/))) { |
| 28 | // detection by url query (?lang=xx) |
| 29 | fullLang = locm[1]; |
| 30 | } else { |
| 31 | // detection by browser language |
| 32 | fullLang = (navigator.browserLanguage || navigator.language || navigator.userLanguage || ''); |
| 33 | } |
| 34 | fullLang = fullLang.replace('-', '_').substr(0,5).toLowerCase(); |
| 35 | if (full[fullLang]) { |
| 36 | lang = full[fullLang]; |
| 37 | } else { |
| 38 | lang = (fullLang || 'en').substr(0,2); |
| 39 | if (map[lang]) { |
| 40 | lang = map[lang]; |
| 41 | } |
| 42 | } |
| 43 | return lang; |
| 44 | })(), |
| 45 | |
| 46 | // Start elFinder (REQUIRED) |
| 47 | start = function(elFinder, editors, config) { |
| 48 | // load jQueryUI CSS |
| 49 | elFinder.prototype.loadCss('//code.jquery.com/ui/'+uiver+'/themes/smoothness/jquery-ui.css'); |
| 50 | |
| 51 | $(function() { |
| 52 | var optEditors = { |
| 53 | commandsOptions: { |
| 54 | edit: { |
| 55 | editors: Array.isArray(editors)? editors : [] |
| 56 | } |
| 57 | } |
| 58 | }, |
| 59 | opts = {}; |
| 60 | |
| 61 | // Interpretation of "elFinderConfig" |
| 62 | if (config && config.managers) { |
| 63 | $.each(config.managers, function(id, mOpts) { |
| 64 | opts = Object.assign(opts, config.defaultOpts || {}); |
| 65 | // editors marges to opts.commandOptions.edit |
| 66 | try { |
| 67 | mOpts.commandsOptions.edit.editors = mOpts.commandsOptions.edit.editors.concat(editors || []); |
| 68 | } catch(e) { |
| 69 | Object.assign(mOpts, optEditors); |
| 70 | } |
| 71 | // Make elFinder |
| 72 | $('#' + id).elfinder( |
| 73 | // 1st Arg - options |
| 74 | $.extend(true, { lang: lang }, opts, mOpts || {}), |
| 75 | // 2nd Arg - before boot up function |
| 76 | function(fm, extraObj) { |
| 77 | // `init` event callback function |
| 78 | fm.bind('init', function() { |
| 79 | // Optional for Japanese decoder "encoding-japanese" |
| 80 | if (fm.lang === 'ja') { |
| 81 | require( |
| 82 | [ 'encoding-japanese' ], |
| 83 | function(Encoding) { |
| 84 | if (Encoding && Encoding.convert) { |
| 85 | fm.registRawStringDecoder(function(s) { |
| 86 | return Encoding.convert(s, {to:'UNICODE',type:'string'}); |
| 87 | }); |
| 88 | } |
| 89 | } |
| 90 | ); |
| 91 | } |
| 92 | }); |
| 93 | } |
| 94 | ); |
| 95 | }); |
| 96 | } else { |
| 97 | alert('"elFinderConfig" object is wrong.'); |
| 98 | } |
| 99 | }); |
| 100 | }, |
| 101 | |
| 102 | // JavaScript loader (REQUIRED) |
| 103 | load = function() { |
| 104 | require( |
| 105 | [ |
| 106 | 'elfinder' |
| 107 | , 'extras/editors.default.min' // load text, image editors |
| 108 | , 'elFinderConfig' |
| 109 | // , 'extras/quicklook.googledocs.min' // optional preview for GoogleApps contents on the GoogleDrive volume |
| 110 | ], |
| 111 | start, |
| 112 | function(error) { |
| 113 | alert(error.message); |
| 114 | } |
| 115 | ); |
| 116 | }; |
| 117 | |
| 118 | // config of RequireJS (REQUIRED) |
| 119 | require.config({ |
| 120 | baseUrl : 'js', |
| 121 | paths : { |
| 122 | 'jquery' : '//code.jquery.com/jquery-'+jqver+'.min', |
| 123 | 'jquery-ui': '//code.jquery.com/ui/'+uiver+'/jquery-ui.min', |
| 124 | 'elfinder' : 'elfinder.min', |
| 125 | 'encoding-japanese': '//cdn.jsdelivr.net/npm/encoding-japanese@2.2.0/encoding.min' |
| 126 | }, |
| 127 | waitSeconds : 10 // optional |
| 128 | }); |
| 129 | |
| 130 | // check elFinderConfig and fallback |
| 131 | // This part don't used if you are using elfinder.html, see elfinder.html |
| 132 | if (! require.defined('elFinderConfig')) { |
| 133 | define('elFinderConfig', { |
| 134 | // elFinder options (REQUIRED) |
| 135 | // Documentation for client options: |
| 136 | // https://github.com/Studio-42/elFinder/wiki/Client-configuration-options |
| 137 | defaultOpts : { |
| 138 | url : 'php/connector.minimal.php' // connector URL (REQUIRED) |
| 139 | ,commandsOptions : { |
| 140 | edit : { |
| 141 | extraOptions : { |
| 142 | // set API key to enable Creative Cloud image editor |
| 143 | // see https://console.adobe.io/ |
| 144 | creativeCloudApiKey : '', |
| 145 | // browsing manager URL for CKEditor, TinyMCE |
| 146 | // uses self location with the empty value |
| 147 | managerUrl : '' |
| 148 | } |
| 149 | } |
| 150 | ,quicklook : { |
| 151 | // to enable CAD-Files and 3D-Models preview with sharecad.org |
| 152 | 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'], |
| 153 | // to enable preview with Google Docs Viewer |
| 154 | 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'], |
| 155 | // to enable preview with Microsoft Office Online Viewer |
| 156 | // these MIME types override "googleDocsMimes" |
| 157 | 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'] |
| 158 | } |
| 159 | } |
| 160 | }, |
| 161 | managers : { |
| 162 | 'elfinder': {}, |
| 163 | } |
| 164 | }); |
| 165 | } |
| 166 | |
| 167 | // load JavaScripts (REQUIRED) |
| 168 | load(); |
| 169 | |
| 170 | })(); |
| 171 |