mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-27 20:36:33 -04:00
WIP
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ gulp.task('clean', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('browserify', ['clean'], function(done) {
|
||||
gulp.task('browserify', ['clean'], function() {
|
||||
return browserify('src/scripts/config-page.js', { debug: false })
|
||||
.transform(stringify(['.html', '.mustache']))
|
||||
.bundle()
|
||||
|
||||
Regular → Executable
+1
-1
@@ -15,6 +15,6 @@
|
||||
<body>
|
||||
<form id="main-form"></form>
|
||||
<script src="../vendor/pebble-slate/dist/js/slate.min.js"></script>
|
||||
<script src="../tmp/config-page.js"></script>
|
||||
<script uglify src="../tmp/config-page.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* @property {string|boolean} default
|
||||
* @property {string} label
|
||||
* @property {object} attributes
|
||||
* @property {array} options
|
||||
* @property {array} items
|
||||
* @property {Array} options
|
||||
* @property {Array} items
|
||||
*/
|
||||
|
||||
var mustache = require('mustache');
|
||||
@@ -47,8 +47,10 @@ function getSetting(key, defaultValue) {
|
||||
// settings[key] = value;
|
||||
// }
|
||||
|
||||
var index = 0;
|
||||
|
||||
/**
|
||||
* @param {Clay~Item} item
|
||||
* @param {Clay~Item|Array} item
|
||||
* @param {$} $parent
|
||||
*/
|
||||
function processConfigItem(item, $parent) {
|
||||
@@ -73,9 +75,11 @@ function processConfigItem(item, $parent) {
|
||||
var itemType = itemTypes[item.type];
|
||||
var templateData = $.extend({}, item, {
|
||||
attributes: $.map(item.attributes || [], function(item, key) {
|
||||
console.log(index);
|
||||
return {
|
||||
key: key,
|
||||
value: item.toString()
|
||||
value: item.toString(),
|
||||
index: index++
|
||||
};
|
||||
})
|
||||
});
|
||||
@@ -145,7 +149,7 @@ api.getItemsByType = function(type) {
|
||||
});
|
||||
};
|
||||
|
||||
processConfigItem(config, $mainForm, 0);
|
||||
processConfigItem(config, $mainForm);
|
||||
$mainForm.on('submit', submit);
|
||||
|
||||
module.exports = api;
|
||||
|
||||
@@ -31,6 +31,10 @@ module.exports = {
|
||||
template: require('../../templates/components/toggle.mustache'),
|
||||
manipulator: manipulators.checked
|
||||
},
|
||||
radiogroup: {
|
||||
template: require('../../templates/components/radiogroup.mustache'),
|
||||
manipulator: manipulators.radiogroup
|
||||
},
|
||||
submit: {
|
||||
template: require('../../templates/components/submit.mustache'),
|
||||
manipulator: manipulators.val
|
||||
|
||||
@@ -43,5 +43,23 @@ module.exports = {
|
||||
return this.$manipulatorTarget.prop('disabled', false)
|
||||
.triggerHandler('change');
|
||||
}
|
||||
},
|
||||
radiogroup: {
|
||||
get: function() {
|
||||
return this.$manipulatorTarget.find('input:checked').val();
|
||||
},
|
||||
set: function(value) {
|
||||
this.$manipulatorTarget.find('[value="' + value + '"]')
|
||||
.prop('checked', true);
|
||||
return this.$manipulatorTarget.triggerHandler('change');
|
||||
},
|
||||
disable: function() {
|
||||
return this.$manipulatorTarget.prop('disabled', true)
|
||||
.triggerHandler('change');
|
||||
},
|
||||
enable: function() {
|
||||
return this.$manipulatorTarget.prop('disabled', false)
|
||||
.triggerHandler('change');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<div class="">
|
||||
<span class="label">{{label}}</span>
|
||||
<div data-manipulator-target>
|
||||
{{#options}}
|
||||
<label class="item">
|
||||
<span class="label">{{label}}</span>
|
||||
<input type="radio"
|
||||
class="item-radio"
|
||||
name="{{index}}"
|
||||
value="{{value}}"
|
||||
/>
|
||||
</label>
|
||||
{{/options}}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user