nathanaelsousa / myActions

A different approach to clicks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

myActions

A tool to help you respond to clicks in a easy way.

Example:

<body>
	<h1>Title</h1>
	<button data-act="turn">Turn me red</button>
	<button data-act="show" data-secret="42">
		Show my secret
	</button>
</body>
myActions.add({
	'turn' (dataset, target) {
		target.style.color = "red"
	},
	'show' (dataset) {
		alert(dataset.secret)
	}
})

myActions.add(args) A method for adding actions. It accepts a single key-function pair or an object with several pairs.
  args:(key, function)
    The key is a string representing the data-act="key" attribute and function is the function to be executed for that action.
  args:({key: function})
    An object where the property names must be the keys and the property values must be the functions.


myActions.remove(args) A method for removing actions. It accepts a single key or an object with several keys.
  args:(key)
    The key for the action that you want to remove.
  args:({key})
    An object with all the keys that you want to remove. Tip: you can use the same object provided to myActions.add(actionsObj)

About

A different approach to clicks.

License:MIT License


Languages

Language:JavaScript 92.0%Language:HTML 8.0%