Skip to content

Commit

Permalink
Adding allowEvent option to Fx.Reveal; reworking how targets are foun…
Browse files Browse the repository at this point in the history
…d and shown/hidden.
  • Loading branch information
anutron committed Nov 1, 2011
1 parent c63a3d8 commit 29add22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Docs/Delegators/Delegator.Fx.Reveal.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ The above examples use `Fx.Reveal` to show, hide, and destroy their respective t

* target - (*string*) - a selector which will return the DOM element to show/hide. Use selectors provided by [Slick](https://github.com/mootools/slick) to select parents and sibling trees.
* targets - (*string*) - same as `target` except this will apply the effect to multiple targets (all the ones that match the selector).
* fxOptions - (*object*; optional) - a set of options to be passed to `Fx.Reveal`.
* fxOptions - (*object*; optional) - a set of options to be passed to `Fx.Reveal`.
* allowEvent - (*boolean*) if `true` the trigger does not call `event.preventDefault()` - defaults to `false`.
25 changes: 13 additions & 12 deletions Source/Delegators/Delegator.FxReveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ name: Delegator.FxReveal

triggers[action] = {
handler: function(event, link, api){
var target = link;
var targets;
if (api.get('target')){
target = link.getElement(api.get('target'));
if (!target) api.fail('could not locate target element to ' + action, link);
}
if (api.get('targets')){
target = link.getElements(api.get('targets'));
if (!target.length) api.fail('could not locate target elements to ' + action, link);
targets = new Elements(link.getElement(api.get('target')));
if (!targets) api.fail('could not locate target element to ' + action, link);
} else if (api.get('targets')){
targets = link.getElements(api.get('targets'));
if (!targets.length) api.fail('could not locate target elements to ' + action, link);
} else {
targets = new Elements(link);
}

var fxOptions = api.get('fxOptions');
if (fxOptions) target.set('reveal', fxOptions);
target.get('reveal');
if (action == 'toggleReveal') target.get('reveal').toggle();
else target[action]();
event.preventDefault();
if (fxOptions) targets.set('reveal', fxOptions);
targets.get('reveal');
if (action == 'toggleReveal') targets.get('reveal').invoke('toggle');
else targets[action]();
if (!api.getAsBoolean('allowEvent')) event.preventDefault();
}
};

Expand Down

0 comments on commit 29add22

Please sign in to comment.