Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/** Requires **/
var ContainerSurface = require('../famous/surfaces/ContainerSurface');
var StateModifier = require('../famous/modifiers/StateModifier');
var _ = require('underscore');
var extend = require('node.extend');
var generateRadioButton = require('./generateRadioButton');
var generateBebopRatio = require('./generateBebopRatio');
var processRadioButton = require('./processRadioButton');
var defaultSurfaceOptions = {
size: [50, 50],
};
var RadioBebop = function RadioBebop(radioButtonOptionsAry, surfaceOptions) {
var _this = this;
var mergedSurfaceOptions = extend(defaultSurfaceOptions, surfaceOptions);
var containerWidth = mergedSurfaceOptions.size[0] * radioButtonOptionsAry.length;
var containerHeight = mergedSurfaceOptions.size[1];
ContainerSurface.apply(this, [{size: [containerWidth, containerHeight]}]);
var originX = 0;
var originDx = generateBebopRatio(radioButtonOptionsAry.length);//Change in X, the origin incrementor value
_this.radioButtonAry = [];
_.each(radioButtonOptionsAry, function (element, index, ary) {
var stateModifier = new StateModifier({ origin: [originX, 0] });
originX += originDx;
var radioButton = generateRadioButton(mergedSurfaceOptions, element);
_this.radioButtonAry.push(radioButton);
processRadioButton(radioButton, _this);
_this.add(stateModifier).add(radioButton)
});
_this.radioButtonAry[0].select();
_this.whatIsSelected = function () {
var selected;
_.each(_this.radioButtonAry, function (radioButton) {
if (radioButton.isSelected()) selected = radioButton.value;
});
return selected;
}
};
RadioBebop.prototype = Object.create(ContainerSurface.prototype);
RadioBebop.prototype.constructor = RadioBebop;
module.exports = RadioBebop;
/** Requires **/
var ContainerSurface = require('../famous/surfaces/ContainerSurface');
var StateModifier = require('../famous/modifiers/StateModifier');
var _ = require('underscore');
var extend = require('node.extend');
var generateRadioButton = require('./generateRadioButton');
var generateBebopRatio = require('./generateBebopRatio');
var processRadioButton = require('./processRadioButton');
var defaultSurfaceOptions = {
size: [50, 50],
};
var RadioBebop = function RadioBebop(radioButtonOptionsAry, surfaceOptions) {
var _this = this;
var mergedSurfaceOptions = extend(defaultSurfaceOptions, surfaceOptions);
var containerWidth = mergedSurfaceOptions.size[0] * radioButtonOptionsAry.length;
var containerHeight = mergedSurfaceOptions.size[1];
ContainerSurface.apply(this, [{size: [containerWidth, containerHeight]}]);
var originX = 0;
var originDx = generateBebopRatio(radioButtonOptionsAry.length);//Change in X, the origin incrementor value
_this.radioButtonAry = [];
_.each(radioButtonOptionsAry, function (element, index, ary) {
var stateModifier = new StateModifier({ origin: [originX, 0] });
originX += originDx;
var radioButton = generateRadioButton(mergedSurfaceOptions, element);
_this.radioButtonAry.push(radioButton);
processRadioButton(radioButton, _this);
_this.add(stateModifier).add(radioButton)
});
_this.radioButtonAry[0].select();
_this.whatIsSelected = function () {
var selected;
_.each(_this.radioButtonAry, function (radioButton) {
if (radioButton.isSelected()) selected = radioButton.value;
});
return selected;
}
};
RadioBebop.prototype = Object.create(ContainerSurface.prototype);
RadioBebop.prototype.constructor = RadioBebop;
module.exports = RadioBebop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.