Merge branch 'development' into 'master'

Remove file extensions modifier until recode due to issues with module, Switched to Ace\'s module detection system, Added a multi line option for find and replace, Fixed Delete contents button

See merge request xevidos/codiad!21
This commit is contained in:
Isaac Brown 2019-01-15 08:36:31 -05:00
commit 664654c6b5
20 changed files with 300 additions and 935 deletions

View File

@ -25,8 +25,8 @@ Current Tasks:
Task List:
* Add ability to login with LDAP.
* Add custom market.
* Add ability to login with LDAP
* Add custom market
* Add in new admin interface
- Group Management
- Permissions Management
@ -34,18 +34,19 @@ Task List:
- Project Management
- System Settings
- User Management
* Add if file could not be saved 5 times close the open file.
* Add if file could not be saved 5 times close the open file
* Add multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility.
* Clean up update script.
* Add mobile compatibility
* Clean up update script
* Re Add the language recognition system after recode
Completed:
* Add Auto Save.
* Add ability to center bottom of code.
* Add updating script.
* Add site renaming.
* Fix JS errors already showing.
* Remove Codiad autocomplete in favor of Ace's.
* Updated for PHP 7.2.
* Add ability to center bottom of code
* Add updating script
* Add site renaming
* Fix JS errors already showing
* Remove Codiad autocomplete in favor of Ace's
* Updated for PHP 7.2

View File

@ -66,8 +66,8 @@
return;
}
var ext = codiad.filemanager.getExtension(path);
var mode = codiad.editor.selectMode(ext);
var mode = codiad.editor.selectMode( path );
var fn = function() {
//var Mode = require('ace/mode/' + mode)
// .Mode;
@ -82,7 +82,7 @@
//var session = new EditSession(content, new Mode());
var session = new EditSession(content);
session.setMode("ace/mode/" + mode);
session.setMode(mode.mode);
session.setUndoManager(new UndoManager());
session.path = path;
@ -98,7 +98,7 @@
};
// Assuming the mode file has no dependencies
$.loadScript('components/editor/ace-editor/mode-' + mode + '.js',
$.loadScript('components/editor/ace-editor/mode-' + mode.name + '.js',
fn);
},
@ -674,7 +674,7 @@
}
newSession.on("changeMode", fn);
newSession.setMode("ace/mode/" + mode);
newSession.setMode( mode.mode );
} else {
// A folder was renamed
var newKey;

View File

@ -28,16 +28,18 @@ switch($_GET['action']){
$type = $_GET['type'];
?>
<label><?php i18n("Find:"); ?></label>
<textarea name="find" autofocus="autofocus" autocomplete="off"></textarea>
<input name="find" autofocus="autofocus" autocomplete="off">
<textarea style="display: none;" name="find" autofocus="autofocus" autocomplete="off"></textarea>
<?php if($type=='replace'){ ?>
<label><?php i18n("Replace:"); ?></label>
<textarea name="replace"></textarea>
<input name="replace">
<textarea style="display: none;" name="replace"></textarea>
<?php } ?>
<button class="btn-left" onclick="codiad.editor.search('find');return false;"><?php i18n("Find"); ?></button>
<button class="btn-mid" onclick="codiad.editor.toggleMultiLine( this );return false;"><?php i18n("Multi Line"); ?></button>
<?php if($type=='replace'){ ?>
<button class="btn-mid" onclick="codiad.editor.search('replace');return false;"><?php i18n("Replace"); ?></button>
<button class="btn-mid" onclick="codiad.editor.search('replaceAll');return false;"><?php i18n("Replace ALL"); ?></button>
@ -52,8 +54,15 @@ switch($_GET['action']){
<script>
$(function(){
<?php if($_GET['action']=='search'){ ?>
$('textarea[name="find"]').val(codiad.active.getSelectedText());
$('textarea[name="find"]').focus();
if( codiad.editor.multi_line ) {
$('textarea[name="find"]').val(codiad.active.getSelectedText());
$('textarea[name="find"]').focus();
} else {
$('input[name="find"]').val(codiad.active.getSelectedText());
$('input[name="find"]').focus();
}
<?php } ?>
});

View File

@ -10,6 +10,7 @@
var VirtualRenderer = ace.require('ace/virtual_renderer').VirtualRenderer;
var Editor = ace.require('ace/editor').Editor;
var EditSession = ace.require('ace/edit_session').EditSession;
var ModeList = ace.require("ace/ext/modelist");
var UndoManager = ace.require("ace/undomanager").UndoManager;
// Editor modes that have been loaded
@ -24,142 +25,6 @@
codiad.editor.init();
});
// modes available for selecting
var availableTextModes = new Array(
'abap',
'abc',
'actionscript',
'ada',
'apache_conf',
'applescript',
'asciidoc',
'assembly_x86',
'autohotkey',
'batchfile',
'c9search',
'c_cpp',
'cirru',
'clojure',
'cobol',
'coffee',
'coldfusion',
'csharp',
'css',
'curly',
'd',
'dart',
'diff',
'django',
'dockerfile',
'dot',
'eiffel',
'ejs',
'elixir',
'elm',
'erlang',
'forth',
'ftl',
'gcode',
'gherkin',
'gitignore',
'glsl',
'gobstones',
'golang',
'groovy',
'haml',
'handlebars',
'haskell',
'haxe',
'html',
'html_elixir',
'html_ruby',
'ini',
'io',
'jack',
'jade',
'java',
'javascript',
'json',
'jsoniq',
'jsp',
'jsx',
'julia',
'latex',
'lean',
'less',
'liquid',
'lisp',
'livescript',
'logiql',
'lsl',
'lua',
'luapage',
'lucene',
'makefile',
'markdown',
'mask',
'matlab',
'maze',
'mel',
'mips_assembler',
'mushcode',
'mysql',
'nix',
'nsis',
'objectivec',
'ocaml',
'pascal',
'perl',
'pgsql',
'php',
'plain_text',
'powershell',
'praat',
'prolog',
'protobuf',
'python',
'r',
'razor',
'rdoc',
'rhtml',
'rst',
'ruby',
'rust',
'sass',
'scad',
'scala',
'scheme',
'scss',
'sh',
'sjs',
'smarty',
'snippets',
'soy_template',
'space',
'sql',
'sqlserver',
'stylus',
'svg',
'swift',
'swig',
'tcl',
'tex',
'text',
'textile',
'toml',
'twig',
'typescript',
'vala',
'vbscript',
'velocity',
'verilog',
'vhdl',
'wollok',
'xml',
'xquery',
'yaml'
);
function SplitContainer(root, children, splitType) {
var _this = this;
@ -400,7 +265,9 @@
fileManagerTrigger: false,
tabSize: 4
},
multi_line: false,
rootContainer: null,
fileExtensionTextMode: {},
@ -636,10 +503,11 @@
var firstOption = 0;
this.initMenuHandler($('#current-mode'),_thisMenu);
availableTextModes.sort();
$.each(availableTextModes, function(i){
modeOptions.push('<li><a>'+availableTextModes[i]+'</a></li>');
var modes = Object.keys( ModeList.modesByName ).sort();
$.each(modes, function(i){
modeOptions.push('<li><a>'+modes[i]+'</a></li>');
});
var html = '<table><tr>';
@ -872,12 +740,7 @@
return 'text';
}
e = e.toLowerCase();
if(e in this.fileExtensionTextMode){
return this.fileExtensionTextMode[e];
}else{
return 'text';
}
return( ModeList.getModeForPath( e ) );
},
/////////////////////////////////////////////////////////////////
@ -1484,10 +1347,19 @@
search: function(action, i) {
i = i || this.getActive();
if (! i) return;
var find = $('#modal textarea[name="find"]')
if( this.multi_line ) {
var find = $('#modal textarea[name="find"]')
.val();
var replace = $('#modal textarea[name="replace"]')
var replace = $('#modal textarea[name="replace"]')
.val();
} else {
var find = $('#modal input[name="find"]')
.val();
var replace = $('#modal input[name="replace"]')
.val();
}
switch (action) {
case 'find':
@ -1599,7 +1471,33 @@
//Database
codiad.settings.update_option( 'codiad.editor.autocomplete', s );
},
toggleMultiLine: function( e ) {
if( e.innerText === "Multi Line" ) {
this.multi_line = true;
e.innerText = "Single Line";
$('input[name="find"]').hide();
$('textarea[name="find"]').show();
$('textarea[name="find"]').val( $('input[name="find"]').val() );
$('input[name="replace"]').hide();
$('textarea[name="replace"]').show();
$('textarea[name="replace"]').val( $('input[name="replace"]').val() );
} else {
this.multi_line = false;
e.innerText = "Multi Line";
$('input[name="find"]').show();
$('textarea[name="find"]').hide();
$('input[name="find"]').val( $('textarea[name="find"]').val() );
$('input[name="replace"]').show();
$('textarea[name="replace"]').hide();
$('input[name="replace"]').val( $('textarea[name="replace"]').val() );
}
}
};
})(this, jQuery);

View File

@ -1,353 +0,0 @@
<?php
/*
* (c) Codiad & ccvca (https://github.com/ccvca)
* @author ccvca (https://github.com/ccvca)
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
* See [root]/license.txt for more. This information must remain intact.
*/
require_once '../../common.php';
class fileextension_textmode
{
//////////////////////////////////////////////////////////////////
//default associations
//////////////////////////////////////////////////////////////////
private $defaultExtensions = array(
'html' => 'html',
'htm' => 'html',
'tpl' => 'html',
'js' => 'javascript',
'css' => 'css',
'scss' => 'scss',
'sass' => 'scss',
'less' => 'less',
'php' => 'php',
'php4' => 'php',
'php5' => 'php',
'phtml' => 'php',
'json' => 'json',
'java' => 'java',
'xml' => 'xml',
'sql' => 'sql',
'md' => 'markdown',
'c' => 'c_cpp',
'cpp' => 'c_cpp',
'd' => 'd',
'h' => 'c_cpp',
'hpp' => 'c_cpp',
'py' => 'python',
'rb' => 'ruby',
'erb' => 'html_ruby',
'jade' => 'jade',
'coffee' => 'coffee',
'vm' => 'velocity');
//////////////////////////////////////////////////////////////////
//availiable text modes
//////////////////////////////////////////////////////////////////
private $availiableTextModes = array(
'abap',
'abc',
'actionscript',
'ada',
'apache_conf',
'applescript',
'asciidoc',
'assembly_x86',
'autohotkey',
'batchfile',
'c9search',
'c_cpp',
'cirru',
'clojure',
'cobol',
'coffee',
'coldfusion',
'csharp',
'css',
'curly',
'd',
'dart',
'diff',
'django',
'dockerfile',
'dot',
'eiffel',
'ejs',
'elixir',
'elm',
'erlang',
'forth',
'ftl',
'gcode',
'gherkin',
'gitignore',
'glsl',
'gobstones',
'golang',
'groovy',
'haml',
'handlebars',
'haskell',
'haxe',
'html',
'html_elixir',
'html_ruby',
'ini',
'io',
'jack',
'jade',
'java',
'javascript',
'json',
'jsoniq',
'jsp',
'jsx',
'julia',
'latex',
'lean',
'less',
'liquid',
'lisp',
'livescript',
'logiql',
'lsl',
'lua',
'luapage',
'lucene',
'makefile',
'markdown',
'mask',
'matlab',
'maze',
'mel',
'mips_assembler',
'mushcode',
'mysql',
'nix',
'nsis',
'objectivec',
'ocaml',
'pascal',
'perl',
'pgsql',
'php',
'plain_text',
'powershell',
'praat',
'prolog',
'protobuf',
'python',
'r',
'razor',
'rdoc',
'rhtml',
'rst',
'ruby',
'rust',
'sass',
'scad',
'scala',
'scheme',
'scss',
'sh',
'sjs',
'smarty',
'snippets',
'soy_template',
'space',
'sql',
'sqlserver',
'stylus',
'svg',
'swift',
'swig',
'tcl',
'tex',
'text',
'textile',
'toml',
'twig',
'typescript',
'vala',
'vbscript',
'velocity',
'verilog',
'vhdl',
'wollok',
'xml',
'xquery',
'yaml'
);
const storeFilename = 'extensions.php';
//////////////////////////////////////////////////////////////////
//check the session if the user is allowed to do anything here
//////////////////////////////////////////////////////////////////
public function __construct()
{
Common::checkSession();
}
public function getAvailiableTextModes()
{
return $this->availiableTextModes;
}
public function getDefaultExtensions()
{
return $this->defaultExtensions;
}
//////////////////////////////////////////////////////////////////
//checks if the sended extensions are valid to prevent any injections
//////////////////////////////////////////////////////////////////
public function validateExtension($extension)
{
return preg_match('#^[a-z0-9\_]+$#i', $extension);
}
//////////////////////////////////////////////////////////////////
//checks if the sended extensions are valid to prevent any injections and usage of removed text modes
//////////////////////////////////////////////////////////////////
public function validTextMode($mode)
{
return in_array($mode, $this->availiableTextModes);
}
//////////////////////////////////////////////////////////////////
//process the form with the associations
//////////////////////////////////////////////////////////////////
private function processFileExtTextModeForm()
{
if (!Common::checkAccess()) {
return array('status' =>'error', 'msg' =>'You are not allowed to edit the file extensions.');
}
//Store Fileextensions and Textmodes in File:
if (!isset($_POST['extension']) || !is_array($_POST['extension'])
|| !isset($_POST['textMode']) || !is_array($_POST['textMode'])) {
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send'));
}
$exMap = array();
$warning = '';
//Iterate over the sended extensions
foreach ($_POST['extension'] as $key => $extension) {
//ignore empty extensions, so that they are going to removed
if (trim($extension) == '') {
continue;
}
//get the sended data and check it
if (!isset($_POST["textMode"][$key])) {
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send.'));
}
$extension = strtolower(trim($extension));
$textMode = strtolower(trim($_POST["textMode"][$key]));
if (!$this->validateExtension($extension)) {
return json_encode(array('status' => 'error', 'msg' => 'incorrect extension:'.htmlentities($extension)));
}
if (!$this->validTextMode($textMode)) {
return json_encode(array('status' => 'error', 'msg' => 'incorrect text mode:'.htmlentities($textMode)));
}
//data was correct and could be insert
if (isset($exMap[$extension])) {
$warning = htmlentities($extension).' is already set.<br/>';
} else {
$exMap[$extension] = $textMode;
}
}
//store the associations
Common::saveJSON(fileextension_textmode::storeFilename, $exMap);
if ($warning != '') {
return json_encode(array('status' => 'warning', 'msg' => $warning, 'extensions' => $exMap ));
} else {
return json_encode(array('status' => 'success', 'msg' => 'File extensions are saved successfully.', 'extensions' => $exMap));
}
}
//////////////////////////////////////////////////////////////////
//process all the possible forms
//////////////////////////////////////////////////////////////////
public function processForms()
{
if (!isset($_GET['action'])) {
return json_encode(array('status' => 'error', 'msg' => 'incorrect data send.'));
}
switch ($_GET['action']) {
case 'FileExtTextModeForm':
return $this->processFileExtTextModeForm();
break;
case 'GetFileExtTextModes':
return $this->prcessGetFileExtTextModes();
break;
default:
return json_encode(array('status' => 'error', 'msg' => 'Incorrect data send'));
break;
}
}
//////////////////////////////////////////////////////////////////
//Send the default extensions
//////////////////////////////////////////////////////////////////
private function prcessGetFileExtTextModes()
{
$ext = false;
//ignore warnings
$ext = @Common::getJSON(fileextension_textmode::storeFilename);
if (!is_array($ext)) {
//default extensions
$ext = $this->defaultExtensions;
}
//the availiable extensions, which aren't removed
$availEx = array();
foreach ($ext as $ex => $mode) {
if (in_array($mode, $this->availiableTextModes)) {
$availEx[$ex] = $mode;
}
}
return json_encode(array('status' => 'success', 'extensions' => $availEx, 'textModes' => $this->availiableTextModes));
}
//////////////////////////////////////////////////////////////////
//return a select-field with all availiable text modes, the one in the parameter is selected
//////////////////////////////////////////////////////////////////
public function getTextModeSelect($extension)
{
$extension = trim(strtolower($extension));
$find = false;
$ret = '<select name="textMode[]" class="textMode">'."\n";
foreach ($this->getAvailiableTextModes() as $textmode) {
$ret .= ' <option';
if ($textmode == $extension) {
$ret .= ' selected="selected"';
$find = true;
}
$ret .='>'.$textmode.'</option>'."\n";
}
//unknown extension, print it in the end
if (!$find && $extension != '') {
$ret .= ' <option selected="selected">'.$textmode.'</option>'."\n";
}
$ret .= '</select>'."\n";
return $ret;
}
}

View File

@ -1,15 +0,0 @@
<?php
/*
* (c) Codiad & ccvca (https://github.com/ccvca)
* @author ccvca (https://github.com/ccvca)
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
* See [root]/license.txt for more. This information must remain intact.
*/
require_once 'class.fileextension_textmode.php';
$fileExTM = new fileextension_textmode();
echo $fileExTM->processForms();

View File

@ -1,79 +0,0 @@
<?php
/*
* (c) Codiad & ccvca (https://github.com/ccvca)
* @author ccvca (https://github.com/ccvca)
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
* See [root]/license.txt for more. This information must remain intact.
*/
require_once 'class.fileextension_textmode.php';
//check Session is done in constructor
$fileExTM = new fileextension_textmode();
if(!isset($_GET['action'])){
die('Missing $_GET["action"]');
}
switch($_GET['action']){
//////////////////////////////////////////////////////////////////
//The form for edit the assotiations
//////////////////////////////////////////////////////////////////
case 'fileextension_textmode_form':
if(!Common::checkAccess()){
die('You are not allowed to edit the file extensions.');
}
//////////////////////////////////////////////////////////////////
//Reading the current extensions
//////////////////////////////////////////////////////////////////
$ext = false;
//ignore warnings
$ext = @Common::getJSON(fileextension_textmode::storeFilename);
if(!is_array($ext)){
//default extensions
$ext = $fileExTM->getDefaultExtensions();
}
$textModes = $fileExTM->getAvailiableTextModes();
if(!@ksort($ext)){
die(json_encode(array('status' => 'error', 'msg' => 'Internal PHP error.') ));
}
?>
<label><span class="icon-pencil big-icon"></span><?php i18n("Extensions"); ?></label>
<table id="FileExtModeHeader">
<thead>
<tr>
<th><?php i18n("Extension"); ?></th>
<th><?php i18n("Mode"); ?></th>
</tr>
</thead>
</table>
<div id="FileExtTextModeDiv">
<table id="FileExtTextModeTable">
<tbody id="FileExtTextModeTableTbody">
<?php
foreach($ext as $ex => $mode){
//////////////////////////////////////////////////////////////////
//print only valid assotiations
//////////////////////////////////////////////////////////////////
if(!$fileExTM->validTextMode($mode)){
continue;
}?>
<tr>
<td><input class="FileExtension" type="text" name="extension[]" value="<?php echo $ex ?>" /></td>
<td><?php echo $fileExTM->getTextModeSelect($mode)?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<br>
<button class="btn-left" onClick="codiad.fileext_textmode.addFieldToForm()"><?php i18n("New Extension"); ?></button>
<?php
break;
}
?>

View File

@ -1,136 +0,0 @@
/*
* (c) Codiad & ccvca (https://github.com/ccvca)
* @author ccvca (https://github.com/ccvca)
* This Code is released under the same licence as Codiad (https://github.com/Codiad/Codiad)
* See [root]/license.txt for more. This information must remain intact.
*/
(function(global, $) {
var self = null;
$(function() {
codiad.fileext_textmode.init();
});
global.codiad.fileext_textmode = {
dialog: 'components/fileext_textmode/dialog.php',
controller: 'components/fileext_textmode/controller.php',
//////////////////////////////////////////////////////////////////
//do a post request for the first associations of fileextensions and textmodes
//////////////////////////////////////////////////////////////////
availableTextModes : [],
init : function() {
self = this;
this.initEditorFileExtensionTextModes();
amplify.subscribe('settings.dialog.save', function(){
if ($('#FileExtTextModeDiv:visible').length !== 0) {
self.sendForm();
}
});
},
//////////////////////////////////////////////////////////////////
//do a post request for the first associations of fileextensions and textmodes
//////////////////////////////////////////////////////////////////
initEditorFileExtensionTextModes : function(){
$.get(this.controller, {'action' : 'GetFileExtTextModes'}, this.setEditorFileExtensionTextModes);
},
//////////////////////////////////////////////////////////////////
//initial method to get the stored associations
//////////////////////////////////////////////////////////////////
setEditorFileExtensionTextModes : function(data){
resp = $.parseJSON(data);
if(resp.status != 'error' && resp.extensions != undefined){
codiad.editor.clearFileExtensionTextMode();
for(i in resp.extensions){
codiad.editor.addFileExtensionTextMode(i, resp.extensions[i]);
}
if(resp.textModes != undefined && resp.textModes != []){
self.availableTextModes = resp.textModes;
}
/* Notify listeners. */
amplify.publish('fileext_textmode.loadedExtensions');
}
self.showStatus(data);
},
formWidth : 400,
//////////////////////////////////////////////////////////////////
// Open the component dialog
//////////////////////////////////////////////////////////////////
open : function() {
//codiad.modal.unload();
codiad.modal.load(this.formWidth,
this.dialog+"?action=fileextension_textmode_form");
codiad.modal.hideOverlay();
},
//////////////////////////////////////////////////////////////////
//send the insert extesions and textmodes to the server.
//////////////////////////////////////////////////////////////////
sendForm : function(){
var $div = $('#FileExtTextModeDiv');
var extensions = $div.find('.FileExtension');
//data to send
var formData = {'extension[]' : [], 'textMode[]' : []};
for(var i = 0; i < extensions.size(); ++i){
formData['extension[]'].push(extensions[i].value);
}
var textMode = $div.find('.textMode');
for(var i = 0; i < textMode.size(); ++i){
formData['textMode[]'].push(textMode[i].value);
}
$.post(this.controller+'?action=FileExtTextModeForm', formData, self.setEditorFileExtensionTextModes);
},
//////////////////////////////////////////////////////////////////
//Add a new insert line to the form
//////////////////////////////////////////////////////////////////
addFieldToForm : function(){
var $table = $('#FileExtTextModeTable');
var $tbody = $('#FileExtTextModeTableTbody');
var code = '<tr><td><input class="FileExtension" type="text" name="extension[]" value="" /></td>';
code += '<td><select name="textMode[]" class="textMode">';
for(var i = 0; i < this.availableTextModes.length; ++i){
code += '<option>'+ this.availableTextModes[i] +'</option>';
}
code += '</select></td></tr>';
$tbody.append(code);
//scroll as far down as possible
$table.scrollTop(1000000);
},
//////////////////////////////////////////////////////////////////
//showing the status and msg from a http-request
//////////////////////////////////////////////////////////////////
showStatus : function(resp) {
resp = $.parseJSON(resp);
if(resp.status != undefined && resp.status != '' && resp.msg != undefined && resp.message != ''){
switch (resp.status) {
case 'success':
codiad.message.success(resp.msg);
break;
case 'error':
codiad.message.error(resp.msg);
break;
case 'notice':
codiad.message.notice(resp.msg);
break;
};
}
}
};
})(this, jQuery);

View File

@ -95,10 +95,16 @@
"applies-to" : "non-root",
"onclick": "codiad.filemanager.deleteNode($('#context-menu').attr('data-path'));"
},
{
"title": "Break",
"icon": null,
"applies-to" : "both no-external",
"onclick": null
},
{
"title": "Delete Contents",
"icon": "icon-cancel-circled",
"applies-to" : "non-root",
"applies-to" : "directory-only",
"onclick": "codiad.filemanager.deleteInnerNode($('#context-menu').attr('data-path'));"
},
{

View File

@ -305,6 +305,7 @@ ALTER TABLE `user_options`
/**
* Create sessions path.
*/
@ -318,7 +319,7 @@ ALTER TABLE `user_options`
// Create Active file
//////////////////////////////////////////////////////////////////
saveJSON($active, array(''));
saveJSON( $active, array( '' ) );
//////////////////////////////////////////////////////////////////
// Create Config

View File

@ -20,7 +20,7 @@
switch($_GET['action']) {
case "settings":
?>
?>
<div class="settings-view">
<div class="config-menu">
<label><?php i18n("Settings"); ?></label>
@ -32,15 +32,6 @@
<li name="system-settings" data-file="components/settings/settings.system.php" data-name="system">
<a><span class="icon-doc-text bigger-icon"></span><?php i18n("System"); ?></a>
</li>
<?php
if (COMMON::checkAccess()) {
?>
<li name="extension-settings" data-file="components/fileext_textmode/dialog.php?action=fileextension_textmode_form" data-name="fileext_textmode">
<a><span class="icon-pencil bigger-icon"></span><?php i18n("Extensions"); ?></a>
</li>
<?php
}
?>
</ul>
</div>
<hr>
@ -74,6 +65,7 @@
</div>
<button class="btn-right" onclick="save(); return false;"><?php i18n("Save"); ?></button>
<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Close"); ?></button>
<div class="loading"></div>
<script>
var settings = {};
@ -82,6 +74,7 @@
});
function save() {
codiad.modal.show_loading();
$('.setting').each(function(){
var setting = $(this).data('setting');
var val = $(this).val();
@ -152,14 +145,14 @@
});
/* Notify listeners */
amplify.publish('settings.dialog.save',{});
codiad.modal.unload();
codiad.settings.save( settings );
codiad.modal.unload();
}
</script>
<?php
<?php
break;
case "iframe":
?>
?>
<script>
/*
* Storage Event:
@ -174,7 +167,7 @@
}
}, false);
</script>
<?php
<?php
break;
default:
break;

View File

@ -29,7 +29,7 @@
$( 'body' ).append( '<iframe src="components/settings/dialog.php?action=iframe"></iframe>' );
//Load Settings
//this.load();
this.load();
},
get_option: async function( option ) {
@ -80,7 +80,7 @@
load: function() {
amplify.publish( 'settings.loaded', null );
amplify.publish( 'settings.loaded', {} );
codiad.editor.getSettings();
},

View File

@ -53,28 +53,4 @@
</td>
</tr>
<tr>
<td><?php i18n("Sync system settings on all devices"); ?></td>
<td>
<select class="setting" data-setting="codiad.settings.system.sync">
<option value="true"><?php i18n("Yes") ?></option>
<option value="false" default><?php i18n("No") ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Sync plugin settings on all devices"); ?></td>
<td>
<select class="setting" data-setting="codiad.settings.plugin.sync">
<option value="true"><?php i18n("Yes") ?></option>
<option value="false" default><?php i18n("No") ?></option>
</select>
</td>
</tr>
</table>

View File

@ -12,7 +12,7 @@ class Update {
// CONSTANTS
//////////////////////////////////////////////////////////////////
CONST VERSION = "v.2.9.3.1";
CONST VERSION = "v.2.9.3.2";
//////////////////////////////////////////////////////////////////
// PROPERTIES

View File

@ -318,9 +318,10 @@ class User {
if( sql::check_sql_error( $return ) ) {
echo formatJSEND( "success", null );
} else {
echo formatJSEND( "success", null );
echo( $return );
}
}

View File

@ -101,6 +101,7 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
<script src="js/jquery.css3.min.js"></script>
<script src="js/jquery.easing.js"></script>
<script src="js/jquery.toastmessage.js"></script>
<script src="js/jquery.ui.touch-punch.min.js"></script>
<script src="js/amplify.min.js"></script>
<script src="js/localstorage.js"></script>
<script src="js/jquery.hoverIntent.min.js"></script>
@ -418,6 +419,8 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
<!-- ACE -->
<script src="components/editor/ace-editor/ace.js"></script>
<script src="components/editor/ace-editor/ext-language_tools.js"></script>
<script src="components/editor/ace-editor/ext-modelist.js"></script>
<script src="components/editor/ace-editor/ext-themelist.js"></script>
<!-- Codiad System Variables -->
<script>

11
js/jquery.ui.touch-punch.min.js vendored Executable file
View File

@ -0,0 +1,11 @@
/*!
* jQuery UI Touch Punch 0.2.3
*
* Copyright 20112014, Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Depends:
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);

View File

@ -1,120 +1,149 @@
(function(global, $){
var codiad = global.codiad;
//////////////////////////////////////////////////////////////////////
// Modal
//////////////////////////////////////////////////////////////////////
codiad.modal = {
load: function(width, url, data) {
data = data || {};
var bounds = this._getBounds(width);
$('#modal')
.css({
'top': bounds.top,
'left': bounds.left,
'min-width': width + 'px',
'margin-left': '-' + Math.ceil(width / 2) + 'px'
})
.draggable({
handle: '#drag-handle'
});
$('#modal-content')
.html('<div id="modal-loading"></div>');
this.load_process = $.get(url, data, function(data) {
$('#modal-content').html(data);
// Fix for Firefox autofocus goofiness
$('input[autofocus="autofocus"]')
.focus();
});
var event = {animationPerformed: false};
amplify.publish('modal.onLoad', event);
// If no plugin has provided a custom load animation
if(!event.animationPerformed) {
$('#modal, #modal-overlay')
.fadeIn(200);
}
codiad.sidebars.modalLock = true;
},
hideOverlay: function() {
$('#modal-overlay')
.hide();
},
unload: function() {
this._setBounds();
$('#modal-content form')
.die('submit'); // Prevent form bubbling
var event = { animationPerformed : false };
amplify.publish('modal.onUnload', event);
// If no plugin has provided a custom unload animation
if(!event.animationPerformed) {
$('#modal, #modal-overlay')
.fadeOut(200);
$('#modal-content')
.html('');
}
codiad.sidebars.modalLock = false;
if (!codiad.sidebars.leftLock) { // Slide sidebar back
$('#sb-left')
.animate({
'left': '-290px'
}, 300, 'easeOutQuart');
$('#editor-region')
.animate({
'margin-left': '10px'
}, 300, 'easeOutQuart');
}
codiad.editor.focus();
},
_setBounds: function(bounds) {
if (typeof(bounds) == 'undefined') {
if ($('#modal').is(':visible')) {
bounds = {};
bounds.top = Math.floor($('#modal').offset().top);
bounds.left = Math.floor($('#modal').offset().left);
} else {
return false;
}
}
//Save bounds
localStorage.setItem("codiad.modal.top", bounds.top);
localStorage.setItem("codiad.modal.left", bounds.left);
},
_getBounds: function(width) {
if (localStorage.getItem("codiad.modal.top") !== null && localStorage.getItem("codiad.modal.left") !== null && codiad.editor.settings.persistentModal) {
var top = parseInt(localStorage.getItem('codiad.modal.top'), 10),
left = parseInt(localStorage.getItem('codiad.modal.left'), 10);
//Check if modal is out of window
if ((top + 40) > $(window).height()) {
top = "15%";
} else {
top += "px";
}
if ((left + width + 40) > $(window).width()) {
left = "50%";
} else {
left += Math.ceil(width / 2);
left += "px";
}
return {
top: top,
left: left
};
} else {
return {
top: "15%",
left: "50%"
};
}
}
};
})(this, jQuery);
var codiad = global.codiad;
//////////////////////////////////////////////////////////////////////
// Modal
//////////////////////////////////////////////////////////////////////
codiad.modal = {
hide_loading: function() {
let loading = document.getElementById( 'modal' ).getElementsByClassName( 'loading' )[0];
loading.style.display = "none";
},
hideOverlay: function() {
$('#modal-overlay')
.hide();
},
load: function( width, url, data ) {
data = data || {};
var bounds = this._getBounds( width );
$('#modal')
.css({
'top': bounds.top,
'left': bounds.left,
'min-width': width + 'px',
'margin-left': '-' + Math.ceil( width / 2 ) + 'px'
})
.draggable({
handle: '#drag-handle'
});
$('#modal-content')
.html('<div id="modal-loading"></div>');
this.load_process = $.get( url, data, function( data ) {
$('#modal-content').html( data );
// Fix for Firefox autofocus goofiness
$('input[autofocus="autofocus"]')
.focus();
});
var event = {animationPerformed: false};
amplify.publish( 'modal.onLoad', event );
// If no plugin has provided a custom load animation
if( ! event.animationPerformed ) {
$('#modal, #modal-overlay')
.fadeIn(200);
}
codiad.sidebars.modalLock = true;
},
show_loading: function() {
let loading = document.getElementById( 'modal' ).getElementsByClassName( 'loading' )[0];
loading.style.display = "inline-block";
},
unload: function() {
this._setBounds();
$('#modal-content form')
.die('submit'); // Prevent form bubbling
var event = { animationPerformed : false };
amplify.publish( 'modal.onUnload', event );
// If no plugin has provided a custom unload animation
if( ! event.animationPerformed ) {
$('#modal, #modal-overlay')
.fadeOut( 200 );
$('#modal-content')
.html( '' );
}
codiad.sidebars.modalLock = false;
if ( ! codiad.sidebars.leftLock ) {
// Slide sidebar back
$('#sb-left')
.animate({
'left': '-290px'
}, 300, 'easeOutQuart');
$('#editor-region')
.animate({
'margin-left': '10px'
}, 300, 'easeOutQuart');
}
codiad.editor.focus();
},
_setBounds: function( bounds ) {
if ( typeof( bounds ) == 'undefined' ) {
if ( $( '#modal' ).is( ':visible' ) ) {
bounds = {};
bounds.top = Math.floor( $( '#modal' ).offset().top );
bounds.left = Math.floor( $( '#modal' ).offset().left );
} else {
return false;
}
}
//Save bounds
localStorage.setItem( "codiad.modal.top", bounds.top );
localStorage.setItem( "codiad.modal.left", bounds.left );
},
_getBounds: function( width ) {
if (localStorage.getItem( "codiad.modal.top" ) !== null && localStorage.getItem( "codiad.modal.left" ) !== null && codiad.editor.settings.persistentModal ) {
var top = parseInt( localStorage.getItem( 'codiad.modal.top' ), 10 ),
left = parseInt( localStorage.getItem( 'codiad.modal.left' ), 10 );
//Check if modal is out of window
if ( (top + 40) > $(window).height() ) {
top = "15%";
} else {
top += "px";
}
if ( ( left + width + 40 ) > $(window).width() ) {
left = "50%";
} else {
left += Math.ceil( width / 2 );
left += "px";
}
return {
top: top,
left: left
};
} else {
return {
top: "15%",
left: "50%"
};
}
}
};
})( this, jQuery );

View File

@ -15,15 +15,15 @@
isLeftSidebarOpen: true,
isRightSidebarOpen: false,
init: function() {
init: async function() {
var _this = this;
amplify.subscribe('settings.loaded', async function( settings ) {
var sbWidth = codiad.settings.get_option( 'codiad.sidebars.sb-left-width' );
var lock_left = codiad.settings.get_option( 'codiad.sidebars.lock-left-sidebar' );
var lock_right = codiad.settings.get_option( 'codiad.sidebars.lock-right-sidebar' );
var sbWidth = await codiad.settings.get_option( 'codiad.sidebars.sb-left-width' );
var lock_left = await codiad.settings.get_option( 'codiad.sidebars.lock-left-sidebar' );
var lock_right = await codiad.settings.get_option( 'codiad.sidebars.lock-right-sidebar' );
console.log( "Sidebar width", sbWidth );
if (sbWidth !== null) {
$('#sb-left').width(sbWidth);
$(window).resize();
@ -111,20 +111,31 @@
});
$("#sb-left .sidebar-handle")
.draggable({
axis: 'x',
drag: function(event, ui) {
newWidth = ui.position.left;
$("#sb-left")
.width(newWidth + 10);
},
stop: function() {
$(window).resize();
$('#editor-region')
.trigger('h-resize-init');
codiad.settings.update_option( 'codiad.sidebars.sb-left-width', $('#sb-left').width() );
}
});
.draggable({
axis: 'x',
drag: function(event, ui) {
newWidth = ui.position.left;
$("#sb-left")
.width(newWidth + 10);
},
stop: function() {
$(window).resize();
$('#editor-region')
.trigger('h-resize-init');
codiad.settings.update_option( 'codiad.sidebars.sb-left-width', $('#sb-left').width() );
}
});
$("#sb-left .sidebar-handle")
.dblclick(function() {
let default_width = 300;
$("#sb-left").width( default_width );
$(window).resize();
$('#editor-region').trigger('h-resize-init');
$("#sb-left .sidebar-handle").css( "left", 288 );
codiad.settings.update_option( 'codiad.sidebars.sb-left-width', default_width );
});
},
closeLeftSidebar: function() {

View File

@ -809,3 +809,12 @@ table [class^="icon-"], [class*=" icon-"] {
#download {
display: none;
}
.loading {
background: url(loading.gif) no-repeat center;
display: none;
height: 25px;
vertical-align: middle;
width: 25px;
}