Fix the template and layout linker for packages. Add native module builder for Joomla 4/5. Refactor dynamic get methods into dedicated classes. Move Joomla DB handling into compiler injector flow. Fix auto-check(in) method for Joomla 4/5 compatibility. Migrates view HTML classes to use getModel() directly instead of the deprecated magic get() calls to model methods. Refactores event handling (contentPrepare, titlePrepare, contentBeforeDisplay, contentAfterDisplay) to use Joomla 5's native event dispatcher via the model's new getDispatcher() method. Updates table classes to properly support NULL values, both in the store() method and in table variable definitions. #1245. Extractes the setAutoCheckIn() and setCheckInCall() logic into a dedicated CheckInNow class for cleaner design. Replace all direct $app->input property calls with the recommended $app->getInput() method across the entire codebase. Add Joomla 6 build option. Fix Custom Rule Validation Bug. Unpublish Joomla 6 Backward Compatibility Plugin. Refactors the Compiler Model by dropping deprecated calls and adopting Joomla 5+ conventions. Refactors Compiler Controller to remove deprecated usage and follow Joomla 5+ best practices. Adds check to ensure expert mode subforms in the Demo Component remain set and unchanged when user lacks edit permissions. Improves validation handling of Fields by ensuring field validation rules are properly registered. Replace StringHelper with the correct Super Power key so it loads in the Compiler Controller. Add functionality to add component changelog into the package if configured. Refactor PHP classes for building HTML view files in admin and site views to align with Joomla 5+ standards. Fix issues in the site view HtmlView caused by the refactor, including missing class calls and outdated function references. Fix issue where the DatabaseSchemaCheckAll pulled all Component Builder tables into DB on install. #1253. Fix issue in the Dynamic Get when the value key is 0 it wouldn't add the 'WHERE' statement to the generated code. #1254. Change radio buttons with a empty option to save Datatype CHAR instead of TINYINT as other radio buttons. #1252. Add extra xml details to Modules built with JCB that adds advance options to the module. #1248. Remove setDocumentTitle method from the admin view since it is not being used by Joomla. #1255. Refactor compiler Move file update to classes. Refactor compiler Move plugin and module fields and rules files mover to classes. Fix issue where custom powers was not added to PowerloaderHelper. #1256. Fix normalization issue when compiling on Windows systems. #1219. Fix installer issue on Joomla 6 where components containing multiple plugins failed during installation. Completely refactors the Compiler Dashboard to align with Joomla 5+ architecture and Bootstrap 5 standards. Add a default VARCHAR(36) length to easily create fields intended to store GUID values. Update the file uploader in the Demo Component for more dynamic file display and naming. Update the SQL file dump generator to handle large SQL dumps in batches, ensuring safe and reliable database imports. Update example hints in the field expert mode options.
1372 lines
35 KiB
JavaScript
1372 lines
35 KiB
JavaScript
/**
|
|
* @package Joomla.Component.Builder
|
|
*
|
|
* @created 30th April, 2015
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
// Some Global Values
|
|
jform_vvvvwaqvwp_required = false;
|
|
jform_vvvvwbevwq_required = false;
|
|
jform_vvvvwbevwr_required = false;
|
|
|
|
// Initial Script
|
|
document.addEventListener('DOMContentLoaded', function()
|
|
{
|
|
var how_vvvvwao = jQuery("#jform_how").val();
|
|
var target_vvvvwao = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwao(how_vvvvwao,target_vvvvwao);
|
|
|
|
var how_vvvvwaq = jQuery("#jform_how").val();
|
|
var target_vvvvwaq = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwaq(how_vvvvwaq,target_vvvvwaq);
|
|
|
|
var how_vvvvwas = jQuery("#jform_how").val();
|
|
var target_vvvvwas = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwas(how_vvvvwas,target_vvvvwas);
|
|
|
|
var how_vvvvwau = jQuery("#jform_how").val();
|
|
var target_vvvvwau = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwau(how_vvvvwau,target_vvvvwau);
|
|
|
|
var how_vvvvwaw = jQuery("#jform_how").val();
|
|
var target_vvvvwaw = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwaw(how_vvvvwaw,target_vvvvwaw);
|
|
|
|
var target_vvvvwax = jQuery("#jform_target input[type='radio']:checked").val();
|
|
var how_vvvvwax = jQuery("#jform_how").val();
|
|
vvvvwax(target_vvvvwax,how_vvvvwax);
|
|
|
|
var how_vvvvway = jQuery("#jform_how").val();
|
|
var target_vvvvway = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvway(how_vvvvway,target_vvvvway);
|
|
|
|
var target_vvvvwaz = jQuery("#jform_target input[type='radio']:checked").val();
|
|
var how_vvvvwaz = jQuery("#jform_how").val();
|
|
vvvvwaz(target_vvvvwaz,how_vvvvwaz);
|
|
|
|
var how_vvvvwba = jQuery("#jform_how").val();
|
|
var target_vvvvwba = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwba(how_vvvvwba,target_vvvvwba);
|
|
|
|
var target_vvvvwbb = jQuery("#jform_target input[type='radio']:checked").val();
|
|
var how_vvvvwbb = jQuery("#jform_how").val();
|
|
vvvvwbb(target_vvvvwbb,how_vvvvwbb);
|
|
|
|
var target_vvvvwbc = jQuery("#jform_target input[type='radio']:checked").val();
|
|
var type_vvvvwbc = jQuery("#jform_type input[type='radio']:checked").val();
|
|
vvvvwbc(target_vvvvwbc,type_vvvvwbc);
|
|
|
|
var target_vvvvwbe = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwbe(target_vvvvwbe);
|
|
|
|
var target_vvvvwbf = jQuery("#jform_target input[type='radio']:checked").val();
|
|
vvvvwbf(target_vvvvwbf);
|
|
});
|
|
|
|
// the vvvvwao function
|
|
function vvvvwao(how_vvvvwao,target_vvvvwao)
|
|
{
|
|
if (isSet(how_vvvvwao) && how_vvvvwao.constructor !== Array)
|
|
{
|
|
var temp_vvvvwao = how_vvvvwao;
|
|
var how_vvvvwao = [];
|
|
how_vvvvwao.push(temp_vvvvwao);
|
|
}
|
|
else if (!isSet(how_vvvvwao))
|
|
{
|
|
var how_vvvvwao = [];
|
|
}
|
|
var how = how_vvvvwao.some(how_vvvvwao_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwao) && target_vvvvwao.constructor !== Array)
|
|
{
|
|
var temp_vvvvwao = target_vvvvwao;
|
|
var target_vvvvwao = [];
|
|
target_vvvvwao.push(temp_vvvvwao);
|
|
}
|
|
else if (!isSet(target_vvvvwao))
|
|
{
|
|
var target_vvvvwao = [];
|
|
}
|
|
var target = target_vvvvwao.some(target_vvvvwao_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('#jform_addconditions-lbl').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('#jform_addconditions-lbl').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwao Some function
|
|
function how_vvvvwao_SomeFunc(how_vvvvwao)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwao == 2)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwao Some function
|
|
function target_vvvvwao_SomeFunc(target_vvvvwao)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwao == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaq function
|
|
function vvvvwaq(how_vvvvwaq,target_vvvvwaq)
|
|
{
|
|
if (isSet(how_vvvvwaq) && how_vvvvwaq.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaq = how_vvvvwaq;
|
|
var how_vvvvwaq = [];
|
|
how_vvvvwaq.push(temp_vvvvwaq);
|
|
}
|
|
else if (!isSet(how_vvvvwaq))
|
|
{
|
|
var how_vvvvwaq = [];
|
|
}
|
|
var how = how_vvvvwaq.some(how_vvvvwaq_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwaq) && target_vvvvwaq.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaq = target_vvvvwaq;
|
|
var target_vvvvwaq = [];
|
|
target_vvvvwaq.push(temp_vvvvwaq);
|
|
}
|
|
else if (!isSet(target_vvvvwaq))
|
|
{
|
|
var target_vvvvwaq = [];
|
|
}
|
|
var target = target_vvvvwaq.some(target_vvvvwaq_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('#jform_php_setdocument').closest('.control-group').show();
|
|
// add required attribute to php_setdocument field
|
|
if (jform_vvvvwaqvwp_required)
|
|
{
|
|
updateFieldRequired('php_setdocument',0);
|
|
jQuery('#jform_php_setdocument').prop('required','required');
|
|
jQuery('#jform_php_setdocument').attr('aria-required',true);
|
|
jQuery('#jform_php_setdocument').addClass('required');
|
|
jform_vvvvwaqvwp_required = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
jQuery('#jform_php_setdocument').closest('.control-group').hide();
|
|
// remove required attribute from php_setdocument field
|
|
if (!jform_vvvvwaqvwp_required)
|
|
{
|
|
updateFieldRequired('php_setdocument',1);
|
|
jQuery('#jform_php_setdocument').removeAttr('required');
|
|
jQuery('#jform_php_setdocument').removeAttr('aria-required');
|
|
jQuery('#jform_php_setdocument').removeClass('required');
|
|
jform_vvvvwaqvwp_required = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
// the vvvvwaq Some function
|
|
function how_vvvvwaq_SomeFunc(how_vvvvwaq)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwaq == 3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaq Some function
|
|
function target_vvvvwaq_SomeFunc(target_vvvvwaq)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwaq == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwas function
|
|
function vvvvwas(how_vvvvwas,target_vvvvwas)
|
|
{
|
|
if (isSet(how_vvvvwas) && how_vvvvwas.constructor !== Array)
|
|
{
|
|
var temp_vvvvwas = how_vvvvwas;
|
|
var how_vvvvwas = [];
|
|
how_vvvvwas.push(temp_vvvvwas);
|
|
}
|
|
else if (!isSet(how_vvvvwas))
|
|
{
|
|
var how_vvvvwas = [];
|
|
}
|
|
var how = how_vvvvwas.some(how_vvvvwas_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwas) && target_vvvvwas.constructor !== Array)
|
|
{
|
|
var temp_vvvvwas = target_vvvvwas;
|
|
var target_vvvvwas = [];
|
|
target_vvvvwas.push(temp_vvvvwas);
|
|
}
|
|
else if (!isSet(target_vvvvwas))
|
|
{
|
|
var target_vvvvwas = [];
|
|
}
|
|
var target = target_vvvvwas.some(target_vvvvwas_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('.note_display_library_config').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_display_library_config').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwas Some function
|
|
function how_vvvvwas_SomeFunc(how_vvvvwas)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwas == 2 || how_vvvvwas == 3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwas Some function
|
|
function target_vvvvwas_SomeFunc(target_vvvvwas)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwas == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwau function
|
|
function vvvvwau(how_vvvvwau,target_vvvvwau)
|
|
{
|
|
if (isSet(how_vvvvwau) && how_vvvvwau.constructor !== Array)
|
|
{
|
|
var temp_vvvvwau = how_vvvvwau;
|
|
var how_vvvvwau = [];
|
|
how_vvvvwau.push(temp_vvvvwau);
|
|
}
|
|
else if (!isSet(how_vvvvwau))
|
|
{
|
|
var how_vvvvwau = [];
|
|
}
|
|
var how = how_vvvvwau.some(how_vvvvwau_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwau) && target_vvvvwau.constructor !== Array)
|
|
{
|
|
var temp_vvvvwau = target_vvvvwau;
|
|
var target_vvvvwau = [];
|
|
target_vvvvwau.push(temp_vvvvwau);
|
|
}
|
|
else if (!isSet(target_vvvvwau))
|
|
{
|
|
var target_vvvvwau = [];
|
|
}
|
|
var target = target_vvvvwau.some(target_vvvvwau_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('.note_display_library_files_folders_urls').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_display_library_files_folders_urls').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwau Some function
|
|
function how_vvvvwau_SomeFunc(how_vvvvwau)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwau == 1 || how_vvvvwau == 2 || how_vvvvwau == 3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwau Some function
|
|
function target_vvvvwau_SomeFunc(target_vvvvwau)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwau == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaw function
|
|
function vvvvwaw(how_vvvvwaw,target_vvvvwaw)
|
|
{
|
|
if (isSet(how_vvvvwaw) && how_vvvvwaw.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaw = how_vvvvwaw;
|
|
var how_vvvvwaw = [];
|
|
how_vvvvwaw.push(temp_vvvvwaw);
|
|
}
|
|
else if (!isSet(how_vvvvwaw))
|
|
{
|
|
var how_vvvvwaw = [];
|
|
}
|
|
var how = how_vvvvwaw.some(how_vvvvwaw_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwaw) && target_vvvvwaw.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaw = target_vvvvwaw;
|
|
var target_vvvvwaw = [];
|
|
target_vvvvwaw.push(temp_vvvvwaw);
|
|
}
|
|
else if (!isSet(target_vvvvwaw))
|
|
{
|
|
var target_vvvvwaw = [];
|
|
}
|
|
var target = target_vvvvwaw.some(target_vvvvwaw_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('.note_no_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_no_behaviour_three').closest('.control-group').show();
|
|
jQuery('.note_no_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_no_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_no_behaviour_three').closest('.control-group').hide();
|
|
jQuery('.note_no_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwaw Some function
|
|
function how_vvvvwaw_SomeFunc(how_vvvvwaw)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwaw == 0)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaw Some function
|
|
function target_vvvvwaw_SomeFunc(target_vvvvwaw)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwaw == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwax function
|
|
function vvvvwax(target_vvvvwax,how_vvvvwax)
|
|
{
|
|
if (isSet(target_vvvvwax) && target_vvvvwax.constructor !== Array)
|
|
{
|
|
var temp_vvvvwax = target_vvvvwax;
|
|
var target_vvvvwax = [];
|
|
target_vvvvwax.push(temp_vvvvwax);
|
|
}
|
|
else if (!isSet(target_vvvvwax))
|
|
{
|
|
var target_vvvvwax = [];
|
|
}
|
|
var target = target_vvvvwax.some(target_vvvvwax_SomeFunc);
|
|
|
|
if (isSet(how_vvvvwax) && how_vvvvwax.constructor !== Array)
|
|
{
|
|
var temp_vvvvwax = how_vvvvwax;
|
|
var how_vvvvwax = [];
|
|
how_vvvvwax.push(temp_vvvvwax);
|
|
}
|
|
else if (!isSet(how_vvvvwax))
|
|
{
|
|
var how_vvvvwax = [];
|
|
}
|
|
var how = how_vvvvwax.some(how_vvvvwax_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (target && how)
|
|
{
|
|
jQuery('.note_no_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_no_behaviour_three').closest('.control-group').show();
|
|
jQuery('.note_no_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_no_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_no_behaviour_three').closest('.control-group').hide();
|
|
jQuery('.note_no_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwax Some function
|
|
function target_vvvvwax_SomeFunc(target_vvvvwax)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwax == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwax Some function
|
|
function how_vvvvwax_SomeFunc(how_vvvvwax)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwax == 0)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvway function
|
|
function vvvvway(how_vvvvway,target_vvvvway)
|
|
{
|
|
if (isSet(how_vvvvway) && how_vvvvway.constructor !== Array)
|
|
{
|
|
var temp_vvvvway = how_vvvvway;
|
|
var how_vvvvway = [];
|
|
how_vvvvway.push(temp_vvvvway);
|
|
}
|
|
else if (!isSet(how_vvvvway))
|
|
{
|
|
var how_vvvvway = [];
|
|
}
|
|
var how = how_vvvvway.some(how_vvvvway_SomeFunc);
|
|
|
|
if (isSet(target_vvvvway) && target_vvvvway.constructor !== Array)
|
|
{
|
|
var temp_vvvvway = target_vvvvway;
|
|
var target_vvvvway = [];
|
|
target_vvvvway.push(temp_vvvvway);
|
|
}
|
|
else if (!isSet(target_vvvvway))
|
|
{
|
|
var target_vvvvway = [];
|
|
}
|
|
var target = target_vvvvway.some(target_vvvvway_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('.note_yes_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_yes_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_yes_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_yes_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvway Some function
|
|
function how_vvvvway_SomeFunc(how_vvvvway)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvway == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvway Some function
|
|
function target_vvvvway_SomeFunc(target_vvvvway)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvway == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaz function
|
|
function vvvvwaz(target_vvvvwaz,how_vvvvwaz)
|
|
{
|
|
if (isSet(target_vvvvwaz) && target_vvvvwaz.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaz = target_vvvvwaz;
|
|
var target_vvvvwaz = [];
|
|
target_vvvvwaz.push(temp_vvvvwaz);
|
|
}
|
|
else if (!isSet(target_vvvvwaz))
|
|
{
|
|
var target_vvvvwaz = [];
|
|
}
|
|
var target = target_vvvvwaz.some(target_vvvvwaz_SomeFunc);
|
|
|
|
if (isSet(how_vvvvwaz) && how_vvvvwaz.constructor !== Array)
|
|
{
|
|
var temp_vvvvwaz = how_vvvvwaz;
|
|
var how_vvvvwaz = [];
|
|
how_vvvvwaz.push(temp_vvvvwaz);
|
|
}
|
|
else if (!isSet(how_vvvvwaz))
|
|
{
|
|
var how_vvvvwaz = [];
|
|
}
|
|
var how = how_vvvvwaz.some(how_vvvvwaz_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (target && how)
|
|
{
|
|
jQuery('.note_yes_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_yes_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_yes_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_yes_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwaz Some function
|
|
function target_vvvvwaz_SomeFunc(target_vvvvwaz)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwaz == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwaz Some function
|
|
function how_vvvvwaz_SomeFunc(how_vvvvwaz)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwaz == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwba function
|
|
function vvvvwba(how_vvvvwba,target_vvvvwba)
|
|
{
|
|
if (isSet(how_vvvvwba) && how_vvvvwba.constructor !== Array)
|
|
{
|
|
var temp_vvvvwba = how_vvvvwba;
|
|
var how_vvvvwba = [];
|
|
how_vvvvwba.push(temp_vvvvwba);
|
|
}
|
|
else if (!isSet(how_vvvvwba))
|
|
{
|
|
var how_vvvvwba = [];
|
|
}
|
|
var how = how_vvvvwba.some(how_vvvvwba_SomeFunc);
|
|
|
|
if (isSet(target_vvvvwba) && target_vvvvwba.constructor !== Array)
|
|
{
|
|
var temp_vvvvwba = target_vvvvwba;
|
|
var target_vvvvwba = [];
|
|
target_vvvvwba.push(temp_vvvvwba);
|
|
}
|
|
else if (!isSet(target_vvvvwba))
|
|
{
|
|
var target_vvvvwba = [];
|
|
}
|
|
var target = target_vvvvwba.some(target_vvvvwba_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (how && target)
|
|
{
|
|
jQuery('.note_build_in_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_build_in_behaviour_three').closest('.control-group').show();
|
|
jQuery('.note_build_in_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_build_in_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_build_in_behaviour_three').closest('.control-group').hide();
|
|
jQuery('.note_build_in_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwba Some function
|
|
function how_vvvvwba_SomeFunc(how_vvvvwba)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwba == 4)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwba Some function
|
|
function target_vvvvwba_SomeFunc(target_vvvvwba)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwba == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwbb function
|
|
function vvvvwbb(target_vvvvwbb,how_vvvvwbb)
|
|
{
|
|
if (isSet(target_vvvvwbb) && target_vvvvwbb.constructor !== Array)
|
|
{
|
|
var temp_vvvvwbb = target_vvvvwbb;
|
|
var target_vvvvwbb = [];
|
|
target_vvvvwbb.push(temp_vvvvwbb);
|
|
}
|
|
else if (!isSet(target_vvvvwbb))
|
|
{
|
|
var target_vvvvwbb = [];
|
|
}
|
|
var target = target_vvvvwbb.some(target_vvvvwbb_SomeFunc);
|
|
|
|
if (isSet(how_vvvvwbb) && how_vvvvwbb.constructor !== Array)
|
|
{
|
|
var temp_vvvvwbb = how_vvvvwbb;
|
|
var how_vvvvwbb = [];
|
|
how_vvvvwbb.push(temp_vvvvwbb);
|
|
}
|
|
else if (!isSet(how_vvvvwbb))
|
|
{
|
|
var how_vvvvwbb = [];
|
|
}
|
|
var how = how_vvvvwbb.some(how_vvvvwbb_SomeFunc);
|
|
|
|
|
|
// set this function logic
|
|
if (target && how)
|
|
{
|
|
jQuery('.note_build_in_behaviour_one').closest('.control-group').show();
|
|
jQuery('.note_build_in_behaviour_three').closest('.control-group').show();
|
|
jQuery('.note_build_in_behaviour_two').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_build_in_behaviour_one').closest('.control-group').hide();
|
|
jQuery('.note_build_in_behaviour_three').closest('.control-group').hide();
|
|
jQuery('.note_build_in_behaviour_two').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwbb Some function
|
|
function target_vvvvwbb_SomeFunc(target_vvvvwbb)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwbb == 1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwbb Some function
|
|
function how_vvvvwbb_SomeFunc(how_vvvvwbb)
|
|
{
|
|
// set the function logic
|
|
if (how_vvvvwbb == 4)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// the vvvvwbc function
|
|
function vvvvwbc(target_vvvvwbc,type_vvvvwbc)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwbc == 1 && type_vvvvwbc == 2)
|
|
{
|
|
jQuery('#jform_libraries').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('#jform_libraries').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
// the vvvvwbe function
|
|
function vvvvwbe(target_vvvvwbe)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwbe == 1)
|
|
{
|
|
jQuery('#jform_how').closest('.control-group').show();
|
|
// add required attribute to how field
|
|
if (jform_vvvvwbevwq_required)
|
|
{
|
|
updateFieldRequired('how',0);
|
|
jQuery('#jform_how').prop('required','required');
|
|
jQuery('#jform_how').attr('aria-required',true);
|
|
jQuery('#jform_how').addClass('required');
|
|
jform_vvvvwbevwq_required = false;
|
|
}
|
|
jQuery('#jform_type').closest('.control-group').show();
|
|
// add required attribute to type field
|
|
if (jform_vvvvwbevwr_required)
|
|
{
|
|
updateFieldRequired('type',0);
|
|
jQuery('#jform_type').prop('required','required');
|
|
jQuery('#jform_type').attr('aria-required',true);
|
|
jQuery('#jform_type').addClass('required');
|
|
jform_vvvvwbevwr_required = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
jQuery('#jform_how').closest('.control-group').hide();
|
|
// remove required attribute from how field
|
|
if (!jform_vvvvwbevwq_required)
|
|
{
|
|
updateFieldRequired('how',1);
|
|
jQuery('#jform_how').removeAttr('required');
|
|
jQuery('#jform_how').removeAttr('aria-required');
|
|
jQuery('#jform_how').removeClass('required');
|
|
jform_vvvvwbevwq_required = true;
|
|
}
|
|
jQuery('#jform_type').closest('.control-group').hide();
|
|
// remove required attribute from type field
|
|
if (!jform_vvvvwbevwr_required)
|
|
{
|
|
updateFieldRequired('type',1);
|
|
jQuery('#jform_type').removeAttr('required');
|
|
jQuery('#jform_type').removeAttr('aria-required');
|
|
jQuery('#jform_type').removeClass('required');
|
|
jform_vvvvwbevwr_required = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
// the vvvvwbf function
|
|
function vvvvwbf(target_vvvvwbf)
|
|
{
|
|
// set the function logic
|
|
if (target_vvvvwbf == 2)
|
|
{
|
|
jQuery('.note_yes_behaviour_library').closest('.control-group').show();
|
|
}
|
|
else
|
|
{
|
|
jQuery('.note_yes_behaviour_library').closest('.control-group').hide();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update the "not required" field list by adding or removing a field name.
|
|
*
|
|
* Mirrors the original jQuery logic exactly but uses pure JavaScript.
|
|
*
|
|
* @param {string} name The field name to add or remove.
|
|
* @param {number} status 1 to add as not required, 0 to remove.
|
|
*
|
|
* @return {void}
|
|
* @since 3.1.3
|
|
*/
|
|
function updateFieldRequired(name, status) {
|
|
// Check if #jform_not_required exists
|
|
const notRequiredField = document.getElementById('jform_not_required');
|
|
if (!notRequiredField) {
|
|
return;
|
|
}
|
|
|
|
// Split the comma-separated list into an array
|
|
let not_required = notRequiredField.value ? notRequiredField.value.split(',') : [];
|
|
|
|
// Add or remove the field name from the list
|
|
if (status == 1) {
|
|
not_required.push(name);
|
|
} else {
|
|
not_required = removeFieldFromNotRequired(not_required, name);
|
|
}
|
|
|
|
// Clean and deduplicate the list
|
|
const fixedList = fixNotRequiredArray(not_required);
|
|
|
|
// Write back the updated comma-separated list
|
|
notRequiredField.value = fixedList.toString();
|
|
}
|
|
|
|
/**
|
|
* Remove a specific field name from the "not required" array.
|
|
*
|
|
* @param {Array<string>} array The list of not-required field names.
|
|
* @param {string} what The field name to remove.
|
|
*
|
|
* @return {Array<string>} The updated array.
|
|
* @since 3.1.3
|
|
*/
|
|
function removeFieldFromNotRequired(array, what) {
|
|
return array.filter(function (element) {
|
|
return element !== what;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Deduplicate and clean a "not required" array.
|
|
*
|
|
* @param {Array<string>} array The array to fix.
|
|
*
|
|
* @return {Array<string>} A cleaned, unique array.
|
|
* @since 3.1.3
|
|
*/
|
|
function fixNotRequiredArray(array) {
|
|
const seen = {};
|
|
return removeEmptyFromNotRequiredArray(array).filter(function (item) {
|
|
return seen.hasOwnProperty(item) ? false : (seen[item] = true);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Remove empty or invalid entries from a "not required" array.
|
|
*
|
|
* Also removes the literal '一_一' token (legacy quirk preserved for compatibility).
|
|
*
|
|
* @param {Array<string>} array The array to process.
|
|
*
|
|
* @return {Array<string>} The cleaned array.
|
|
* @since 3.1.3
|
|
*/
|
|
function removeEmptyFromNotRequiredArray(array) {
|
|
return array.filter(function (el) {
|
|
return el && el.length > 0 && el !== '一_一';
|
|
});
|
|
}
|
|
|
|
// the isSet function
|
|
function isSet(val)
|
|
{
|
|
if ((val != undefined) && (val != null) && 0 !== val.length){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
jQuery(document).ready(function()
|
|
{
|
|
// get the linked details
|
|
getLinked();
|
|
// now load the displays
|
|
getAjaxDisplay('library_config');
|
|
getAjaxDisplay('library_files_folders_urls');
|
|
|
|
// check and load all the customcode edit buttons
|
|
setTimeout(getEditCustomCodeButtons, 300);
|
|
});
|
|
|
|
function addData(result,where){
|
|
jQuery(result).insertAfter(jQuery(where).closest('.control-group'));
|
|
}
|
|
|
|
function getAjaxDisplay(type){
|
|
getCodeFrom_server(1, type, 'type', 'getAjaxDisplay').then(function(result) {
|
|
if (result) {
|
|
jQuery('#display_'+type).html(result);
|
|
}
|
|
// set button
|
|
addButtonID(type,'header_'+type+'_buttons', 2); // <-- little edit button
|
|
});
|
|
}
|
|
|
|
function getFieldSelectOptions(fieldKey){
|
|
// first check if the field is set
|
|
if(jQuery("#jform_addconditions__addconditions"+fieldKey+"__option_field").length) {
|
|
var fieldId = jQuery("#jform_addconditions__addconditions"+fieldKey+"__option_field option:selected").val();
|
|
getCodeFrom_server(fieldId, 'type', 'type', 'fieldSelectOptions').then(function(result) {
|
|
if(result) {
|
|
jQuery('textarea#jform_addconditions__addconditions'+fieldKey+'__field_options').val(result);
|
|
} else {
|
|
jQuery('textarea#jform_addconditions__addconditions'+fieldKey+'__field_options').val('');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fetch data from the server with validated parameters.
|
|
*
|
|
* @param {number|string} id The record ID (integer > 0 or string > 30 chars)
|
|
* @param {string} type The type value to send
|
|
* @param {string} typeName The type parameter name (e.g. "type" or "context")
|
|
* @param {string} callingName The AJAX task name (e.g. "getCode")
|
|
* @global {string} token The CSRF token name or key
|
|
* @global {string} vastDevMod The developer key or mode flag (optional)
|
|
*
|
|
* @return {Promise<object|null>} Returns parsed JSON data or null on failure
|
|
* @since 3.1.2
|
|
*/
|
|
async function getCodeFrom_server(id, type, typeName, callingName) {
|
|
try {
|
|
// --- Validation ---
|
|
if (!getCodeFrom_isValidId(id)) {
|
|
console.error('[getCodeFrom_server] Invalid ID provided:', id);
|
|
return null;
|
|
}
|
|
if (typeof type !== 'string' || !type.trim()) {
|
|
console.error('[getCodeFrom_server] Invalid type provided:', type);
|
|
return null;
|
|
}
|
|
if (typeof typeName !== 'string' || !typeName.trim()) {
|
|
console.error('[getCodeFrom_server] Invalid typeName provided:', typeName);
|
|
return null;
|
|
}
|
|
if (typeof callingName !== 'string' || !callingName.trim()) {
|
|
console.error('[getCodeFrom_server] Invalid callingName provided:', callingName);
|
|
return null;
|
|
}
|
|
if (typeof token !== 'string' || !token.trim()) {
|
|
console.error('[getCodeFrom_server] Missing security token.');
|
|
return null;
|
|
}
|
|
|
|
// --- Construct URL safely ---
|
|
const baseUrl = 'index.php';
|
|
const params = new URLSearchParams({
|
|
option: 'com_componentbuilder',
|
|
task: `ajax.${callingName}`,
|
|
format: 'json',
|
|
raw: 'true',
|
|
[token]: '1',
|
|
[typeName]: type,
|
|
id: id
|
|
});
|
|
if (vastDevMod) params.append('vdm', vastDevMod);
|
|
|
|
const fullUrl = JRouter(`${baseUrl}?${params.toString()}`);
|
|
|
|
// --- Execute request ---
|
|
const response = await fetch(fullUrl, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
cache: 'no-store',
|
|
credentials: 'same-origin'
|
|
});
|
|
|
|
// --- Validate HTTP response ---
|
|
if (!response.ok) {
|
|
console.error(`[getCodeFromServer] Server responded with status ${response.status}: ${response.statusText}`);
|
|
return null;
|
|
}
|
|
|
|
// --- Parse JSON response ---
|
|
const data = await response.json();
|
|
return data ?? null;
|
|
|
|
} catch (error) {
|
|
console.error('[getCodeFromServer] Fetch operation failed:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Validate if the given ID is acceptable.
|
|
*
|
|
* @param {number|string} id The ID value to validate.
|
|
* @return {boolean} True if valid, false otherwise.
|
|
* @since 3.1.2
|
|
*/
|
|
function getCodeFrom_isValidId(id) {
|
|
if (typeof id === 'number') {
|
|
return Number.isInteger(id) && id > 0;
|
|
}
|
|
if (typeof id === 'string') {
|
|
return id.trim().length > 30;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the Edit Custom Code buttons from the server.
|
|
*
|
|
* @param {number} id The record ID to load custom code buttons for.
|
|
*
|
|
* @return {Promise<object|null>} Returns JSON object of buttons or null on failure.
|
|
* @since 3.1.3
|
|
*/
|
|
async function getEditCustomCodeButtons_server(id) {
|
|
try {
|
|
// --- Validation ---
|
|
if (typeof token !== 'string' || !token.trim()) {
|
|
console.error('[getEditCustomCodeButtons_server] Missing or invalid CSRF token.');
|
|
return null;
|
|
}
|
|
if (typeof id !== 'number' || id <= 0) {
|
|
console.error('[getEditCustomCodeButtons_server] Invalid ID provided:', id);
|
|
return null;
|
|
}
|
|
if (typeof return_here !== 'string' || !return_here.trim()) {
|
|
console.warn('[getEditCustomCodeButtons_server] "return_here" not set; continuing without it.');
|
|
}
|
|
|
|
// --- Build URL safely ---
|
|
const baseUrl = 'index.php';
|
|
const params = new URLSearchParams({
|
|
option: 'com_componentbuilder',
|
|
task: 'ajax.getEditCustomCodeButtons',
|
|
format: 'json',
|
|
raw: 'true',
|
|
[token]: '1',
|
|
id: id,
|
|
return_here: return_here || ''
|
|
});
|
|
if (typeof vastDevMod === 'string' && vastDevMod.length > 0) {
|
|
params.append('vdm', vastDevMod);
|
|
}
|
|
|
|
const urlWithParams = JRouter(`${baseUrl}?${params.toString()}`);
|
|
|
|
// --- Execute request ---
|
|
const response = await fetch(urlWithParams, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
cache: 'no-store',
|
|
credentials: 'same-origin'
|
|
});
|
|
|
|
// --- Handle network errors ---
|
|
if (!response.ok) {
|
|
console.error(`[getEditCustomCodeButtons_server] HTTP ${response.status}: ${response.statusText}`);
|
|
return null;
|
|
}
|
|
|
|
// --- Parse JSON result ---
|
|
const data = await response.json();
|
|
return data ?? null;
|
|
|
|
} catch (error) {
|
|
console.error('[getEditCustomCodeButtons_server] Fetch failed:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Load and inject Edit Custom Code buttons into the DOM.
|
|
*
|
|
* @return {Promise<void>}
|
|
* @since 3.1.3
|
|
*/
|
|
async function getEditCustomCodeButtons() {
|
|
try {
|
|
// --- Get record ID from the form ---
|
|
const idField = document.querySelector('#jform_id');
|
|
if (!idField) {
|
|
console.error('[getEditCustomCodeButtons] #jform_id not found.');
|
|
return;
|
|
}
|
|
|
|
const idValue = parseInt(idField.value, 10);
|
|
if (isNaN(idValue) || idValue <= 0) {
|
|
console.warn('[getEditCustomCodeButtons] Invalid or empty ID; skipping button load.');
|
|
return;
|
|
}
|
|
|
|
// --- Request data from server ---
|
|
const result = await getEditCustomCodeButtons_server(idValue);
|
|
if (!result || typeof result !== 'object') {
|
|
console.warn('[getEditCustomCodeButtons] No result returned or invalid format.');
|
|
return;
|
|
}
|
|
|
|
// --- Inject returned button groups ---
|
|
Object.entries(result).forEach(([field, buttons]) => {
|
|
// Create the container div
|
|
const div = document.createElement('div');
|
|
div.className = 'control-group';
|
|
div.innerHTML = `
|
|
<div class="control-label">
|
|
<label>Add/Edit Customcode</label>
|
|
</div>
|
|
<div class="controls control-customcode-buttons-${field}"></div>
|
|
`;
|
|
|
|
// Find where to insert (before .control-wrapper-{field})
|
|
const insertBeforeElement = document.querySelector(`.control-wrapper-${field}`);
|
|
if (insertBeforeElement && insertBeforeElement.parentNode) {
|
|
insertBeforeElement.parentNode.insertBefore(div, insertBeforeElement);
|
|
}
|
|
|
|
// Append buttons to the new container
|
|
const controlsDiv = div.querySelector(`.control-customcode-buttons-${field}`);
|
|
if (controlsDiv && typeof buttons === 'object') {
|
|
Object.entries(buttons).forEach(([name, buttonHtml]) => {
|
|
if (typeof buttonHtml === 'string') {
|
|
const wrapper = document.createElement('div');
|
|
wrapper.innerHTML = buttonHtml.trim();
|
|
const buttonNode = wrapper.firstElementChild;
|
|
if (buttonNode) {
|
|
controlsDiv.appendChild(buttonNode);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} catch (error) {
|
|
console.error('[getEditCustomCodeButtons] Error rendering buttons:', error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Request a button ID from the server.
|
|
*
|
|
* @param {string} type The button type identifier.
|
|
* @param {number} size The button size (must be > 0).
|
|
* @global {string} token The Joomla CSRF token name.
|
|
* @global {string} vastDevMod Optional developer mode flag.
|
|
*
|
|
* @return {Promise<object|null>} JSON response or null on failure.
|
|
* @since 3.1.3
|
|
*/
|
|
async function addButtonID_server(type, size) {
|
|
try {
|
|
// --- Validate parameters ---
|
|
if (typeof type !== 'string' || !type.trim()) {
|
|
console.error('[addButtonID_server] Invalid type provided:', type);
|
|
return null;
|
|
}
|
|
if (typeof size !== 'number' || size <= 0) {
|
|
console.error('[addButtonID_server] Invalid size provided:', size);
|
|
return null;
|
|
}
|
|
if (typeof token !== 'string' || !token.trim()) {
|
|
console.error('[addButtonID_server] Missing CSRF token.');
|
|
return null;
|
|
}
|
|
|
|
// --- Build request URL ---
|
|
const baseUrl = 'index.php';
|
|
const params = new URLSearchParams({
|
|
option: 'com_componentbuilder',
|
|
task: 'ajax.getButtonID',
|
|
format: 'json',
|
|
raw: 'true',
|
|
[token]: '1',
|
|
type: type,
|
|
size: size
|
|
});
|
|
if (vastDevMod) params.append('vdm', vastDevMod);
|
|
const fullUrl = JRouter(`${baseUrl}?${params.toString()}`);
|
|
|
|
// --- Perform fetch ---
|
|
const response = await fetch(fullUrl, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
cache: 'no-store',
|
|
credentials: 'same-origin'
|
|
});
|
|
|
|
if (!response.ok) {
|
|
console.error(`[addButtonID_server] Server responded with ${response.status}: ${response.statusText}`);
|
|
return null;
|
|
}
|
|
|
|
// --- Parse JSON result ---
|
|
const data = await response.json();
|
|
return data ?? null;
|
|
|
|
} catch (error) {
|
|
console.error('[addButtonID_server] Fetch operation failed:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Insert a button ID result into the DOM.
|
|
*
|
|
* @param {string} type The button type identifier.
|
|
* @param {string} where The DOM element ID or selector where to inject the result.
|
|
* @param {number} size The button size (default: 1).
|
|
* @global {string} token The Joomla CSRF token name.
|
|
* @global {string} vastDevMod Optional developer mode flag.
|
|
*
|
|
* @return {Promise<void>}
|
|
* @since 3.1.3
|
|
*/
|
|
async function addButtonID(type, where, size) {
|
|
try {
|
|
const result = await addButtonID_server(type, size);
|
|
|
|
if (!result) {
|
|
console.warn('[addButtonID] No data returned.');
|
|
return;
|
|
}
|
|
|
|
// Find target element
|
|
const target =
|
|
document.querySelector(`#${where}`) ||
|
|
document.querySelector(`#jform_${where}`);
|
|
|
|
if (!target) {
|
|
console.error(`[addButtonID] Target element "${where}" not found.`);
|
|
return;
|
|
}
|
|
|
|
// Insert the content
|
|
if (size === 2) {
|
|
target.innerHTML = result;
|
|
} else {
|
|
addData(result, `#jform_${where}`);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('[addButtonID] Error while inserting button ID:', error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fetches button data from the server.
|
|
*
|
|
* @param {string} type The button type identifier.
|
|
* @param {number} size The button size indicator (default: 1).
|
|
* @global {string} token The CSRF token key.
|
|
* @global {string} vastDevMod Developer mode flag (optional).
|
|
*
|
|
* @return {Promise<object|null>} Returns JSON data or null on failure.
|
|
* @since 3.1.3
|
|
*/
|
|
async function addButton_server(type, size = 1) {
|
|
try {
|
|
// --- Validate input ---
|
|
if (typeof type !== 'string' || !type.trim()) {
|
|
console.error('[addButton_server] Invalid type provided:', type);
|
|
return null;
|
|
}
|
|
if (typeof token !== 'string' || !token.trim()) {
|
|
console.error('[addButton_server] Missing CSRF token.');
|
|
return null;
|
|
}
|
|
|
|
// --- Build URL and query ---
|
|
const baseUrl = 'index.php';
|
|
const params = new URLSearchParams({
|
|
option: 'com_componentbuilder',
|
|
task: 'ajax.getButton',
|
|
format: 'json',
|
|
raw: 'true',
|
|
[token]: '1',
|
|
type: type,
|
|
size: size
|
|
});
|
|
if (vastDevMod) params.append('vdm', vastDevMod);
|
|
|
|
const fullUrl = JRouter(`${baseUrl}?${params.toString()}`);
|
|
|
|
// --- Fetch the data ---
|
|
const response = await fetch(fullUrl, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
cache: 'no-store',
|
|
credentials: 'same-origin'
|
|
});
|
|
|
|
if (!response.ok) {
|
|
console.error(`[addButton_server] Server responded with ${response.status}: ${response.statusText}`);
|
|
return null;
|
|
}
|
|
|
|
const data = await response.json();
|
|
return data ?? null;
|
|
} catch (error) {
|
|
console.error('[addButton_server] Fetch failed:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles button rendering into the DOM.
|
|
*
|
|
* @param {string} type The button type identifier.
|
|
* @param {string} where The target element ID or selector.
|
|
* @param {number} size Optional button size (default: 1).
|
|
* @global {string} token The CSRF token key.
|
|
* @global {string} vastDevMod Developer mode flag (optional).
|
|
*
|
|
* @return {Promise<void>}
|
|
* @since 3.1.3
|
|
*/
|
|
async function addButton(type, where, size) {
|
|
const result = await addButton_server(type, size);
|
|
|
|
if (!result) {
|
|
console.warn('[addButton] No button data returned from server.');
|
|
return;
|
|
}
|
|
|
|
const target = document.querySelector(size === 2 ? `#${where}` : `#jform_${where}`);
|
|
if (!target) {
|
|
console.error('[addButton] Target element not found:', where);
|
|
return;
|
|
}
|
|
|
|
if (size === 2) {
|
|
target.innerHTML = result;
|
|
} else {
|
|
addData(result, target);
|
|
}
|
|
}
|
|
|
|
function getLinked() {
|
|
getCodeFrom_server(1, 'type', 'type', 'getLinked').then(function(result) {
|
|
if (result.error) {
|
|
console.error(result.error);
|
|
} else if (result) {
|
|
document.getElementById('display_linked_to').innerHTML = result;
|
|
}
|
|
});
|
|
}
|