Skip to content

Node.js based forum software built for the modern web

664 B
Raw Blame
'use strict';

define('settings/checkbox', function () {
	let Settings = null;

	const SettingsCheckbox = {
		types: ['checkbox'],
		use: function () {
			Settings = this;
		},
		create: function () {
			return Settings.helper.createElement('input', {
				type: 'checkbox',
			});
		},
		set: function (element, value) {
			element.prop('checked', value);
		},
		get: function (element, trim, empty) {
			const value = element.prop('checked');
			if (value == null) {
				return;
			}
			if (!empty) {
				if (value) {
					return value;
				}
				return;
			}
			if (trim) {
				return value ? 1 : 0;
			}
			return value;
		},
	};

	return SettingsCheckbox;
});