From 9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 13 Apr 2025 18:48:02 +0100 Subject: initial --- site/app/twirl/stdui.js | 494 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 site/app/twirl/stdui.js (limited to 'site/app/twirl/stdui.js') diff --git a/site/app/twirl/stdui.js b/site/app/twirl/stdui.js new file mode 100644 index 0000000..8141912 --- /dev/null +++ b/site/app/twirl/stdui.js @@ -0,0 +1,494 @@ +twirl.stdui = { + PlayButton: function(options) { + var self = this; + var txtPlay = "\u25b6"; + var txtStop = "\u23f9"; + + this.state = false; + + this.element = $("

").text(txtPlay).css("cursor", "pointer"); + + if (options.hasOwnProperty("fontsize")) { + this.element.css("font-size", options.fontsize); + } + + this.show = function() { + self.element.css("visibility", "visible"); + }; + + this.hide = function() { + self.element.css("visibility", "hidden"); + }; + + this.element.click(function() { + if (!self.state) { + self.element.text(txtStop); + self.state = true; + } else { + self.element.text(txtPlay); + self.state = false; + } + if (options.stateAlter) { + options.stateAlter(self.state, self); + } + if (options.hasOwnProperty("change")) { + options.change(self.state, self); + } + }); + + this.setValue = function(v, runChange) { + if (v) { + self.element.text(txtStop); + self.state = true; + } else { + self.element.text(txtPlay); + self.state = false; + } + + if (runChange && options.hasOwnProperty("change")) { + options.change(self.state, self); + } + }; + + if (options.tooltip) { + this.element.on("mouseover", function(e){ + twirl.tooltip.show(e, options.tooltip); + }).on("mouseout", function(){ + twirl.tooltip.hide(); + }); + } + + if (options.target) { + $("#" + options.target).append(this.element); + } + }, + StandardButton: function(options) { + var self = this; + this.element = $("