Guard lt.* calls when base.js unavailable to prevent crash
Wraps all lt.keys.initDefaults() calls in `if (window.lt)` guards across 6 view files. Adds `if (!window.lt) return` bail-out in keyboard-shortcuts.js and `if (window.lt)` guard in settings.js DOMContentLoaded handler. This prevents TypeError crashes when /web_template/base.js returns 404, which was causing the admin menu click delegation to never register. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,8 @@ function showKeyboardHelp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
if (!window.lt) return;
|
||||||
|
|
||||||
// Ctrl+E: Toggle edit mode (ticket pages)
|
// Ctrl+E: Toggle edit mode (ticket pages)
|
||||||
lt.keys.on('ctrl+e', function() {
|
lt.keys.on('ctrl+e', function() {
|
||||||
const editButton = document.getElementById('editButton');
|
const editButton = document.getElementById('editButton');
|
||||||
|
|||||||
@@ -131,4 +131,6 @@ document.addEventListener('keydown', (e) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Initialize on page load
|
// Initialize on page load
|
||||||
document.addEventListener('DOMContentLoaded', loadUserPreferences);
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
if (window.lt) loadUserPreferences();
|
||||||
|
});
|
||||||
|
|||||||
@@ -854,7 +854,7 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/advanced-search.js"></script>
|
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/advanced-search.js"></script>
|
||||||
<script nonce="<?php echo $nonce; ?>">
|
<script nonce="<?php echo $nonce; ?>">
|
||||||
// Initialize lt keyboard defaults (ESC closes modals, Ctrl+K focuses search, ? shows help)
|
// Initialize lt keyboard defaults (ESC closes modals, Ctrl+K focuses search, ? shows help)
|
||||||
lt.keys.initDefaults();
|
if (window.lt) lt.keys.initDefaults();
|
||||||
// Event delegation for all data-action handlers
|
// Event delegation for all data-action handlers
|
||||||
document.addEventListener('click', function(event) {
|
document.addEventListener('click', function(event) {
|
||||||
const target = event.target.closest('[data-action]');
|
const target = event.target.closest('[data-action]');
|
||||||
|
|||||||
@@ -816,6 +816,6 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
|
|
||||||
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/keyboard-shortcuts.js"></script>
|
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/keyboard-shortcuts.js"></script>
|
||||||
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/settings.js"></script>
|
<script nonce="<?php echo $nonce; ?>" src="<?php echo $GLOBALS['config']['ASSETS_URL']; ?>/js/settings.js"></script>
|
||||||
<script nonce="<?php echo $nonce; ?>">lt.keys.initDefaults();</script>
|
<script nonce="<?php echo $nonce; ?>">if (window.lt) lt.keys.initDefaults();</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -204,7 +204,7 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
saveField(e);
|
saveField(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
lt.keys.initDefaults();
|
if (window.lt) lt.keys.initDefaults();
|
||||||
|
|
||||||
function toggleOptionsField() {
|
function toggleOptionsField() {
|
||||||
const type = document.getElementById('field_type').value;
|
const type = document.getElementById('field_type').value;
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
saveRecurring(e);
|
saveRecurring(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
lt.keys.initDefaults();
|
if (window.lt) lt.keys.initDefaults();
|
||||||
|
|
||||||
function updateScheduleOptions() {
|
function updateScheduleOptions() {
|
||||||
const type = document.getElementById('schedule_type').value;
|
const type = document.getElementById('schedule_type').value;
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
saveTemplate(e);
|
saveTemplate(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
lt.keys.initDefaults();
|
if (window.lt) lt.keys.initDefaults();
|
||||||
|
|
||||||
function saveTemplate(e) {
|
function saveTemplate(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ $nonce = SecurityHeadersMiddleware::getNonce();
|
|||||||
saveTransition(e);
|
saveTransition(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
lt.keys.initDefaults();
|
if (window.lt) lt.keys.initDefaults();
|
||||||
|
|
||||||
function saveTransition(e) {
|
function saveTransition(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user