From 5f3722ceac635cbd7364875773941bf61c36c22a Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Tue, 21 Feb 2017 22:33:24 +0100 Subject: [PATCH 1/4] add editor options menu --- ifm.php | 38 +++++++++++++++++++++++++++++++------- src/ifm.js | 38 +++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 14 deletions(-) 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 = '
'; - 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'; 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 = '
'; - 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'; From f4ff5ec549b05fcf3ddfec7232bd6b463a724c06 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Tue, 21 Feb 2017 22:35:17 +0100 Subject: [PATCH 2/4] removed highlighting with mouse click because of unwanted mobile/touchscreen behaviour --- ifm.php | 2 -- src/ifm.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/ifm.php b/ifm.php index b88ce4f..1486c71 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) ); } }); } diff --git a/src/ifm.js b/src/ifm.js index b7dcf16..0ff115b 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) ); } }); } From 1dd264b1b8b5851ee43eca8d206a06d33fa52689 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Tue, 21 Feb 2017 22:40:15 +0100 Subject: [PATCH 3/4] line break above editor option button --- ifm.php | 2 +- src/ifm.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ifm.php b/ifm.php index 1486c71..8e3199b 100644 --- a/ifm.php +++ b/ifm.php @@ -597,7 +597,7 @@ function IFM() { var content = arguments.length > 1 ? arguments[1] : ""; var overlay = '
' + '