From 204029678d409a34eaf6cc4d39ba28d4d06f291a Mon Sep 17 00:00:00 2001 From: Abdul Rehman Date: Mon, 17 Feb 2025 15:32:01 +0500 Subject: [PATCH] fix: Fixed dark-theme toggle not working in legacy pages --- ..._135531_abdul.rehman02_fix_dark_theme_legacy_pages.md | 1 + tutorindigo/templates/indigo/lms/static/js/dark-theme.js | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md diff --git a/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md b/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md new file mode 100644 index 000000000..aae795022 --- /dev/null +++ b/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md @@ -0,0 +1 @@ +- [Bugfix] Fixed breaking dark theme toggle not working in legacy pages. (by @rehmansheikh222) \ No newline at end of file diff --git a/tutorindigo/templates/indigo/lms/static/js/dark-theme.js b/tutorindigo/templates/indigo/lms/static/js/dark-theme.js index 93b4d47cc..99687b51c 100644 --- a/tutorindigo/templates/indigo/lms/static/js/dark-theme.js +++ b/tutorindigo/templates/indigo/lms/static/js/dark-theme.js @@ -1,3 +1,11 @@ +(function() { + if (window.INDIGO_DARK_THEME_INITIALIZED) { + console.log("dark-theme.js: script already initialized, skipping second run."); + return; + } + window.INDIGO_DARK_THEME_INITIALIZED = true; + // ========== END GUARD CHECK =============== + $(document).ready(function() { 'use strict'; @@ -36,3 +44,4 @@ $(document).ready(function() { $('#toggle-switch').on('change', toggleTheme); }); +})();