Created
May 21, 2014 19:12
-
-
Save cj3kim/4bb943c654e1d6d07dd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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