diff --git a/components/active/init.js b/components/active/init.js index bb8d24b..102e58d 100755 --- a/components/active/init.js +++ b/components/active/init.js @@ -537,14 +537,14 @@ } else { console.log( "calling save while failed diff", path, newContent, alerts ); - codiad.filemanager.save_file( path, newContent, alerts ) + codiad.filemanager.save_file( path, {content: newContent}, alerts ) .then( handleSuccess ); } }, this ); } else { console.log( "calling save without mtime and untainted", path, newContent, alerts ); - codiad.filemanager.save_file( path, newContent, alerts ) + codiad.filemanager.save_file( path, {content: newContent}, alerts ) .then( handleSuccess ); } }, diff --git a/components/editor/init.js b/components/editor/init.js index e9fc366..5f8f86d 100755 --- a/components/editor/init.js +++ b/components/editor/init.js @@ -297,7 +297,7 @@ let path = codiad.active.getPath(); $( e.target ).attr( 'data-path', path ); - codiad.filemanager.contextMenuShow( e, path, 'editor', 'editor' ); + codiad.filemanager.display_context_menu( e, path, 'editor', 'editor' ); $( this ).addClass( 'context-menu-active' ); } }); diff --git a/components/filemanager/class.filemanager.php b/components/filemanager/class.filemanager.php index 1a54e51..0b2c01e 100755 --- a/components/filemanager/class.filemanager.php +++ b/components/filemanager/class.filemanager.php @@ -606,7 +606,7 @@ class Filemanager extends Common { // OPEN IN BROWSER (Return URL) ////////////////////////////////////////////////////////////////// - public function openinbrowser( $path ) { + public function preview( $path ) { $protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) || $_SERVER['SERVER_PORT'] == 443 ) ? "https://" : "http://"; $domainName = $_SERVER['HTTP_HOST']; diff --git a/components/filemanager/controller.php b/components/filemanager/controller.php index 2d82ca4..b55324b 100755 --- a/components/filemanager/controller.php +++ b/components/filemanager/controller.php @@ -229,9 +229,9 @@ switch( $action ) { $response = $Filemanager->open( $path ); break; - case 'open_in_browser': + case 'preview': - $response = $Filemanager->openinbrowser( $path ); + $response = $Filemanager->preview( $path ); break; case 'rename': diff --git a/components/filemanager/init.js b/components/filemanager/init.js index 689a181..86b6011 100755 --- a/components/filemanager/init.js +++ b/components/filemanager/init.js @@ -1346,7 +1346,36 @@ preview: function( path ) { + let _this = this; + $.ajax({ + type: 'GET', + url: _this.controller + '?action=preview&path=' + encodeURIComponent( path ), + success: function( data ) { + + console.log( data ); + let r = JSON.parse( data ); + + if( r.status === "success" ) { + + _this.preview = window.open( r.data, '_newtab' ); + + let editor = codiad.editor.getActive(); + + if( _this.auto_reload && editor !== null ) { + + editor.addEventListener( "change", _this.refresh_preview ); + } + } else { + + codiad.message.error( i18n( r.message ) ); + } + }, + error: function( data ) { + + codiad.message.error( i18n( r.message ) ); + }, + }); }, rescan: function( path ) {