css
9 months ago
files
9 months ago
img
9 months ago
jquery
9 months ago
js
9 months ago
php
9 months ago
sounds
9 months ago
Changelog
9 months ago
LICENSE.md
9 months ago
README.md
9 months ago
bower.json
9 months ago
composer.json
9 months ago
main.default.js
9 months ago
package.json
9 months ago
main.default.js
176 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 = '3.7.1', |
| 11 | uiver = '1.13.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('//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+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 | // is IE8 or :? for determine the jQuery version to use (optional) |
| 119 | old = (typeof window.addEventListener === 'undefined' && typeof document.getElementsByClassName === 'undefined') |
| 120 | || |
| 121 | (!window.chrome && !document.unqueID && !window.opera && !window.sidebar && 'WebkitAppearance' in document.documentElement.style && document.body.style && typeof document.body.style.webkitFilter === 'undefined'); |
| 122 | |
| 123 | // config of RequireJS (REQUIRED) |
| 124 | require.config({ |
| 125 | baseUrl : 'js', |
| 126 | paths : { |
| 127 | 'jquery' : '//cdnjs.cloudflare.com/ajax/libs/jquery/'+(old? '1.12.4' : jqver)+'/jquery.min', |
| 128 | 'jquery-ui': '//cdnjs.cloudflare.com/ajax/libs/jqueryui/'+uiver+'/jquery-ui.min', |
| 129 | 'elfinder' : 'elfinder.min', |
| 130 | 'encoding-japanese': '//cdn.rawgit.com/polygonplanet/encoding.js/1.0.26/encoding.min' |
| 131 | }, |
| 132 | waitSeconds : 10 // optional |
| 133 | }); |
| 134 | |
| 135 | // check elFinderConfig and fallback |
| 136 | // This part don't used if you are using elfinder.html, see elfinder.html |
| 137 | if (! require.defined('elFinderConfig')) { |
| 138 | define('elFinderConfig', { |
| 139 | // elFinder options (REQUIRED) |
| 140 | // Documentation for client options: |
| 141 | // https://github.com/Studio-42/elFinder/wiki/Client-configuration-options |
| 142 | defaultOpts : { |
| 143 | url : 'php/connector.minimal.php' // connector URL (REQUIRED) |
| 144 | ,commandsOptions : { |
| 145 | edit : { |
| 146 | extraOptions : { |
| 147 | // set API key to enable Creative Cloud image editor |
| 148 | // see https://console.adobe.io/ |
| 149 | creativeCloudApiKey : '', |
| 150 | // browsing manager URL for CKEditor, TinyMCE |
| 151 | // uses self location with the empty value |
| 152 | managerUrl : '' |
| 153 | } |
| 154 | } |
| 155 | ,quicklook : { |
| 156 | // to enable CAD-Files and 3D-Models preview with sharecad.org |
| 157 | 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'], |
| 158 | // to enable preview with Google Docs Viewer |
| 159 | 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'], |
| 160 | // to enable preview with Microsoft Office Online Viewer |
| 161 | // these MIME types override "googleDocsMimes" |
| 162 | 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'] |
| 163 | } |
| 164 | } |
| 165 | }, |
| 166 | managers : { |
| 167 | 'elfinder': {}, |
| 168 | } |
| 169 | }); |
| 170 | } |
| 171 | |
| 172 | // load JavaScripts (REQUIRED) |
| 173 | load(); |
| 174 | |
| 175 | })(); |
| 176 |