MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / checkBox

Function checkBox

lib/web/drags.js:163–202  ·  view source on GitHub ↗
(into, w, h, get, setAndGet)

Source from the content-addressed store, hash-verified

161}
162
163var checkBox = function (into, w, h, get, setAndGet) {
164 var shapes = into.circle(w / 2, w / 2, w / 2 - 4);
165 var click = function () {
166 var v = setAndGet(!get());
167 shapes.animate({
168 "fill-opacity": (v ? 0.5 : 0)
169 }, 50);
170
171 if (v)
172 shapes.attr({"stroke-dasharray": ""});
173 else
174 shapes.attr({"stroke-dasharray": "-"})
175
176 };
177
178 var initial = get();
179
180 shapes.attr({
181 fill: "#eee",
182 "fill-opacity": (initial ? 0.5 : 0),
183 "stroke-width": 1,
184 cursor: "move",
185 stroke: "#000"
186 });
187 if (initial)
188 shapes.attr({"stroke-dasharray": ""});
189 else
190 shapes.attr({"stroke-dasharray": "-"});
191
192 shapes.hover(
193 function () {
194 this.attr({"stroke": "#300"})
195 },
196 function () {
197 this.attr({"stroke": "#000"})
198 });
199 shapes.click(click);
200
201 return shapes;
202};
203
204var dragThang = function (into, get, setAndGet, diameter, onUp) {
205

Callers 2

insertBoolFunction · 0.85

Calls 5

hoverMethod · 0.80
clickMethod · 0.80
getFunction · 0.70
circleMethod · 0.45
attrMethod · 0.45

Tested by

no test coverage detected