Skip to content

Commit

Permalink
elFinder up to newly ( Studio-42/elFinder@44346c4 )
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Feb 1, 2020
1 parent 58fb0d6 commit 69f095f
Show file tree
Hide file tree
Showing 24 changed files with 859 additions and 306 deletions.
2 changes: 1 addition & 1 deletion html/common/elfinder/README.md
Expand Up @@ -124,7 +124,7 @@ Installation
Downloads
------------
**Stable releases** ([Changelog](https://github.com/Studio-42/elFinder/blob/master/Changelog))
+ [elFinder 2.1.52](https://github.com/Studio-42/elFinder/archive/2.1.52.zip)
+ [elFinder 2.1.53](https://github.com/Studio-42/elFinder/archive/2.1.53.zip)
+ [elFinder 2.0.9](https://github.com/Studio-42/elFinder/archive/2.0.9.zip) (deprecated)

**Nightly builds**
Expand Down
27 changes: 24 additions & 3 deletions html/common/elfinder/css/elfinder.full.css
@@ -1,6 +1,6 @@
/*!
* elFinder - file manager for web
* Version 2.1.52 (2.1 Nightly: 93c2045) (2020-01-21)
* Version 2.1.53 (2.1 Nightly: 44346c4) (2020-02-01)
* http://elfinder.org
*
* Copyright 2009-2020, Studio 42
Expand Down Expand Up @@ -4192,9 +4192,10 @@ button.elfinder-info-button {
}

/* image in preview */
.elfinder-quicklook-preview img {
.elfinder-quicklook-preview > img,
.elfinder-quicklook-preview > div > canvas {
display: block;
margin: 0 auto;
margin: auto;
}

/* navigation bar on quicklook window bottom */
Expand Down Expand Up @@ -4274,6 +4275,26 @@ button.elfinder-info-button {
display: none;
}

/* text encoding selector */
.elfinder-quicklook-encoding {
height: 40px;
}
.elfinder-quicklook-encoding > select {
color: #fff;
background: #000;
border: 0;
font-size: 12px;
max-width: 100px;
display: inline-block;
position: relative;
top: 6px;
left: 5px;
}
.elfinder-navdock .elfinder-quicklook .elfinder-quicklook-encoding {
display: none;
}


/* text files preview wrapper */
.elfinder-quicklook-preview-text-wrapper {
width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions html/common/elfinder/css/elfinder.min.css

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions html/common/elfinder/css/quicklook.css
Expand Up @@ -313,9 +313,10 @@
}

/* image in preview */
.elfinder-quicklook-preview img {
.elfinder-quicklook-preview > img,
.elfinder-quicklook-preview > div > canvas {
display: block;
margin: 0 auto;
margin: auto;
}

/* navigation bar on quicklook window bottom */
Expand Down Expand Up @@ -395,6 +396,26 @@
display: none;
}

/* text encoding selector */
.elfinder-quicklook-encoding {
height: 40px;
}
.elfinder-quicklook-encoding > select {
color: #fff;
background: #000;
border: 0;
font-size: 12px;
max-width: 100px;
display: inline-block;
position: relative;
top: 6px;
left: 5px;
}
.elfinder-navdock .elfinder-quicklook .elfinder-quicklook-encoding {
display: none;
}


/* text files preview wrapper */
.elfinder-quicklook-preview-text-wrapper {
width: 100%;
Expand Down
133 changes: 86 additions & 47 deletions html/common/elfinder/js/commands/edit.js
Expand Up @@ -114,7 +114,7 @@ elFinder.prototype.commands.edit = function() {
* @param String content file content
* @return $.Deferred
**/
dialog = function(id, file, content, encoding, editor) {
dialog = function(id, file, content, encoding, editor, toasts) {

var dfrd = $.Deferred(),
_loaded = false,
Expand All @@ -128,12 +128,20 @@ elFinder.prototype.commands.edit = function() {
}
return true;
},
makeToasts = function() {
// make toast message
if (toasts && Array.isArray(toasts)) {
$.each(toasts, function() {
this.msg && fm.toast(this);
});
}
},
save = function() {
var encord = selEncoding? selEncoding.val():void(0),
saveDfd = $.Deferred().fail(function(err) {
dialogNode.show().find('button.elfinder-btncnt-0,button.elfinder-btncnt-1').hide();
}),
conf, res;
conf, res, tm;
if (!loaded()) {
return saveDfd.resolve();
}
Expand All @@ -147,7 +155,20 @@ elFinder.prototype.commands.edit = function() {
res = getContent();
setOld(res);
if (res.promise) {
res.done(function(data) {
tm = setTimeout(function() {
fm.notify({
type : 'chkcontent',
cnt : 1,
hideCnt: true,
cancel : function() {
res.reject();
}
});
}, 100);
res.always(function() {
tm && clearTimeout(tm);
fm.notify({ type : 'chkcontent', cnt: -1 });
}).done(function(data) {
dfrd.notifyWith(ta, [encord, ta.data('hash'), old, saveDfd]);
}).fail(function(err) {
saveDfd.reject(err);
Expand Down Expand Up @@ -253,7 +274,10 @@ elFinder.prototype.commands.edit = function() {
fm.notify({
type : 'chkcontent',
cnt : 1,
hideCnt: true
hideCnt: true,
cancel : function() {
res.reject();
}
});
}, 100);
res.always(function() {
Expand Down Expand Up @@ -364,7 +388,7 @@ elFinder.prototype.commands.edit = function() {
error && fm.error(error);
ta.elfinderdialog('destroy');
return;
});
}).always(makeToasts);
} else {
_loaded = true;
if (loadRes && (typeof loadRes === 'string' || Array.isArray(loadRes))) {
Expand All @@ -378,6 +402,7 @@ elFinder.prototype.commands.edit = function() {
requestAnimationFrame(function() {
dialogNode.trigger('resize');
});
makeToasts();
}
conf = ta.editor.confObj;
if (conf.info && conf.info.syncInterval) {
Expand Down Expand Up @@ -416,6 +441,17 @@ elFinder.prototype.commands.edit = function() {
}, interval);
}
},
stateChange = function() {
if (selEncoding) {
changed().done(function(change) {
if (change) {
selEncoding.attr('title', fm.i18n('saveAsEncoding')).addClass('elfinder-edit-changed');
} else {
selEncoding.attr('title', fm.i18n('openAsEncoding')).removeClass('elfinder-edit-changed');
}
});
}
},
saveAsFile = {},
ta, old, dialogNode, selEncoding, extEditor, maxW, syncInterval;

Expand Down Expand Up @@ -450,22 +486,10 @@ elFinder.prototype.commands.edit = function() {
return dfrd.reject('errEditorNotFound');
}
(function() {
var stateChange = function() {
if (selEncoding) {
changed().done(function(change) {
if (change) {
selEncoding.attr('title', fm.i18n('saveAsEncoding')).addClass('elfinder-edit-changed');
} else {
selEncoding.attr('title', fm.i18n('openAsEncoding')).removeClass('elfinder-edit-changed');
}
});
}
};

ta = $('<textarea class="elfinder-file-edit" rows="20" id="'+id+'-ta"></textarea>')
.on('input propertychange', stateChange);

if (!ta.editor || !ta.editor.info || ta.editor.info.useTextAreaEvent) {
if (!editor || !editor.info || editor.info.useTextAreaEvent) {
ta.on('keydown', function(e) {
var code = e.keyCode,
value, start;
Expand Down Expand Up @@ -500,37 +524,42 @@ elFinder.prototype.commands.edit = function() {
}

ta.initEditArea = function(id, file, content) {
var heads = (encoding && encoding !== 'unknown')? [{value: encoding}] : [],
wfake = $('<select/>').hide(),
setSelW = function(init) {
init && wfake.appendTo(selEncoding.parent());
wfake.empty().append($('<option/>').text(selEncoding.val()));
selEncoding.width(wfake.width());
};
// ta.hide() for performance tune. Need ta.show() in `load()` if use textarea node.
ta.hide().val(content);
if (content === '' || ! encoding || encoding !== 'UTF-8') {
heads.push({value: 'UTF-8'});
}
selEncoding = getEncSelect(heads).on('touchstart', function(e) {
// for touch punch event handler
e.stopPropagation();
}).on('change', function() {
// reload to change encoding if not edited
changed().done(function(change) {
if (! change && getContent() !== '') {
cancel();
edit(file, selEncoding.val(), editor).fail(function(err) { err && fm.error(err); });
}
});
setSelW();
}).on('mouseover', stateChange);
ta.parent().next().prepend($('<div class="ui-dialog-buttonset elfinder-edit-extras"/>').append(selEncoding));
setSelW(true);
this._setupSelEncoding(content);
};
})();
}


// extended function to setup selector of encoding for text editor
ta._setupSelEncoding = function(content) {
var heads = (encoding && encoding !== 'unknown')? [{value: encoding}] : [],
wfake = $('<select/>').hide(),
setSelW = function(init) {
init && wfake.appendTo(selEncoding.parent());
wfake.empty().append($('<option/>').text(selEncoding.val()));
selEncoding.width(wfake.width());
};
if (content === '' || ! encoding || encoding !== 'UTF-8') {
heads.push({value: 'UTF-8'});
}
selEncoding = getEncSelect(heads).on('touchstart', function(e) {
// for touch punch event handler
e.stopPropagation();
}).on('change', function() {
// reload to change encoding if not edited
changed().done(function(change) {
if (! change && getContent() !== '') {
cancel();
edit(file, selEncoding.val(), editor).fail(function(err) { err && fm.error(err); });
}
});
setSelW();
}).on('mouseover', stateChange);
ta.parent().next().prepend($('<div class="ui-dialog-buttonset elfinder-edit-extras"/>').append(selEncoding));
setSelW(true);
};

ta.data('hash', file.hash);

if (extEditor) {
Expand Down Expand Up @@ -655,6 +684,10 @@ elFinder.prototype.commands.edit = function() {
req.resolve({});
}
} else {
if (conv) {
file.encoding = conv;
fm.cache(file, 'change');
}
req = fm.request({
data : {cmd : 'get', target : hash, conv : conv, _t : file.ts},
options : {type: 'get', cache : true},
Expand Down Expand Up @@ -707,7 +740,7 @@ elFinder.prototype.commands.edit = function() {
}
}
}
dialog(id, file, data.content, data.encoding, editor)
dialog(id, file, data.content, data.encoding, editor, data.toasts)
.done(function(data) {
dfrd.resolve(data);
})
Expand Down Expand Up @@ -754,6 +787,10 @@ elFinder.prototype.commands.edit = function() {
.fail(function(error) {
var err = fm.parseError(error);
err = Array.isArray(err)? err[0] : err;
if (file.encoding) {
file.encoding = '';
fm.cache(file, 'change');
}
(err !== 'errConvUTF8') && fm.sync();
dfrd.reject(error);
});
Expand Down Expand Up @@ -910,7 +947,9 @@ elFinder.prototype.commands.edit = function() {
},
stored;


// make public method
this.getEncSelect = getEncSelect;

this.shortcuts = [{
pattern : 'ctrl+e'
}];
Expand Down Expand Up @@ -1143,7 +1182,7 @@ elFinder.prototype.commands.edit = function() {

getEditor().done(function(editor) {
while ((file = files.shift())) {
list.push(edit(file, void(0), editor).fail(function(error) {
list.push(edit(file, (file.encoding || void(0)), editor).fail(function(error) {
error && fm.error(error);
}));
}
Expand Down
2 changes: 1 addition & 1 deletion html/common/elfinder/js/commands/help.js
Expand Up @@ -74,7 +74,7 @@

html.push(sep);
html.push('<div class="'+lic+'">Licence: 3-clauses BSD Licence</div>');
html.push('<div class="'+lic+'">Copyright © 2009-2019, Studio 42</div>');
html.push('<div class="'+lic+'">Copyright © 2009-2020, Studio 42</div>');
html.push('<div class="'+lic+'">„ …'+fm.i18n('dontforget')+' ”</div>');
html.push('</div>');
},
Expand Down
10 changes: 9 additions & 1 deletion html/common/elfinder/js/commands/quicklook.js
Expand Up @@ -361,6 +361,11 @@
init = true,
dockHeight, getSize, tm4cwd, dockedNode, selectTm;

/**
* Any flags for each plugin
*/
this.flags = {};

this.cover = cover;
this.evUpdate = evUpdate;
(this.navbar = navbar)._show = navShow;
Expand Down Expand Up @@ -558,7 +563,10 @@
state = animated;
win.hasClass(fullscreen) && fsicon.click();
(hash && (node = cwd.find('#'+hash)).length)
? win.animate(closedCss(node), 500, function() { close(closed, true); })
? win.animate(closedCss(node), 500, function() {
preview.off('changesize');
close(closed, true);
})
: close(closed, true);
} else {
dockedNode = fm.getUI('navdock').data('removeNode')(self.window.attr('id'), 'detach');
Expand Down

0 comments on commit 69f095f

Please sign in to comment.