style-select.js: format

This commit is contained in:
Zankaria 2024-08-05 18:47:53 +02:00
parent a018772267
commit 902c558237

View File

@ -6,7 +6,7 @@
* *
* Released under the MIT license * Released under the MIT license
* Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org> * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net> * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
* *
* Usage: * Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/jquery.min.js';
@ -14,32 +14,32 @@
* *
*/ */
onready(function(){ onready(function() {
var stylesDiv = $('div.styles'); let stylesDiv = $('div.styles');
var stylesSelect = $('<select></select>'); let stylesSelect = $('<select></select>');
var i = 1; let i = 1;
stylesDiv.children().each(function() { stylesDiv.children().each(function() {
var opt = $('<option></option>') let opt = $('<option></option>')
.html(this.innerHTML.replace(/(^\[|\]$)/g, '')) .html(this.innerHTML.replace(/(^\[|\]$)/g, ''))
.val(i); .val(i);
if ($(this).hasClass('selected')) if ($(this).hasClass('selected')) {
opt.attr('selected', true); opt.attr('selected', true);
}
stylesSelect.append(opt); stylesSelect.append(opt);
$(this).attr('id', 'style-select-' + i); $(this).attr('id', 'style-select-' + i);
i++; i++;
}); });
stylesSelect.change(function() { stylesSelect.change(function() {
$('#style-select-' + $(this).val()).click(); $('#style-select-' + $(this).val()).click();
}); });
stylesDiv.hide(); stylesDiv.hide();
stylesDiv.after( stylesDiv.after(
$('<div id="style-select" style="float:right;margin-bottom:10px"></div>') $('<div id="style-select" style="float:right;margin-bottom:10px"></div>')
.text(_('Style: ')) .text(_('Style: '))
.append(stylesSelect) .append(stylesSelect)
); );
}); });