From db80db6d0bbae3333d367fbc1312dd73629bb6e6 Mon Sep 17 00:00:00 2001 From: netniV Date: Mon, 12 Nov 2018 16:27:23 +0000 Subject: [PATCH] Make radio buttons look nicer, inline with checkboxes --- include/themes/dark/main.css | 81 +++++++++++++++++++ include/themes/dark/main.js | 1 - include/themes/modern/main.css | 79 +++++++++++++++++++ include/themes/modern/main.js | 1 - include/themes/paper-plane/main.css | 75 ++++++++++++++++++ include/themes/paw/main.css | 75 ++++++++++++++++++ include/themes/sunrise/main.css | 117 ++++++++++++++++++++-------- lib/html_form.php | 10 ++- 8 files changed, 404 insertions(+), 35 deletions(-) diff --git a/include/themes/dark/main.css b/include/themes/dark/main.css index 633d119c85..4f3f58def3 100644 --- a/include/themes/dark/main.css +++ b/include/themes/dark/main.css @@ -2364,3 +2364,84 @@ input:checked + .checkboxSlider:before { .center { text-align: center; } + +.radioSwitch { + position: relative; + display: inline-block; + margin-left: 5px; + margin-right: 5px; + vertical-align: middle; +} + +.radioSwitch input { + /* display:none; */ +} + +.radioSlider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + height: 24px; + width: 24px; + background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6+ */ + background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #45484d 0%,#000000 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #45484d 0%,#000000 100%); /* IE10+ */ + -webkit-transition: .4s; + transition: .4s; +} + +.radioSlider:before { + display: none; + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + background-image: url('./images/cacti_logo.svg'); + background-repeat: no-repeat; + background-size: 7px; + background-position: center; /*left 5px;*/ + -webkit-transition: .4s; + transition: .4s; +} + +input:disabled + .radioSlider { + cursor: not-allowed; +} + +input:checked + .radioSlider { + background: #31442b url("images/ui-bg_highlight-hard_20_31442b_1x100.png") repeat-x scroll 50% 50%; +} + +input:focus + .radioSlider { + box-shadow: -moz-linear-gradient(top, #45484d 100%, #000000 100%); /* FF3.6+ */ + box-shadow: -webkit-linear-gradient(top, #45484d 100%,#000000 100%); /* Chrome10+,Safari5.1+ */ + box-shadow: -o-linear-gradient(top, #45484d 100%,#000000 100%); /* Opera 11.10+ */ + box-shadow: -ms-linear-gradient(top, #45484d 100%,#000000 100%); /* IE10+ */ +} + +input:checked + .radioSlider:before { + display: block; +} + +/* Rounded.radioSliders */ +.radioSlider.radioRound { + border-radius: 24px; +} + +.radioSlider.radioRound:before { + border-radius: 50%; +} + +.radioLabelWanted { + display: inline-block; + margin-left: 5px; + margin-right: 10px; + vertical-align: middle; +} diff --git a/include/themes/dark/main.js b/include/themes/dark/main.js index 2079f68910..d9cacbbc6f 100644 --- a/include/themes/dark/main.js +++ b/include/themes/dark/main.js @@ -10,7 +10,6 @@ function themeReady() { $('#navigation').css('height', ($(window).height()-80)+'px'); $('#navigation_right').css('height', ($(window).height()-80)+'px'); $('.formItemDescription').hide(); - $('input[type="radio"]').button(); keepWindowSize(); diff --git a/include/themes/modern/main.css b/include/themes/modern/main.css index 4af7e33c75..919cd79dad 100644 --- a/include/themes/modern/main.css +++ b/include/themes/modern/main.css @@ -2491,3 +2491,82 @@ input:checked + .checkboxSlider:before { .center { text-align: center; } + +.radioSwitch { + position: relative; + display: inline-block; + margin-left: 5px; + margin-right: 5px; + vertical-align: middle; +} + +.radioSwitch input { + /* display:none; */ +} + +.radioSlider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + height: 24px; + width: 24px; + background-color: rgba(98,125,77,1); + -webkit-transition: .4s; + transition: .4s; +} + +.radioSlider:before { + display: none; + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + background-image: url('./images/cacti_logo.svg'); + background-repeat: no-repeat; + background-size: 7px; + background-position: center; /*left 5px;*/ + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .radioSlider { + background-color: rgba(167,217,134,1); +} + +input:checked + .radioSlider:before { + display: inline-block; +} + +input:disabled + .radioSlider { + cursor: not-allowed; +} + +input:focus + .radioSlider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .radioSlider:before { + display: block; +} + +/* Rounded.radioSliders */ +.radioSlider.radioRound { + border-radius: 24px; +} + +.radioSlider.radioRound:before { + border-radius: 50%; +} + +.radioLabelWanted { + display: inline-block; + margin-left: 5px; + margin-right: 10px; + vertical-align: middle; +} diff --git a/include/themes/modern/main.js b/include/themes/modern/main.js index 3ea70329fe..55b10550be 100644 --- a/include/themes/modern/main.js +++ b/include/themes/modern/main.js @@ -9,7 +9,6 @@ function themeReady() { $('body').css('height', $(window).height()); $('#navigation').css('height', ($(window).height()-40)+'px'); $('#navigation_right').css('height', ($(window).height()-40)+'px'); - $('input[type="radio"]').button(); keepWindowSize(); diff --git a/include/themes/paper-plane/main.css b/include/themes/paper-plane/main.css index 00b0ab9c01..1d1cd874f2 100644 --- a/include/themes/paper-plane/main.css +++ b/include/themes/paper-plane/main.css @@ -2389,3 +2389,78 @@ input:checked + .checkboxSlider:before { .center { text-align: center; } + +.radioSwitch { + position: relative; + display: inline-block; + margin-left: 5px; + margin-right: 5px; + vertical-align: middle; +} + +.radioSwitch input { + /* display:none; */ +} + +.radioSlider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + width: 24px; + height: 24px; + background-color: #aaa; + -webkit-transition: .4s; + transition: .4s; +} + +.radioSlider:before { + display: none; + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + background-image: url('./images/cacti_logo.svg'); + background-repeat: no-repeat; + background-size: 7px; + background-position: center; /*left 5px;*/ + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .radioSlider { + background-color: #3a3b3c; +} + +input:disabled + .radioSlider { + cursor: not-allowed; +} + +input:focus + .radioSlider { + box-shadow: 0 0 1px #3a3b3c; +} + +input:checked + .radioSlider:before { + display: inline-block; +} + +/* Rounded.radioSliders */ +.radioSlider.radioRound { + border-radius: 24px; +} + +.radioSlider.radioRound:before { + border-radius: 50%; +} + +.radioLabelWanted { + display: inline-block; + margin-left: 5px; + margin-right: 10px; + vertical-align: middle; +} diff --git a/include/themes/paw/main.css b/include/themes/paw/main.css index 1ef493308e..f46809f3be 100644 --- a/include/themes/paw/main.css +++ b/include/themes/paw/main.css @@ -2183,3 +2183,78 @@ input:checked + .checkboxSlider:before { .center { text-align: center; } + +.radioSwitch { + position: relative; + display: inline-block; + margin-left: 5px; + margin-right: 5px; + vertical-align: middle; +} + +.radioSwitch input { + /* display:none; */ +} + +.radioSlider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + height: 24px; + width: 24px; + background-color: rgba(0, 0, 0, 0.55); + -webkit-transition: .4s; + transition: .4s; +} + +.radioSlider:before { + display:none; + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + background-image: url('./images/cacti_logo.svg'); + background-repeat: no-repeat; + background-size: 7px; + background-position: center; /*left 5px;*/ + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .radioSlider { + background-color: rgba(0,0,0,0.9); +} + +input:disabled + .radioSlider { + cursor: not-allowed; +} + +input:focus + .radioSlider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .radioSlider:before { + display: block; +} + +/* Rounded.radioSliders */ +.radioSlider.radioRound { + border-radius: 24px; +} + +.radioSlider.radioRound:before { + border-radius: 50%; +} + +.radioLabelWanted { + display: inline-block; + margin-left: 5px; + margin-right: 10px; + vertical-align: middle; +} diff --git a/include/themes/sunrise/main.css b/include/themes/sunrise/main.css index 144003ab01..2b342faa45 100644 --- a/include/themes/sunrise/main.css +++ b/include/themes/sunrise/main.css @@ -125,9 +125,6 @@ input, select { } input[type="checkbox"]:not([name^="multiselect"]), -input[type="radio"]:not([name^="reindex"]) { - display: none; -} label { cursor: pointer; @@ -161,34 +158,6 @@ input[type="checkbox"]:checked + label:before { } input[type="checkbox"]:checked + label, -input[type="radio"]:not([name^="reindex"]):checked + label { - color: #FFFFFF; -} - -input[type="radio"]:not([name^="reindex"]) + label:before { - border: 1px solid #7f83a2; - border-radius: 10px; - content: "\00a0"; - display: inline-block; - font: 10px/1em sans-serif; - height: 12px; - margin: .25em .25em 0 0; - vertical-align:text-bottom; - width: 12px; - background: transparent; -} - -input[type="radio"]:not([name^="reindex"]):checked + label:before { - background: #FFFFFF; - box-shadow: 0 0 0 3px #3C8A3C inset; - border: 1px solid #7f83a2; - text-align: center; - font-weight: bold; -} - -input[type="radio"]:not([name^="reindex"]) + label.ui-state-hover:before { - border: 1px solid #FFFFFF; -} label { white-space:nowrap; @@ -2559,3 +2528,89 @@ input:checked + .checkboxSlider:before { .center { text-align: center; } + +.radioSwitch { + position: relative; + display: inline-block; + margin-left: 5px; + margin-right: 5px; + vertical-align: middle; +} + +.radioSwitch input { + /* display:none; */ +} + +.radioSlider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + width: 24px; + height: 24px; + background-color: #FFAA00; + -webkit-transition: .4s; + transition: .4s; + + border: 1px solid #7f83a2; + background-image: -webkit-radial-gradient(50% 50%, ellipse cover, #000000 1%, #04335b 35%, #000000 65%); + background-image: -moz-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: -o-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: -ms-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); +} + +.radioSlider:before { + display: none; + position: absolute; + content: ""; + height: 16px; + width: 16px; + left: 4px; + bottom: 4px; + background-color: white; + background-image: url('./images/cacti_logo.svg'); + background-repeat: no-repeat; + background-size: 7px; + background-position: center; /*left 5px;*/ + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .radioSlider { + background-image: -webkit-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: -moz-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: -o-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: -ms-radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); + background-image: radial-gradient(50% 50%, ellipse cover, #ffa254 1%, #04335b 35%, #000000 65%); +} + +input:focus + .radioSlider { + box-shadow: 0 0 1px #2196F3; +} + +input:disabled + .radioSlider { + cursor: not-allowed; +} + +input:checked + .radioSlider:before { + display: block; +} + +/* Rounded.radioSliders */ +.radioSlider.radioRound { + border-radius: 24px; +} + +.radioSlider.radioRound:before { + border-radius: 50%; +} + +.radioLabelWanted { + display: inline-block; + margin-left: 5px; + margin-right: 10px; + vertical-align: middle; +} diff --git a/lib/html_form.php b/lib/html_form.php index 033a9bdac9..f8c7c57cbf 100644 --- a/lib/html_form.php +++ b/lib/html_form.php @@ -907,7 +907,7 @@ function form_radio_button($form_name, $form_previous_value, $form_current_value } if ($class != '') { - $class = " class='$class' "; + $class = " $class"; } if ($on_change != '') { @@ -922,7 +922,13 @@ function form_radio_button($form_name, $form_previous_value, $form_current_value $css_id = $form_name . '_' . $form_current_value; - print "\n"; + + print ""; + print ""; + print ""; + print ""; } /* form_text_area - draws a standard html text area box