mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 13:52:16 +01:00
Added auto reloading preview window as an option, Converted showing and hiding of loading icon to jquery, Reformatted system settings page.
This commit is contained in:
parent
a0105544c0
commit
10f2bcb86b
5 changed files with 121 additions and 58 deletions
|
@ -15,14 +15,15 @@
|
|||
|
||||
|
||||
codiad.filemanager = {
|
||||
|
||||
|
||||
auto_reload: false,
|
||||
clipboard: '',
|
||||
|
||||
controller: 'components/filemanager/controller.php',
|
||||
dialog: 'components/filemanager/dialog.php',
|
||||
dialogUpload: 'components/filemanager/dialog_upload.php',
|
||||
|
||||
init: function() {
|
||||
preview: null,
|
||||
|
||||
init: async function() {
|
||||
|
||||
this.noAudio = [
|
||||
//Audio
|
||||
|
@ -58,6 +59,33 @@
|
|||
|
||||
// Initialize node listener
|
||||
this.nodeListener();
|
||||
this.auto_reload = ( await codiad.settings.get_option( "codiad.filemanager.auto_reload_preview" ) == "true" );
|
||||
|
||||
console.log( this.auto_reload );
|
||||
|
||||
amplify.subscribe( 'settings.save', async function() {
|
||||
|
||||
let option = ( await codiad.settings.get_option( "codiad.filemanager.auto_reload_preview" ) == "true" );
|
||||
if( option != codiad.filemanager.auto_reload ) {
|
||||
|
||||
//codiad.auto_save.reload_interval();
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
/* Subscribe to know when a file become active. */
|
||||
amplify.subscribe( 'active.onFocus', async function( path ) {
|
||||
|
||||
let _this = codiad.filemanager;
|
||||
let editor = codiad.editor.getActive();
|
||||
|
||||
if( _this.auto_reload && editor !== null ) {
|
||||
|
||||
_this.preview.addEventListener( "beforeunload", _this.closePreview );
|
||||
codiad.editor.getActive().addEventListener( "change", _this.refreshPreview );
|
||||
}
|
||||
});
|
||||
|
||||
// Load uploader
|
||||
$.loadScript("components/filemanager/upload_scripts/jquery.ui.widget.js", true);
|
||||
$.loadScript("components/filemanager/upload_scripts/jquery.iframe-transport.js", true);
|
||||
|
@ -440,17 +468,50 @@
|
|||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
openInBrowser: function(path) {
|
||||
|
||||
let _this = this;
|
||||
|
||||
$.ajax({
|
||||
url: this.controller + '?action=open_in_browser&path=' + encodeURIComponent(path),
|
||||
success: function(data) {
|
||||
var openIBResponse = codiad.jsend.parse(data);
|
||||
if (openIBResponse != 'error') {
|
||||
window.open(openIBResponse.url, '_newtab');
|
||||
|
||||
_this.preview = window.open( openIBResponse.url, '_newtab' );
|
||||
|
||||
let editor = codiad.editor.getActive();
|
||||
|
||||
if( _this.auto_reload && editor !== null ) {
|
||||
|
||||
_this.preview.addEventListener( "beforeunload", _this.closePreview );
|
||||
codiad.editor.getActive().addEventListener( "change", _this.refreshPreview );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
|
||||
closePreview: function( event ) {
|
||||
|
||||
_this = codiad.filemanager;
|
||||
_this.preview = null;
|
||||
},
|
||||
|
||||
refreshPreview: function( event ) {
|
||||
|
||||
_this = codiad.filemanager;
|
||||
|
||||
if( _this.preview == null ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_this.preview.location.reload();
|
||||
},
|
||||
|
||||
openInModal: function(path) {
|
||||
|
||||
let type = "";
|
||||
|
|
|
@ -134,11 +134,14 @@
|
|||
codiad.editor.setOverScroll(val);
|
||||
break;
|
||||
case "codiad.editor.autocomplete":
|
||||
var bool_val = (val == "true");
|
||||
var bool_val = (val == "true");
|
||||
codiad.editor.setLiveAutocomplete(bool_val)
|
||||
break;
|
||||
case "codiad.settings.autosave":
|
||||
var bool_val = (val == "true");
|
||||
break;
|
||||
case "codiad.filemanager.auto_reload_preview":
|
||||
var bool_val = (val == "true");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +164,6 @@
|
|||
/* Notify listeners */
|
||||
amplify.publish( 'settings.dialog.save', null );
|
||||
codiad.settings.save( settings );
|
||||
codiad.modal.unload();
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
|
|
@ -65,15 +65,20 @@
|
|||
var systemRegex = /^codiad/;
|
||||
var pluginRegex = /^codiad.plugin/;
|
||||
|
||||
$.post( this.controller + '?action=save', {settings: JSON.stringify( settings )}, function( data ) {
|
||||
|
||||
data = data.replace(/},/gi, ",").split(",");
|
||||
length = data.length;
|
||||
|
||||
for( i = 0;i < length; i++ ) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: this.controller + '?action=save',
|
||||
data: {settings: JSON.stringify( settings )},
|
||||
success: function( data ) {
|
||||
data = data.replace(/},/gi, ",").split(",");
|
||||
length = data.length;
|
||||
|
||||
parsed = codiad.jsend.parse( data );
|
||||
}
|
||||
for( i = 0;i < length; i++ ) {
|
||||
|
||||
parsed = codiad.jsend.parse( data );
|
||||
}
|
||||
codiad.modal.unload();
|
||||
},
|
||||
});
|
||||
|
||||
/* Notify listeners */
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
<hr>
|
||||
<label></label>
|
||||
<table class="settings">
|
||||
|
||||
<tr>
|
||||
|
||||
<td><?php i18n("Auto Save"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.settings.autosave">
|
||||
|
@ -15,42 +13,41 @@
|
|||
<option value="false" default><?php i18n("False") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td><?php i18n("Right Sidebar Trigger"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.rightSidebarTrigger">
|
||||
<option value="false" default><?php i18n("Hover") ?></option>
|
||||
<option value="true"><?php i18n("Click") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td><?php i18n("Filemanager Trigger"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.fileManagerTrigger">
|
||||
<option value="false" default><?php i18n("Double Click") ?></option>
|
||||
<option value="true"><?php i18n("Single Click") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td><?php i18n("Persistent Modal"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.persistentModal">
|
||||
<option value="true" default><?php i18n("Yes") ?></option>
|
||||
<option value="false"><?php i18n("No") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php i18n("Auto Reload Preview"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.filemanager.auto_reload_preview">
|
||||
<option value="false" default><?php i18n("False") ?></option>
|
||||
<option value="true"><?php i18n("True") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php i18n("Right Sidebar Trigger"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.rightSidebarTrigger">
|
||||
<option value="false" default><?php i18n("Hover") ?></option>
|
||||
<option value="true"><?php i18n("Click") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php i18n("Filemanager Trigger"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.fileManagerTrigger">
|
||||
<option value="false" default><?php i18n("Double Click") ?></option>
|
||||
<option value="true"><?php i18n("Single Click") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php i18n("Persistent Modal"); ?></td>
|
||||
<td>
|
||||
<select class="setting" data-setting="codiad.editor.persistentModal">
|
||||
<option value="true" default><?php i18n("Yes") ?></option>
|
||||
<option value="false"><?php i18n("No") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
|
||||
hide_loading: function() {
|
||||
|
||||
let loading = document.getElementById( 'modal' ).getElementsByClassName( 'loading' )[0];
|
||||
loading.style.display = "none";
|
||||
$('#modal-content .loading').css( "display", "none" );
|
||||
},
|
||||
|
||||
hideOverlay: function() {
|
||||
|
@ -55,8 +54,7 @@
|
|||
|
||||
show_loading: function() {
|
||||
|
||||
let loading = document.getElementById( 'modal' ).getElementsByClassName( 'loading' )[0];
|
||||
loading.style.display = "inline-block";
|
||||
$('#modal-content .loading').css( "display", "inline-block" );
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
|
|
Loading…
Reference in a new issue