Skip to content

Commit

Permalink
[js:core,ui:cwd,tree] fix #2664 problem of handling of connector opti…
Browse files Browse the repository at this point in the history
…on `maxTargets`
  • Loading branch information
nao-pon committed Sep 20, 2018
1 parent 81ba8a4 commit df65524
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,6 @@ var elFinder = function(elm, opts, bootCallback) {
requestQueueSkipOpen = true;
}

requestCnt++;

dfrd.always(function() {
delete options.headers['X-elFinderReqid'];
}).fail(function(error, xhr, response) {
Expand Down Expand Up @@ -2331,7 +2329,9 @@ var elFinder = function(elm, opts, bootCallback) {
dfrd.syncOnFail = function(state) {
syncOnFail = !!state;
};


requestCnt++;

dfrd.xhr = xhr = self.transport.send(options).always(function() {
// set responseURL from native xhr object
if (options._xhr && typeof options._xhr.responseURL !== 'undefined') {
Expand Down
9 changes: 8 additions & 1 deletion js/ui/cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,18 @@ $.fn.elfindercwd = function(fm, options) {
selectCheckbox && selectAllCheckbox.find('input').prop('checked', true);
fm.lazy(function() {
var files;
cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect);
if (fm.maxTargets && (incHashes || cwdHashes).length > fm.maxTargets) {
unselectAll({ notrigger: true });
files = $.map(incHashes || cwdHashes, function(hash) { return fm.file(hash) || null; });
files = files.slice(0, fm.maxTargets);
selectedFiles = {};
$.each(files, function(i, v) {
selectedFiles[v.hash] = true;
$('#'+fm.cwdHash2Id(v.hash)).trigger(evtSelect);
});
fm.toast({mode: 'warning', msg: fm.i18n(['errMaxTargets', fm.maxTargets])});
} else {
cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect);
selectedFiles = fm.arrayFlip(incHashes || cwdHashes, true);
}
trigger();
Expand Down Expand Up @@ -2470,6 +2472,11 @@ $.fn.elfindercwd = function(fm, options) {
.bind('request.open', function() {
bufferExt.getTmbs = [];
})
.one('open', function() {
if (fm.maxTargets) {
tmbNum = Math.min(fm.maxTargets, tmbNum);
}
})
.bind('open add remove searchend', function() {
var phash = fm.cwd().hash,
type = this.type;
Expand Down
3 changes: 2 additions & 1 deletion js/ui/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,15 @@ $.fn.elfindertree = function(fm, opts) {
*/
execSubdirs = function() {
var cnt = opts.subdirsMaxConn - subdirsPending,
atOnce = fm.maxTargets? Math.min(fm.maxTargets, opts.subdirsAtOnce) : opts.subdirsAtOnce,
i, ids;
execSubdirsTm && cancelAnimationFrame(execSubdirsTm);
if (subdirsExecQue.length) {
if (cnt > 0) {
for (i = 0; i < cnt; i++) {
if (subdirsExecQue.length) {
subdirsPending++;
subdirs(subdirsExecQue.splice(0, opts.subdirsAtOnce)).always(function() {
subdirs(subdirsExecQue.splice(0, atOnce)).always(function() {
subdirsPending--;
execSubdirs();
});
Expand Down

0 comments on commit df65524

Please sign in to comment.