Release of v6.1.3
Stability update addressing a post-release field issue. #1262. Fix a security vulnerability in custom code redirect URL validation. Add an alert to the Compiler view when no Components exist. #1263.
This commit is contained in:
76 files changed
+2805
-1644
No files matched your search
+120
-47
@@ -36,60 +36,124 @@ $noticeboardOptions = ['vdm', 'pro'];
|
||||
|
||||
?>
|
||||
<?php if ($this->canDo->get('compiler.access')): ?>
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task) {
|
||||
if (task === 'compiler.back') {
|
||||
parent.history.back();
|
||||
return false;
|
||||
} else {
|
||||
var form = document.getElementById('adminForm');
|
||||
form.task.value = task;
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task, key) {
|
||||
if (task === '') {
|
||||
/**
|
||||
* Enhanced Joomla submit button handler for the compiler interface.
|
||||
*
|
||||
* Handles form submission tasks safely with DOM validation,
|
||||
* smooth UI transitions, and contextual loading states.
|
||||
*
|
||||
* @param {string} task The Joomla task to perform.
|
||||
* @param {string} [key] Optional key for install-related tasks.
|
||||
*
|
||||
* @return {boolean} Returns true if the form submission proceeds, false otherwise.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
Joomla.submitbutton = function (task, key = '') {
|
||||
// Abort early if task is not provided
|
||||
if (!task) {
|
||||
console.warn('Joomla.submitbutton: No task provided.');
|
||||
return false;
|
||||
} else {
|
||||
var component = document.getElementById('component_id').value;
|
||||
var isValid = true;
|
||||
}
|
||||
|
||||
if (component === '' && task === 'compiler.compiler') {
|
||||
isValid = false;
|
||||
}
|
||||
if (isValid) {
|
||||
document.getElementById('form').style.display = 'none';
|
||||
var form = document.getElementById('adminForm');
|
||||
if (task === 'compiler.installCompiledModule' || task === 'compiler.installCompiledPlugin') {
|
||||
form.install_item_id.value = key;
|
||||
}
|
||||
form.task.value = task;
|
||||
setTimeout(function() {
|
||||
form.submit();
|
||||
}, 100);
|
||||
const form = document.getElementById('adminForm');
|
||||
if (!form) {
|
||||
console.error('Joomla.submitbutton: #adminForm not found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task === 'compiler.compiler') {
|
||||
let component_name = document.querySelector("#component_id option:checked").textContent;
|
||||
document.querySelectorAll(".component-name").forEach(elem => {
|
||||
elem.textContent = component_name;
|
||||
});
|
||||
setTimeout(function() {
|
||||
document.getElementById('compiler').style.display = 'block';
|
||||
document.getElementById('compiling').style.display = 'block';
|
||||
setTimeout(function() {
|
||||
document.getElementById('compiler-spinner').style.display = 'block';
|
||||
document.getElementById('compiler-notice').style.display = 'block';
|
||||
}, 100);
|
||||
}, 100);
|
||||
} else if (task === 'compiler.clearTmp') {
|
||||
document.getElementById('clear').style.display = 'block';
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
} else if (task === 'compiler.getCompilerAnimations') {
|
||||
document.getElementById('get-compiler-animations').style.display = 'block';
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
} else {
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
}
|
||||
return true;
|
||||
const componentField = document.getElementById('component_id');
|
||||
const component = componentField ? componentField.value.trim() : '';
|
||||
const isCompilerTask = task === 'compiler.compiler';
|
||||
let isValid = true;
|
||||
|
||||
// Validate component selection for compilation
|
||||
if (!component && isCompilerTask) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
document.querySelectorAll('.notice').forEach(elem => {
|
||||
elem.style.display = 'block';
|
||||
});
|
||||
console.warn('Joomla.submitbutton: Component not selected.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hide form while processing
|
||||
const formContainer = document.getElementById('form');
|
||||
if (formContainer) {
|
||||
formContainer.style.display = 'none';
|
||||
}
|
||||
|
||||
// Handle install tasks with key assignment
|
||||
if (task === 'compiler.installCompiledModule' || task === 'compiler.installCompiledPlugin') {
|
||||
if (form.install_item_id) {
|
||||
form.install_item_id.value = key;
|
||||
} else {
|
||||
document.querySelectorAll('.notice').forEach(elem => {
|
||||
elem.style.display = 'block';
|
||||
});
|
||||
return false;
|
||||
console.warn('Joomla.submitbutton: install_item_id field not found.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the task and safely submit
|
||||
form.task.value = task;
|
||||
setTimeout(() => form.submit(), 100);
|
||||
|
||||
// UI update helper
|
||||
const show = (id, delay = 0) => {
|
||||
setTimeout(() => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.style.display = 'block';
|
||||
}, delay);
|
||||
};
|
||||
|
||||
// Manage contextual UI loading animations
|
||||
switch (task) {
|
||||
case 'compiler.compiler': {
|
||||
const selectedOption = document.querySelector('#component_id option:checked');
|
||||
const componentName = selectedOption ? selectedOption.textContent.trim() : '';
|
||||
|
||||
document.querySelectorAll('.component-name').forEach(elem => {
|
||||
elem.textContent = componentName;
|
||||
});
|
||||
|
||||
show('compiler', 100);
|
||||
show('compiling', 100);
|
||||
show('compiler-spinner', 200);
|
||||
show('compiler-notice', 200);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'compiler.clearTmp':
|
||||
show('clear');
|
||||
show('loading');
|
||||
break;
|
||||
|
||||
case 'compiler.getCompilerAnimations':
|
||||
show('get-compiler-animations');
|
||||
show('loading');
|
||||
break;
|
||||
|
||||
default:
|
||||
show('loading');
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
// Add spindle-wheel for importations:
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
@@ -135,6 +199,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
outerBodyDiv.appendChild(compilingDiv);
|
||||
});
|
||||
</script>
|
||||
<?php if (empty($this->Components)): ?>
|
||||
<?php echo $this->loadTemplate('nocomponentstocompile'); ?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_componentbuilder&view=compiler'); ?>"
|
||||
method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo Html::_('form.token'); ?>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="main-card p-md-3">
|
||||
<?php if (StringHelper::check($this->SuccessMessage)): ?>
|
||||
<div class="alert alert-success">
|
||||
@@ -258,7 +330,8 @@ function JRouter(link) {
|
||||
?>
|
||||
return url+link;
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<h1><?php echo Text::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
||||
<div class="container my-5">
|
||||
<div class="p-5 bg-light border rounded-4 shadow-sm text-center position-relative overflow-hidden">
|
||||
<div class="position-absolute top-0 start-0 w-100 h-100 bg-warning bg-opacity-10"></div>
|
||||
<div class="position-relative">
|
||||
<div class="mb-3">
|
||||
<i class="bi bi-box-seam display-4 text-warning"></i>
|
||||
</div>
|
||||
<h3 class="fw-semibold mb-2"><?php echo Text::_('COM_COMPONENTBUILDER_NO_COMPONENTS_TO_COMPILE'); ?></h3>
|
||||
<p class="lead text-muted mb-4">
|
||||
<?php echo Text::_('COM_COMPONENTBUILDER_THERE_ARE_CURRENTLY_NO_COMPONENTS_AVAILABLE_FOR_COMPILATION'); ?><br>
|
||||
<?php echo Text::_('COM_COMPONENTBUILDER_PLEASE_CREATE_ONE_OR_MORE_COMPONENTS_BEFORE_ATTEMPTING_TO_COMPILE'); ?>
|
||||
</p>
|
||||
<a href="index.php?option=com_componentbuilder&view=joomla_components" class="btn btn-primary btn-lg px-4">
|
||||
<i class="bi bi-plus-circle me-2"></i>
|
||||
<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_COMPONENT'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<?php echo LayoutHelper::render('jcbnoticeboard', ['dankie' => $this->dankie]); ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
|
||||
// No direct access to this file
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
|
||||
// No direct access to this file
|
||||
|
||||
@@ -370,19 +370,38 @@ var select_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_SELECT_A_SNIPPE
|
||||
var create_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_SNIPPET'); ?>';
|
||||
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
@@ -283,44 +283,77 @@ jQuery('#adminForm').on('change', '#jform_add_javascript_views_footer',function
|
||||
|
||||
|
||||
|
||||
jQuery(function() {
|
||||
setTimeout(
|
||||
function() {
|
||||
// make sure the code bocks are active
|
||||
document.querySelectorAll("code").forEach(function(codeBlock) {
|
||||
codeBlock.addEventListener("click", function() {
|
||||
codeBlock.selText(); // Call the custom selText function
|
||||
codeBlock.classList.add("selected"); // Add the "selected" class
|
||||
});
|
||||
/**
|
||||
* Initialize form listeners and code block click handlers.
|
||||
*
|
||||
* Fully replaces the original jQuery logic in pure JavaScript.
|
||||
*
|
||||
* @since 5.1.3
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
setTimeout(function () {
|
||||
document.querySelectorAll('code').forEach(function (codeBlock) {
|
||||
codeBlock.addEventListener('click', function () {
|
||||
codeBlock.selText();
|
||||
codeBlock.classList.add('selected');
|
||||
});
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
jQuery('#adminForm').on('change', '#jform_fieldtype',function (e) {
|
||||
e.preventDefault();
|
||||
// get type value
|
||||
var fieldId = jQuery("#jform_fieldtype option:selected").val();
|
||||
getFieldTypeProperties(fieldId, true);
|
||||
// get the field type text
|
||||
var fieldText = jQuery("#jform_fieldtype option:selected").text().toLowerCase();
|
||||
// now check if database input is needed
|
||||
dbChecker(fieldText);
|
||||
});
|
||||
const adminForm = document.getElementById('adminForm');
|
||||
if (adminForm) {
|
||||
adminForm.addEventListener('change', function (e) {
|
||||
if (e.target && e.target.id === 'jform_fieldtype') {
|
||||
e.preventDefault();
|
||||
|
||||
// Get selected option
|
||||
const select = document.getElementById('jform_fieldtype');
|
||||
const selected = select.options[select.selectedIndex];
|
||||
if (!selected) return;
|
||||
|
||||
const fieldId = selected.value;
|
||||
const fieldText = selected.textContent.trim().toLowerCase();
|
||||
|
||||
// Run your existing functions (kept identical)
|
||||
getFieldTypeProperties(fieldId, true);
|
||||
dbChecker(fieldText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
<?php
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
|
||||
// No direct access to this file
|
||||
|
||||
@@ -417,19 +417,38 @@ var select_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_SELECT_A_SNIPPE
|
||||
var create_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_SNIPPET'); ?>';
|
||||
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
<?php
|
||||
|
||||
@@ -207,19 +207,38 @@ jQuery(document).ready(function() {
|
||||
var select_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_SELECT_A_SNIPPET'); ?>';
|
||||
var create_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_SNIPPET'); ?>';
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
<?php
|
||||
|
||||
@@ -52,19 +52,38 @@ if ($this->saveOrder)
|
||||
<script type="text/javascript">
|
||||
// layouts footer script
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// get page body
|
||||
|
||||
@@ -66,19 +66,38 @@ $wa->useScript('core')
|
||||
<script type="text/javascript">
|
||||
// layouts footer script
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// get page body
|
||||
|
||||
@@ -396,19 +396,38 @@ var select_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_SELECT_A_SNIPPE
|
||||
var create_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_SNIPPET'); ?>';
|
||||
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
@@ -212,19 +212,38 @@ jQuery(document).ready(function() {
|
||||
var select_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_SELECT_A_SNIPPET'); ?>';
|
||||
var create_a_snippet = '<?php echo Text::_('COM_COMPONENTBUILDER_CREATE_A_SNIPPET'); ?>';
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
<?php
|
||||
|
||||
@@ -52,19 +52,38 @@ if ($this->saveOrder)
|
||||
<script type="text/javascript">
|
||||
// templates footer script
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// get page body
|
||||
|
||||
@@ -66,19 +66,38 @@ $wa->useScript('core')
|
||||
<script type="text/javascript">
|
||||
// templates footer script
|
||||
|
||||
HTMLElement.prototype.selText = function() {
|
||||
var obj = this;
|
||||
/**
|
||||
* Select all text content within an HTMLElement.
|
||||
*
|
||||
* Adds a convenient `selText()` method to all HTMLElements.
|
||||
* Works across modern browsers and gracefully handles errors.
|
||||
*
|
||||
* @return {HTMLElement} Returns the element itself for chaining.
|
||||
* @since 5.1.3
|
||||
*/
|
||||
HTMLElement.prototype.selText = function () {
|
||||
try {
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
console.warn('selText: window.getSelection() not supported in this environment.');
|
||||
return this;
|
||||
}
|
||||
|
||||
// For modern browsers, handle the selection
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(this);
|
||||
|
||||
// Select the content of the element
|
||||
range.selectNodeContents(obj);
|
||||
selection.removeAllRanges(); // Clear any previous selections
|
||||
selection.addRange(range); // Add the new selection range
|
||||
selection.removeAllRanges(); // clear any prior selections
|
||||
selection.addRange(range); // select the element's text content
|
||||
|
||||
return this;
|
||||
// Optionally bring the element into view if it's outside viewport
|
||||
if (typeof this.scrollIntoView === 'function') {
|
||||
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('selText failed:', error);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// get page body
|
||||
|
||||
Reference in new issue
Block a user