MCPcopy
hub / github.com/gmattie/Data-Pixels / buildControlButton

Function buildControlButton

resources/source/js/application/controls.js:167–180  ·  view source on GitHub ↗

* @description Assigns attributes and event handling to an HTMLInputElement object that is of type "image". * @param {Object} button - The target HTMLInputElement object that is of type "image". * @param {string} src - The URL of the button's image. * @param {string} title - The label assigned as

(button, src, title, clickHandler, events = [C.Event.CLICK])

Source from the content-addressed store, hash-verified

165 *
166 */
167function buildControlButton(button, src, title, clickHandler, events = [C.Event.CLICK]) {
168
169 button.src = src;
170 button.title = title;
171 button.classList.add(C.CSSClass.CONTROL_BUTTON);
172 button.classList.add(S.Theme === C.Theme.LIGHT ? C.CSSClass.CONTROL_BUTTON_THEME_DARK : C.CSSClass.CONTROL_BUTTON_THEME_LIGHT);
173
174 for (let event of events) {
175
176 button.addEventListener(event, clickHandler);
177 }
178
179 return button;
180}
181
182/**
183 * @description Event handler called when either of the layout control buttons are clicked.

Callers 1

initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected