Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobbubu/toggle-button
A toggle button for simple web demos
https://github.com/jacobbubu/toggle-button
Last synced: 14 days ago
JSON representation
A toggle button for simple web demos
- Host: GitHub
- URL: https://github.com/jacobbubu/toggle-button
- Owner: jacobbubu
- Created: 2015-01-19T10:20:58.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-11T13:49:35.000Z (almost 10 years ago)
- Last Synced: 2024-12-14T01:13:25.278Z (about 1 month ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# toggle-button
This module provides a very simple toggled button for your demos and prototypes up and running.Ideal for use with Beefy.
# api
```js
toggleButton([onClick], [options])
````[onClick]` receives 2 parameters:
1. button: a DOM element for the toggled button.
2. stopped: current status, `true` or `false`.Example:
```js
var toggleButton = require('toggle-button');toggleButton(function(button, stopped) {
console.log('stopped', stopped);
});
```with options:
```js
toggleButton(function(button, stopped){
console.log('stopped', stopped);
}, {
toBottom: 10,
toRight: 10,
width: 100,
height: 100,
startedCaption: 'Running Now',
stoppedCaption: 'Waiting Now'
});
```and you can inject your own buttom element:
```js
domready(function() {
var button = document.createElement('button');
button.type = 'button';
document.body.appendChild(button);toggleButton(function(button, stopped){
console.log('stopped', stopped);
}, {
button: button
});
});
```# testing with beefy
First install beefy:
```npm i beefy -g```
Then run the demo:
```beefy demo/demo.js --live```
And open up `localhost:9966` in your browser.