diff --git a/ifm.php b/ifm.php index 590d76c..9d12ce3 100644 --- a/ifm.php +++ b/ifm.php @@ -559,8 +559,6 @@ function IFM() { $('.clickable-row').click(function(event) { if( event.ctrlKey ) { $(this).toggleClass( 'selectedItem' ); - } else { - self.highlightItem( $(this) ); } }); } @@ -597,14 +595,38 @@ function IFM() { this.showFileForm = function () { var filename = arguments.length > 0 ? arguments[0] : "newfile.txt"; var content = arguments.length > 1 ? arguments[1] : ""; - var overlay = '
'; - overlay += ''; - overlay += '
'; + var overlay = '
' + + '' + + '
'; self.showModal( overlay, { large: true } ); - $('#ifmmodal').on('remove', function () { self.editor = null; self.fileChanged = false; }); + $('#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; }); // Start ACE self.editor = ace.edit("content"); self.editor.$blockScrolling = 'Infinity'; @@ -1048,7 +1070,7 @@ function IFM() { $(document.body).prepend('
'); //$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); }); } - $("#waitqueue").append('
'+name+'
'); + $("#waitqueue").prepend('
'+name+'
'); }; this.task_done = function(id) { $("#"+id).remove(); @@ -1060,27 +1082,29 @@ function IFM() { $('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress); }; 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 ) { - param.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' ); + highlight( param ); } else { var highlightedItem = $('.highlightedItem'); if( ! highlightedItem.length ) { - $('#filetable tbody tr:first-child').addClass( 'highlightedItem' ); + highlight( $('#filetable tbody tr:first-child') ); } else { var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() ); if( newItem.is( 'tr' ) ) { - highlightedItem.removeClass( 'highlightedItem' ); - 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 ); - } + highlight( newItem ); } } } diff --git a/src/ifm.js b/src/ifm.js index 8f11544..109e908 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -124,8 +124,6 @@ function IFM() { $('.clickable-row').click(function(event) { if( event.ctrlKey ) { $(this).toggleClass( 'selectedItem' ); - } else { - self.highlightItem( $(this) ); } }); } @@ -162,14 +160,38 @@ function IFM() { this.showFileForm = function () { var filename = arguments.length > 0 ? arguments[0] : "newfile.txt"; var content = arguments.length > 1 ? arguments[1] : ""; - var overlay = '
'; - overlay += ''; - overlay += '
'; + var overlay = '
' + + '' + + '
'; self.showModal( overlay, { large: true } ); - $('#ifmmodal').on('remove', function () { self.editor = null; self.fileChanged = false; }); + $('#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; }); // Start ACE self.editor = ace.edit("content"); self.editor.$blockScrolling = 'Infinity'; @@ -613,7 +635,7 @@ function IFM() { $(document.body).prepend('
'); //$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); }); } - $("#waitqueue").append('
'+name+'
'); + $("#waitqueue").prepend('
'+name+'
'); }; this.task_done = function(id) { $("#"+id).remove(); @@ -625,27 +647,29 @@ function IFM() { $('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress); }; 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 ) { - param.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' ); + highlight( param ); } else { var highlightedItem = $('.highlightedItem'); if( ! highlightedItem.length ) { - $('#filetable tbody tr:first-child').addClass( 'highlightedItem' ); + highlight( $('#filetable tbody tr:first-child') ); } else { var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() ); if( newItem.is( 'tr' ) ) { - highlightedItem.removeClass( 'highlightedItem' ); - 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 ); - } + highlight( newItem ); } } }