Updated docs, fixed issue where autosave trigger was not saving.

This commit is contained in:
xevidos 2019-01-15 10:33:59 -05:00
parent 359297af7b
commit 08aab5dfb6
6 changed files with 101 additions and 50 deletions

View file

@ -4,7 +4,7 @@ Your contributions are welcome and we're very open about how contributions are m
* Check the issues to ensure that someone else isn't already working on the bug or feature
* Submit an issue for bugs and feature additions before you start with it
* Familiarize yourself with the documentation in the [Wiki](https://github.com/Codiad/Codiad/wiki)
* Familiarize yourself with the documentation in the [Wiki](https://gitlab.com/xevidos/codiad/wikis/home)
There is an established format for `components` which utilizes one JS (`init.js`) and one CSS (`screen.css`) which is handled by the loader file. Any other resources used should be loaded or accessed from one of these.
@ -20,9 +20,28 @@ Stick to the conventions defined in other components as closely as possible.
**Javascript Formatting**
In order to maintain a consistant code structure to the code across the application please run any changes through JSBeautifier (http://jsbeautifier.org/) with the default settings.
In order to maintain a consistant code structure to the code across the application please follow the wordpress standard, or run any changes through JSBeautifier (http://jsbeautifier.org/) with the settings below.
If you have questions, please ask. Submit an issue or [contact us directly](mailto:dev@codiad.com).
{
"indent_size": "1",
"indent_char": "\t",
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": true,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_before_conditional": false,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": true,
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false
}
If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com).
**PHP Formatting**

View file

@ -15,10 +15,15 @@
// Instantiates plugin
$( function() {
amplify.subscribe( 'settings.changed', function() {
codiad.auto_save.settings.autosave = codiad.settings.get_option( 'codiad.settings.autosave' );
codiad.auto_save.reload_interval();
amplify.subscribe( 'settings.save', async function() {
let option = await codiad.settings.get_option( 'codiad.settings.autosave' );
if( option != codiad.auto_save.settings.autosave ) {
//codiad.auto_save.reload_interval();
window.location.reload();
}
});
codiad.auto_save.init();
@ -37,13 +42,13 @@
},
verbose: false,
init: function() {
init: async function() {
codiad.auto_save.settings.autosave = codiad.settings.get_option( 'codiad.settings.autosave' );
codiad.auto_save.settings.autosave = await codiad.settings.get_option( 'codiad.settings.autosave' );
// Check if the auto save setting is true or false
// Also check to see if the editor is any of the invalid states
if( this.settings.autosave === false || this.settings.autosave === "false" ) {
if( this.settings.autosave == false || this.settings.autosave == "false" ) {
window.clearInterval( this.auto_save_trigger );
@ -90,14 +95,14 @@
auto_save: function() {
if( this.settings.toggle === false || this.settings.autosave === false || codiad.auto_save.invalid_states.includes( codiad.editor.getContent() ) ) {
if( this.settings.toggle == false || this.settings.autosave == false || codiad.auto_save.invalid_states.includes( codiad.editor.getContent() ) ) {
return;
}
this.saving = true;
if ( codiad.active.getPath() === null ) {
if ( codiad.active.getPath() == null ) {
this.saving = false;
return;
@ -127,15 +132,16 @@
this.saving = false;
},
reload_interval: function() {
reload_interval: async function() {
codiad.auto_save.settings.autosave = await codiad.settings.get_option( 'codiad.settings.autosave' );
try {
window.clearInterval( codiad.autosave.auto_save_trigger );
window.clearInterval( this.auto_save_trigger );
} catch( error ) {}
if( codiad.auto_save.settings.autosave === true || codiad.auto_save.settings.autosave === "true" ) {
if( codiad.auto_save.settings.autosave == true || codiad.auto_save.settings.autosave == "true" ) {
codiad.auto_save.auto_save_trigger = setInterval( codiad.auto_save.auto_save, 256 );
}

View file

@ -307,46 +307,46 @@
//
//////////////////////////////////////////////////////////////////
getSettings: async function() {
getSettings: function() {
var boolVal = null;
var _this = this;
var options = [
'fontSize',
'overScroll',
'printMarginColumn',
'tabSize',
'theme',
'editor.fontSize',
'editor.overScroll',
'editor.printMarginColumn',
'editor.tabSize',
'editor.theme',
];
var bool_options = [
'autocomplete',
'printMargin',
'highlightLine',
'indentGuides',
'wrapMode',
'rightSidebarTrigger',
'fileManagerTrigger',
'softTabs',
'persistentModal',
'editor.autocomplete',
'settings.autosave',
'editor.printMargin',
'editor.highlightLine',
'editor.indentGuides',
'editor.wrapMode',
'editor.rightSidebarTrigger',
'editor.fileManagerTrigger',
'editor.softTabs',
'editor.persistentModal',
];
$.each( options, async function( idx, key ) {
var localValue = await codiad.settings.get_option( 'codiad.editor.' + key );
let localValue = await codiad.settings.get_option( 'codiad.' + key );
if ( localValue !== null ) {
_this.settings[key] = localValue;
}
});
$.each( bool_options, async function(idx, key) {
var localValue = await codiad.settings.get_option( 'codiad.editor.' + key );
if (localValue === null) {
return;
}
_this.settings[key] = (localValue == 'true');
});
let localValue = await codiad.settings.get_option( 'codiad.' + key );
if ( localValue !== null ) {
_this.settings[key] = (localValue == 'true').toString();
}
});
},
/////////////////////////////////////////////////////////////////

View file

@ -13,6 +13,10 @@ class Settings {
"name" => "codiad.editor.autocomplete",
"value" => "false",
),
array(
"name" => "codiad.editor.autosave",
"value" => "true",
),
array(
"name" => "codiad.editor.fileManagerTrigger",
"value" => "false",

View file

@ -78,10 +78,10 @@
$('.setting').each(function(){
var setting = $(this).data('setting');
var val = $(this).val();
if(val===null){
if( val===null ){
codiad.message.alert(i18n("You Must Choose A Value"));
return;
}else{
} else {
switch(setting) {
case 'codiad.editor.theme':
codiad.editor.setTheme(val);
@ -137,14 +137,29 @@
var bool_val = (val == "true");
codiad.editor.setLiveAutocomplete(bool_val)
break;
case "codiad.settings.autosave":
var bool_val = (val == "true");
break;
}
}
if( bool_val != undefined && bool_val != null ) {
if( bool_val ) {
val = "true";
} else {
val = "false";
}
}
//localStorage.setItem(setting, val);
settings[setting] = val
settings[setting] = val;
bool_val = null;
});
/* Notify listeners */
amplify.publish('settings.dialog.save',{});
amplify.publish( 'settings.dialog.save', null );
codiad.settings.save( settings );
codiad.modal.unload();
}

View file

@ -65,13 +65,13 @@
var systemRegex = /^codiad/;
var pluginRegex = /^codiad.plugin/;
/* Notify listeners */
amplify.publish( 'settings.save', {} );
console.log( settings );
$.post( this.controller + '?action=save', {settings: JSON.stringify( settings )}, function( data ) {
parsed = codiad.jsend.parse( data );
});
/* Notify listeners */
amplify.publish( 'settings.save', {} );
},
//////////////////////////////////////////////////////////////////
@ -80,8 +80,8 @@
load: function() {
amplify.publish( 'settings.loaded', {} );
codiad.editor.getSettings();
amplify.publish( 'settings.loaded', null );
},
//////////////////////////////////////////////////////////////////
@ -115,6 +115,11 @@
update_option: function( option, value ) {
if( option == undefined || value == undefined ) {
return false;
}
jQuery.ajax({
url: this.controller + '?action=update_option',
@ -177,12 +182,14 @@
_loadTabValues: function( data_file ) {
//Load settings
var key, value;
$( '.settings-view .panel[data-file="' + data_file + '"] .setting').each( async function( i, item ) {
key = $( item ).attr( 'data-setting' );
value = await codiad.settings.get_option( key );
if ( value !== null ) {
let key = await $( item ).attr( 'data-setting' );
let value = await codiad.settings.get_option( key );
console.log( key, value, i, $( item ).attr( 'data-setting' ) );
if ( value != null && value != undefined ) {
$( item ).val( value );
}