EventStack 1.0.5
Helps you Escape. Provides a stack that gets popped every time a certain condition, determined usually by a keyboard event, gets fulfilled. Imagine different widgets overlaying your page and on escape the widget currently on top should be removed.
This Plugin is part of MooTools PowerTools!.
Details
- Author
- Christoph Pojer
- Current version
- 1.0.5
- GitHub
- cpojer/event-stack
- Downloads
- 816
- Category
- Utilities
- Tags
- Report
- GitHub Issues
Releases
Dependencies
-
_self_/_current_:
- EventStack
- Core/Class.Extras
- Core/Element.Event
- Class-Extras/Class.Binds
How to use
This plugin provides an EventStack Class.
var EscapeStack = new EventStack; // The default options pop the stack when the user presses 'esc'
EscapeStack.push(closeMyWidget); // MyWidget will be closed when the user presses 'esc'
// Now if MyWidget spawns another widget on top of MyWidget you can push the close handler too
MyWidget.openAnotherWidget = function(){
EscapeStack.push(closeMyOtherWidget);
openAnotherWidget();
};
// Now pressing the 'esc'-Button once closes 'AnotherWidget', pressing it again closes 'MyWidget'
If your widget has other ways of closing it (like an 'X'-Button) you should remove the close-handler from the stack.
EscapeStack.erase(closeMyWidget);
Build
Build via Packager, requires MooTools Core and MooTools Class-Extras to be registered to Packager already
packager register /path/to/event-stack packager build EventStack/* > event-stack.js
To build this plugin without external dependencies use
packager build EventStack/* +use-only EventStack > event-stack.js
Demo
See Demos/index.html
Options
- event - (defaults to keyup) The event to be used
- condition - Function to be used to determine whether to pop the stack. Defaults to pressing the ESC-Button.
Plugins
An OuterClick-stack can be used to close widgets if the user clicks outside of them.
Create an OuterClickStack:
var OuterClickStack = new EventStack.OuterClick;
Usage:
OuterClickStack.push(fn, element); // Note the second argument, it allows you to associate any value with the pushed stack function
Notes
It's not a real stack :)
Discuss
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus