Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUAL upgrade jQuery Jeditable to 2.0.21 #32629

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jQuery select2 4.0.13 GPL and Apache License Yes
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)
jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors
jQuery JCrop 0.9.8 GPL and MIT License Yes JS library plugin Crop (to crop images)
jQuery Jeditable 1.7.1 GPL and MIT License Yes JS library plugin jeditable (to edit in place)
jQuery Jeditable 2.0.19 GPL and MIT License Yes JS library plugin jeditable (to edit in place)
jQuery jNotify 1.1.00 Apache License 2.0 Yes JS library plugin jNotify (to use ajax popups)
jQuery jPicker 1.1.6 GPL and MIT License Yes JS library for color picker with not defined list of colors
jQuery jqueryFileTree 1.0.1 GPL and MIT License Yes JS library for filetree
Expand Down
6 changes: 4 additions & 2 deletions dev/setup/codesniffer/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@
<rule ref="Generic.PHP.DeprecatedFunctions.Deprecated">
<severity>0</severity>
</rule>

<rule ref="Generic.PHP.DisallowShortOpenTag" />

<rule ref="Generic.PHP.DisallowShortOpenTag">
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound" />
</rule>

<rule ref="Generic.PHP.ForbiddenFunctions" />

Expand Down
5 changes: 4 additions & 1 deletion htdocs/core/ajax/loadinplace.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2011-2014 Regis Houssin <[email protected]>
/* Copyright (C) 2011-2025 Regis Houssin <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
*
Expand Down Expand Up @@ -34,6 +34,9 @@
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}

// Load Dolibarr environment
require '../../main.inc.php';
Expand Down
3 changes: 3 additions & 0 deletions htdocs/core/ajax/saveinplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}

// Load Dolibarr environment
require '../../main.inc.php';
Expand Down
137 changes: 96 additions & 41 deletions htdocs/core/js/editinplace.js → htdocs/core/js/editinplace.js.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,85 @@
// Copyright (C) 2011-2014 Regis Houssin <[email protected]>
// Copyright (C) 2011-2017 Laurent Destailleur <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// or see https://www.gnu.org/
//
<?php
/* Copyright (C) 2011-2014 Regis Houssin <[email protected]>
* Copyright (C) 2011-2017 Laurent Destailleur <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/

//
// \file htdocs/core/js/editinplace.js
// \brief File that include javascript functions for edit in place
//
/**
* \file htdocs/core/js/editinplace.js.php
* \brief File that include javascript functions for edit in place
*/

if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', 1);
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}

session_cache_limiter('public');

require_once '../../main.inc.php';
/**
* @var Conf $conf
* @var Translate $langs
*/

/*
* View
*/

// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache)) {
header('Cache-Control: max-age=10800, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}

?>

$(document).ready(function() {
var element = $('#jeditable_element').html();
var table_element = $('#jeditable_table_element').html();
var fk_element = $('#jeditable_fk_element').html();



var urlSaveInPlace = '<?= DOL_URL_ROOT.'/core/ajax/saveinplace.php' ?>';
var urlLoadInPlace = '<?= DOL_URL_ROOT.'/core/ajax/loadinplace.php' ?>';
var currentToken = '<?= currentToken() ?>';

var tooltipInPlace = '<?= $langs->transnoentities('ClickToEdit') ?>';
var placeholderInPlace = '';
var cancelInPlace = '<?= $langs->transnoentities("Cancel") ?>';
var submitInPlace = '<?= $langs->transnoentities('Ok') ?>';
var indicatorInPlace = '<img src="<?= DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif" ?>">';
var withInPlace = 300; /* width in pixel for default string edit */

if ($('.editval_string').length > 0) {
$('.editval_string').editable(urlSaveInPlace, {
type : 'text',
Expand Down Expand Up @@ -69,7 +122,7 @@ function () {
$('#editval_' + $(this).attr('id').substr(8)).show().click();
});
}

if ($('.editval_textarea').length > 0) {
$('.editval_textarea').editable(urlSaveInPlace, {
type : 'textarea',
Expand Down Expand Up @@ -117,7 +170,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

if (typeof ckeditorConfig != 'undefined') {
$('.editval_ckeditor').editable(urlSaveInPlace, {
type : 'ckeditor',
Expand All @@ -134,9 +187,9 @@ function () {
filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,
filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,
filebrowserWindowWidth : '900',
filebrowserWindowHeight : '500',
filebrowserImageWindowWidth : '900',
filebrowserImageWindowHeight : '500'
filebrowserWindowHeight : '500',
filebrowserImageWindowWidth : '900',
filebrowserImageWindowHeight : '500'
},
submitdata : function(result, settings) {
return getParameters(this, 'ckeditor');
Expand Down Expand Up @@ -170,7 +223,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

if ($('.editval_numeric').length > 0) {
$('.editval_numeric').editable(urlSaveInPlace, {
type : 'text',
Expand Down Expand Up @@ -213,7 +266,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

if ($('.editval_datepicker').length > 0) {
$('.editval_datepicker').editable(urlSaveInPlace, {
type : 'datepicker',
Expand Down Expand Up @@ -253,7 +306,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

if ($('.editval_select').length > 0) {
$('.editval_select').editable(urlSaveInPlace, {
type : 'select',
Expand Down Expand Up @@ -298,7 +351,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

// for test only (not stable)
if ($('.editval_autocomplete').length > 0) {
$('.editval_autocomplete').editable(urlSaveInPlace, {
Expand Down Expand Up @@ -345,7 +398,7 @@ function () {
$('#editval_' + $(this).attr('id')).show().click();
});
}

function getParameters(obj, type) {
var htmlname = $(obj).attr('id').substr(8);
var element = $('#element_' + htmlname).val();
Expand All @@ -355,7 +408,8 @@ function getParameters(obj, type) {
var savemethod = $('#savemethod_' + htmlname).val();
var ext_element = $('#ext_element_' + htmlname).val();
var timestamp = $('#timestamp').val();

var token = currentToken;

return {
type: type,
element: element,
Expand All @@ -364,10 +418,11 @@ function getParameters(obj, type) {
loadmethod: loadmethod,
savemethod: savemethod,
timestamp: timestamp,
ext_element: ext_element
ext_element: ext_element,
token: token
};
}

function getResult(obj, result) {
var res = $.parseJSON(result);
if (res.error) {
Expand All @@ -379,7 +434,7 @@ function getResult(obj, result) {
} else {
$.jnotify(res.error, "error", true);
}

} else {
var htmlname = $(obj).attr('id').substr(8);
var successmsg = $( '#successmsg_' + htmlname ).val();
Expand All @@ -392,7 +447,7 @@ function getResult(obj, result) {
$('#viewval_' + htmlname).show();
}
}

function getDefault(settings) {
var htmlname = $(settings).attr('id').substr(8);
$('#editval_' + htmlname).hide();
Expand Down
Loading
Loading