mirror of
https://github.com/myvesta/vesta
synced 2025-07-14 09:03:23 -07:00
WebFileManager JS stuff
This commit is contained in:
parent
998b500aca
commit
a1ac9cfee8
3 changed files with 102 additions and 19 deletions
|
@ -65,8 +65,20 @@ FM.init = function() {
|
||||||
FM.TAB_A_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_A);
|
FM.TAB_A_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_A);
|
||||||
FM.TAB_B_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_B);
|
FM.TAB_B_CURRENT_PATH = FM.formatPath(GLOBAL.START_DIR_B);
|
||||||
|
|
||||||
FM.open(dir_A, FM.TAB_A);
|
FM.open(dir_A, FM.TAB_A, function() {
|
||||||
FM.open(dir_B, FM.TAB_B);
|
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||||
|
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||||
|
FM.setActive(0, FM.CURRENT_TAB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
FM.open(dir_B, FM.TAB_B, function() {
|
||||||
|
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||||
|
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||||
|
FM.setActive(0, FM.CURRENT_TAB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.setActive = function(index, box) {
|
FM.setActive = function(index, box) {
|
||||||
|
@ -74,18 +86,31 @@ FM.setActive = function(index, box) {
|
||||||
$(box + ' .selected').removeClass('selected');
|
$(box + ' .selected').removeClass('selected');
|
||||||
$(box).find('li:eq('+index+')').addClass('selected');
|
$(box).find('li:eq('+index+')').addClass('selected');
|
||||||
//$(box).find('li:eq('+index+')').addClass('selected');
|
//$(box).find('li:eq('+index+')').addClass('selected');
|
||||||
var w_h = $(window).height();
|
//var w_h = $(window).height() - 100;
|
||||||
var pos = $(box).find('li:eq('+index+')').position();
|
var w_offset = $(box).scrollTop();
|
||||||
console.log(w_h);
|
var w_height = $(box).height()
|
||||||
console.log(pos);
|
var pos = $(box).find('li.selected').position();
|
||||||
if (pos.top > w_h) {
|
//console.log(w_height);
|
||||||
$(box).scrollTo($(box).find('li:eq('+index+')'));
|
//console.log(w_offset);
|
||||||
}
|
//console.log(pos);
|
||||||
else {
|
var wwh = w_height - w_offset + pos.top;
|
||||||
if (Math.abs(pos.top) > w_h) {
|
//console.info(wwh);
|
||||||
$(box).scrollTo($(box).find('li:eq('+index+')'));
|
console.info((pos.top + w_offset) + ' > ' + w_height);
|
||||||
}
|
console.log((pos.top + w_offset) > w_height);
|
||||||
|
/* if (pos.top > w_height) {
|
||||||
|
var cur_elm = $(box).find('li.selected').position();
|
||||||
|
var cur_elm_height = $(box).find('li.selected').height();
|
||||||
|
//$(box).scrollTo(wwh - 350);
|
||||||
|
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {*/
|
||||||
|
var cur_elm = $(box).find('li.selected').position();
|
||||||
|
var cur_elm_height = $(box).find('li.selected').height();
|
||||||
|
|
||||||
|
$(box).scrollTo(w_offset + cur_elm.top - w_height/2 + cur_elm_height/2);
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
FM['CURRENT_' + tab + '_LINE'] = index;
|
FM['CURRENT_' + tab + '_LINE'] = index;
|
||||||
FM.CURRENT_TAB = box;
|
FM.CURRENT_TAB = box;
|
||||||
|
@ -122,7 +147,7 @@ FM.goDown = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FM.open = function(dir, box) {
|
FM.open = function(dir, box, callback) {
|
||||||
var tab = FM.getTabLetter(box);
|
var tab = FM.getTabLetter(box);
|
||||||
|
|
||||||
FM['TAB_'+tab+'_CURRENT_PATH'] = dir;
|
FM['TAB_'+tab+'_CURRENT_PATH'] = dir;
|
||||||
|
@ -137,7 +162,15 @@ FM.open = function(dir, box) {
|
||||||
else {
|
else {
|
||||||
FM.directoryNotAvailable(reply);
|
FM.directoryNotAvailable(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callback && callback(reply);
|
||||||
|
|
||||||
|
var current_pwd = dir.trim() == '' ? FM.ROOT_DIR : dir;
|
||||||
|
|
||||||
|
$('.pwd-tab-' + tab).html(current_pwd);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.isItemFile = function(item) {
|
FM.isItemFile = function(item) {
|
||||||
|
@ -405,6 +438,18 @@ FM.fotoramaOpen = function(tab, img_index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.selectItem = function(item, box) {
|
FM.selectItem = function(item, box) {
|
||||||
|
|
||||||
|
if (FM.CURRENT_TAB == FM.TAB_A) {
|
||||||
|
FM.setTabActive(FM.TAB_B);
|
||||||
|
$(FM.TAB_B).find('.selected-inactive').removeClass('selected-inactive');
|
||||||
|
$(FM.TAB_A).find('.selected').addClass('selected-inactive');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FM.setTabActive(FM.TAB_A);
|
||||||
|
$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive');
|
||||||
|
$(FM.TAB_B).find('.selected').addClass('selected-inactive');
|
||||||
|
}
|
||||||
|
|
||||||
$(box).find('.active').removeClass('active');
|
$(box).find('.active').removeClass('active');
|
||||||
$(box).find('.selected').removeClass('selected');
|
$(box).find('.selected').removeClass('selected');
|
||||||
/*if ($(item).hasClass('active')) {
|
/*if ($(item).hasClass('active')) {
|
||||||
|
@ -421,6 +466,8 @@ FM.selectItem = function(item, box) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.setTabActive(box);
|
FM.setTabActive(box);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.switchTab = function() {
|
FM.switchTab = function() {
|
||||||
|
@ -434,6 +481,12 @@ FM.switchTab = function() {
|
||||||
$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive');
|
$(FM.TAB_A).find('.selected-inactive').removeClass('selected-inactive');
|
||||||
$(FM.TAB_B).find('.selected').addClass('selected-inactive');
|
$(FM.TAB_B).find('.selected').addClass('selected-inactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||||
|
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||||
|
FM.setActive(0, FM.CURRENT_TAB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FM.setTabActive = function(box) {
|
FM.setTabActive = function(box) {
|
||||||
|
@ -448,7 +501,7 @@ FM.setTabActive = function(box) {
|
||||||
FM.confirmRename = function() {
|
FM.confirmRename = function() {
|
||||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||||
var box = FM['TAB_' + tab];
|
var box = FM['TAB_' + tab];
|
||||||
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
|
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
return alert('No file selected');
|
return alert('No file selected');
|
||||||
}
|
}
|
||||||
|
@ -481,7 +534,7 @@ FM.confirmRename = function() {
|
||||||
|
|
||||||
FM.renameItems = function() {
|
FM.renameItems = function() {
|
||||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||||
var selected = $(FM['TAB_' + tab] ).find('.dir.active');
|
var selected = $(FM['TAB_' + tab] ).find('.dir.selected');
|
||||||
if (selected.length == 0) {
|
if (selected.length == 0) {
|
||||||
return alert('No file selected');
|
return alert('No file selected');
|
||||||
}
|
}
|
||||||
|
@ -822,11 +875,11 @@ FM.reOrderList = function(elm){
|
||||||
FM.ORDER_TAB_B = entity+'_'+direction;
|
FM.ORDER_TAB_B = entity+'_'+direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
primary_box.find('span').removeClass('selected');
|
primary_box.find('span').removeClass('active');
|
||||||
$(menu).find('.sort-by .entity').html(elm.closest('li').find('span').html());
|
$(menu).find('.sort-by .entity').html(elm.closest('li').find('span').html());
|
||||||
$(menu).find('.sort-by').removeClass('desc asc').addClass(direction).addClass('sort-by');
|
$(menu).find('.sort-by').removeClass('desc asc').addClass(direction).addClass('sort-by');
|
||||||
|
|
||||||
elm.addClass('selected');
|
elm.addClass('active');
|
||||||
primary_box.hide();
|
primary_box.hide();
|
||||||
|
|
||||||
FM.open(path, tab);
|
FM.open(path, tab);
|
||||||
|
|
|
@ -211,6 +211,22 @@
|
||||||
|
|
||||||
function turnOff(e) {
|
function turnOff(e) {
|
||||||
if (f.detect.ctrl(e)) {
|
if (f.detect.ctrl(e)) {
|
||||||
|
/*
|
||||||
|
shortcut.add("Ctrl+a", function(evt){
|
||||||
|
if(jQuery('.ch-toggle:checked').length > 0) {
|
||||||
|
f.t.unHAll(p, o);
|
||||||
|
jQuery('.ch-toggle:checked').attr('checked', false);
|
||||||
|
} else {
|
||||||
|
f.t.hAll(p,o);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'type': 'keyup',
|
||||||
|
'propagate': false,
|
||||||
|
'disable_in_input': true,
|
||||||
|
'target': document
|
||||||
|
}
|
||||||
|
);
|
||||||
|
*/
|
||||||
if (e.keyCode == 65) { // ctrl + a
|
if (e.keyCode == 65) { // ctrl + a
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
//if(f.detect.alt(e)) {
|
//if(f.detect.alt(e)) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ App.Templates.html = {
|
||||||
<p class="ok" onClick="FM.confirmDelete();">delete</p>\
|
<p class="ok" onClick="FM.confirmDelete();">delete</p>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>'],
|
</div>'],
|
||||||
popup_rename: ['<div class="confirm-box rename warning">\
|
popup_rename_: ['<div class="confirm-box rename warning">\
|
||||||
<div class="message">Rename file <span class="title">"~!:FILENAME~!"</span></div>\
|
<div class="message">Rename file <span class="title">"~!:FILENAME~!"</span></div>\
|
||||||
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\
|
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\
|
||||||
<div class="warning"></div>\
|
<div class="warning"></div>\
|
||||||
|
@ -42,6 +42,20 @@ App.Templates.html = {
|
||||||
<p class="ok" onClick="FM.confirmRename();">rename</p>\
|
<p class="ok" onClick="FM.confirmRename();">rename</p>\
|
||||||
</div>\
|
</div>\
|
||||||
</div>'],
|
</div>'],
|
||||||
|
|
||||||
|
popup_rename: ['<div class="confirm-box unpack warning">\
|
||||||
|
<div class="message">Extract archive <span class="title">"~!:FILENAME~!"</span> to <span class="title">"~!:DIRNAME~!"</span></div>\
|
||||||
|
<div class="warning"></div>\
|
||||||
|
<div class="actions">\
|
||||||
|
<label><input type="checkbox" name="overwrite" class="title" />Overwrite exising files</label>\
|
||||||
|
</div>\
|
||||||
|
<div class="controls">\
|
||||||
|
<p class="cancel" onClick="FM.popupClose();">cancel</p>\
|
||||||
|
<p class="ok" onClick="FM.confirmRename();">Extract</p>\
|
||||||
|
</div>\
|
||||||
|
</div>'],
|
||||||
|
|
||||||
|
|
||||||
popup_create_file: ['<div class="confirm-box rename warning">\
|
popup_create_file: ['<div class="confirm-box rename warning">\
|
||||||
<div class="message">Create file</div>\
|
<div class="message">Create file</div>\
|
||||||
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\
|
<!-- div class="warning">File <span class="title">"reading.txt"</span> already exists</div -->\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue