Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js
File: elFinder.resources.js
/**
[0] Fix | Delete
* elFinder resources registry.
[1] Fix | Delete
* Store shared data
[2] Fix | Delete
*
[3] Fix | Delete
* @type Object
[4] Fix | Delete
* @author Dmitry (dio) Levashov
[5] Fix | Delete
**/
[6] Fix | Delete
elFinder.prototype.resources = {
[7] Fix | Delete
'class' : {
[8] Fix | Delete
hover : 'ui-state-hover',
[9] Fix | Delete
active : 'ui-state-active',
[10] Fix | Delete
disabled : 'ui-state-disabled',
[11] Fix | Delete
draggable : 'ui-draggable',
[12] Fix | Delete
droppable : 'ui-droppable',
[13] Fix | Delete
adroppable : 'elfinder-droppable-active',
[14] Fix | Delete
cwdfile : 'elfinder-cwd-file',
[15] Fix | Delete
cwd : 'elfinder-cwd',
[16] Fix | Delete
tree : 'elfinder-tree',
[17] Fix | Delete
treeroot : 'elfinder-navbar-root',
[18] Fix | Delete
navdir : 'elfinder-navbar-dir',
[19] Fix | Delete
navdirwrap : 'elfinder-navbar-dir-wrapper',
[20] Fix | Delete
navarrow : 'elfinder-navbar-arrow',
[21] Fix | Delete
navsubtree : 'elfinder-navbar-subtree',
[22] Fix | Delete
navcollapse : 'elfinder-navbar-collapsed',
[23] Fix | Delete
navexpand : 'elfinder-navbar-expanded',
[24] Fix | Delete
treedir : 'elfinder-tree-dir',
[25] Fix | Delete
placedir : 'elfinder-place-dir',
[26] Fix | Delete
searchbtn : 'elfinder-button-search',
[27] Fix | Delete
editing : 'elfinder-to-editing',
[28] Fix | Delete
preventback : 'elfinder-prevent-back',
[29] Fix | Delete
tabstab : 'ui-state-default ui-tabs-tab ui-corner-top ui-tab',
[30] Fix | Delete
tabsactive : 'ui-tabs-active ui-state-active'
[31] Fix | Delete
},
[32] Fix | Delete
tpl : {
[33] Fix | Delete
perms : '<span class="elfinder-perms"></span>',
[34] Fix | Delete
lock : '<span class="elfinder-lock"></span>',
[35] Fix | Delete
symlink : '<span class="elfinder-symlink"></span>',
[36] Fix | Delete
navicon : '<span class="elfinder-nav-icon"></span>',
[37] Fix | Delete
navspinner : '<span class="elfinder-spinner elfinder-navbar-spinner"></span>',
[38] Fix | Delete
navdir : '<div class="elfinder-navbar-wrapper{root}"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}"{title}><span class="elfinder-navbar-arrow"></span><span class="elfinder-navbar-icon" {style}></span>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"></div></div>',
[39] Fix | Delete
placedir : '<div class="elfinder-navbar-wrapper"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}"{title}><span class="elfinder-navbar-arrow"></span><span class="elfinder-navbar-icon" {style}></span>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"></div></div>'
[40] Fix | Delete
[41] Fix | Delete
},
[42] Fix | Delete
// mimes.text will be overwritten with connector config if `textMimes` is included in initial response
[43] Fix | Delete
// @see php/elFInder.class.php `public static $textMimes`
[44] Fix | Delete
mimes : {
[45] Fix | Delete
text : [
[46] Fix | Delete
'application/dash+xml',
[47] Fix | Delete
'application/docbook+xml',
[48] Fix | Delete
'application/javascript',
[49] Fix | Delete
'application/json',
[50] Fix | Delete
'application/plt',
[51] Fix | Delete
'application/sat',
[52] Fix | Delete
'application/sql',
[53] Fix | Delete
'application/step',
[54] Fix | Delete
'application/vnd.hp-hpgl',
[55] Fix | Delete
'application/x-awk',
[56] Fix | Delete
'application/x-config',
[57] Fix | Delete
'application/x-csh',
[58] Fix | Delete
'application/x-empty',
[59] Fix | Delete
'application/x-mpegurl',
[60] Fix | Delete
'application/x-perl',
[61] Fix | Delete
'application/x-php',
[62] Fix | Delete
'application/x-web-config',
[63] Fix | Delete
'application/xhtml+xml',
[64] Fix | Delete
'application/xml',
[65] Fix | Delete
'audio/x-mp3-playlist',
[66] Fix | Delete
'image/cgm',
[67] Fix | Delete
'image/svg+xml',
[68] Fix | Delete
'image/vnd.dxf',
[69] Fix | Delete
'model/iges'
[70] Fix | Delete
]
[71] Fix | Delete
},
[72] Fix | Delete
[73] Fix | Delete
mixin : {
[74] Fix | Delete
make : function() {
[75] Fix | Delete
"use strict";
[76] Fix | Delete
var self = this,
[77] Fix | Delete
fm = this.fm,
[78] Fix | Delete
cmd = this.name,
[79] Fix | Delete
req = this.requestCmd || cmd,
[80] Fix | Delete
wz = fm.getUI('workzone'),
[81] Fix | Delete
org = (this.origin && this.origin === 'navbar')? 'tree' : 'cwd',
[82] Fix | Delete
tree = (org === 'tree'),
[83] Fix | Delete
find = tree? 'navHash2Elm' : 'cwdHash2Elm',
[84] Fix | Delete
tarea= (! tree && fm.storage('view') != 'list'),
[85] Fix | Delete
sel = fm.selected(),
[86] Fix | Delete
move = this.move || false,
[87] Fix | Delete
empty= wz.hasClass('elfinder-cwd-wrapper-empty'),
[88] Fix | Delete
unselect = function() {
[89] Fix | Delete
requestAnimationFrame(function() {
[90] Fix | Delete
input && input.trigger('blur');
[91] Fix | Delete
});
[92] Fix | Delete
},
[93] Fix | Delete
rest = function(){
[94] Fix | Delete
if (!overlay.is(':hidden')) {
[95] Fix | Delete
overlay.elfinderoverlay('hide').off('click close', cancel);
[96] Fix | Delete
}
[97] Fix | Delete
if (nnode) {
[98] Fix | Delete
pnode.removeClass('ui-front')
[99] Fix | Delete
.css('position', '')
[100] Fix | Delete
.off('unselect.'+fm.namespace, unselect);
[101] Fix | Delete
if (tarea) {
[102] Fix | Delete
nnode && nnode.css('max-height', '');
[103] Fix | Delete
} else if (!tree) {
[104] Fix | Delete
pnode.css('width', '')
[105] Fix | Delete
.parent('td').css('overflow', '');
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
}, colwidth,
[109] Fix | Delete
dfrd = $.Deferred()
[110] Fix | Delete
.fail(function(error) {
[111] Fix | Delete
dstCls && dst.attr('class', dstCls);
[112] Fix | Delete
empty && wz.addClass('elfinder-cwd-wrapper-empty');
[113] Fix | Delete
if (sel) {
[114] Fix | Delete
move && fm.trigger('unlockfiles', {files: sel});
[115] Fix | Delete
fm.clipboard([]);
[116] Fix | Delete
fm.trigger('selectfiles', { files: sel });
[117] Fix | Delete
}
[118] Fix | Delete
error && fm.error(error);
[119] Fix | Delete
})
[120] Fix | Delete
.always(function() {
[121] Fix | Delete
rest();
[122] Fix | Delete
cleanup();
[123] Fix | Delete
fm.enable().unbind('open', openCallback).trigger('resMixinMake');
[124] Fix | Delete
}),
[125] Fix | Delete
id = 'tmp_'+parseInt(Math.random()*100000),
[126] Fix | Delete
phash = this.data && this.data.target? this.data.target : (tree? fm.file(sel[0]).hash : fm.cwd().hash),
[127] Fix | Delete
date = new Date(),
[128] Fix | Delete
file = {
[129] Fix | Delete
hash : id,
[130] Fix | Delete
phash : phash,
[131] Fix | Delete
name : fm.uniqueName(this.prefix, phash),
[132] Fix | Delete
mime : this.mime,
[133] Fix | Delete
read : true,
[134] Fix | Delete
write : true,
[135] Fix | Delete
date : 'Today '+date.getHours()+':'+date.getMinutes(),
[136] Fix | Delete
move : move
[137] Fix | Delete
},
[138] Fix | Delete
dum = fm.getUI(org).trigger('create.'+fm.namespace, file),
[139] Fix | Delete
data = this.data || {},
[140] Fix | Delete
node = fm[find](id),
[141] Fix | Delete
nnode, pnode,
[142] Fix | Delete
overlay = fm.getUI('overlay'),
[143] Fix | Delete
cleanup = function() {
[144] Fix | Delete
if (node && node.length) {
[145] Fix | Delete
input.off();
[146] Fix | Delete
node.hide();
[147] Fix | Delete
fm.unselectfiles({files : [id]}).unbind('resize', resize);
[148] Fix | Delete
requestAnimationFrame(function() {
[149] Fix | Delete
if (tree) {
[150] Fix | Delete
node.closest('.elfinder-navbar-wrapper').remove();
[151] Fix | Delete
} else {
[152] Fix | Delete
node.remove();
[153] Fix | Delete
}
[154] Fix | Delete
});
[155] Fix | Delete
}
[156] Fix | Delete
},
[157] Fix | Delete
cancel = function(e) {
[158] Fix | Delete
if (!overlay.is(':hidden')) {
[159] Fix | Delete
pnode.css('z-index', '');
[160] Fix | Delete
}
[161] Fix | Delete
if (! inError) {
[162] Fix | Delete
cleanup();
[163] Fix | Delete
dfrd.reject();
[164] Fix | Delete
if (e) {
[165] Fix | Delete
e.stopPropagation();
[166] Fix | Delete
e.preventDefault();
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
},
[170] Fix | Delete
input = $(tarea? '<textarea></textarea>' : '<input type="text"/>')
[171] Fix | Delete
.on('keyup text', function(){
[172] Fix | Delete
if (tarea) {
[173] Fix | Delete
this.style.height = '1px';
[174] Fix | Delete
this.style.height = this.scrollHeight + 'px';
[175] Fix | Delete
} else if (colwidth) {
[176] Fix | Delete
this.style.width = colwidth + 'px';
[177] Fix | Delete
if (this.scrollWidth > colwidth) {
[178] Fix | Delete
this.style.width = this.scrollWidth + 10 + 'px';
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
})
[182] Fix | Delete
.on('keydown', function(e) {
[183] Fix | Delete
e.stopImmediatePropagation();
[184] Fix | Delete
if (e.keyCode == $.ui.keyCode.ESCAPE) {
[185] Fix | Delete
dfrd.reject();
[186] Fix | Delete
} else if (e.keyCode == $.ui.keyCode.ENTER) {
[187] Fix | Delete
e.preventDefault();
[188] Fix | Delete
input.trigger('blur');
[189] Fix | Delete
}
[190] Fix | Delete
})
[191] Fix | Delete
.on('mousedown click dblclick', function(e) {
[192] Fix | Delete
e.stopPropagation();
[193] Fix | Delete
if (e.type === 'dblclick') {
[194] Fix | Delete
e.preventDefault();
[195] Fix | Delete
}
[196] Fix | Delete
})
[197] Fix | Delete
.on('blur', function() {
[198] Fix | Delete
var name = $.trim(input.val()),
[199] Fix | Delete
parent = input.parent(),
[200] Fix | Delete
valid = true,
[201] Fix | Delete
cut;
[202] Fix | Delete
[203] Fix | Delete
if (!overlay.is(':hidden')) {
[204] Fix | Delete
pnode.css('z-index', '');
[205] Fix | Delete
}
[206] Fix | Delete
if (name === '') {
[207] Fix | Delete
return cancel();
[208] Fix | Delete
}
[209] Fix | Delete
if (!inError && parent.length) {
[210] Fix | Delete
[211] Fix | Delete
if (fm.options.validName && fm.options.validName.test) {
[212] Fix | Delete
try {
[213] Fix | Delete
valid = fm.options.validName.test(name);
[214] Fix | Delete
} catch(e) {
[215] Fix | Delete
valid = false;
[216] Fix | Delete
}
[217] Fix | Delete
}
[218] Fix | Delete
if (!name || name === '.' || name === '..' || !valid) {
[219] Fix | Delete
inError = true;
[220] Fix | Delete
fm.error(file.mime === 'directory'? 'errInvDirname' : 'errInvName', {modal: true, close: function(){setTimeout(select, 120);}});
[221] Fix | Delete
return false;
[222] Fix | Delete
}
[223] Fix | Delete
if (fm.fileByName(name, phash)) {
[224] Fix | Delete
inError = true;
[225] Fix | Delete
fm.error(['errExists', name], {modal: true, close: function(){setTimeout(select, 120);}});
[226] Fix | Delete
return false;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
cut = (sel && move)? fm.exec('cut', sel) : null;
[230] Fix | Delete
[231] Fix | Delete
$.when(cut)
[232] Fix | Delete
.done(function() {
[233] Fix | Delete
var toast = {},
[234] Fix | Delete
nextAct = {};
[235] Fix | Delete
[236] Fix | Delete
rest();
[237] Fix | Delete
input.hide().before($('<span>').text(name));
[238] Fix | Delete
[239] Fix | Delete
fm.lockfiles({files : [id]});
[240] Fix | Delete
[241] Fix | Delete
fm.request({
[242] Fix | Delete
data : Object.assign({cmd : req, name : name, target : phash}, data || {}),
[243] Fix | Delete
notify : {type : req, cnt : 1},
[244] Fix | Delete
preventFail : true,
[245] Fix | Delete
syncOnFail : true,
[246] Fix | Delete
navigate : {toast : toast},
[247] Fix | Delete
})
[248] Fix | Delete
.fail(function(error) {
[249] Fix | Delete
fm.unlockfiles({files : [id]});
[250] Fix | Delete
inError = true;
[251] Fix | Delete
input.show().prev().remove();
[252] Fix | Delete
fm.error(error, {
[253] Fix | Delete
modal: true,
[254] Fix | Delete
close: function() {
[255] Fix | Delete
if (Array.isArray(error) && $.inArray('errUploadMime', error) !== -1) {
[256] Fix | Delete
dfrd.notify('errUploadMime').reject();
[257] Fix | Delete
} else {
[258] Fix | Delete
setTimeout(select, 120);
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
});
[262] Fix | Delete
})
[263] Fix | Delete
.done(function(data) {
[264] Fix | Delete
if (data && data.added && data.added[0]) {
[265] Fix | Delete
var item = data.added[0],
[266] Fix | Delete
dirhash = item.hash,
[267] Fix | Delete
newItem = fm[find](dirhash),
[268] Fix | Delete
acts = {
[269] Fix | Delete
'directory' : { cmd: 'open', msg: 'cmdopendir' },
[270] Fix | Delete
'text' : { cmd: 'edit', msg: 'cmdedit' },
[271] Fix | Delete
'default' : { cmd: 'open', msg: 'cmdopen' }
[272] Fix | Delete
},
[273] Fix | Delete
tmpMimes;
[274] Fix | Delete
if (sel && move) {
[275] Fix | Delete
fm.one(req+'done', function() {
[276] Fix | Delete
fm.exec('paste', dirhash);
[277] Fix | Delete
});
[278] Fix | Delete
}
[279] Fix | Delete
if (!move) {
[280] Fix | Delete
if (fm.mimeIsText(item.mime) && !fm.mimesCanMakeEmpty[item.mime] && fm.mimeTypes[item.mime]) {
[281] Fix | Delete
fm.trigger('canMakeEmptyFile', {mimes: [item.mime], unshift: true});
[282] Fix | Delete
tmpMimes = {};
[283] Fix | Delete
tmpMimes[item.mime] = fm.mimeTypes[item.mime];
[284] Fix | Delete
fm.storage('mkfileTextMimes', Object.assign(tmpMimes, fm.storage('mkfileTextMimes') || {}));
[285] Fix | Delete
}
[286] Fix | Delete
Object.assign(nextAct, nextAction || acts[item.mime] || acts[item.mime.split('/')[0]] || acts[(fm.mimesCanMakeEmpty[item.mime] || $.inArray(item.mime, fm.resources.mimes.text) !== -1) ? 'text' : 'none'] || acts['default']);
[287] Fix | Delete
Object.assign(toast, nextAct.cmd ? {
[288] Fix | Delete
incwd : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)]), action: nextAct},
[289] Fix | Delete
inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)]), action: nextAct}
[290] Fix | Delete
} : {
[291] Fix | Delete
inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)])}
[292] Fix | Delete
});
[293] Fix | Delete
}
[294] Fix | Delete
}
[295] Fix | Delete
dfrd.resolve(data);
[296] Fix | Delete
});
[297] Fix | Delete
})
[298] Fix | Delete
.fail(function() {
[299] Fix | Delete
dfrd.reject();
[300] Fix | Delete
});
[301] Fix | Delete
}
[302] Fix | Delete
})
[303] Fix | Delete
.on('dragenter dragleave dragover drop', function(e) {
[304] Fix | Delete
// stop bubbling to prevent upload with native drop event
[305] Fix | Delete
e.stopPropagation();
[306] Fix | Delete
}),
[307] Fix | Delete
select = function() {
[308] Fix | Delete
var name = fm.splitFileExtention(input.val())[0];
[309] Fix | Delete
if (!inError && fm.UA.Mobile && !fm.UA.iOS) { // since iOS has a bug? (z-index not effect) so disable it
[310] Fix | Delete
overlay.on('click close', cancel).elfinderoverlay('show');
[311] Fix | Delete
pnode.css('z-index', overlay.css('z-index') + 1);
[312] Fix | Delete
}
[313] Fix | Delete
inError = false;
[314] Fix | Delete
! fm.enabled() && fm.enable();
[315] Fix | Delete
input.trigger('focus').trigger('select');
[316] Fix | Delete
input[0].setSelectionRange && input[0].setSelectionRange(0, name.length);
[317] Fix | Delete
},
[318] Fix | Delete
resize = function() {
[319] Fix | Delete
node.trigger('scrolltoview', {blink : false});
[320] Fix | Delete
},
[321] Fix | Delete
openCallback = function() {
[322] Fix | Delete
dfrd && (dfrd.state() === 'pending') && dfrd.reject();
[323] Fix | Delete
},
[324] Fix | Delete
inError = false,
[325] Fix | Delete
nextAction,
[326] Fix | Delete
// for tree
[327] Fix | Delete
dst, dstCls, collapsed, expanded, arrow, subtree;
[328] Fix | Delete
[329] Fix | Delete
if (!fm.isCommandEnabled(req, phash) || !node.length) {
[330] Fix | Delete
return dfrd.reject();
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
if ($.isPlainObject(self.nextAction)){
[334] Fix | Delete
nextAction = Object.assign({}, self.nextAction);
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
if (tree) {
[338] Fix | Delete
dst = fm[find](phash);
[339] Fix | Delete
collapsed = fm.res('class', 'navcollapse');
[340] Fix | Delete
expanded = fm.res('class', 'navexpand');
[341] Fix | Delete
arrow = fm.res('class', 'navarrow');
[342] Fix | Delete
subtree = fm.res('class', 'navsubtree');
[343] Fix | Delete
[344] Fix | Delete
node.closest('.'+subtree).show();
[345] Fix | Delete
if (! dst.hasClass(collapsed)) {
[346] Fix | Delete
dstCls = dst.attr('class');
[347] Fix | Delete
dst.addClass(collapsed+' '+expanded+' elfinder-subtree-loaded');
[348] Fix | Delete
}
[349] Fix | Delete
if (dst.is('.'+collapsed+':not(.'+expanded+')')) {
[350] Fix | Delete
dst.children('.'+arrow).trigger('click').data('dfrd').done(function() {
[351] Fix | Delete
if (input.val() === file.name) {
[352] Fix | Delete
input.val(fm.uniqueName(self.prefix, phash)).trigger('select').trigger('focus');
[353] Fix | Delete
}
[354] Fix | Delete
});
[355] Fix | Delete
}
[356] Fix | Delete
nnode = node.contents().filter(function(){ return this.nodeType==3 && $(this).parent().attr('id') === fm.navHash2Id(file.hash); });
[357] Fix | Delete
pnode = nnode.parent();
[358] Fix | Delete
nnode.replaceWith(input.val(file.name));
[359] Fix | Delete
} else {
[360] Fix | Delete
empty && wz.removeClass('elfinder-cwd-wrapper-empty');
[361] Fix | Delete
nnode = node.find('.elfinder-cwd-filename');
[362] Fix | Delete
pnode = nnode.parent();
[363] Fix | Delete
if (tarea) {
[364] Fix | Delete
nnode.css('max-height', 'none');
[365] Fix | Delete
} else {
[366] Fix | Delete
colwidth = pnode.width();
[367] Fix | Delete
pnode.width(colwidth - 15)
[368] Fix | Delete
.parent('td').css('overflow', 'visible');
[369] Fix | Delete
}
[370] Fix | Delete
nnode.empty().append(input.val(file.name));
[371] Fix | Delete
}
[372] Fix | Delete
pnode.addClass('ui-front')
[373] Fix | Delete
.css('position', 'relative')
[374] Fix | Delete
.on('unselect.'+fm.namespace, unselect);
[375] Fix | Delete
[376] Fix | Delete
fm.bind('resize', resize).one('open', openCallback);
[377] Fix | Delete
[378] Fix | Delete
input.trigger('keyup');
[379] Fix | Delete
select();
[380] Fix | Delete
[381] Fix | Delete
return dfrd;
[382] Fix | Delete
[383] Fix | Delete
}
[384] Fix | Delete
},
[385] Fix | Delete
blink: function(elm, mode) {
[386] Fix | Delete
"use strict";
[387] Fix | Delete
var acts = {
[388] Fix | Delete
slowonce : function(){elm.hide().delay(250).fadeIn(750).delay(500).fadeOut(3500);},
[389] Fix | Delete
lookme : function(){elm.show().fadeOut(500).fadeIn(750);}
[390] Fix | Delete
}, func;
[391] Fix | Delete
mode = mode || 'slowonce';
[392] Fix | Delete
[393] Fix | Delete
func = acts[mode] || acts['lookme'];
[394] Fix | Delete
[395] Fix | Delete
elm.stop(true, true);
[396] Fix | Delete
func();
[397] Fix | Delete
}
[398] Fix | Delete
};
[399] Fix | Delete
[400] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function