From 1dac65fc8ac98b41531c671175cc234fdd5d74d8 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Thu, 19 Feb 2026 20:18:09 -0500 Subject: [PATCH] Wire styleguide.css and ajax.js into root.mako globally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Load styleguide.css before style.css so new design tokens are available app-wide and new styles take precedence - Load ajax.js after scripts.min.js — provides qs(), onReady(), onDelegate(), setCookie(), getCookie(), and other vanilla utilities - Keep jQuery's $ intact via qs() alias to avoid breaking existing code - Add no-js class to for capability-driven presentation - Update error_document.mako with same CSS/JS stack --- rhodecode/public/js/ajax.js | 23 +++++++++++-------- rhodecode/templates/base/root.mako | 4 +++- .../templates/errors/error_document.mako | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/rhodecode/public/js/ajax.js b/rhodecode/public/js/ajax.js index f43653bd..4b40620f 100644 --- a/rhodecode/public/js/ajax.js +++ b/rhodecode/public/js/ajax.js @@ -8,10 +8,13 @@ DOM UTILITIES ===================================================================== */ - /** Query single element */ - window.$ = function(selector, context) { + /** Query single element — only override $ if jQuery is not loaded */ + window.qs = function(selector, context) { return (context || document).querySelector(selector); }; + if (!window.jQuery) { + window.$ = window.qs; + } /** Query all elements */ window.$$ = function(selector, context) { @@ -89,17 +92,17 @@ ===================================================================== */ window.show = function(el) { - if (typeof el === 'string') el = $(el); + if (typeof el === 'string') el = qs(el); if (el) el.style.display = ''; }; window.hide = function(el) { - if (typeof el === 'string') el = $(el); + if (typeof el === 'string') el = qs(el); if (el) el.style.display = 'none'; }; window.toggle = function(el) { - if (typeof el === 'string') el = $(el); + if (typeof el === 'string') el = qs(el); if (!el) return; el.style.display = (el.style.display === 'none') ? '' : 'none'; }; @@ -128,14 +131,14 @@ ===================================================================== */ window.openDialog = function(selector) { - var dialog = typeof selector === 'string' ? $(selector) : selector; + var dialog = typeof selector === 'string' ? qs(selector) : selector; if (dialog && dialog.showModal) { dialog.showModal(); } }; window.closeDialog = function(selector) { - var dialog = typeof selector === 'string' ? $(selector) : selector; + var dialog = typeof selector === 'string' ? qs(selector) : selector; if (dialog && dialog.close) { dialog.close(); } @@ -166,7 +169,7 @@ ===================================================================== */ window.tooltip = function(el, text) { - if (typeof el === 'string') el = $(el); + if (typeof el === 'string') el = qs(el); if (!el) return; el.setAttribute('title', text); }; @@ -184,7 +187,7 @@ ===================================================================== */ window.dismissAlert = function(el) { - if (typeof el === 'string') el = $(el); + if (typeof el === 'string') el = qs(el); if (!el) return; el.style.transition = 'opacity 0.2s'; el.style.opacity = '0'; @@ -196,7 +199,7 @@ ===================================================================== */ window.scrollToElement = function(selector) { - var el = typeof selector === 'string' ? $(selector) : selector; + var el = typeof selector === 'string' ? qs(selector) : selector; if (el) { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); } diff --git a/rhodecode/templates/base/root.mako b/rhodecode/templates/base/root.mako index a0de0cc7..ec0648e2 100644 --- a/rhodecode/templates/base/root.mako +++ b/rhodecode/templates/base/root.mako @@ -40,7 +40,7 @@ c.template_context['attachment_store'] = { } %> - + ${self.title()} @@ -62,6 +62,7 @@ c.template_context['attachment_store'] = { ## CSS definitions <%def name="css()"> + ## EXTRA FOR CSS @@ -144,6 +145,7 @@ c.template_context['attachment_store'] = { ## avoide escaping the %N + ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates ${self.js_extra()} diff --git a/rhodecode/templates/errors/error_document.mako b/rhodecode/templates/errors/error_document.mako index d58ff3ef..6e88c2ac 100644 --- a/rhodecode/templates/errors/error_document.mako +++ b/rhodecode/templates/errors/error_document.mako @@ -13,14 +13,15 @@ + - <%include file="/base/plugins_base.mako"/> +