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