Skip to content

Commit

Permalink
Allow addRemoveClass delegator to target multiple elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
anutron committed Aug 31, 2013
1 parent f9b4a56 commit 00f8a75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Docs/Delegators/Delegators.AddRemoveClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Toggles a Class on a specified element.
### Options

* target - (*string*; optional) A selector for the element you wish to toggle the class. If not specified will change the class on the element itself.
* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set.
* class - (*string*; **required**) The class you wish to toggle.

Delegator Trigger: addClass
Expand All @@ -39,6 +40,7 @@ Adds a Class to a specified element.
### Options

* target - (*string*; optional) A selector for the element you to which to add the class. If not specified will change the class on the element itself.
* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set.
* class - (*string*; **required**) The class you wish to add.

Delegator Trigger: removeClass
Expand All @@ -58,4 +60,5 @@ Removes a Class from a specified element.
### Options

* target - (*string*; optional) A selector for the element you from which to remove the class. If not specified will change the class on the element itself.
* targets - (*string*; optional) A selector that returns multiple elements you wish to alter. Ignored if `target` is set.
* class - (*string*; **required**) The class you wish to remove.
8 changes: 4 additions & 4 deletions Source/Delegators/Delegator.AddRemoveClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ name: Delegator.AddRemoveClass
require: ['class'],
handler: function(event, link, api){
var target = link;
if (api.get('target')) {
target = link.getElement(api.get('target'));
if (!target) api.fail('could not locate target element to ' + action + ' its class', link);
}

if (api.get('target')) target = api.getElements('target')
else if (api.get('targets')) target = api.getElements('targets');

target[action + 'Class'](api.get('class'));
}
};
Expand Down

0 comments on commit 00f8a75

Please sign in to comment.