toggle-button
Advanced tools
+1
| node_modules/.bin/beefy $1 --live |
+15
-12
@@ -0,2 +1,5 @@ | ||
| "use strict"; | ||
| var domready = require('domready'); | ||
| var idCounter = 0; | ||
@@ -13,3 +16,4 @@ module.exports = function(cb, options) { | ||
| var hasWidth = typeof options.width === 'number', | ||
| hasHeight = typeof options.height === 'number'; | ||
| hasHeight = typeof options.height === 'number', | ||
| buttonId; | ||
@@ -19,14 +23,13 @@ if (typeof options.id === 'string') | ||
| else | ||
| buttonId = 'toggleButton'; | ||
| buttonId = 'toggleButton' + idCounter++; | ||
| buttonWidth = hasWidth ? options.width : window.innerWidth; | ||
| buttonHeight = hasHeight ? options.height : window.innerHeight; | ||
| startedCaption = options.startedCaption || 'Stop'; | ||
| stoppedCaption = options.stoppedCaption ||'Start'; | ||
| var buttonWidth = hasWidth ? options.width : window.innerWidth; | ||
| var buttonHeight = hasHeight ? options.height : window.innerHeight; | ||
| var startedCaption = options.startedCaption || 'Stop'; | ||
| var stoppedCaption = options.stoppedCaption ||'Start'; | ||
| var toTop, toRight, toBottom, toLeft; | ||
| toTop = parseInt(options.toTop); | ||
| toRight = parseInt(options.toRight); | ||
| toBottom = parseInt(options.toBottom); | ||
| toLeft = parseInt(options.toLeft); | ||
| var toTop = parseInt(options.toTop); | ||
| var toRight = parseInt(options.toRight); | ||
| var toBottom = parseInt(options.toBottom); | ||
| var toLeft = parseInt(options.toLeft); | ||
@@ -90,3 +93,3 @@ domready(function() { | ||
| var stateToCaption = function(curr) { | ||
| button.innerText = curr ? stoppedCaption : startedCaption; | ||
| button.innerHTML = curr ? stoppedCaption : startedCaption; | ||
| }; | ||
@@ -93,0 +96,0 @@ stateToCaption(stopped); |
+7
-2
| { | ||
| "name": "toggle-button", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "description": "A toggle button for simple web demos", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "start": "./start.sh" | ||
| }, | ||
@@ -28,3 +29,7 @@ "repository": { | ||
| "domready": "^1.0.7" | ||
| }, | ||
| "devDependencies": { | ||
| "beefy": "^2.1.3", | ||
| "browserify": "^8.1.3" | ||
| } | ||
| } |
5386
3.72%5
25%86
2.38%2
Infinity%