Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-03-06 18:01:09 +05:30
commit 590a6cd80b
9 changed files with 92 additions and 94 deletions

View File

@ -202,6 +202,7 @@ table.dataTable thead th {
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -232,7 +232,6 @@ table.dataTable tbody td {
document.addEventListener("DOMContentLoaded", init); document.addEventListener("DOMContentLoaded", init);
function init() { function init() {
const table = document.getElementById("tickets-table"); const table = document.getElementById("tickets-table");
let activeDropdown = null; let activeDropdown = null;
@ -264,8 +263,21 @@ function init() {
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Clone original dropdown items while moving onclick handlers to data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Transfer onclick handlers to data attributes
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalItem = originalItems[index];
const originalOnclick = originalItem.getAttribute('onclick');
if (originalOnclick) {
item.setAttribute('data-onclick', originalOnclick);
item.removeAttribute('onclick'); // Remove original handler
}
});
return customDropdown; return customDropdown;
} }
@ -287,11 +299,15 @@ function init() {
} }
function handleItemClick(e, item) { function handleItemClick(e, item) {
const onclickAttr = item.getAttribute('onclick'); e.preventDefault();
// Execute the stored onclick handler
const onclickAttr = item.getAttribute('data-onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);
} }
// Handle href navigation
const href = item.getAttribute('href'); const href = item.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') {
window.location.href = href; window.location.href = href;

View File

@ -133,6 +133,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
event.preventDefault(e);
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -470,17 +470,21 @@ document.addEventListener("DOMContentLoaded", function () {
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -494,45 +498,33 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the action column // Ignore clicks on the first column
if (event.target.closest('td:last-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Handle custom dropdown clicks
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -543,7 +535,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

View File

@ -129,6 +129,7 @@
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -362,23 +362,26 @@ custom-dropdown-menu {
<?php include('policy_transaction_endorsement_form.php'); ?> <?php include('policy_transaction_endorsement_form.php'); ?>
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table"); const table = document.getElementById("tickets-table");
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -392,45 +395,34 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the action column // Ignore clicks on the first column
if (event.target.closest('td:last-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Preserve click handlers and add auto-close // Handle custom dropdown clicks
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -441,7 +433,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

View File

@ -177,6 +177,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers // Preserve click handlers
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -420,17 +420,21 @@ document.addEventListener("DOMContentLoaded", function () {
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -444,45 +448,34 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the first column (td:first-child) // Ignore clicks on the first column
if (event.target.closest('td:first-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Preserve click handlers and add auto-close // Handle custom dropdown clicks
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -493,7 +486,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

View File

@ -128,6 +128,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);