From 6ecac7e5e14ce796719c6b8aa5d2c1b0f2488c4a Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 25 Apr 2016 22:28:41 +0530 Subject: [PATCH] adds inline radio support --- less/_radios.less | 112 +++++++++++++++++++++----------------------- scripts/material.js | 2 +- 2 files changed, 55 insertions(+), 59 deletions(-) diff --git a/less/_radios.less b/less/_radios.less index 3ed73752..b8b18581 100644 --- a/less/_radios.less +++ b/less/_radios.less @@ -1,75 +1,73 @@ -.radio-color(@color, @opacity){ +.radio-color(@color, @opacity) { & ~ .check, & ~ .circle { opacity: @opacity; } - & ~ .check { background-color: @color; } - & ~ .circle { border-color: @color; } } -.radio { - label { - cursor: pointer; - padding-left: 45px; - position: relative; - color: @mdb-radio-label-color; - .mdb-label-color-toggle-focus(); - - span { - display: block; - position: absolute; - left: 10px; - top: 2px; - transition-duration: 0.2s; - } - .circle { - border: 2px solid @mdb-radio-color-off; - height: 15px; - width: 15px; - border-radius: 100%; - } - .check { - height: 15px; - width: 15px; - border-radius: 100%; - background-color: @mdb-radio-color-on; - transform: scale3d(0, 0, 0); - } - .check:after { - display: block; - position: absolute; - content: ""; - background-color: @mdb-text-color-primary; - left: -18px; - top: -18px; - height: 50px; - width: 50px; - border-radius: 100%; - z-index: 1; - opacity: 0; - margin: 0; - transform: scale3d(1.5, 1.5, 1); - } - input[type=radio]:not(:checked) ~ .check:after { - animation: rippleOff 500ms; - } - input[type=radio]:checked ~ .check:after { - animation: rippleOn; - } +.radio label, +label.radio-inline { + cursor: pointer; + padding-left: 45px; + position: relative; + color: @mdb-radio-label-color; + .mdb-label-color-toggle-focus(); + span { + display: block; + position: absolute; + left: 10px; + top: 2px; + transition-duration: 0.2s; } + .circle { + border: 2px solid @mdb-radio-color-off; + height: 15px; + width: 15px; + border-radius: 100%; + } + .check { + height: 15px; + width: 15px; + border-radius: 100%; + background-color: @mdb-radio-color-on; + transform: scale3d(0, 0, 0); + } + .check:after { + display: block; + position: absolute; + content: ""; + background-color: @mdb-text-color-primary; + left: -18px; + top: -18px; + height: 50px; + width: 50px; + border-radius: 100%; + z-index: 1; + opacity: 0; + margin: 0; + transform: scale3d(1.5, 1.5, 1); + } + input[type=radio]:not(:checked) ~ .check:after { + animation: rippleOff 500ms; + } + input[type=radio]:checked ~ .check:after { + animation: rippleOn; + } +} +.radio, +.radio-inline { input[type=radio] { opacity: 0; height: 0; width: 0; overflow: hidden; - &:checked { .radio-color(@mdb-radio-color-on, 1); } @@ -77,12 +75,9 @@ transform: scale3d(0.55, 0.55, 1); } } - input[type=radio][disabled] { - // light theme spec: Disabled: #000000, Opacity 26% .radio-color(@black, 0.26); - // dark theme spec: Disabled: #FFFFFF, Opacity 30% .theme-dark & { .radio-color(@white, 0.30); @@ -92,7 +87,8 @@ // Prevent ripple effect on page load .is-focused { - .radio { + .radio, + .radio-inline { input[type=radio]:checked ~ .check:after { animation: rippleOn 500ms; } @@ -121,4 +117,4 @@ 100% { opacity: 0; } -} +} \ No newline at end of file diff --git a/scripts/material.js b/scripts/material.js index 9655f7d9..89ff1e86 100644 --- a/scripts/material.js +++ b/scripts/material.js @@ -72,7 +72,7 @@ "inputElements": "input.form-control, textarea.form-control, select.form-control", "checkboxElements": ".checkbox > label > input[type=checkbox], label.checkbox-inline > input[type=checkbox]", "togglebuttonElements": ".togglebutton > label > input[type=checkbox]", - "radioElements": ".radio > label > input[type=radio]" + "radioElements": ".radio > label > input[type=radio],label.radio-inline > input[type=radio]" }, "checkbox": function (selector) { // Add fake-checkbox to material checkboxes