mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 08:37:43 -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 })
|
return browserify('src/scripts/config-page.js', { debug: false })
|
||||||
.transform(stringify(['.html', '.mustache']))
|
.transform(stringify(['.html', '.mustache']))
|
||||||
.bundle()
|
.bundle()
|
||||||
|
|||||||
Regular → Executable
+1
-1
@@ -15,6 +15,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<form id="main-form"></form>
|
<form id="main-form"></form>
|
||||||
<script src="../vendor/pebble-slate/dist/js/slate.min.js"></script>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
* @property {string|boolean} default
|
* @property {string|boolean} default
|
||||||
* @property {string} label
|
* @property {string} label
|
||||||
* @property {object} attributes
|
* @property {object} attributes
|
||||||
* @property {array} options
|
* @property {Array} options
|
||||||
* @property {array} items
|
* @property {Array} items
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var mustache = require('mustache');
|
var mustache = require('mustache');
|
||||||
@@ -47,8 +47,10 @@ function getSetting(key, defaultValue) {
|
|||||||
// settings[key] = value;
|
// settings[key] = value;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Clay~Item} item
|
* @param {Clay~Item|Array} item
|
||||||
* @param {$} $parent
|
* @param {$} $parent
|
||||||
*/
|
*/
|
||||||
function processConfigItem(item, $parent) {
|
function processConfigItem(item, $parent) {
|
||||||
@@ -73,9 +75,11 @@ function processConfigItem(item, $parent) {
|
|||||||
var itemType = itemTypes[item.type];
|
var itemType = itemTypes[item.type];
|
||||||
var templateData = $.extend({}, item, {
|
var templateData = $.extend({}, item, {
|
||||||
attributes: $.map(item.attributes || [], function(item, key) {
|
attributes: $.map(item.attributes || [], function(item, key) {
|
||||||
|
console.log(index);
|
||||||
return {
|
return {
|
||||||
key: key,
|
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);
|
$mainForm.on('submit', submit);
|
||||||
|
|
||||||
module.exports = api;
|
module.exports = api;
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ module.exports = {
|
|||||||
template: require('../../templates/components/toggle.mustache'),
|
template: require('../../templates/components/toggle.mustache'),
|
||||||
manipulator: manipulators.checked
|
manipulator: manipulators.checked
|
||||||
},
|
},
|
||||||
|
radiogroup: {
|
||||||
|
template: require('../../templates/components/radiogroup.mustache'),
|
||||||
|
manipulator: manipulators.radiogroup
|
||||||
|
},
|
||||||
submit: {
|
submit: {
|
||||||
template: require('../../templates/components/submit.mustache'),
|
template: require('../../templates/components/submit.mustache'),
|
||||||
manipulator: manipulators.val
|
manipulator: manipulators.val
|
||||||
|
|||||||
@@ -43,5 +43,23 @@ module.exports = {
|
|||||||
return this.$manipulatorTarget.prop('disabled', false)
|
return this.$manipulatorTarget.prop('disabled', false)
|
||||||
.triggerHandler('change');
|
.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