From 17ec9aa170fee176209a0dcb327145d9b19a4f20 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 24 Sep 2019 09:39:06 -0500 Subject: [PATCH] Fixes: #3464 - Change color picker to dynamic coloring from static CSS --- netbox/project-static/css/base.css | 110 ------------------ netbox/project-static/js/forms.js | 7 +- .../templates/widgets/colorselect_option.html | 3 +- 3 files changed, 4 insertions(+), 116 deletions(-) diff --git a/netbox/project-static/css/base.css b/netbox/project-static/css/base.css index 24cf9a9ea..d37a2106e 100644 --- a/netbox/project-static/css/base.css +++ b/netbox/project-static/css/base.css @@ -133,116 +133,6 @@ input[name="pk"] { margin-top: 0; } -/* Color Selections */ -.color-selection-aa1409 { - background-color: #aa1409; - color: #ffffff; -} -.color-selection-f44336 { - background-color: #f44336; - color: #ffffff; -} -.color-selection-e91e63 { - background-color: #e91e63; - color: #ffffff; -} -.color-selection-ffe4e1 { - background-color: #ffe4e1; - color: #000000; -} -.color-selection-ff66ff { - background-color: #ff66ff; - color: #ffffff; -} -.color-selection-9c27b0 { - background-color: #9c27b0; - color: #ffffff; -} -.color-selection-673ab7 { - background-color: #673ab7; - color: #ffffff; -} -.color-selection-3f51b5 { - background-color: #3f51b5; - color: #ffffff; -} -.color-selection-2196f3 { - background-color: #2196f3; - color: #ffffff; -} -.color-selection-03a9f4 { - background-color: #03a9f4; - color: #ffffff; -} -.color-selection-00bcd4 { - background-color: #00bcd4; - color: #ffffff; -} -.color-selection-009688 { - background-color: #009688; - color: #ffffff; -} -.color-selection-00ffff { - background-color: #00ffff; - color: #ffffff; -} -.color-selection-2f6a31 { - background-color: #2f6a31; - color: #ffffff; -} -.color-selection-4caf50 { - background-color: #4caf50; - color: #ffffff; -} -.color-selection-8bc34a { - background-color: #8bc34a; - color: #ffffff; -} -.color-selection-cddc39 { - background-color: #cddc39; - color: #000000; -} -.color-selection-ffeb3b { - background-color: #ffeb3b; - color: #000000; -} -.color-selection-ffc107 { - background-color: #ffc107; - color: #000000; -} -.color-selection-ff9800 { - background-color: #ff9800; - color: #ffffff; -} -.color-selection-ff5722 { - background-color: #ff5722; - color: #ffffff; -} -.color-selection-795548 { - background-color: #795548; - color: #ffffff; -} -.color-selection-c0c0c0 { - background-color: #c0c0c0; - color: #000000; -} -.color-selection-9e9e9e { - background-color: #9e9e9e; - color: #ffffff; -} -.color-selection-607d8b { - background-color: #607d8b; - color: #ffffff; -} -.color-selection-111111 { - background-color: #111111; - color: #ffffff; -} -.color-selection-ffffff { - background-color: #ffffff; - color: #000000; -} - /* Tables */ th.pk, td.pk { diff --git a/netbox/project-static/js/forms.js b/netbox/project-static/js/forms.js index 4e50095ef..0c5bc2a2e 100644 --- a/netbox/project-static/js/forms.js +++ b/netbox/project-static/js/forms.js @@ -91,11 +91,8 @@ $(document).ready(function() { // Assign color picker selection classes function colorPickerClassCopy(data, container) { if (data.element) { - // Remove any existing color-selection classes - $(container).attr('class', function(i, c) { - return c.replace(/(^|\s)color-selection-\S+/g, ''); - }); - $(container).addClass($(data.element).attr("class")); + // Swap the style + $(container).attr('style', $(data.element).attr("style")); } return data.text; } diff --git a/netbox/utilities/templates/widgets/colorselect_option.html b/netbox/utilities/templates/widgets/colorselect_option.html index a0e488f18..db40173de 100644 --- a/netbox/utilities/templates/widgets/colorselect_option.html +++ b/netbox/utilities/templates/widgets/colorselect_option.html @@ -1 +1,2 @@ - +{% load helpers %} +