mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 16:47:37 -04:00
Merge remote-tracking branch 'origin/master' into #13/fix-checkboxgroups-return-value
# Conflicts: # test/spec/lib/manipulators.js
This commit is contained in:
@@ -108,7 +108,7 @@ Sections help divide up the page into logical groups of items. It is recommended
|
||||
|
||||
### Heading
|
||||
|
||||
**Manipulator:** `html`
|
||||
**Manipulator:** [`html`](#html)
|
||||
|
||||
Headings can be used in anywhere and can have their size adjusted to suit the context. If you place a heading item at the first position of a section's `items` array then it will automatically be styled as the header for that section.
|
||||
|
||||
@@ -138,7 +138,7 @@ Headings can be used in anywhere and can have their size adjusted to suit the co
|
||||
|
||||
### Text
|
||||
|
||||
**Manipulator:** `html`
|
||||
**Manipulator:** [`html`](#html)
|
||||
|
||||
Text is used to provide descriptions of sections or to explain complex parts of your page. Feel free to add any extra HTML you require to the `defaultValue`
|
||||
|
||||
@@ -165,7 +165,7 @@ Text is used to provide descriptions of sections or to explain complex parts of
|
||||
|
||||
### Input
|
||||
|
||||
**Manipulator:** `val`
|
||||
**Manipulator:** [`val`](#val)
|
||||
|
||||
Standard text input field.
|
||||
|
||||
@@ -203,7 +203,7 @@ Standard text input field.
|
||||
|
||||
#### Toggle
|
||||
|
||||
**Manipulator:** `checked`
|
||||
**Manipulator:** [`checked`](#checked)
|
||||
|
||||
Switch for a single item.
|
||||
|
||||
@@ -238,7 +238,7 @@ Switch for a single item.
|
||||
|
||||
#### Select
|
||||
|
||||
**Manipulator:** `val`
|
||||
**Manipulator:** [`val`](#val)
|
||||
|
||||
A dropdown menu containing multiple options.
|
||||
|
||||
@@ -291,7 +291,7 @@ A dropdown menu containing multiple options.
|
||||
|
||||
#### Color
|
||||
|
||||
**Manipulator:** `color`
|
||||
**Manipulator:** [`color`](#color)
|
||||
|
||||
A color picker containing the 64 supported colors on Basalt and Chalk.
|
||||
|
||||
@@ -321,9 +321,9 @@ A color picker containing the 64 supported colors on Basalt and Chalk.
|
||||
|
||||
---
|
||||
|
||||
#### RadioGroup
|
||||
#### Radio Group
|
||||
|
||||
**Manipulator:** `radiogroup`
|
||||
**Manipulator:** [`radiogroup`](#radiogroup)
|
||||
|
||||
A list of options allowing the user can only choose one option to submit.
|
||||
|
||||
@@ -366,9 +366,9 @@ A list of options allowing the user can only choose one option to submit.
|
||||
|
||||
---
|
||||
|
||||
#### CheckboxGroup
|
||||
#### Checkbox Group
|
||||
|
||||
**Manipulator:** `checkboxgroup`
|
||||
**Manipulator:** [`checkboxgroup`](#checkboxgroup)
|
||||
|
||||
A list of options where a user may choose more than one option to submit.
|
||||
|
||||
@@ -412,9 +412,35 @@ A list of options where a user may choose more than one option to submit.
|
||||
|
||||
---
|
||||
|
||||
### Generic Button
|
||||
|
||||
**Manipulator:** [`button`](#button)
|
||||
|
||||
##### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| type | string | Set to `button`. |
|
||||
| defaultValue | string | The text displayed on the button. |
|
||||
| primary | boolean | If `true` the button will be orange, if `false`, the button will be gray (defaults to `false`)|
|
||||
| attributes | object | An object containing HTML attributes to set on the input field. |
|
||||
| description | string | Optional sub-text to include below the component |
|
||||
|
||||
##### Example
|
||||
|
||||
```javascript
|
||||
{
|
||||
"type": "button",
|
||||
"primary": true,
|
||||
"defaultValue": "Send"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Submit
|
||||
|
||||
**Manipulator:** `html`
|
||||
**Manipulator:** [`button`](#button)
|
||||
|
||||
The submit button for the page. You **MUST** include this component somewhere in the config page (traditionally at the bottom) or users will not be able to save the form.
|
||||
|
||||
@@ -440,7 +466,6 @@ The submit button for the page. You **MUST** include this component somewhere in
|
||||
### Coming Soon
|
||||
|
||||
- Range Slider
|
||||
- Generic Button
|
||||
- Tabs
|
||||
- Footer
|
||||
- Dynamic + draggable list
|
||||
@@ -452,8 +477,12 @@ The submit button for the page. You **MUST** include this component somewhere in
|
||||
Each component has a **manipulator**. This is a set of methods used to talk to the item on the page.
|
||||
At a minimum, manipulators must have a `.get()` and `.set(value)` method however there are also methods to assist in interactivity such as `.hide()` and `.disable()`.
|
||||
**NOTE:** There is currently no way to disable or hide an entire section. You must disable/hide each item in the section to achieve this effect.
|
||||
|
||||
When the config page is closed, the `.get()` method is run on all components registered with an `appKey` to construct the object sent to the C app.
|
||||
Many of these methods fire an event when the method is called. You can listen for these events with `ClayItem.on()`.
|
||||
|
||||
Many of these methods fire an event when the method is called. You can listen for these events with `ClayItem.on()`.
|
||||
**NOTE** These events will only be fired if the state actually changes.
|
||||
Eg: If you run the `.show()` manipulator on an item that is already visible, the `show` event will not be triggered.
|
||||
|
||||
#### html
|
||||
|
||||
@@ -464,6 +493,17 @@ Many of these methods fire an event when the method is called. You can listen fo
|
||||
| `.hide()` | `ClayItem` | `hide` | Hides the item |
|
||||
| `.show()` | `ClayItem` | `show` | Shows the item |
|
||||
|
||||
#### button
|
||||
|
||||
| Method | Returns | Event Fired | Description |
|
||||
|--------|---------|-------------| ------------|
|
||||
| `.set( [string\|HTML] value)` | `ClayItem` | `change` | Sets the content of this item. |
|
||||
| `.get()` | `string` | | Gets the content of this item. |
|
||||
| `.disable()` | `ClayItem` | `disabled` | Prevents this item from being clicked by the user. |
|
||||
| `.enable()` | `ClayItem` | `enabled` | Allows this item to be clicked by the user. |
|
||||
| `.hide()` | `ClayItem` | `hide` | Hides the item |
|
||||
| `.show()` | `ClayItem` | `show` | Shows the item |
|
||||
|
||||
#### val
|
||||
|
||||
| Method | Returns | Event Fired | Description |
|
||||
@@ -532,15 +572,23 @@ Example:
|
||||
```javascript
|
||||
var Clay = require('./clay');
|
||||
var clayConfig = require('./config');
|
||||
var clayConfigAplite = require('./config-aplite');
|
||||
var clay = new Clay(clayConfig, null, { autoHandleEvents: false });
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function(e) {
|
||||
|
||||
// This is an example of how you might load a different config based on platform.
|
||||
var platform = clay.meta.activeWatchInfo.platform || 'aplite';
|
||||
if (platform === 'aplite') {
|
||||
clay.config = clayConfigAplite;
|
||||
}
|
||||
|
||||
Pebble.openURL(clay.generateUrl());
|
||||
});
|
||||
|
||||
Pebble.addEventListener('webviewclosed', function(e) {
|
||||
if (e && !e.response) {
|
||||
return;
|
||||
if (e && !e.response) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the keys and values from each config item
|
||||
@@ -558,6 +606,17 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||
|
||||
### `Clay([Array] config, [function] customFn, [object] options)`
|
||||
|
||||
#### Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `.config` | Array | Reference to the config passed to the constructor and used for generating the page. **WARNING** this is a direct reference, not a copy of the config so any modification you make to it, will be reflected on the original as well |
|
||||
| `.customFn` | Function | Reference to the custom function passed to the constructor. **WARNING** this is a direct reference, not a copy of the custom function so any modification you make to it, will be reflected on the original as well |
|
||||
| `.meta` | Object | Contains information about the current user and watch. **WARNING** This will only be populated in the `showConfiguration` event handler. (See example above) |
|
||||
| `.meta.activeWatchInfo` | watchinfo\|null | An object containing information on the currently connected Pebble smartwatch or null if unavailable. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getActiveWatchInfo). |
|
||||
| `.meta.accountToken` | String | A unique account token that is associated with the Pebble account of the current user. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getAccountToken). |
|
||||
| `.meta.watchToken` | String | A unique token that can be used to identify a Pebble device. Read more [here](https://developer.pebble.com/docs/js/Pebble/#getWatchToken). |
|
||||
|
||||
#### Methods
|
||||
|
||||
| Method | Returns |
|
||||
@@ -595,27 +654,27 @@ var clay = new Clay(clayConfig, customClay);
|
||||
|
||||
```javascript
|
||||
module.exports = function(minified) {
|
||||
var Clay = this;
|
||||
var clayConfig = this;
|
||||
var _ = minified._;
|
||||
var $ = minified.$;
|
||||
var HTML = minified.HTML;
|
||||
|
||||
function toggleBackground() {
|
||||
if (this.get()) {
|
||||
Clay.getItemByAppKey('background').enable();
|
||||
clayConfig.getItemByAppKey('background').enable();
|
||||
} else {
|
||||
Clay.getItemByAppKey('background').disable();
|
||||
clayConfig.getItemByAppKey('background').disable();
|
||||
}
|
||||
}
|
||||
|
||||
Clay.on(Clay.EVENTS.AFTER_BUILD, function() {
|
||||
var coolStuffToggle = Clay.getItemByAppKey('cool_stuff');
|
||||
clayConfig.on(clayConfig.EVENTS.AFTER_BUILD, function() {
|
||||
var coolStuffToggle = clayConfig.getItemByAppKey('cool_stuff');
|
||||
toggleBackground.call(coolStuffToggle);
|
||||
coolStuffToggle.on('change', toggleBackground);
|
||||
|
||||
// Hide the color picker for aplite
|
||||
if (Clay.meta.activeWatchInfo.platform === 'aplite') {
|
||||
Clay.getItemByAppKey('background').hide();
|
||||
if (!clayConfig.meta.activeWatchInfo || clayConfig.meta.activeWatchInfo.platform === 'aplite') {
|
||||
clayConfig.getItemByAppKey('background').hide();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -626,7 +685,7 @@ module.exports = function(minified) {
|
||||
|
||||
### `ClayConfig([Object] settings, [Array] config, [$Minified] $rootContainer)`
|
||||
|
||||
This is the main way of talking to your generated config page.
|
||||
This is the main way of talking to your generated config page. An instance of this class will be passed as the context of your custom function when it runs on the generated config page.
|
||||
|
||||
#### Properties
|
||||
|
||||
|
||||
Reference in New Issue
Block a user