From a697f1b8540135abe4bf610e89988469b31f5718 Mon Sep 17 00:00:00 2001 From: TJ Date: Sun, 22 May 2016 15:58:36 +0530 Subject: [PATCH] fixes cursor style for disabled checkbox and radio --- scripts/material.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/scripts/material.js b/scripts/material.js index b0466f03..819152e1 100644 --- a/scripts/material.js +++ b/scripts/material.js @@ -37,15 +37,34 @@ } } + function _toggleDisabledState($element, state) { + var $target; + if ($element.hasClass('checkbox-inline') || $element.hasClass('radio-inline')) { + $target = $element; + } else { + $target = $element.closest('.checkbox').length ? $element.closest('.checkbox') : $element.closest('.radio'); + } + return $target.toggleClass('disabled', state); + } + function _toggleTypeFocus($input) { + var disabledToggleType = false; + if ($input.is($.material.options.checkboxElements) || $input.is($.material.options.radioElements)) { + disabledToggleType = true; + } $input.closest('label').hover(function () { - var $i = $(this).find('input'); - if (!$i.prop('disabled')) { // hack because the _addFormGroupFocus() wasn't identifying the property on chrome - _addFormGroupFocus($i); // need to find the input so we can check disablement - } - }, function () { - _removeFormGroupFocus($(this).find('input')); - }); + var $i = $(this).find('input'); + var isDisabled = $i.prop('disabled'); // hack because the _addFormGroupFocus() wasn't identifying the property on chrome + if (disabledToggleType) { + _toggleDisabledState($(this), isDisabled); + } + if (!isDisabled) { + _addFormGroupFocus($i); // need to find the input so we can check disablement + } + }, + function () { + _removeFormGroupFocus($(this).find('input')); + }); } function _removeFormGroupFocus(element) {