MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / updateButtonDisplay

Method updateButtonDisplay

static/widgets/toggles.ts:76–96  ·  view source on GitHub ↗
(button: JQuery, checkbox: JQuery, forcedState?: boolean)

Source from the content-addressed store, hash-verified

74 }
75
76 private updateButtonDisplay(button: JQuery, checkbox: JQuery, forcedState?: boolean) {
77 if (forcedState !== undefined) {
78 checkbox.prop('checked', forcedState);
79 }
80 const isChecked = checkbox.is(':checked');
81
82 // Set the button's state
83 button.data('state', isChecked ? 'on' : 'off');
84
85 // Set the button's icon
86 button
87 .find('.state-icon')
88 .removeClass()
89 .addClass(`state-icon ${settings[button.data('state') as keyof typeof settings].icon}`);
90
91 // Update the button's color
92 button.toggleClass('active', isChecked);
93 if (forcedState === undefined) {
94 this.set(button.data('bind'), isChecked);
95 }
96 }
97
98 get() {
99 return {...this.state};

Callers 1

constructorMethod · 0.95

Calls 3

setMethod · 0.95
dataMethod · 0.80
findMethod · 0.80

Tested by

no test coverage detected