Skip to content

Commit c9c8697

Browse files
committed
very final fixes for FM
1 parent 99994dc commit c9c8697

File tree

1 file changed

+26
-44
lines changed

1 file changed

+26
-44
lines changed

web/js/file_manager.js

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -161,34 +161,16 @@ FM.setActive = function(index, box) {
161161
$(box + ' .active').removeClass('active');
162162
$(box).find('li.dir:eq('+index+')').addClass('active');
163163

164-
//$(box).find('li:eq('+index+')').addClass('selected');
165-
//var w_h = $(window).height() - 100;
166164
var w_offset = $(box).scrollTop();
167165
var w_height = $(box).height()
168166
var pos = $(box).find('li.selected').position();
169-
//console.log(w_height);
170-
//console.log(w_offset);
171-
//console.log(pos);
167+
172168
var wwh = w_height - w_offset + pos.top;
173-
//console.info(wwh);
174-
//console.info((pos.top + w_offset) + ' > ' + w_height);
175-
//console.log((pos.top + w_offset) > w_height);
176-
/* if (pos.top > w_height) {
177-
var cur_elm = $(box).find('li.selected').position();
178-
var cur_elm_height = $(box).find('li.selected').height();
179-
//$(box).scrollTo(wwh - 350);
180-
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
181-
182-
}
183-
else {*/
184-
var cur_elm = $(box).find('li.selected').position();
185-
var cur_elm_height = $(box).find('li.selected').height();
186169

187-
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
170+
var cur_elm = $(box).find('li.selected').position();
171+
var cur_elm_height = $(box).find('li.selected').height();
188172

189-
//}
190-
191-
173+
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
192174

193175

194176
FM['CURRENT_' + tab + '_LINE'] = index;
@@ -215,7 +197,6 @@ FM.setActive = function(index, box) {
215197
}
216198

217199
FM.setSecondInactive = function(index, box) {
218-
//$(box + ' .active').removeClass('selected-inactive');
219200
$(box).find('li:eq('+index+')').addClass('selected-inactive');
220201

221202
FM.BG_LINE = index;
@@ -286,9 +267,7 @@ FM.goDown = function() {
286267
var tab = FM.getTabLetter(FM.CURRENT_TAB);
287268
var index = FM['CURRENT_' + tab + '_LINE'];
288269
index += 1;
289-
/*if (index > ($(FM.CURRENT_TAB).find('li.dir').length - 1)) {
290-
index = 0;
291-
}*/
270+
292271
if (index > ($(FM.CURRENT_TAB).find('li.dir').length - 1)) {
293272
index = $(FM.CURRENT_TAB).find('li.dir').length - 1;
294273
}
@@ -298,7 +277,7 @@ FM.goDown = function() {
298277

299278
// reloads provided tab
300279
// reloads opposite tab if its needed
301-
FM.openAndSync = function(dir, box, callback) {
280+
FM.openAndSync = function(dir, box, callback, forceOppositeSync) {
302281
var tab = FM.getTabLetter(box);
303282

304283
var opposite_tab = 'A';
@@ -312,6 +291,9 @@ FM.openAndSync = function(dir, box, callback) {
312291
oppositeSyncNeeded = true;
313292
}
314293

294+
if ('undefined' != typeof forceOppositeSync) {
295+
oppositeSyncNeeded = forceOppositeSync;
296+
}
315297

316298
if (oppositeSyncNeeded) {
317299
FM.open(dir, FM['TAB_' + opposite_tab], callback);
@@ -365,11 +347,16 @@ FM.updateTopLevelPathBar = function(box, tab, path) {
365347
path = path.replace(FM.ROOT_DIR, '');
366348
formattedPath.push('<a href="javascript:void(0)" onClick="FM.open(\''+FM.ROOT_DIR+'\', \''+box+'\')">'+FM.ROOT_DIR+'</span>');
367349

350+
var fullDirPath = FM.ROOT_DIR;
368351
$.each(path.split('/'), function(i, part) {
369352
if (part.trim() == '') {
370353
return;
371354
}
372-
formattedPath.push('<a href="javascript:void(0)" onClick="FM.open(\''+part+'\', \''+box+'\')">'+part+'</span>');
355+
fullDirPath += '/' + part;
356+
357+
fullDirPath = fullDirPath.replace(/\/\//g, '/');
358+
359+
formattedPath.push('<a href="javascript:void(0)" onClick="FM.open(\''+fullDirPath+'\', \''+box+'\')">'+part+'</span>');
373360
});
374361

375362
$('.pwd-tab-' + tab).html(formattedPath.join(' / '));
@@ -403,6 +390,7 @@ FM.sortItems = function(items, box) {
403390
$.each(items, function(i, o) {
404391
if (i > 0) { // i == 0 means first .. element in list
405392
if (FM.isItemFile(o) || FM.isItemLink(o)) {
393+
o.filetype = FM.getFileType(o.name);
406394
files.push(o);
407395
}
408396
else {
@@ -411,7 +399,6 @@ FM.sortItems = function(items, box) {
411399
}
412400
});
413401

414-
// var sort_type = $(box).parents('.window').find('.menu').find('.sort-by-v').val();
415402
var sort_type = FM.ORDER_TAB_A;
416403
if($(box).closest('.window').find('.menu').hasClass('menu-right')){
417404
sort_type = FM.ORDER_TAB_B;
@@ -420,7 +407,7 @@ FM.sortItems = function(items, box) {
420407
switch (sort_type) {
421408
case 'type_asc':
422409
files.sort(function (a, b) {
423-
return a.name.localeCompare( b.name );
410+
return a.filetype.localeCompare( b.filetype );
424411
});
425412
dirs.sort(function (a, b) {
426413
return a.name.localeCompare( b.name );
@@ -429,7 +416,7 @@ FM.sortItems = function(items, box) {
429416
break;
430417
case 'type_desc':
431418
files.sort(function (a, b) {
432-
return a.name.localeCompare( b.name );
419+
return b.filetype.localeCompare( a.filetype );
433420
});
434421
dirs.sort(function (a, b) {
435422
return a.name.localeCompare( b.name );
@@ -555,8 +542,6 @@ FM.downloadFileFromSubcontext = function(elm) {
555542
FM.openFile = function(dir, box, elm) {
556543
var tab = FM.getTabLetter(box);
557544

558-
//FM['TAB_'+tab+'_CURRENT_PATH'] = dir;
559-
560545
var elm = $(elm).hasClass('dir') ? $(elm) : $(elm).closest('.dir');
561546
var src = $.parseJSON($(elm).find('.source').val());
562547

@@ -769,19 +754,16 @@ FM.checkBulkStatus = function(bulkStatuses, acc) {
769754
}
770755

771756
if (status == true) {
772-
//$('#popup .results').html(App.Constants.FM_DONE);
773-
//$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
774757
FM.popupClose();
775-
776-
var box = FM['TAB_' + tab];
777-
var tab = FM.getTabLetter(FM.CURRENT_TAB);
778-
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box);
779758
}
780759
else {
781760
$('#popup .results').show().html(msg);
782-
//$('.controls').html('<p class="ok" onClick="FM.bulkPopupClose();">'+App.Constants.FM_DONE+'</p>');
783761
$('#popup .ok').hide();
784762
}
763+
764+
var box = FM['TAB_' + tab];
765+
var tab = FM.getTabLetter(FM.CURRENT_TAB);
766+
FM.openAndSync(FM['TAB_' + tab + '_CURRENT_PATH'], box, function(){}, true);
785767
}
786768

787769
FM.bulkPopupClose = function() {
@@ -901,7 +883,7 @@ FM.bulkCopy = function() {
901883
var src = $(ref).find('.source').val();
902884
src = $.parseJSON(src);
903885

904-
if (!FM.isItemPseudo(o)) {
886+
if (!FM.isItemPseudo(src)) {
905887
cfr_html += '<div>'+src.name+'</div>';
906888
numberOfItems++;
907889
}
@@ -1002,7 +984,7 @@ FM.bulkRemove = function() {
1002984
var src = $(ref).find('.source').val();
1003985
src = $.parseJSON(src);
1004986

1005-
if (!FM.isItemPseudo(o)) {
987+
if (!FM.isItemPseudo(src)) {
1006988
cfr_html += '<div>'+src.name+'</div>';
1007989
numberOfItems++;
1008990
}
@@ -1355,7 +1337,7 @@ FM.setTabActive = function(box, action) {
13551337
FM.confirmRename = function() {
13561338
var tab = FM.getTabLetter(FM.CURRENT_TAB);
13571339
var box = FM['TAB_' + tab];
1358-
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
1340+
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
13591341
if (!selected) {
13601342
return FM.displayError(
13611343
App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED
@@ -1531,7 +1513,7 @@ FM.confirmUnpackItem = function () {
15311513
FM.confirmPackItem = function () {
15321514
var tab = FM.getTabLetter(FM.CURRENT_TAB);
15331515
var box = FM['TAB_' + tab];
1534-
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
1516+
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
15351517
if (selected.length == 0) {
15361518
return FM.displayError(
15371519
App.Constants.FM_NO_FILE_OR_DIRECTORY_SELECTED

0 commit comments

Comments
 (0)