* @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])
| 165 | * |
| 166 | */ |
| 167 | function 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. |