Skip to content

Commit

Permalink
* First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Micky Brunetti committed Feb 2, 2014
0 parents commit 8cc2f05
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
89 changes: 89 additions & 0 deletions README.md
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;
};
```
17 changes: 17 additions & 0 deletions component.json
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"
]
}
18 changes: 18 additions & 0 deletions index.js
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;
11 changes: 11 additions & 0 deletions styles.css
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;
}

0 comments on commit 8cc2f05

Please sign in to comment.