From 7a18582218dbbcbff4e3d6886073a3deb5fe3850 Mon Sep 17 00:00:00 2001 From: jcowley Date: Sat, 4 Jun 2016 07:26:45 -0700 Subject: [PATCH] Allow setting disabled attribute on active-link --- README.md | 16 ++++++++++++++++ addon/mixins/active-link.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e68b4ab..a3759a1 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ There are several options available to adjust functionality: | linkSelector | 'a.ember-view' | jQuery selector for child `{{link-to}}`'s | | activeClass | _Computed_** | Class name to apply when any child `{{link-to}}` is also active | | disabledClass | _Computed_** | Class name to apply when ALL child `{{link-to}}`'s are disabled | +| disable | null | Boolean: ignore children and apply the disabled class | ** Default class names are pulled from the child `{{link-to}}`, which in turn defaults to 'active'. You can change it on either @@ -102,6 +103,21 @@ even if child `{{link-to}}`'s are active/disabled. ``` +The the parent element can be forcibly disabled +by passing a boolean `true` for disabled. + +```hbs +{{#active-link disabled=true}} + {{link-to "Index" "index"}} +{{/active-link}} +``` + +```html +
  • + Index +
  • +``` + If the child `{{link-to}}`'s have their `tagName` changed, be sure to adjust the selector. Always include the `.ember-view` class since all link-to's apply that class. diff --git a/addon/mixins/active-link.js b/addon/mixins/active-link.js index 6a2c2a1..f6b2e27 100644 --- a/addon/mixins/active-link.js +++ b/addon/mixins/active-link.js @@ -61,7 +61,7 @@ export default Ember.Mixin.create({ }), _disabled: Ember.computed('allLinksDisabled', 'disabledClass', function(){ - return (this.get('allLinksDisabled') ? this.get('disabledClass') : false); + return (this.get('disabled') || this.get('allLinksDisabled') ? this.get('disabledClass') : false); }) });