Skip to content

Commit a1ac9cf

Browse files
committed
WebFileManager JS stuff
1 parent 998b500 commit a1ac9cf

File tree

3 files changed

+102
-19
lines changed

3 files changed

+102
-19
lines changed

web/js/file_manager.js

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,52 @@ FM.init = function() {
6565
FM.TAB_A_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_A);
6666
FM.TAB_B_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_B);
6767

68-
FM.open(dir_A, FM.TAB_A);
69-
FM.open(dir_B, FM.TAB_B);
68+
FM.open(dir_A, FM.TAB_A, function() {
69+
var tab = FM.getTabLetter(FM.CURRENT_TAB);
70+
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
71+
FM.setActive(0, FM.CURRENT_TAB);
72+
}
73+
});
74+
FM.open(dir_B, FM.TAB_B, function() {
75+
var tab = FM.getTabLetter(FM.CURRENT_TAB);
76+
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
77+
FM.setActive(0, FM.CURRENT_TAB);
78+
}
79+
});
80+
81+
7082
}
7183

7284
FM.setActive = function(index, box) {
7385
var tab = FM.getTabLetter(box);
7486
$(box + ' .selected').removeClass('selected');
7587
$(box).find('li:eq('+index+')').addClass('selected');
7688
//$(box).find('li:eq('+index+')').addClass('selected');
77-
var w_h = $(window).height();
78-
var pos = $(box).find('li:eq('+index+')').position();
79-
console.log(w_h);
80-
console.log(pos);
81-
if (pos.top > w_h) {
82-
$(box).scrollTo($(box).find('li:eq('+index+')'));
83-
}
84-
else {
85-
if (Math.abs(pos.top) > w_h) {
86-
$(box).scrollTo($(box).find('li:eq('+index+')'));
87-
}
89+
//var w_h = $(window).height() - 100;
90+
var w_offset = $(box).scrollTop();
91+
var w_height = $(box).height()
92+
var pos = $(box).find('li.selected').position();
93+
//console.log(w_height);
94+
//console.log(w_offset);
95+
//console.log(pos);
96+
var wwh = w_height - w_offset + pos.top;
97+
//console.info(wwh);
98+
console.info((pos.top + w_offset) + ' > ' + w_height);
99+
console.log((pos.top + w_offset) > w_height);
100+
/* if (pos.top > w_height) {
101+
var cur_elm = $(box).find('li.selected').position();
102+
var cur_elm_height = $(box).find('li.selected').height();
103+
//$(box).scrollTo(wwh - 350);
104+
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
105+
88106
}
107+
else {*/
108+
var cur_elm = $(box).find('li.selected').position();
109+
var cur_elm_height = $(box).find('li.selected').height();
110+
111+
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
112+
113+
//}
89114

90115
FM['CURRENT_' + tab + '_LINE'] = index;
91116
FM.CURRENT_TAB = box;
@@ -122,7 +147,7 @@ FM.goDown = function() {
122147
}
123148

124149

125-
FM.open = function(dir, box) {
150+
FM.open = function(dir, box, callback) {
126151
var tab = FM.getTabLetter(box);
127152

128153
FM['TAB_'+tab+'_CURRENT_PATH'] = dir;
@@ -137,7 +162,15 @@ FM.open = function(dir, box) {
137162
else {
138163
FM.directoryNotAvailable(reply);
139164
}
165+
166+
callback && callback(reply);
167+
168+
var current_pwd = dir.trim() == '' ? FM.ROOT_DIR : dir;
169+
170+
$('.pwd-tab-' + tab).html(current_pwd);
140171
});
172+
173+
141174
}
142175

143176
FM.isItemFile = function(item) {
@@ -405,6 +438,18 @@ FM.fotoramaOpen = function(tab, img_index) {
405438
}
406439

407440
FM.selectItem = function(item, box) {
441+
442+
if (FM.CURRENT_TAB == FM.TAB_A) {
443+
FM.setTabActive(FM.TAB_B);
444+
$(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive');
445+
$(FM.TAB_A).find('.selected').addClass('selected-inactive');
446+
}
447+
else {
448+
FM.setTabActive(FM.TAB_A);
449+
$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive');
450+
$(FM.TAB_B).find('.selected').addClass('selected-inactive');
451+
}
452+
408453
$(box).find('.active').removeClass('active');
409454
$(box).find('.selected').removeClass('selected');
410455
/*if ($(item).hasClass('active')) {
@@ -421,6 +466,8 @@ FM.selectItem = function(item, box) {
421466
}
422467

423468
FM.setTabActive(box);
469+
470+
424471
}
425472

426473
FM.switchTab = function() {
@@ -434,6 +481,12 @@ FM.switchTab = function() {
434481
$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive');
435482
$(FM.TAB_B).find('.selected').addClass('selected-inactive');
436483
}
484+
485+
486+
var tab = FM.getTabLetter(FM.CURRENT_TAB);
487+
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
488+
FM.setActive(0, FM.CURRENT_TAB);
489+
}
437490
}
438491

439492
FM.setTabActive = function(box) {
@@ -448,7 +501,7 @@ FM.setTabActive = function(box) {
448501
FM.confirmRename = function() {
449502
var tab = FM.getTabLetter(FM.CURRENT_TAB);
450503
var box = FM['TAB_' + tab];
451-
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
504+
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
452505
if (!selected) {
453506
return alert('No file selected');
454507
}
@@ -481,7 +534,7 @@ FM.confirmRename = function() {
481534

482535
FM.renameItems = function() {
483536
var tab = FM.getTabLetter(FM.CURRENT_TAB);
484-
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
537+
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
485538
if (selected.length == 0) {
486539
return alert('No file selected');
487540
}
@@ -822,11 +875,11 @@ FM.reOrderList = function(elm){
822875
FM.ORDER_TAB_B = entity+'_'+direction;
823876
}
824877

825-
primary_box.find('span').removeClass('selected');
878+
primary_box.find('span').removeClass('active');
826879
$(menu).find('.sort-by .entity').html(elm.closest('li').find('span').html());
827880
$(menu).find('.sort-by').removeClass('desc asc').addClass(direction).addClass('sort-by');
828881

829-
elm.addClass('selected');
882+
elm.addClass('active');
830883
primary_box.hide();
831884

832885
FM.open(path, tab);

web/js/jquery.finder.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@
211211

212212
function turnOff(e) {
213213
if (f.detect.ctrl(e)) {
214+
/*
215+
shortcut.add("Ctrl+a", function(evt){
216+
if(jQuery('.ch-toggle:checked').length > 0) {
217+
f.t.unHAll(p, o);
218+
jQuery('.ch-toggle:checked').attr('checked', false);
219+
} else {
220+
f.t.hAll(p,o);
221+
}
222+
}, {
223+
'type': 'keyup',
224+
'propagate': false,
225+
'disable_in_input': true,
226+
'target': document
227+
}
228+
);
229+
*/
214230
if (e.keyCode == 65) { // ctrl + a
215231
e.preventDefault();
216232
//if(f.detect.alt(e)) {

web/js/templates.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ App.Templates.html = {
2626
<p class="ok" onClick="FM.confirmDelete();">delete</p>\
2727
</div>\
2828
</div>'],
29-
popup_rename: ['<div class="confirm-box rename warning">\
29+
popup_rename_: ['<div class="confirm-box rename warning">\
3030
<div class="message">Rename file <span class="title">"~!:FILENAME~!"</span></div>\
3131
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\
3232
<div class="warning"></div>\
@@ -42,6 +42,20 @@ App.Templates.html = {
4242
<p class="ok" onClick="FM.confirmRename();">rename</p>\
4343
</div>\
4444
</div>'],
45+
46+
popup_rename: ['<div class="confirm-box unpack warning">\
47+
<div class="message">Extract archive <span class="title">"~!:FILENAME~!"</span> to <span class="title">"~!:DIRNAME~!"</span></div>\
48+
<div class="warning"></div>\
49+
<div class="actions">\
50+
<label><input type="checkbox" name="overwrite" class="title" />Overwrite exising files</label>\
51+
</div>\
52+
<div class="controls">\
53+
<p class="cancel" onClick="FM.popupClose();">cancel</p>\
54+
<p class="ok" onClick="FM.confirmRename();">Extract</p>\
55+
</div>\
56+
</div>'],
57+
58+
4559
popup_create_file: ['<div class="confirm-box rename warning">\
4660
<div class="message">Create file</div>\
4761
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\

0 commit comments

Comments
 (0)