Skip to content

Commit

Permalink
[ui:cwd] correction of UI feedback when cwd is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed May 16, 2016
1 parent 198833d commit 66b75c4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
11 changes: 10 additions & 1 deletion css/cwd.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
filter:Alpha(Opacity=80);
}

.elfinder .elfinder-workzone.elfinder-cwd-wrapper-empty .elfinder-cwd-selectall {
display: none;
}

/************************** ICONS VIEW ********************************/

.elfinder-ltr .elfinder-workzone .elfinder-cwd-selectall {
Expand Down Expand Up @@ -280,7 +284,7 @@
.elfinder-cwd-icon-group { background-position:0 -1300px;}

/* textfield inside icon */
.elfinder-cwd input:text { width:100%; border:0px solid; margin:0; padding:0; }
.elfinder-cwd-filename input { width:100%; border:none; margin:0; padding:0; }
.elfinder-cwd-view-icons input {text-align:center; }
.elfinder-cwd-view-icons textarea {
width: 100%;
Expand Down Expand Up @@ -442,3 +446,8 @@ tr.elfinder-cwd-file td .elfinder-cwd-select {
/* icon in ltr/rtl enviroment */
.elfinder-ltr .elfinder-cwd-view-list .elfinder-cwd-icon { left:0; }
.elfinder-rtl .elfinder-cwd-view-list .elfinder-cwd-icon { right:0; }

/* empty message */
.elfinder-cwd-wrapper-empty .elfinder-cwd-view-list.elfinder-cwd:after {
margin-top: 0;
}
4 changes: 4 additions & 0 deletions js/elFinder.resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ elFinder.prototype.resources = {
make : function() {
var fm = this.fm,
cmd = this.name,
wz = fm.getUI('workzone'),
cwd = fm.getUI('cwd'),
tarea= (fm.storage('view') != 'list'),
sel = fm.selected(),
move = this.move || false,
empty= wz.hasClass('elfinder-cwd-wrapper-empty'),
rest = function(){
if (!overlay.is(':hidden')) {
overlay.addClass('ui-front')
Expand All @@ -80,6 +82,7 @@ elFinder.prototype.resources = {
}, colwidth,
dfrd = $.Deferred()
.fail(function(error) {
empty && wz.addClass('elfinder-cwd-wrapper-empty');
if (sel) {
move && fm.trigger('unlockfiles', {files: sel});
fm.clipboard([]);
Expand Down Expand Up @@ -226,6 +229,7 @@ elFinder.prototype.resources = {
return dfrd.reject();
}

empty && wz.removeClass('elfinder-cwd-wrapper-empty');
nnode = node.find('.elfinder-cwd-filename');
pnode = nnode.parent();
node.css('position', 'relative').addClass('ui-front');
Expand Down
1 change: 1 addition & 0 deletions js/i18n/elfinder.LANG.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ if (elFinder && elFinder.prototype && typeof(elFinder.prototype.i18) == 'object'
'nowLoading' : 'Now loading...', // from v2.1.12 added 4.26.2016
'openMulti' : 'Open multiple files', // from v2.1.12 added 5.14.2016
'openMultiConfirm': 'You are trying to open the $1 files. Are you sure you want to open in browser?', // from v2.1.12 added 5.14.2016
'emptySearch' : 'Search results is empty', // from v2.1.12 added 5.16.2016

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
Expand Down
3 changes: 2 additions & 1 deletion js/i18n/elfinder.en.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* English translation
* @author Troex Nevelin <[email protected]>
* @version 2016-05-14
* @version 2016-05-16
*/
if (elFinder && elFinder.prototype && typeof(elFinder.prototype.i18) == 'object') {
elFinder.prototype.i18.en = {
Expand Down Expand Up @@ -344,6 +344,7 @@ if (elFinder && elFinder.prototype && typeof(elFinder.prototype.i18) == 'object'
'nowLoading' : 'Now loading...', // from v2.1.12 added 4.26.2016
'openMulti' : 'Open multiple files', // from v2.1.12 added 5.14.2016
'openMultiConfirm': 'You are trying to open the $1 files. Are you sure you want to open in browser?', // from v2.1.12 added 5.14.2016
'emptySearch' : 'Search results is empty', // from v2.1.12 added 5.16.2016

/********************************** mimetypes **********************************/
'kindUnknown' : 'Unknown',
Expand Down
3 changes: 2 additions & 1 deletion js/i18n/elfinder.jp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Japanese translation
* @author Tomoaki Yoshida <[email protected]>
* @author Naoki Sawada <[email protected]>
* @version 2016-05-14
* @version 2016-05-16
*/
if (elFinder && elFinder.prototype && typeof(elFinder.prototype.i18) == 'object') {
elFinder.prototype.i18.jp = {
Expand Down Expand Up @@ -345,6 +345,7 @@ if (elFinder && elFinder.prototype && typeof(elFinder.prototype.i18) == 'object'
'nowLoading' : '読み込んでいます...', // from v2.1.12 added 4.26.2016
'openMulti' : '複数ファイルオープン', // from v2.1.12 added 5.14.2016
'openMultiConfirm': '$1 個のファイルを開こうとしています。このままブラウザで開きますか?', // from v2.1.12 added 5.14.2016
'emptySearch' : '検索対象に該当するアイテムはありません', // from v2.1.12 added 5.16.2016

/********************************** mimetypes **********************************/
'kindUnknown' : '不明',
Expand Down
34 changes: 17 additions & 17 deletions js/ui/cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ $.fn.elfindercwd = function(fm, options) {
cwd.css('margin-top', hheight - parseInt(table.css('padding-top')));
base = $('<div/>').addClass(cwd.attr('class')).append($('<table/>').append(thead));
tableHeader = $('<div/>').addClass(wrapper.attr('class') + ' elfinder-cwd-fixheader')
.removeClass('ui-droppable native-droppable elfinder-cwd-wrapper-empty')
.removeClass('ui-droppable native-droppable')
.css(wrapper.position())
.css('height', hheight)
.append(base);
Expand Down Expand Up @@ -798,7 +798,7 @@ $.fn.elfindercwd = function(fm, options) {
},
file, hash, node, ndx;

l && wrapper.removeClass('elfinder-cwd-wrapper-empty');
l && wz.removeClass('elfinder-cwd-wrapper-empty');

while (l--) {
file = files[l];
Expand Down Expand Up @@ -865,13 +865,6 @@ $.fn.elfindercwd = function(fm, options) {
buffer.splice(ndx, 1);
}
}

// refresh cwd if empty for a bug of browser (ex. Android Chrome 43.0.2357.93)
if (cwd.children().length < 1) {
wrapper.addClass('elfinder-cwd-wrapper-empty');
cwd.hide();
setTimeout(function(){ cwd.show(); }, 0);
}
},

msg = {
Expand Down Expand Up @@ -969,21 +962,22 @@ $.fn.elfindercwd = function(fm, options) {
* @return void
*/
content = function(files, any) {
var phash = fm.cwd().hash;
var phash = fm.cwd().hash,
emptyMethod;

cwdParents = fm.parents(phash);

unselectAll();

wz.append(selectAllCheckbox);

try {
// to avoid problem with draggable
cwd.empty();
} catch (e) {
cwd.html('');
}

wz.append(selectAllCheckbox);

if (tableHeader) {
wrapper.off('scroll.fixheader resize.fixheader');
tableHeader.remove();
Expand Down Expand Up @@ -1017,7 +1011,8 @@ $.fn.elfindercwd = function(fm, options) {

buffer = fm.sortFiles(buffer);

wrapper[(!any && buffer.length < 1) ? 'addClass' : 'removeClass']('elfinder-cwd-wrapper-empty').on(scrollEvent, render).trigger(scrollEvent);
wz[(buffer.length < 1) ? 'addClass' : 'removeClass']('elfinder-cwd-wrapper-empty');
wrapper.on(scrollEvent, render).trigger(scrollEvent);

phash = fm.cwd().phash;

Expand Down Expand Up @@ -1494,8 +1489,9 @@ $.fn.elfindercwd = function(fm, options) {
document.head.appendChild(style);
sheet = style.sheet;
sheet.insertRule('.elfinder-cwd-wrapper-empty .elfinder-cwd:after{ content:"'+fm.i18n('emptyFolder')+'" }', 0);
sheet.insertRule('.ui-droppable.elfinder-cwd-wrapper-empty .elfinder-cwd:after{ content:"'+fm.i18n('emptyFolder'+(mobile? 'LTap' : 'Drop'))+'" }', 1);
sheet.insertRule('.ui-droppable.elfinder-cwd-wrapper-empty.ui-droppable-disabled .elfinder-cwd:after{ content:"'+fm.i18n('emptyFolder')+'" }', 2);
sheet.insertRule('.elfinder-cwd-wrapper-empty .ui-droppable .elfinder-cwd:after{ content:"'+fm.i18n('emptyFolder'+(mobile? 'LTap' : 'Drop'))+'" }', 1);
sheet.insertRule('.elfinder-cwd-wrapper-empty .ui-droppable-disabled .elfinder-cwd:after{ content:"'+fm.i18n('emptyFolder')+'" }', 2);
sheet.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result .elfinder-cwd:after{ content:"'+fm.i18n('emptySearch')+'" }', 3);
})
.bind('open', function(e) {
content(e.data.files);
Expand All @@ -1504,19 +1500,19 @@ $.fn.elfindercwd = function(fm, options) {
.bind('search', function(e) {
lastSearch = e.data.files;
content(lastSearch, true);
wrapper.addClass('elfinder-search-result');
wz.addClass('elfinder-search-result');
fm.autoSync('stop');
resize();
})
.bind('searchend', function(e) {
lastSearch = [];
wz.removeClass('elfinder-search-result elfinder-cwd-wrapper-empty');
if (query) {
query = '';
if (!e.data || !e.data.noupdate) {
content(fm.files());
}
}
wrapper.removeClass('elfinder-search-result');
fm.autoSync();
resize();
})
Expand Down Expand Up @@ -1600,6 +1596,10 @@ $.fn.elfindercwd = function(fm, options) {
.remove(function(e) {
remove(e.data.removed || []);
trigger();
if (buffer.length < 1 && (list ? cwd.find('tbody') : cwd).children().length < 1) {
wz.addClass('elfinder-cwd-wrapper-empty');
selectCheckbox && selectAllCheckbox.find('input').prop('checked', false);
}
})
// select dragged file if no selected, disable selectable
.dragstart(function(e) {
Expand Down

0 comments on commit 66b75c4

Please sign in to comment.