diff --git a/ifm.php b/ifm.php index 590d76c..b88ce4f 100644 --- a/ifm.php +++ b/ifm.php @@ -597,14 +597,38 @@ function IFM() { this.showFileForm = function () { var filename = arguments.length > 0 ? arguments[0] : "newfile.txt"; var content = arguments.length > 1 ? arguments[1] : ""; - var 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'; diff --git a/src/ifm.js b/src/ifm.js index 8f11544..b7dcf16 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -162,14 +162,38 @@ function IFM() { this.showFileForm = function () { var filename = arguments.length > 0 ? arguments[0] : "newfile.txt"; var content = arguments.length > 1 ? arguments[1] : ""; - var 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';