mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-03 07:37:46 -04:00
Merge remote-tracking branch 'origin/master' into #47/range-slider-component
# Conflicts: # index.js
This commit is contained in:
@@ -3,14 +3,17 @@
|
||||
var configPageHtml = require('./tmp/config-page.html');
|
||||
var toSource = require('tosource');
|
||||
var standardComponents = require('./src/scripts/components');
|
||||
var deepcopy = require('deepcopy/build/deepcopy.min');
|
||||
|
||||
/**
|
||||
* @param {Array} config - the Clay config
|
||||
* @param {function} [customFn] - Custom code to run from the config page. Will run
|
||||
* with the ClayConfig instance as context
|
||||
* @param {Object} [options] - Additional options to pass to Clay
|
||||
* @param {boolean} [options.autoHandleEvents] - If false, Clay will not
|
||||
* @param {boolean} [options.autoHandleEvents=true] - If false, Clay will not
|
||||
* automatically handle the 'showConfiguration' and 'webviewclosed' events
|
||||
* @param {*} [options.userData={}] - Arbitrary data to pass to the config page. Will
|
||||
* be available as `clayConfig.meta.userData`
|
||||
* @constructor
|
||||
*/
|
||||
function Clay(config, customFn, options) {
|
||||
@@ -26,15 +29,30 @@ function Clay(config, customFn, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
self.config = config;
|
||||
self.config = deepcopy(config);
|
||||
self.customFn = customFn || function() {};
|
||||
self.components = {};
|
||||
self.meta = {
|
||||
activeWatchInfo: null,
|
||||
accountToken: '',
|
||||
watchToken: ''
|
||||
watchToken: '',
|
||||
userData: {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Populate the meta with data from the Pebble object. Make sure to run this inside
|
||||
* either the "showConfiguration" or "ready" event handler
|
||||
* @return {void}
|
||||
*/
|
||||
function _populateMeta() {
|
||||
self.meta = {
|
||||
activeWatchInfo: Pebble.getActiveWatchInfo && Pebble.getActiveWatchInfo(),
|
||||
accountToken: Pebble.getAccountToken(),
|
||||
watchToken: Pebble.getWatchToken(),
|
||||
userData: deepcopy(options.userData || {})
|
||||
};
|
||||
}
|
||||
|
||||
// Let Clay handle all the magic
|
||||
if (options.autoHandleEvents !== false && typeof Pebble !== 'undefined') {
|
||||
|
||||
@@ -61,19 +79,6 @@ function Clay(config, customFn, options) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the meta with data from the Pebble object. Make sure to run this inside
|
||||
* either the "showConfiguration" or "ready" event handler
|
||||
* @return {void}
|
||||
*/
|
||||
function _populateMeta() {
|
||||
self.meta = {
|
||||
activeWatchInfo: Pebble.getActiveWatchInfo && Pebble.getActiveWatchInfo(),
|
||||
accountToken: Pebble.getAccountToken(),
|
||||
watchToken: Pebble.getWatchToken()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Clay~ConfigItem|Array} item
|
||||
|
||||
Reference in New Issue
Block a user