diff --git a/README.md b/README.md index d4ba78a..7a8ec88 100755 --- a/README.md +++ b/README.md @@ -613,7 +613,11 @@ This is the main way of talking to your generated config page. |----------|------|-------------| | `.EVENTS.BEFORE_BUILD` | String | Dispatched prior to building the page. | | `.EVENTS.AFTER_BUILD` | String | Dispatched after building the page. | -| `.config` | Array | Reference to the config passed to the constructer and used for generating the page. | +| `.config` | Array | Reference to the config passed to the constructor and used for generating the page. | +| `.meta` | Object | Contains information about the current user and watch | +| `.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 @@ -643,7 +647,7 @@ This is the main way of talking to your generated config page. | `.appKey` | String | The ID of the item if provided in the config. | | `.config` | Object | Reference to the config passed to the constructer. | | `$element` | $Minified | A Minified list representing the root HTML element of the config item. | -| `$manipulatorTarget` | A Minified list representing the HTML element with **data-manipulator-target** set. This is generally pointing to the main `` element and will be used for binding events. | +| `$manipulatorTarget` | $Minified | A Minified list representing the HTML element with **data-manipulator-target** set. This is generally pointing to the main `` element and will be used for binding events. | #### Methods diff --git a/dev/custom-fn.js b/dev/custom-fn.js index 4688283..259bc60 100644 --- a/dev/custom-fn.js +++ b/dev/custom-fn.js @@ -10,9 +10,9 @@ module.exports = function() { */ function toggleBackground() { if (this.get()) { - Clay.getItemByAppKey('background').enable(); + Clay.getItemByAppKey('colorTest').enable(); } else { - Clay.getItemByAppKey('background').disable(); + Clay.getItemByAppKey('colorTest').disable(); } } diff --git a/gulpfile.js b/gulpfile.js index a65f2a8..5cad718 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -103,6 +103,7 @@ gulp.task('dev-js', ['js', 'sass'], function() { .transform(stringify(stringifyOptions)) .transform('deamdify') .transform(sassify, sassifyOptions) + .transform(autoprefixify, autoprefixerOptions) .bundle() .pipe(source('dev.js')) .pipe(gulp.dest('./tmp/')); diff --git a/index.js b/index.js index 67908be..216391a 100755 --- a/index.js +++ b/index.js @@ -29,11 +29,17 @@ function Clay(config, customFn, options) { self.config = config; self.customFn = customFn || function() {}; self.components = {}; + self.meta = { + activeWatchInfo: null, + accountToken: '', + watchToken: '' + }; // Let Clay handle all the magic if (options.autoHandleEvents !== false && typeof Pebble !== 'undefined') { Pebble.addEventListener('showConfiguration', function() { + _populateMeta(); Pebble.openURL(self.generateUrl()); }); @@ -49,6 +55,23 @@ function Clay(config, customFn, options) { console.log(JSON.stringify(error)); }); }); + } else if (typeof Pebble !== 'undefined') { + Pebble.addEventListener('ready', function() { + _populateMeta(); + }); + } + + /** + * 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() + }; } /** @@ -107,7 +130,8 @@ Clay.prototype.generateUrl = function() { .replace('$$CUSTOM_FN$$', toSource(this.customFn)) .replace('$$CONFIG$$', toSource(this.config)) .replace('$$SETTINGS$$', toSource(settings)) - .replace('$$COMPONENTS$$', toSource(this.components)); + .replace('$$COMPONENTS$$', toSource(this.components)) + .replace('$$META$$', toSource(this.meta)); // if we are in the emulator then we need to proxy the data via a webpage to // obtain the return_to. diff --git a/src/config-page.html b/src/config-page.html index 837fe40..627d44e 100755 --- a/src/config-page.html +++ b/src/config-page.html @@ -10,6 +10,7 @@ window.claySettings = $$SETTINGS$$; window.customFn = $$CUSTOM_FN$$; window.clayComponents = $$COMPONENTS$$; + window.clayMeta = $$META$$;
diff --git a/src/scripts/components/select.js b/src/scripts/components/select.js index 91097cd..ebd3229 100644 --- a/src/scripts/components/select.js +++ b/src/scripts/components/select.js @@ -16,8 +16,10 @@ module.exports = { var $value = self.$element.select('.value'); - self.on('change', function(ev) { - var value = self.$manipulatorTarget.select('option:checked').get('innerHTML'); + self.on('change', function() { + var selectedIndex = self.$manipulatorTarget.get('selectedIndex'); + var $options = self.$manipulatorTarget.select('option'); + var value = $options[selectedIndex] && $options[selectedIndex].innerHTML; $value.set('innerHTML', value); }); } diff --git a/src/scripts/components/submit.js b/src/scripts/components/submit.js index 23ef4df..18c684c 100644 --- a/src/scripts/components/submit.js +++ b/src/scripts/components/submit.js @@ -3,6 +3,7 @@ module.exports = { name: 'submit', template: require('../../templates/components/submit.tpl'), + style: require('../../styles/clay/components/submit.scss'), manipulator: 'html', defaults: { attributes: {} diff --git a/src/scripts/config-page.js b/src/scripts/config-page.js index e0bf3f6..1f5b1c4 100755 --- a/src/scripts/config-page.js +++ b/src/scripts/config-page.js @@ -11,6 +11,7 @@ var settings = _.extend({}, window.claySettings || {}); var returnTo = window.returnTo || 'pebblejs://close#'; var customFn = window.customFn || function() {}; var clayComponents = window.clayComponents || {}; +var clayMeta = window.clayMeta || {}; var platform = window.navigator.userAgent.match(/android/i) ? 'android' : 'ios'; document.documentElement.classList.add('platform-' + platform); @@ -21,7 +22,7 @@ _.eachObj(clayComponents, function(key, component) { }); var $mainForm = $('#main-form'); -var clayConfig = new ClayConfig(settings, config, $mainForm); +var clayConfig = new ClayConfig(settings, config, $mainForm, clayMeta); // add listeners here $mainForm.on('submit', function() { diff --git a/src/scripts/lib/clay-config.js b/src/scripts/lib/clay-config.js index 38d2e1f..750e700 100644 --- a/src/scripts/lib/clay-config.js +++ b/src/scripts/lib/clay-config.js @@ -26,9 +26,10 @@ var manipulators = require('./manipulators'); * @param {Object} settings - setting that were set from a previous session * @param {Array|Object} config * @param {M} $rootContainer + * @param {Object} meta * @constructor */ -function ClayConfig(settings, config, $rootContainer) { +function ClayConfig(settings, config, $rootContainer, meta) { var self = this; var _settings = _.copyObj(settings); @@ -95,6 +96,8 @@ function ClayConfig(settings, config, $rootContainer) { return true; } + self.meta = meta; + self.EVENTS = { /** * Called before framework has initialized. This is when you would attach your @@ -183,7 +186,6 @@ function ClayConfig(settings, config, $rootContainer) { // expose the config to allow developers to update it before the build is run self.config = config; - } /** diff --git a/src/styles/clay/_base.scss b/src/styles/clay/_base.scss index dfbaa6a..b6fda6c 100644 --- a/src/styles/clay/_base.scss +++ b/src/styles/clay/_base.scss @@ -83,9 +83,12 @@ label { } } +.tap-highlight { + @include tap-highlight(); +} + .component { padding-bottom: $item-spacing-v; - @include tap-highlight(); &.disabled { opacity: 0.25; @@ -108,10 +111,10 @@ label { &:last-child, &:first-child { padding-bottom: $item-spacing-v; - - &:after { - display: none; - } + } + + &:last-child:after { + display: none; } &:after { @@ -130,6 +133,10 @@ label { .component-heading:first-child { background: $color-gray-3; border-radius: $border-radius $border-radius 0 0; + + &:after { + display: none; + } } } diff --git a/src/styles/clay/components/checkboxgroup.scss b/src/styles/clay/components/checkboxgroup.scss index 88585a7..e6d62f2 100644 --- a/src/styles/clay/components/checkboxgroup.scss +++ b/src/styles/clay/components/checkboxgroup.scss @@ -3,10 +3,8 @@ .component-checkbox { - @include tap-highlight(rgba(0,0,0,0)); display: block; - > .label { display: block; padding-bottom: $item-spacing-v / 2; @@ -16,7 +14,6 @@ label { padding: $item-spacing-v / 2 0; - @include tap-highlight(); } .label { @@ -39,7 +36,7 @@ flex-shrink: 0; } - input:checked ~ i { + input:checked + i { border-color: $color-orange; background: $color-orange; diff --git a/src/styles/clay/components/color.scss b/src/styles/clay/components/color.scss index 2d0d9d9..272b83d 100644 --- a/src/styles/clay/components/color.scss +++ b/src/styles/clay/components/color.scss @@ -7,6 +7,7 @@ height: $base-height; border-radius: $base-height / 2; box-shadow: $box-shadow-small-components; + display: block; } .picker-wrap { diff --git a/src/styles/clay/components/radiogroup.scss b/src/styles/clay/components/radiogroup.scss index 2db5ea3..dc79392 100644 --- a/src/styles/clay/components/radiogroup.scss +++ b/src/styles/clay/components/radiogroup.scss @@ -3,10 +3,8 @@ .component-radio { - @include tap-highlight(rgba(0,0,0,0)); display: block; - > .label { display: block; padding-bottom: $item-spacing-v / 2; @@ -16,7 +14,6 @@ label { padding: $item-spacing-v / 2 0; - @include tap-highlight(); } .label { @@ -39,7 +36,7 @@ flex-shrink: 0; } - input:checked ~ i { + input:checked + i { border-color: $color-orange; &:after { diff --git a/src/styles/clay/components/select.scss b/src/styles/clay/components/select.scss index 93ae3c3..17ec915 100644 --- a/src/styles/clay/components/select.scss +++ b/src/styles/clay/components/select.scss @@ -11,6 +11,7 @@ $triangle-size: 0.85rem; position: relative; padding-right: $triangle-size + 0.25rem; + display: block; &:after { content: ""; diff --git a/src/styles/clay/components/submit.scss b/src/styles/clay/components/submit.scss new file mode 100644 index 0000000..74b11f4 --- /dev/null +++ b/src/styles/clay/components/submit.scss @@ -0,0 +1,3 @@ +.component-submit { + text-align: center; +} diff --git a/src/styles/clay/elements/_button.scss b/src/styles/clay/elements/_button.scss index 8912034..6ece43c 100644 --- a/src/styles/clay/elements/_button.scss +++ b/src/styles/clay/elements/_button.scss @@ -9,7 +9,7 @@ button, font-size: 1rem; line-height: 1; border: none; - display: block; + display: inline-block; color: $color-white; min-width: 12rem; diff --git a/src/templates/components/checkboxgroup.tpl b/src/templates/components/checkboxgroup.tpl index 708fab4..2a7906b 100755 --- a/src/templates/components/checkboxgroup.tpl +++ b/src/templates/components/checkboxgroup.tpl @@ -2,7 +2,7 @@ {{{label}}}