Skip to content

Commit a320b1f

Browse files
committed
hotkeys for filemanager
1 parent 51125fc commit a320b1f

File tree

2 files changed

+143
-25
lines changed

2 files changed

+143
-25
lines changed

web/js/file_manager.js

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,32 @@ FM.goDown = function() {
292292
FM.setActive(index, FM.CURRENT_TAB);
293293
}
294294

295+
// reloads provided tab
296+
// reloads opposite tab if its needed
297+
FM.openAndSync = function(dir, box, callback) {
298+
var tab = FM.getTabLetter(box);
299+
300+
var opposite_tab = 'A';
301+
if (tab == 'A') {
302+
opposite_tab = 'B';
303+
}
304+
305+
var oppositeSyncNeeded = false;
306+
307+
if (FM.TAB_A_CURRENT_PATH == FM.TAB_B_CURRENT_PATH) {
308+
oppositeSyncNeeded = true;
309+
}
310+
311+
312+
if (oppositeSyncNeeded) {
313+
FM.open(dir, FM['TAB_' + opposite_tab], callback);
314+
return FM.open(dir, box, callback);
315+
}
316+
else {
317+
return FM.open(dir, box, callback);
318+
}
319+
}
320+
295321

296322
FM.open = function(dir, box, callback) {
297323
var tab = FM.getTabLetter(box);
@@ -662,7 +688,14 @@ FM.generate_listing = function(reply, box) {
662688

663689
$(box).html(acc.done());
664690

665-
FM['CURRENT_'+tab+'_LINE'] = -1;
691+
////////
692+
/*if (FM['CURRENT_'+tab+'_LINE'] > -1 && $(box).find('.dir:eq(' + FM['CURRENT_'+tab+'_LINE'] + ')').lrngth > 0) {
693+
694+
}
695+
else {
696+
FM['CURRENT_'+tab+'_LINE'] = -1;
697+
}*/
698+
FM['CURRENT_'+tab+'_LINE'] = -1;
666699
}
667700

668701
FM.toggleCheck = function(uid) {
@@ -1111,7 +1144,7 @@ FM.packItem = function() {
11111144

11121145
var tpl = Tpl.get('popup_pack', 'FM');
11131146
tpl.set(':FILENAME', src.name);
1114-
tpl.set(':DST_DIRNAME', dst + '/' + src.name + '_packed.tar.gz');
1147+
tpl.set(':DST_DIRNAME', dst + '/' + src.name + '.tar.gz');
11151148
FM.popupOpen(tpl.finalize());
11161149
}
11171150

@@ -1198,7 +1231,7 @@ FM.confirmRename = function() {
11981231
App.Ajax.request(action, params, function(reply) {
11991232
if (reply.result == true) {
12001233
FM.popupClose();
1201-
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box);
1234+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
12021235
}
12031236
else {
12041237
FM.showError('rename-items', reply.message);
@@ -1235,6 +1268,7 @@ FM.isPopupOpened = function() {
12351268
}
12361269

12371270
FM.popupOpen = function(html) {
1271+
FM.popupClose();
12381272
//$('#popup').flayer_close();
12391273
$('<div>').attr('id', 'popup').html(html).flayer({
12401274
afterStart: function(elm) {
@@ -1432,7 +1466,7 @@ FM.confirmCopyItems = function () {
14321466
if (reply.result == true) {
14331467
FM.popupClose();
14341468
// FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]);
1435-
FM.open(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]);
1469+
FM.openAndSync(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]);
14361470
}
14371471
else {
14381472
FM.showError('copy-items', reply.message);
@@ -1504,7 +1538,7 @@ FM.confirmDelete = function() {
15041538
App.Ajax.request('delete_files', params, function(reply) {
15051539
if (reply.result == true) {
15061540
FM.popupClose();
1507-
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box);
1541+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
15081542
}
15091543
else {
15101544
FM.showError('delete-items', reply.message);
@@ -1611,7 +1645,7 @@ FM.confirmCreateDir = function() {
16111645
App.Ajax.request('create_dir', params, function(reply) {
16121646
if (reply.result == true) {
16131647
FM.popupClose();
1614-
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box);
1648+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
16151649
}
16161650
else {
16171651
FM.showError('create-dir', reply.message);
@@ -1646,7 +1680,7 @@ FM.confirmCreateFile = function() {
16461680
App.Ajax.request('create_file', params, function(reply) {
16471681
if (reply.result == true) {
16481682
FM.popupClose();
1649-
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box);
1683+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
16501684
}
16511685
else {
16521686
FM.showError('create-file', reply.message);
@@ -1948,6 +1982,7 @@ $(document).ready(function() {
19481982
'disable_in_input': true,
19491983
'target': document
19501984
});
1985+
19511986
shortcut.add("shift+F6",function() {
19521987
FM.renameItems();
19531988
},{
@@ -1988,14 +2023,7 @@ $(document).ready(function() {
19882023
'target': document
19892024
});
19902025

1991-
shortcut.add("u",function() {
1992-
/// TODO upload file FM.uploadFile();
1993-
},{
1994-
'type': 'keydown',
1995-
'propagate': false,
1996-
'disable_in_input': true,
1997-
'target': document
1998-
});
2026+
19992027

20002028
shortcut.add("d",function() {
20012029
FM.downloadFiles();
@@ -2025,7 +2053,15 @@ $(document).ready(function() {
20252053
});*/
20262054

20272055

2028-
2056+
shortcut.add("u",function() {
2057+
var tab_letter = FM.getTabLetter(FM.CURRENT_TAB);
2058+
$('#file_upload_'+tab_letter).trigger('click');
2059+
},{
2060+
'type': 'keydown',
2061+
'propagate': false,
2062+
'disable_in_input': true,
2063+
'target': document
2064+
});
20292065

20302066

20312067
/* is jQuery .live() has been removed in version 1.9 onwards

web/templates/file_manager/main.php

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,16 @@
380380

381381
var tab = FM.getTabLetter(FM.CURRENT_TAB);
382382
var box = FM['TAB_' + tab];
383-
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], box);
384-
383+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
384+
385385
//$('.file-upload-button-' + tab).removeClass('progress');
386386
$('.file-upload-button-' + tab).addClass('done');
387-
387+
388388
setTimeout(function() {
389389
$('.file-upload-button-' + tab).removeClass('progress');
390390
$('.file-upload-button-' + tab).removeClass('done');
391391
}, 2000);
392-
392+
393393
$('.file-upload-button-' + tab).css('background-position', '-96px 0');
394394
},
395395
progressall: function (e, data) {
@@ -448,31 +448,113 @@
448448

449449
$(".listing-left").selectable({
450450
selected: function (event, ui) {
451-
FM.setTabActive(FM.TAB_A, 'skip_highlights');
452-
$(".listing-left .selected, .listing-left .ui-selectee").each(function(i, o) {
451+
//console.log(ui);
452+
//console.log($(".listing-left .selected"));
453+
FM.setTabActive(FM.TAB_A, 'skip_highlights');
454+
455+
$(".listing-left .active").removeClass('active');
456+
457+
$(".listing-left .selected").each(function(i, o) {
453458
if (!$(o).hasClass('ui-selected')) {
454459
$(o).removeClass('selected');
455460
$(o).removeClass('active');
456461
}
457462
});
458463
$(ui.selected).addClass('selected');
459464
$(ui.selected).addClass('active');
465+
466+
467+
//$(ui.selected).addClass('active');
460468
checkIfArchive(ui.selected);
461469
$(".listing-left .ui-selected").addClass('selected');
470+
471+
if ($(".listing-left .active").length > 0) {
472+
FM['CURRENT_A_LINE'] = $(".listing-left .active").index();
473+
}
474+
else {
475+
FM['CURRENT_A_LINE'] = 0;
476+
}
477+
478+
/*FM.setTabActive(FM.TAB_A, 'skip_highlights');
479+
$(".listing-left .selected, .listing-left .ui-selectee").each(function(i, o) {
480+
if (!$(o).hasClass('ui-selected')) {
481+
$(o).removeClass('selected');
482+
$(o).removeClass('active');
483+
}
484+
});
485+
$(ui.selected).addClass('selected');
486+
$(ui.selected).addClass('active');
487+
checkIfArchive(ui.selected);
488+
$(".listing-left .ui-selected").addClass('selected');*/
462489
},
463490
unselected: function (event, ui) {
464-
$(".listing-left .selected, .listing-left .ui-selectee").each(function(i, o) {
491+
FM.setTabActive(FM.TAB_A, 'skip_highlights');
492+
493+
$(ui.unselected).removeClass('selected');
494+
$(ui.unselected).removeClass('active');
495+
496+
if ($(".listing-left .active").length > 0) {
497+
FM['CURRENT_A_LINE'] = $(".listing-left .active").index();
498+
}
499+
else {
500+
FM['CURRENT_A_LINE'] = 0;
501+
}
502+
503+
/*$(".listing-left .selected, .listing-left .ui-selectee").each(function(i, o) {
465504
if (!$(o).hasClass('ui-selected')) {
466505
$(o).removeClass('selected');
467506
$(o).removeClass('active');
468507
}
469508
});
470509
FM.setTabActive(FM.TAB_A, 'skip_highlights');
471510
$(ui.unselected).removeClass('selected');
472-
$(ui.selected).addClass('active');
511+
$(ui.selected).addClass('active');*/
473512
}
474513
});
475514
$(".listing-right").selectable({
515+
selected: function (event, ui) {
516+
FM.setTabActive(FM.TAB_B, 'skip_highlights');
517+
518+
$(".listing-right .active").removeClass('active');
519+
520+
$(".listing-right .selected").each(function(i, o) {
521+
if (!$(o).hasClass('ui-selected')) {
522+
$(o).removeClass('selected');
523+
$(o).removeClass('active');
524+
}
525+
});
526+
$(ui.selected).addClass('selected');
527+
$(ui.selected).addClass('active');
528+
529+
530+
//$(ui.selected).addClass('active');
531+
checkIfArchive(ui.selected);
532+
$(".listing-right .ui-selected").addClass('selected');
533+
534+
535+
if ($(".listing-right .active").length > 0) {
536+
FM['CURRENT_B_LINE'] = $(".listing-right .active").index();
537+
}
538+
else {
539+
FM['CURRENT_B_LINE'] = 0;
540+
}
541+
542+
},
543+
unselected: function (event, ui) {
544+
FM.setTabActive(FM.TAB_B, 'skip_highlights');
545+
546+
$(ui.unselected).removeClass('selected');
547+
$(ui.unselected).removeClass('active');
548+
549+
if ($(".listing-right .active").length > 0) {
550+
FM['CURRENT_B_LINE'] = $(".listing-right .active").index();
551+
}
552+
else {
553+
FM['CURRENT_B_LINE'] = 0;
554+
}
555+
}
556+
});
557+
/*$(".listing-right").selectable({
476558
selected: function (event, ui) {
477559
$(".listing-left .selected").each(function(i, o) {
478560
if (!$(o).hasClass('ui-selected')) {
@@ -493,7 +575,7 @@
493575
FM.setTabActive(FM.TAB_B, 'skip_highlights');
494576
$(ui.unselected).removeClass('selected');
495577
}
496-
});
578+
});*/
497579

498580

499581
});

0 commit comments

Comments
 (0)