mirror of
https://github.com/xevidos/codiad.git
synced 2024-12-22 13:52:16 +01:00
Merge branch 'development' into 'master'
Updated docs, fixed issue where autosave trigger was not saving. See merge request xevidos/codiad!22
This commit is contained in:
commit
00b1b56bee
6 changed files with 101 additions and 50 deletions
|
@ -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
|
* 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
|
* 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.
|
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**
|
**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**
|
**PHP Formatting**
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,15 @@
|
||||||
// Instantiates plugin
|
// Instantiates plugin
|
||||||
$( function() {
|
$( function() {
|
||||||
|
|
||||||
amplify.subscribe( 'settings.changed', function() {
|
amplify.subscribe( 'settings.save', async function() {
|
||||||
|
|
||||||
codiad.auto_save.settings.autosave = codiad.settings.get_option( 'codiad.settings.autosave' );
|
let option = await codiad.settings.get_option( 'codiad.settings.autosave' );
|
||||||
codiad.auto_save.reload_interval();
|
|
||||||
|
if( option != codiad.auto_save.settings.autosave ) {
|
||||||
|
|
||||||
|
//codiad.auto_save.reload_interval();
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
codiad.auto_save.init();
|
codiad.auto_save.init();
|
||||||
|
@ -37,13 +42,13 @@
|
||||||
},
|
},
|
||||||
verbose: false,
|
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
|
// Check if the auto save setting is true or false
|
||||||
// Also check to see if the editor is any of the invalid states
|
// 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 );
|
window.clearInterval( this.auto_save_trigger );
|
||||||
|
|
||||||
|
@ -90,14 +95,14 @@
|
||||||
|
|
||||||
auto_save: function() {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saving = true;
|
this.saving = true;
|
||||||
|
|
||||||
if ( codiad.active.getPath() === null ) {
|
if ( codiad.active.getPath() == null ) {
|
||||||
|
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
return;
|
return;
|
||||||
|
@ -127,15 +132,16 @@
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
reload_interval: function() {
|
reload_interval: async function() {
|
||||||
|
|
||||||
|
codiad.auto_save.settings.autosave = await codiad.settings.get_option( 'codiad.settings.autosave' );
|
||||||
try {
|
try {
|
||||||
|
|
||||||
window.clearInterval( codiad.autosave.auto_save_trigger );
|
window.clearInterval( codiad.autosave.auto_save_trigger );
|
||||||
window.clearInterval( this.auto_save_trigger );
|
window.clearInterval( this.auto_save_trigger );
|
||||||
} catch( error ) {}
|
} 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 );
|
codiad.auto_save.auto_save_trigger = setInterval( codiad.auto_save.auto_save, 256 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,46 +307,46 @@
|
||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
getSettings: async function() {
|
getSettings: function() {
|
||||||
|
|
||||||
var boolVal = null;
|
var boolVal = null;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var options = [
|
var options = [
|
||||||
'fontSize',
|
'editor.fontSize',
|
||||||
'overScroll',
|
'editor.overScroll',
|
||||||
'printMarginColumn',
|
'editor.printMarginColumn',
|
||||||
'tabSize',
|
'editor.tabSize',
|
||||||
'theme',
|
'editor.theme',
|
||||||
];
|
];
|
||||||
var bool_options = [
|
var bool_options = [
|
||||||
'autocomplete',
|
'editor.autocomplete',
|
||||||
'printMargin',
|
'settings.autosave',
|
||||||
'highlightLine',
|
'editor.printMargin',
|
||||||
'indentGuides',
|
'editor.highlightLine',
|
||||||
'wrapMode',
|
'editor.indentGuides',
|
||||||
'rightSidebarTrigger',
|
'editor.wrapMode',
|
||||||
'fileManagerTrigger',
|
'editor.rightSidebarTrigger',
|
||||||
'softTabs',
|
'editor.fileManagerTrigger',
|
||||||
'persistentModal',
|
'editor.softTabs',
|
||||||
|
'editor.persistentModal',
|
||||||
];
|
];
|
||||||
|
|
||||||
$.each( options, async function( idx, key ) {
|
$.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 ) {
|
if ( localValue !== null ) {
|
||||||
|
|
||||||
_this.settings[key] = localValue;
|
_this.settings[key] = localValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each( bool_options, async function(idx, key) {
|
$.each( bool_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) {
|
if ( localValue !== null ) {
|
||||||
return;
|
|
||||||
}
|
_this.settings[key] = (localValue == 'true').toString();
|
||||||
_this.settings[key] = (localValue == 'true');
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -13,6 +13,10 @@ class Settings {
|
||||||
"name" => "codiad.editor.autocomplete",
|
"name" => "codiad.editor.autocomplete",
|
||||||
"value" => "false",
|
"value" => "false",
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
"name" => "codiad.editor.autosave",
|
||||||
|
"value" => "true",
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
"name" => "codiad.editor.fileManagerTrigger",
|
"name" => "codiad.editor.fileManagerTrigger",
|
||||||
"value" => "false",
|
"value" => "false",
|
||||||
|
|
|
@ -78,10 +78,10 @@
|
||||||
$('.setting').each(function(){
|
$('.setting').each(function(){
|
||||||
var setting = $(this).data('setting');
|
var setting = $(this).data('setting');
|
||||||
var val = $(this).val();
|
var val = $(this).val();
|
||||||
if(val===null){
|
if( val===null ){
|
||||||
codiad.message.alert(i18n("You Must Choose A Value"));
|
codiad.message.alert(i18n("You Must Choose A Value"));
|
||||||
return;
|
return;
|
||||||
}else{
|
} else {
|
||||||
switch(setting) {
|
switch(setting) {
|
||||||
case 'codiad.editor.theme':
|
case 'codiad.editor.theme':
|
||||||
codiad.editor.setTheme(val);
|
codiad.editor.setTheme(val);
|
||||||
|
@ -137,14 +137,29 @@
|
||||||
var bool_val = (val == "true");
|
var bool_val = (val == "true");
|
||||||
codiad.editor.setLiveAutocomplete(bool_val)
|
codiad.editor.setLiveAutocomplete(bool_val)
|
||||||
break;
|
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);
|
//localStorage.setItem(setting, val);
|
||||||
settings[setting] = val
|
settings[setting] = val;
|
||||||
|
bool_val = null;
|
||||||
});
|
});
|
||||||
/* Notify listeners */
|
/* Notify listeners */
|
||||||
amplify.publish('settings.dialog.save',{});
|
amplify.publish( 'settings.dialog.save', null );
|
||||||
codiad.settings.save( settings );
|
codiad.settings.save( settings );
|
||||||
codiad.modal.unload();
|
codiad.modal.unload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,13 @@
|
||||||
var systemRegex = /^codiad/;
|
var systemRegex = /^codiad/;
|
||||||
var pluginRegex = /^codiad.plugin/;
|
var pluginRegex = /^codiad.plugin/;
|
||||||
|
|
||||||
/* Notify listeners */
|
|
||||||
amplify.publish( 'settings.save', {} );
|
|
||||||
console.log( settings );
|
|
||||||
$.post( this.controller + '?action=save', {settings: JSON.stringify( settings )}, function( data ) {
|
$.post( this.controller + '?action=save', {settings: JSON.stringify( settings )}, function( data ) {
|
||||||
|
|
||||||
parsed = codiad.jsend.parse( data );
|
parsed = codiad.jsend.parse( data );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Notify listeners */
|
||||||
|
amplify.publish( 'settings.save', {} );
|
||||||
},
|
},
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
@ -80,8 +80,8 @@
|
||||||
|
|
||||||
load: function() {
|
load: function() {
|
||||||
|
|
||||||
amplify.publish( 'settings.loaded', {} );
|
|
||||||
codiad.editor.getSettings();
|
codiad.editor.getSettings();
|
||||||
|
amplify.publish( 'settings.loaded', null );
|
||||||
},
|
},
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
@ -115,6 +115,11 @@
|
||||||
|
|
||||||
update_option: function( option, value ) {
|
update_option: function( option, value ) {
|
||||||
|
|
||||||
|
if( option == undefined || value == undefined ) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
|
|
||||||
url: this.controller + '?action=update_option',
|
url: this.controller + '?action=update_option',
|
||||||
|
@ -177,12 +182,14 @@
|
||||||
_loadTabValues: function( data_file ) {
|
_loadTabValues: function( data_file ) {
|
||||||
|
|
||||||
//Load settings
|
//Load settings
|
||||||
var key, value;
|
|
||||||
$( '.settings-view .panel[data-file="' + data_file + '"] .setting').each( async function( i, item ) {
|
$( '.settings-view .panel[data-file="' + data_file + '"] .setting').each( async function( i, item ) {
|
||||||
|
|
||||||
key = $( item ).attr( 'data-setting' );
|
let key = await $( item ).attr( 'data-setting' );
|
||||||
value = await codiad.settings.get_option( key );
|
let value = await codiad.settings.get_option( key );
|
||||||
if ( value !== null ) {
|
|
||||||
|
console.log( key, value, i, $( item ).attr( 'data-setting' ) );
|
||||||
|
|
||||||
|
if ( value != null && value != undefined ) {
|
||||||
|
|
||||||
$( item ).val( value );
|
$( item ).val( value );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue