|
Lines 187-199
Link Here
|
| 187 |
[% END %] |
187 |
[% END %] |
| 188 |
|
188 |
|
| 189 |
[% IF Koha.debug_flag %] |
189 |
[% IF Koha.debug_flag %] |
| 190 |
<div style="position: fixed; bottom: 0;"> |
190 |
<script> |
| 191 |
<button onclick="window.location.search += '&DISABLE_SYSPREF_IntranetUserCSS=yes&DISABLE_SYSPREF_OPACUserCSS=yes'">Disable User CSS</button> |
191 |
(function () { |
| 192 |
<button onclick="window.location.search += '&DISABLE_SYSPREF_IntranetUserJS=yes&DISABLE_SYSPREF_OPACUserJS=yes'">Disable User JS</button> |
192 |
function getURLParams() { |
| 193 |
<button onclick="window.location.search += '&DISABLE_SYSPREF_OpacAdditionalStylesheet=yes&DISABLE_SYSPREF_opaclayoutstylesheet=yes&DISABLE_SYSPREF_intranetcolorstylesheet=yes&DISABLE_SYSPREF_intranetstylesheet=yes'" |
193 |
const params = new URLSearchParams(window.location.search); |
| 194 |
>Load only default stylesheets</button |
194 |
return params; |
| 195 |
> |
195 |
} |
| 196 |
</div> |
196 |
|
|
|
197 |
function toggleURLParams(paramsToToggle) { |
| 198 |
const url = new URL(window.location.href); |
| 199 |
const params = url.searchParams; |
| 200 |
|
| 201 |
// Check if all params are currently set |
| 202 |
const allSet = paramsToToggle.every(param => params.get(param) === "yes"); |
| 203 |
|
| 204 |
if (allSet) { |
| 205 |
// Remove all params |
| 206 |
paramsToToggle.forEach(param => params.delete(param)); |
| 207 |
} else { |
| 208 |
// Add all params |
| 209 |
paramsToToggle.forEach(param => params.set(param, "yes")); |
| 210 |
} |
| 211 |
|
| 212 |
window.location.href = url.toString(); |
| 213 |
} |
| 214 |
|
| 215 |
function updateButtonText() { |
| 216 |
const params = getURLParams(); |
| 217 |
|
| 218 |
// User CSS button |
| 219 |
const cssDisabled = params.get("DISABLE_SYSPREF_IntranetUserCSS") === "yes" && params.get("DISABLE_SYSPREF_OPACUserCSS") === "yes"; |
| 220 |
const cssToggle = document.getElementById("toggleUserCSS"); |
| 221 |
if (cssToggle) { |
| 222 |
const cssText = cssToggle.querySelector(".toggle-text"); |
| 223 |
if (cssText) cssText.textContent = cssDisabled ? "Enable User CSS" : "Disable User CSS"; |
| 224 |
} |
| 225 |
|
| 226 |
// User JS button |
| 227 |
const jsDisabled = params.get("DISABLE_SYSPREF_IntranetUserJS") === "yes" && params.get("DISABLE_SYSPREF_OPACUserJS") === "yes"; |
| 228 |
const jsToggle = document.getElementById("toggleUserJS"); |
| 229 |
if (jsToggle) { |
| 230 |
const jsText = jsToggle.querySelector(".toggle-text"); |
| 231 |
if (jsText) jsText.textContent = jsDisabled ? "Enable User JS" : "Disable User JS"; |
| 232 |
} |
| 233 |
|
| 234 |
// Stylesheets button |
| 235 |
const stylesheetsDisabled = |
| 236 |
params.get("DISABLE_SYSPREF_OpacAdditionalStylesheet") === "yes" && |
| 237 |
params.get("DISABLE_SYSPREF_opaclayoutstylesheet") === "yes" && |
| 238 |
params.get("DISABLE_SYSPREF_intranetcolorstylesheet") === "yes" && |
| 239 |
params.get("DISABLE_SYSPREF_intranetstylesheet") === "yes"; |
| 240 |
const stylesheetsToggle = document.getElementById("toggleStylesheets"); |
| 241 |
if (stylesheetsToggle) { |
| 242 |
const stylesheetsText = stylesheetsToggle.querySelector(".toggle-text"); |
| 243 |
if (stylesheetsText) stylesheetsText.textContent = stylesheetsDisabled ? "Enable Custom Stylesheets" : "Disable Custom Stylesheets"; |
| 244 |
} |
| 245 |
|
| 246 |
// Update icon color based on whether any toggles are active |
| 247 |
const anyDisabled = cssDisabled || jsDisabled || stylesheetsDisabled; |
| 248 |
const debugIcon = document.getElementById("debug-icon"); |
| 249 |
if (debugIcon) { |
| 250 |
if (anyDisabled) { |
| 251 |
debugIcon.style.color = "#ffc107"; // Warning/amber color |
| 252 |
} else { |
| 253 |
debugIcon.style.color = ""; // Default color |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
// Update button text on page load |
| 259 |
updateButtonText(); |
| 260 |
|
| 261 |
// User CSS toggle |
| 262 |
const cssToggle = document.getElementById("toggleUserCSS"); |
| 263 |
if (cssToggle) { |
| 264 |
cssToggle.addEventListener("click", function (e) { |
| 265 |
e.preventDefault(); |
| 266 |
toggleURLParams(["DISABLE_SYSPREF_IntranetUserCSS", "DISABLE_SYSPREF_OPACUserCSS"]); |
| 267 |
}); |
| 268 |
} |
| 269 |
|
| 270 |
// User JS toggle |
| 271 |
const jsToggle = document.getElementById("toggleUserJS"); |
| 272 |
if (jsToggle) { |
| 273 |
jsToggle.addEventListener("click", function (e) { |
| 274 |
e.preventDefault(); |
| 275 |
toggleURLParams(["DISABLE_SYSPREF_IntranetUserJS", "DISABLE_SYSPREF_OPACUserJS"]); |
| 276 |
}); |
| 277 |
} |
| 278 |
|
| 279 |
// Stylesheets toggle |
| 280 |
const stylesheetsToggle = document.getElementById("toggleStylesheets"); |
| 281 |
if (stylesheetsToggle) { |
| 282 |
stylesheetsToggle.addEventListener("click", function (e) { |
| 283 |
e.preventDefault(); |
| 284 |
toggleURLParams(["DISABLE_SYSPREF_OpacAdditionalStylesheet", "DISABLE_SYSPREF_opaclayoutstylesheet", "DISABLE_SYSPREF_intranetcolorstylesheet", "DISABLE_SYSPREF_intranetstylesheet"]); |
| 285 |
}); |
| 286 |
} |
| 287 |
})(); |
| 288 |
</script> |
| 197 |
[% END # IF %] |
289 |
[% END # IF %] |
| 198 |
|
290 |
|
| 199 |
[% IF ( footerjs ) %] |
291 |
[% IF ( footerjs ) %] |
| 200 |
- |
|
|