-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Micky Brunetti
committed
Feb 2, 2014
0 parents
commit 8cc2f05
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#WUIButton | ||
|
||
## What it is | ||
|
||
WUIButton is a button component made for WUI. It behaves like an HTML5 button would be expected to. | ||
|
||
It can listen for various events such as tap, tapstart and tapend. | ||
This component inherits from WUIDom and utilizes WUI's buttonBehavior. | ||
|
||
## Methods | ||
|
||
WUIButton has methods that it inherits from EventEmitter and WUIDom. | ||
|
||
## enable | ||
|
||
The enable method can be called to enable tap interaction with a disabled WUI button. | ||
|
||
```javascript | ||
button.enable(); | ||
``` | ||
|
||
### disable | ||
|
||
The disable method can be called to prevent tap interaciton with a WUIButton | ||
|
||
```javascript | ||
button.disable(); | ||
``` | ||
|
||
## Events | ||
|
||
### tapstart | ||
|
||
This event occurs when the user first presses a WUIButton. | ||
|
||
### tap | ||
|
||
The tap event occurs when the user confirms a tap event by releasing the tap. | ||
|
||
### tapend | ||
|
||
The tapend event is called when the tapevent has been processed successfully. | ||
|
||
### tapcancel | ||
|
||
The tapcancel event is only called when a tapevent is canceled, and the button loses focus. | ||
|
||
### enabled | ||
|
||
The enabled event is called when a WUIButton is enabled, such as by the enable method. | ||
|
||
### disabled | ||
|
||
The disabled event is called when a WUIButton is disabled, such as by the disable method. | ||
|
||
## How to use WUIButton | ||
|
||
See the example below: | ||
|
||
```javascript | ||
var WuiButton = require('WuiButton'); | ||
var btn; | ||
|
||
form.onsubmit = function () { | ||
if (btn) { | ||
btn.destroy(); | ||
} | ||
|
||
btn = new WuiButton(form.caption.value); | ||
|
||
btn.on('tapstart', function () { | ||
// Users starts a tap event | ||
}); | ||
|
||
btn.on('tapcancel', function () { | ||
// User cancels a tap event | ||
}); | ||
|
||
btn.on('tap', function () { | ||
// Tap event is executing | ||
}); | ||
|
||
btn.on('tapend', function () { | ||
// Tap event has completed | ||
}); | ||
|
||
return false; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "WuiButton", | ||
"repo": "Wizcorp/wui-Button", | ||
"version": "0.1.0", | ||
"description": "Generic button wui component", | ||
"dependencies": { | ||
"component/inherit": "*", | ||
"Wizcorp/wui-Dom": "0.1.0", | ||
"Wizcorp/wui-buttonBehavior": "0.1.0" | ||
}, | ||
"styles": [ | ||
"styles.css" | ||
], | ||
"scripts": [ | ||
"index.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var inherit = require('inherit'); | ||
var Dom = require('WuiDom'); | ||
var buttonBehavior = require('wuiButtonBehavior'); | ||
|
||
/** | ||
* @param {String} caption | ||
* @class | ||
* @classDesc Generic button for Wui | ||
* @augments WuiDom | ||
*/ | ||
function WuiButton(caption) { | ||
Dom.call(this); | ||
this.assign('div', { className: 'WuiButton', text: caption }); | ||
buttonBehavior(this); | ||
} | ||
|
||
inherit(WuiButton, Dom); | ||
module.exports = WuiButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.WuiButton { | ||
width: 250px; | ||
height: 40px; | ||
line-height: 40px; | ||
font-size: 16px; | ||
text-align: center; | ||
border-radius: 8px; | ||
border: 3px solid #000; | ||
background: #ddd; | ||
} | ||
|