From 2d339a45752687c97ee66fedb6827618162b3883 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Sun, 17 Sep 2023 22:56:05 +0200 Subject: [PATCH 1/7] Fix: avoid `` --- CHANGELOG.rst | 6 ++++++ .../djangocms_admin_style/js/modules/dark-mode.js | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 267955c8..6e0f230a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,12 @@ Changelog ========= +unreleased +========== + +* Fix bug which adds 'data-theme="undefined"' to admin html tag + + 3.2.5 (2023-08-22) ================== diff --git a/djangocms_admin_style/static/djangocms_admin_style/js/modules/dark-mode.js b/djangocms_admin_style/static/djangocms_admin_style/js/modules/dark-mode.js index cc967c3f..a6da664d 100644 --- a/djangocms_admin_style/static/djangocms_admin_style/js/modules/dark-mode.js +++ b/djangocms_admin_style/static/djangocms_admin_style/js/modules/dark-mode.js @@ -23,6 +23,10 @@ function getTopWindow() { function getColorSchemeFromSettings(CMS) { var colorScheme; + if (!CMS) { + return; + } + if (CMS.settings && CMS.settings.color_scheme) { // Use color_scheme from settings.py colorScheme = CMS.settings.color_scheme; @@ -54,16 +58,12 @@ function darkModeSettings() { // CMS not loaded: set color scheme for admin site according to settings colorScheme = JSON.parse(localStorage.getItem('cms_cookie') || '{}').color_scheme; } - - if (colorScheme === 'auto' || colorScheme === undefined) { - document.documentElement.dataset.theme = 'auto'; - } else { - document.documentElement.dataset.theme = colorScheme; - } } } } - document.documentElement.dataset.theme = colorScheme; + if (colorScheme) { + document.documentElement.dataset.theme = colorScheme; + } } module.exports = darkModeSettings; From 9f42a4d374dd34b5ed5a912e6d9e773e64eaf2f4 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Sun, 17 Sep 2023 22:57:15 +0200 Subject: [PATCH 2/7] Add bundle --- .../djangocms_admin_style/js/dist/bundle.adminstyle.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_admin_style/static/djangocms_admin_style/js/dist/bundle.adminstyle.min.js b/djangocms_admin_style/static/djangocms_admin_style/js/dist/bundle.adminstyle.min.js index def78d74..6cf9168a 100644 --- a/djangocms_admin_style/static/djangocms_admin_style/js/dist/bundle.adminstyle.min.js +++ b/djangocms_admin_style/static/djangocms_admin_style/js/dist/bundle.adminstyle.min.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,n){var r,i;!function(t,n){"object"==typeof e&&"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(o,a){function s(e){var t="length"in e&&e.length,n=le.type(e);return"function"!==n&&!le.isWindow(e)&&(!(1!==e.nodeType||!t)||("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e))}function u(e,t,n){if(le.isFunction(t))return le.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return le.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(ve.test(t))return le.filter(t,e,n);t=le.filter(t,e)}return le.grep(e,function(e){return le.inArray(e,t)>=0!==n})}function l(e,t){do{e=e[t]}while(e&&1!==e.nodeType);return e}function c(e){var t=Ee[e]={};return le.each(e.match(Ce)||[],function(e,n){t[n]=!0}),t}function d(){xe.addEventListener?(xe.removeEventListener("DOMContentLoaded",f,!1),o.removeEventListener("load",f,!1)):(xe.detachEvent("onreadystatechange",f),o.detachEvent("onload",f))}function f(){(xe.addEventListener||"load"===event.type||"complete"===xe.readyState)&&(d(),le.ready())}function p(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(De,"-$1").toLowerCase();if("string"==typeof(n=e.getAttribute(r))){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:je.test(n)?le.parseJSON(n):n)}catch(e){}le.data(e,t,n)}else n=void 0}return n}function h(e){var t;for(t in e)if(("data"!==t||!le.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function m(e,t,n,r){if(le.acceptData(e)){var i,o,a=le.expando,s=e.nodeType,u=s?le.cache:e,l=s?e[a]:e[a]&&a;if(l&&u[l]&&(r||u[l].data)||void 0!==n||"string"!=typeof t)return l||(l=s?e[a]=Z.pop()||le.guid++:a),u[l]||(u[l]=s?{}:{toJSON:le.noop}),("object"==typeof t||"function"==typeof t)&&(r?u[l]=le.extend(u[l],t):u[l].data=le.extend(u[l].data,t)),o=u[l],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[le.camelCase(t)]=n),"string"==typeof t?null==(i=o[t])&&(i=o[le.camelCase(t)]):i=o,i}}function g(e,t,n){if(le.acceptData(e)){var r,i,o=e.nodeType,a=o?le.cache:e,s=o?e[le.expando]:le.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){le.isArray(t)?t=t.concat(le.map(t,le.camelCase)):t in r?t=[t]:(t=le.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!h(r):!le.isEmptyObject(r))return}(n||(delete a[s].data,h(a[s])))&&(o?le.cleanData([e],!0):se.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function v(){return!0}function y(){return!1}function x(){try{return xe.activeElement}catch(e){}}function b(e){var t=Pe.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function w(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==Se?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==Se?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||le.nodeName(r,t)?o.push(r):le.merge(o,w(r,t));return void 0===t||t&&le.nodeName(e,t)?le.merge([e],o):o}function T(e){Me.test(e.type)&&(e.defaultChecked=e.checked)}function C(e,t){return le.nodeName(e,"table")&&le.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function E(e){return e.type=(null!==le.find.attr(e,"type"))+"/"+e.type,e}function N(e){var t=Ge.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function k(e,t){for(var n,r=0;null!=(n=e[r]);r++)le._data(n,"globalEval",!t||le._data(t[r],"globalEval"))}function S(e,t){if(1===t.nodeType&&le.hasData(e)){var n,r,i,o=le._data(e),a=le._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)le.event.add(t,n,s[n][r])}a.data&&(a.data=le.extend({},a.data))}}function j(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!se.noCloneEvent&&t[le.expando]){i=le._data(t);for(r in i.events)le.removeEvent(t,r,i.handle);t.removeAttribute(le.expando)}"script"===n&&t.text!==e.text?(E(t).text=e.text,N(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),se.html5Clone&&e.innerHTML&&!le.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Me.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function D(e,t){var n,r=le(t.createElement(e)).appendTo(t.body),i=o.getDefaultComputedStyle&&(n=o.getDefaultComputedStyle(r[0]))?n.display:le.css(r[0],"display");return r.detach(),i}function A(e){var t=xe,n=rt[e];return n||(n=D(e,t),"none"!==n&&n||(nt=(nt||le("