Skip to content

Instantly share code, notes, and snippets.

@cj3kim
Created May 21, 2014 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cj3kim/4bb943c654e1d6d07dd0 to your computer and use it in GitHub Desktop.
Save cj3kim/4bb943c654e1d6d07dd0 to your computer and use it in GitHub Desktop.
/** 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