mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-16 04:53:59 +02:00
68
ifm.php
68
ifm.php
@@ -559,8 +559,6 @@ function IFM() {
|
|||||||
$('.clickable-row').click(function(event) {
|
$('.clickable-row').click(function(event) {
|
||||||
if( event.ctrlKey ) {
|
if( event.ctrlKey ) {
|
||||||
$(this).toggleClass( 'selectedItem' );
|
$(this).toggleClass( 'selectedItem' );
|
||||||
} else {
|
|
||||||
self.highlightItem( $(this) );
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -597,13 +595,37 @@ function IFM() {
|
|||||||
this.showFileForm = function () {
|
this.showFileForm = function () {
|
||||||
var filename = arguments.length > 0 ? arguments[0] : "newfile.txt";
|
var filename = arguments.length > 0 ? arguments[0] : "newfile.txt";
|
||||||
var content = arguments.length > 1 ? arguments[1] : "";
|
var content = arguments.length > 1 ? arguments[1] : "";
|
||||||
var overlay = '<form id="showFile">';
|
var overlay = '<form id="showFile">' +
|
||||||
overlay += '<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>';
|
'<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>' +
|
||||||
overlay += '<div id="content" name="content"></div><input type="checkbox" id="aceWordWrap"> word wrap</input></fieldset></div>';
|
'<div id="content" name="content"></div><br>' +
|
||||||
overlay += '<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save';
|
'<button type="button" class="btn btn-default" id="editoroptions">editor options</button><div class="hide" id="editoroptions-head">options</div><div class="hide" id="editoroptions-content">' +
|
||||||
overlay += '</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>';
|
'<input type="checkbox" id="editor-wordwrap"> word wrap</input><br>' +
|
||||||
overlay += '<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
|
'<input type="checkbox" id="editor-softtabs"> use soft tabs</input>' +
|
||||||
|
'<div class="input-group"><span class="input-group-addon">tabsize</span><input class="form-control" type="text" size="2" id="editor-tabsize"title="tabsize"></div>' +
|
||||||
|
'</div></fieldset></div>' +
|
||||||
|
'<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save' +
|
||||||
|
'</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>' +
|
||||||
|
'<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
|
||||||
self.showModal( overlay, { large: true } );
|
self.showModal( overlay, { large: true } );
|
||||||
|
$('#editoroptions').popover({
|
||||||
|
html: true,
|
||||||
|
title: function() { return $('#editoroptions-head').html(); },
|
||||||
|
content: function() {
|
||||||
|
var content = $('#editoroptions-content').clone()
|
||||||
|
var aceSession = self.editor.getSession();
|
||||||
|
content.removeClass( 'hide' );
|
||||||
|
content.find( '#editor-wordwrap' )
|
||||||
|
.prop( 'checked', ( aceSession.getOption( 'wrap' ) == 'off' ? false : true ) )
|
||||||
|
.on( 'change', function() { self.editor.setOption( 'wrap', $( this ).is( ':checked' ) ); });
|
||||||
|
content.find( '#editor-softtabs' )
|
||||||
|
.prop( 'checked', aceSession.getOption( 'useSoftTabs' ) )
|
||||||
|
.on( 'change', function() { self.editor.setOption( 'useSoftTabs', $( this ).is( ':checked' ) ); });
|
||||||
|
content.find( '#editor-tabsize' )
|
||||||
|
.val( aceSession.getOption( 'tabSize' ) )
|
||||||
|
.on( 'keydown', function( e ) { if( e.key == 'Enter' ) { self.editor.setOption( 'tabSize', $( this ).val() ); } });
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#ifmmodal').on( 'remove', function () { self.editor = null; self.fileChanged = false; });
|
$('#ifmmodal').on( 'remove', function () { self.editor = null; self.fileChanged = false; });
|
||||||
// Start ACE
|
// Start ACE
|
||||||
self.editor = ace.edit("content");
|
self.editor = ace.edit("content");
|
||||||
@@ -1048,7 +1070,7 @@ function IFM() {
|
|||||||
$(document.body).prepend('<div id="waitqueue"></div>');
|
$(document.body).prepend('<div id="waitqueue"></div>');
|
||||||
//$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); });
|
//$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); });
|
||||||
}
|
}
|
||||||
$("#waitqueue").append('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
|
$("#waitqueue").prepend('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
|
||||||
};
|
};
|
||||||
this.task_done = function(id) {
|
this.task_done = function(id) {
|
||||||
$("#"+id).remove();
|
$("#"+id).remove();
|
||||||
@@ -1060,27 +1082,29 @@ function IFM() {
|
|||||||
$('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress);
|
$('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress);
|
||||||
};
|
};
|
||||||
this.highlightItem = function( param ) {
|
this.highlightItem = function( param ) {
|
||||||
|
var highlight = function( el ) {
|
||||||
|
el.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
|
||||||
|
el.find( 'a' ).first().focus();
|
||||||
|
if( ! self.isElementInViewport( el ) ) {
|
||||||
|
var scrollOffset = 0;
|
||||||
|
if( param=="prev" )
|
||||||
|
scrollOffset = el.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + el.height() + 15;
|
||||||
|
else
|
||||||
|
scrollOffset = el.offset().top - 55;
|
||||||
|
$('html, body').animate( { scrollTop: scrollOffset }, 500 );
|
||||||
|
}
|
||||||
|
};
|
||||||
if( param.jquery ) {
|
if( param.jquery ) {
|
||||||
param.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
|
highlight( param );
|
||||||
} else {
|
} else {
|
||||||
var highlightedItem = $('.highlightedItem');
|
var highlightedItem = $('.highlightedItem');
|
||||||
if( ! highlightedItem.length ) {
|
if( ! highlightedItem.length ) {
|
||||||
$('#filetable tbody tr:first-child').addClass( 'highlightedItem' );
|
highlight( $('#filetable tbody tr:first-child') );
|
||||||
} else {
|
} else {
|
||||||
var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() );
|
var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() );
|
||||||
|
|
||||||
if( newItem.is( 'tr' ) ) {
|
if( newItem.is( 'tr' ) ) {
|
||||||
highlightedItem.removeClass( 'highlightedItem' );
|
highlight( newItem );
|
||||||
newItem.addClass( 'highlightedItem' );
|
|
||||||
newItem.find( 'a' ).first().focus();
|
|
||||||
if( ! this.isElementInViewport( newItem ) ) {
|
|
||||||
var scrollOffset = 0;
|
|
||||||
if( param=="next" )
|
|
||||||
scrollOffset = highlightedItem.offset().top - 15;
|
|
||||||
else
|
|
||||||
scrollOffset = highlightedItem.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + highlightedItem.height() + 15;
|
|
||||||
$('html, body').animate( { scrollTop: scrollOffset }, 500 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
src/ifm.js
68
src/ifm.js
@@ -124,8 +124,6 @@ function IFM() {
|
|||||||
$('.clickable-row').click(function(event) {
|
$('.clickable-row').click(function(event) {
|
||||||
if( event.ctrlKey ) {
|
if( event.ctrlKey ) {
|
||||||
$(this).toggleClass( 'selectedItem' );
|
$(this).toggleClass( 'selectedItem' );
|
||||||
} else {
|
|
||||||
self.highlightItem( $(this) );
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -162,13 +160,37 @@ function IFM() {
|
|||||||
this.showFileForm = function () {
|
this.showFileForm = function () {
|
||||||
var filename = arguments.length > 0 ? arguments[0] : "newfile.txt";
|
var filename = arguments.length > 0 ? arguments[0] : "newfile.txt";
|
||||||
var content = arguments.length > 1 ? arguments[1] : "";
|
var content = arguments.length > 1 ? arguments[1] : "";
|
||||||
var overlay = '<form id="showFile">';
|
var overlay = '<form id="showFile">' +
|
||||||
overlay += '<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>';
|
'<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>' +
|
||||||
overlay += '<div id="content" name="content"></div><input type="checkbox" id="aceWordWrap"> word wrap</input></fieldset></div>';
|
'<div id="content" name="content"></div><br>' +
|
||||||
overlay += '<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save';
|
'<button type="button" class="btn btn-default" id="editoroptions">editor options</button><div class="hide" id="editoroptions-head">options</div><div class="hide" id="editoroptions-content">' +
|
||||||
overlay += '</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>';
|
'<input type="checkbox" id="editor-wordwrap"> word wrap</input><br>' +
|
||||||
overlay += '<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
|
'<input type="checkbox" id="editor-softtabs"> use soft tabs</input>' +
|
||||||
|
'<div class="input-group"><span class="input-group-addon">tabsize</span><input class="form-control" type="text" size="2" id="editor-tabsize"title="tabsize"></div>' +
|
||||||
|
'</div></fieldset></div>' +
|
||||||
|
'<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save' +
|
||||||
|
'</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>' +
|
||||||
|
'<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
|
||||||
self.showModal( overlay, { large: true } );
|
self.showModal( overlay, { large: true } );
|
||||||
|
$('#editoroptions').popover({
|
||||||
|
html: true,
|
||||||
|
title: function() { return $('#editoroptions-head').html(); },
|
||||||
|
content: function() {
|
||||||
|
var content = $('#editoroptions-content').clone()
|
||||||
|
var aceSession = self.editor.getSession();
|
||||||
|
content.removeClass( 'hide' );
|
||||||
|
content.find( '#editor-wordwrap' )
|
||||||
|
.prop( 'checked', ( aceSession.getOption( 'wrap' ) == 'off' ? false : true ) )
|
||||||
|
.on( 'change', function() { self.editor.setOption( 'wrap', $( this ).is( ':checked' ) ); });
|
||||||
|
content.find( '#editor-softtabs' )
|
||||||
|
.prop( 'checked', aceSession.getOption( 'useSoftTabs' ) )
|
||||||
|
.on( 'change', function() { self.editor.setOption( 'useSoftTabs', $( this ).is( ':checked' ) ); });
|
||||||
|
content.find( '#editor-tabsize' )
|
||||||
|
.val( aceSession.getOption( 'tabSize' ) )
|
||||||
|
.on( 'keydown', function( e ) { if( e.key == 'Enter' ) { self.editor.setOption( 'tabSize', $( this ).val() ); } });
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#ifmmodal').on( 'remove', function () { self.editor = null; self.fileChanged = false; });
|
$('#ifmmodal').on( 'remove', function () { self.editor = null; self.fileChanged = false; });
|
||||||
// Start ACE
|
// Start ACE
|
||||||
self.editor = ace.edit("content");
|
self.editor = ace.edit("content");
|
||||||
@@ -613,7 +635,7 @@ function IFM() {
|
|||||||
$(document.body).prepend('<div id="waitqueue"></div>');
|
$(document.body).prepend('<div id="waitqueue"></div>');
|
||||||
//$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); });
|
//$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); });
|
||||||
}
|
}
|
||||||
$("#waitqueue").append('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
|
$("#waitqueue").prepend('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
|
||||||
};
|
};
|
||||||
this.task_done = function(id) {
|
this.task_done = function(id) {
|
||||||
$("#"+id).remove();
|
$("#"+id).remove();
|
||||||
@@ -625,27 +647,29 @@ function IFM() {
|
|||||||
$('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress);
|
$('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress);
|
||||||
};
|
};
|
||||||
this.highlightItem = function( param ) {
|
this.highlightItem = function( param ) {
|
||||||
|
var highlight = function( el ) {
|
||||||
|
el.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
|
||||||
|
el.find( 'a' ).first().focus();
|
||||||
|
if( ! self.isElementInViewport( el ) ) {
|
||||||
|
var scrollOffset = 0;
|
||||||
|
if( param=="prev" )
|
||||||
|
scrollOffset = el.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + el.height() + 15;
|
||||||
|
else
|
||||||
|
scrollOffset = el.offset().top - 55;
|
||||||
|
$('html, body').animate( { scrollTop: scrollOffset }, 500 );
|
||||||
|
}
|
||||||
|
};
|
||||||
if( param.jquery ) {
|
if( param.jquery ) {
|
||||||
param.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
|
highlight( param );
|
||||||
} else {
|
} else {
|
||||||
var highlightedItem = $('.highlightedItem');
|
var highlightedItem = $('.highlightedItem');
|
||||||
if( ! highlightedItem.length ) {
|
if( ! highlightedItem.length ) {
|
||||||
$('#filetable tbody tr:first-child').addClass( 'highlightedItem' );
|
highlight( $('#filetable tbody tr:first-child') );
|
||||||
} else {
|
} else {
|
||||||
var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() );
|
var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() );
|
||||||
|
|
||||||
if( newItem.is( 'tr' ) ) {
|
if( newItem.is( 'tr' ) ) {
|
||||||
highlightedItem.removeClass( 'highlightedItem' );
|
highlight( newItem );
|
||||||
newItem.addClass( 'highlightedItem' );
|
|
||||||
newItem.find( 'a' ).first().focus();
|
|
||||||
if( ! this.isElementInViewport( newItem ) ) {
|
|
||||||
var scrollOffset = 0;
|
|
||||||
if( param=="next" )
|
|
||||||
scrollOffset = highlightedItem.offset().top - 15;
|
|
||||||
else
|
|
||||||
scrollOffset = highlightedItem.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + highlightedItem.height() + 15;
|
|
||||||
$('html, body').animate( { scrollTop: scrollOffset }, 500 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user