Skip to content

Commit

Permalink
[ui:cwd,tree] accurate feedback sign of jQuery DnD drag icon
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Dec 10, 2015
1 parent b939a5d commit 359d0d0
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 44 deletions.
2 changes: 1 addition & 1 deletion css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

/* show "plus" icon when ctrl/shift pressed */
.elfinder-drag-helper-move .elfinder-drag-helper-icon-status {
background:url('../img/toolbar.png') 0 -528px no-repeat;
background:url('../img/toolbar.png') 0 -720px no-repeat;
display:block;
}
.elfinder-drag-helper-plus .elfinder-drag-helper-icon-status {
Expand Down
Binary file modified img/toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ window.elFinder = function(node, opts) {
? self.selected()
: [self.navId2Hash(element.attr('id'))];

helper.append(icon(files[hashes[0]])).data('files', hashes).data('locked', false).data('droped', false).data('namespace', self.namespace);
helper.append(icon(files[hashes[0]])).data('files', hashes).data('locked', false).data('droped', false).data('namespace', self.namespace).data('dropover', 0);

if ((l = hashes.length) > 1) {
helper.append(icon(files[hashes[l-1]]) + '<span class="elfinder-drag-num">'+l+'</span>');
Expand All @@ -723,7 +723,7 @@ window.elFinder = function(node, opts) {
var chk = (e.shiftKey||e.ctrlKey||e.metaKey);
if (ctr !== chk) {
ctr = chk;
if (helper.is(':visible') && ! helper.data('droped')) {
if (helper.is(':visible') && helper.data('dropover') && ! helper.data('droped')) {
helper.toggleClass('elfinder-drag-helper-plus', helper.data('locked')? true : ctr);
self.trigger(ctr? 'unlockfiles' : 'lockfiles', {files : hashes, helper: helper});
}
Expand Down Expand Up @@ -1842,9 +1842,11 @@ window.elFinder = function(node, opts) {
.change(function(e) {
$.each(e.data.changed||[], function(i, file) {
var hash = file.hash;
if ((files[hash].width && !file.width) || (files[hash].height && !file.height)) {
files[hash].width = undefined;
files[hash].height = undefined;
if (files[hash]) {
if ((files[hash].width && !file.width) || (files[hash].height && !file.height)) {
files[hash].width = undefined;
files[hash].height = undefined;
}
}
files[hash] = files[hash] ? $.extend(files[hash], file) : file;
});
Expand Down
42 changes: 29 additions & 13 deletions js/ui/cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,32 +512,48 @@ $.fn.elfindercwd = function(fm, options) {
over : function(e, ui) {
var dst = $(this),
helper = ui.helper,
hash;
if (dst.data('dropover')) {
return;
}
ctr = (e.shiftKey || e.ctrlKey || e.metaKey),
hash, status, inParent;
e.stopPropagation();
helper.data('dropover', helper.data('dropover') + 1);
dst.data('dropover', true);
if (helper.data('namespace') !== fm.namespace) {
dst.removeClass(clDropActive);
return false;
}
if (dst.hasClass(fm.res(c, 'cwdfile'))) {
hash = dst.attr('id');
dst.data('dropover', hash);
} else {
hash = fm.cwd().hash;
fm.cwd().write && dst.data('dropover', hash);
}
inParent = (fm.file(helper.data('files')[0]).phash === hash);
if (dst.data('dropover') === hash) {
$.each(helper.data('files'), function(i, h) {
if (h === hash || (inParent && !ctr && !helper.hasClass('elfinder-drag-helper-plus'))) {
dst.removeClass(clDropActive);
return false; // break $.each
}
});
} else {
dst.removeClass(clDropActive);
}
dst.data('dropover', hash);
$.each(helper.data('files'), function(i, h) {
if (h === hash || (fm.file(h).phash === hash && !helper.hasClass('elfinder-drag-helper-plus'))) {
dst.removeClass(clDropActive);
return false; // break $.each
if (helper.data('locked') || inParent) {
status = 'elfinder-drag-helper-plus';
} else {
status = 'elfinder-drag-helper-move';
if (ctr) {
status += ' elfinder-drag-helper-plus';
}
});
dst.hasClass(clDropActive) && helper.addClass('elfinder-drag-helper-' + (helper.data('locked')? 'plus' : 'move'));
setTimeout(function(){ dst.hasClass(clDropActive) && helper.addClass('elfinder-drag-helper-' + (helper.data('locked')? 'plus' : 'move')); }, 20);
}
dst.hasClass(clDropActive) && helper.addClass(status);
setTimeout(function(){ dst.hasClass(clDropActive) && helper.addClass(status); }, 20);
},
out : function(e, ui) {
ui.helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus');
var helper = ui.helper;
e.stopPropagation();
helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus').data('dropover', Math.max(helper.data('dropover') - 1, 0));
$(this).removeData('dropover')
.removeClass(clDropActive);
},
Expand Down
55 changes: 30 additions & 25 deletions js/ui/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,39 +156,44 @@ $.fn.elfindertree = function(fm, opts) {
var dst = $(this),
helper = ui.helper,
cl = hover+' '+dropover,
hash;
if (dst.data('dropover')) {
return;
}
hash, status;
e.stopPropagation();
helper.data('dropover', helper.data('dropover') + 1);
dst.data('dropover', true);
if (ui.helper.data('namespace') !== fm.namespace) {
dst.removeClass(cl);
return false;
}
if (insideNavbar(e.clientX)) {
dst.addClass(hover)
if (dst.is('.'+collapsed+':not(.'+expanded+')')) {
dst.data('expandTimer', setTimeout(function() {
dst.children('.'+arrow).click();
}, 500));
dst.addClass(hover)
if (dst.is('.'+collapsed+':not(.'+expanded+')')) {
dst.data('expandTimer', setTimeout(function() {
dst.children('.'+arrow).click();
}, 500));
}
hash = fm.navId2Hash(dst.attr('id'));
dst.data('dropover', hash);
$.each(ui.helper.data('files'), function(i, h) {
if (h === hash || (fm.file(h).phash === hash && !ui.helper.hasClass('elfinder-drag-helper-plus'))) {
dst.removeClass(cl);
return false; // break $.each
}
hash = fm.navId2Hash(dst.attr('id'));
dst.data('dropover', hash);
$.each(ui.helper.data('files'), function(i, h) {
if (h === hash || (fm.file(h).phash === hash && !ui.helper.hasClass('elfinder-drag-helper-plus'))) {
dst.removeClass(cl);
return false; // break $.each
}
});
dst.hasClass(dropover) && helper.addClass('elfinder-drag-helper-' + (helper.data('locked')? 'plus' : 'move'));
setTimeout(function(){ dst.hasClass(dropover) && helper.addClass('elfinder-drag-helper-' + (helper.data('locked')? 'plus' : 'move')); }, 20);
});
if (helper.data('locked')) {
status = 'elfinder-drag-helper-plus';
} else {
dst.removeClass(cl);
status = 'elfinder-drag-helper-move';
if (e.shiftKey || e.ctrlKey || e.metaKey) {
status += ' elfinder-drag-helper-plus';
}
}
dst.hasClass(dropover) && helper.addClass(status);
setTimeout(function(){ dst.hasClass(dropover) && helper.addClass(status); }, 20);
},
out : function(e, ui) {
var dst = $(this);
ui.helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus');
var dst = $(this),
helper = ui.helper;
e.stopPropagation();
helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus').data('dropover', Math.max(helper.data('dropover') - 1, 0));
dst.data('expandTimer') && clearTimeout(dst.data('expandTimer'));
dst.removeData('dropover')
.removeClass(hover+' '+dropover);
Expand Down Expand Up @@ -704,8 +709,8 @@ $.fn.elfindertree = function(fm, opts) {
})
// update changed dirs
.change(function(e) {
var length = dirs.length,
dirs = filter(e.data.changed),
var dirs = filter(e.data.changed),
length = dirs.length,
l = length,
dir, node, tmp, realParent, reqParent, realSibling, reqSibling, isExpanded, isLoaded;

Expand Down

0 comments on commit 359d0d0

Please sign in to comment.