Giter Site home page Giter Site logo

event-stack's Introduction

EventStack

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.

Screenshot

This Plugin is part of MooTools PowerTools!.

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

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);

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 :)

event-stack's People

Contributors

cpojer avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.