-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to disable slider after initialization. #8503
Conversation
Slider will check for disabled state on every event now rather than only at its initialization.
Thanks. Should we check the |
Yeah, you're absolutely right. It only makes sense if you can also enable a disabled slider... Did another commit for this. |
I mean : should we consider the slider as enabled when it has a |
I don't know if |
I guess you mean |
@@ -106,7 +106,11 @@ class Slider { | |||
* @fires Slider#changed | |||
*/ | |||
_setHandlePos($hndl, location, noInvert, cb) { | |||
//might need to alter that slightly for bars that will have odd number selections. | |||
// don't move if the slider has been disabled since its initialization | |||
if (this.$element.hasClass(this.options.disabledClass)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var disabledAttr = this.$element.data('disabled');
var disabledClass = this.$element.hasClass(this.options.disabledClass);
if ((disabledClass || disabledAttr) && !(disabledAttr && disabledAttr == "false")) {
So :
disabled
class or attribute (notfalse
) -> Disableddisabled
option in initialization -> Disableddisabled
option in initialization +disabled
class or attribute (notfalse
) -> Disableddisabled
option in initialization +disabled
class +disabled
attribute equal tofalse
-> Enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer there be a single source of truth, and it looks like we're currently using the class as the way to do that. @ncoden did you see someplace in particular that is setting data-disabled? I'm not seeing that mechanism being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kball this.options
.enabled
is initialized with $element.data
.enabled
@Owlbertz this looks good. Can you set up a unit test for this case in test/javascript/components/slider.js? You can use the tests in test/javascript/components/toggler.js as an example of how these can be structures. See: https://github.com/zurb/foundation-sites/blob/develop/test/javascript/components/toggler.js Thanks! |
Gonna move forward with this |
Slider will check for disabled state on every event now rather than only at its initialization.
Fixes #8497.