Skip to content
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

Merged
merged 2 commits into from
Apr 29, 2016

Conversation

Owlbertz
Copy link
Contributor

@Owlbertz Owlbertz commented Apr 1, 2016

Slider will check for disabled state on every event now rather than only at its initialization.

Fixes #8497.

Slider will check for disabled state on every event now rather than only at its initialization.
@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2016

Thanks. Should we check the [disabled=false] case ?

@Owlbertz
Copy link
Contributor Author

Owlbertz commented Apr 1, 2016

Yeah, you're absolutely right. It only makes sense if you can also enable a disabled slider... Did another commit for this.

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2016

I mean : should we consider the slider as enabled when it has a disabled="false" or disabled="enabled" attribute ?

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2016

I don't know if this.options.disabled care about this cases, or if it is only checking that a disabled attribute has been set, regardless of its value

@Owlbertz
Copy link
Contributor Author

Owlbertz commented Apr 1, 2016

I guess you mean data-disabled, since disabled is only for inputs. The options are only initialized once based on this attribute, so for now only checking the class is possible.

@@ -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)) {
Copy link
Contributor

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 (not false) -> Disabled
  • disabled option in initialization -> Disabled
  • disabled option in initialization + disabled class or attribute (not false) -> Disabled
  • disabled option in initialization + disabled class + disabled attribute equal to false -> Enabled

Copy link
Contributor

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.

Copy link
Contributor

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

@kball
Copy link
Contributor

kball commented Apr 1, 2016

@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!

@kball
Copy link
Contributor

kball commented Apr 29, 2016

Gonna move forward with this

@kball kball merged commit 13d8da4 into foundation:develop Apr 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants