Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion TangleKit/TangleKit.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

/* TKToggle */

.TKToggle {
.TKToggle,
.TKIncrement {
color: #46f;
border-bottom: 1px dashed #46f;
cursor: pointer;
Expand Down
28 changes: 27 additions & 1 deletion TangleKit/TangleKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@ Tangle.classes.TKToggle = {
};


//----------------------------------------------------------
//
// TKIncrement
//
// Click to increment value (modulo the number of options).

Tangle.classes.TKIncrement = {

initialize: function (element, options, tangle, variable) {
element.addEvent("click", function (event) {
var value = tangle.getValue(variable);
tangle.setValue(variable, ++value % element.getChildren().length);
});
},

update: function (element, value) {
element.getChildren().each( function (child, index) {
child.style.display = (index != value) ? "none" : "inline";
});
}
};


//----------------------------------------------------------
//
// TKNumberField
Expand Down Expand Up @@ -288,8 +311,11 @@ Tangle.formats.percent = function (value) {
return "" + (100 * value).round(0) + "%";
};

Tangle.formats.height = function (value) {
return Math.floor(value/12) + "′" + value%12 + "″";
};



//----------------------------------------------------------

})();
Expand Down