MediaWiki:Gadget-idle-util.js: Difference between revisions
From Idle Clans wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/** | /** | ||
* Create a button widget with the given label and flags. | |||
* | |||
* @param {string} [label] | |||
* Optionally, the label for the button. | |||
* @param {string[]} [flags] | |||
* Optionally, the flags for the button. | |||
* | |||
* @returns {OO.ui.ButtonWidget} | |||
* The button widget. | |||
*/ | |||
button: function(label, flags) { | |||
label = label || "Button"; | |||
flags = flags || []; | |||
return new OO.ui.ButtonWidget({ label: label, flags: flags }); | |||
}, | |||
/** | |||
* Create a button input widget with the given label and flags. | |||
* | |||
* @param {string} [label] | |||
* Optionally, the label for the button. | |||
* @param {string[]} [flags] | |||
* Optionally, the flags for the button. | |||
* | |||
* @returns {OO.ui.ButtonInputWidget} | |||
* The button input widget. | |||
*/ | |||
buttonInput: function(label, flags) { | |||
label = label || "Button"; | |||
flags = flags || []; | |||
return new OO.ui.ButtonInputWidget({ label: label, flags: flags }); | |||
}, | |||
/** | |||
* Create a checkbox widget with an optional label and selected | * Create a checkbox widget with an optional label and selected | ||
* state. | * state. |
Revision as of 19:04, 10 June 2024
/** * Create a button widget with the given label and flags. * * @param {string} [label] * Optionally, the label for the button. * @param {string[]} [flags] * Optionally, the flags for the button. * * @returns {OO.ui.ButtonWidget} * The button widget. */ button: function(label, flags) { label = label || "Button"; flags = flags || []; return new OO.ui.ButtonWidget({ label: label, flags: flags }); }, /** * Create a button input widget with the given label and flags. * * @param {string} [label] * Optionally, the label for the button. * @param {string[]} [flags] * Optionally, the flags for the button. * * @returns {OO.ui.ButtonInputWidget} * The button input widget. */ buttonInput: function(label, flags) { label = label || "Button"; flags = flags || []; return new OO.ui.ButtonInputWidget({ label: label, flags: flags }); }, /** * Create a checkbox widget with an optional label and selected * state. * * @param {boolean} [selected] * Optionally, whether the checkbox is selected. * @param {string} [label] * Optionally, the label for the checkbox. * * @returns {OO.ui.CheckboxInputWidget|OO.ui.FieldLayout} * The checkbox widget, or a field layout with the checkbox * and the label. */ checkbox: function(selected, label) { var checkbox = new OO.ui.CheckboxInputWidget({ selected: selected }); if (label !== undefined && typeof label === 'string') { return new OO.ui.FieldLayout(checkbox, { label: label, align: 'inline' }); } return checkbox; }, /** * Create a toggle switch widget with an optional initial state. * * @param {boolean} [switched] * Optionally, whether the switch is on. * * @returns {OO.ui.ToggleSwitchWidget} * The toggle switch widget. */ switch: function(switched) { switched = switched || false; return new OO.ui.ToggleSwitchWidget({ value: switched }); } } } })(window.jQuery, window.mw, window.idleClans = window.idleClans || {});