@@ -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
7284FM . 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
143176FM . isItemFile = function ( item ) {
@@ -405,6 +438,18 @@ FM.fotoramaOpen = function(tab, img_index) {
405438}
406439
407440FM . 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
426473FM . 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
439492FM . setTabActive = function ( box ) {
@@ -448,7 +501,7 @@ FM.setTabActive = function(box) {
448501FM . 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
482535FM . 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 ) ;
0 commit comments