Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions TangleKit/TangleKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,33 @@ Tangle.classes.TKIf = {
};


//----------------------------------------------------------
//
// TKRangeSelect
//
// Chooses between a range of numbers, changing with each click.
//
// By default, the range is from 0 to the number of children of the element.
//
// Attributes: data-min (optional): minimum value
// data-max (optional): maximum value

Tangle.classes.TKRangeSelect = {

initialize: function (element, options, tangle, variable) {
element.addEvent("click", function (event) {
var minRange = (options.min == undefined) ? 0 : options.min;
var maxRange = (options.max == undefined) ? (element.getChildren().length - 1) : options.max;
var curValue = tangle.getValue(variable);
var nextValue = curValue + 1;

if (nextValue > maxRange) nextValue = minRange;
tangle.setValue(variable, nextValue);
});
}
};


//----------------------------------------------------------
//
// TKSwitch
Expand Down