From 44dfe7d3fceee97626e9d209d34d012213a1ab56 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Fri, 17 Feb 2017 14:27:50 +0100 Subject: [PATCH] added ability to change directory by typing the path in the input field in the navbar --- ifm.php | 8 +++++--- src/ifm.js | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ifm.php b/ifm.php index 8654d80..9aff577 100644 --- a/ifm.php +++ b/ifm.php @@ -568,8 +568,10 @@ function IFM() { }); }; - this.changeDirectory = function( newdir, options={ absolute: false, pushState: true } ) { - if( ! options.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); + this.changeDirectory = function( newdir, options={} ) { + config = { absolute: false, pushState: true }; + jQuery.extend( config, options ); + if( ! config.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); $.ajax({ url: self.IFM_SCFN, type: "POST", @@ -582,7 +584,7 @@ function IFM() { self.currentDir = data.realpath; self.refreshFileTable(); $( "#currentDir" ).val( self.currentDir ); - if( options.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); + if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); }, error: function() { self.showMessage( "General error occured: No or broken response", "e" ); } }); diff --git a/src/ifm.js b/src/ifm.js index c08b7ff..bb4fede 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -140,8 +140,10 @@ function IFM() { }); }; - this.changeDirectory = function( newdir, options={ absolute: false, pushState: true } ) { - if( ! options.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); + this.changeDirectory = function( newdir, options={} ) { + config = { absolute: false, pushState: true }; + jQuery.extend( config, options ); + if( ! config.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); $.ajax({ url: self.IFM_SCFN, type: "POST", @@ -154,7 +156,7 @@ function IFM() { self.currentDir = data.realpath; self.refreshFileTable(); $( "#currentDir" ).val( self.currentDir ); - if( options.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); + if( config.pushState ) history.pushState( { dir: self.currentDir }, self.currentDir, "#"+self.currentDir ); }, error: function() { self.showMessage( "General error occured: No or broken response", "e" ); } });