mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-12-18 18:36:00 +01:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
/*
|
|
* style-select.js
|
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/style-select.js
|
|
*
|
|
* Changes the stylesheet chooser links to a <select>
|
|
*
|
|
* Released under the MIT license
|
|
* Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
|
|
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
|
*
|
|
* Usage:
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
* $config['additional_javascript'][] = 'js/style-select.js';
|
|
*
|
|
*/
|
|
|
|
onReady(function() {
|
|
let stylesDiv = $('div.styles');
|
|
let stylesSelect = $('<select></select>');
|
|
|
|
let i = 1;
|
|
stylesDiv.children().each(function() {
|
|
let opt = $('<option></option>')
|
|
.html(this.innerHTML.replace(/(^\[|\]$)/g, ''))
|
|
.val(i);
|
|
if ($(this).hasClass('selected')) {
|
|
opt.attr('selected', true);
|
|
}
|
|
stylesSelect.append(opt);
|
|
$(this).attr('id', 'style-select-' + i);
|
|
i++;
|
|
});
|
|
|
|
stylesSelect.change(function() {
|
|
$('#style-select-' + $(this).val()).click();
|
|
});
|
|
|
|
stylesDiv.hide();
|
|
|
|
stylesDiv.after(
|
|
$('<div id="style-select" style="float:right;margin-bottom:10px"></div>')
|
|
.text(_('Style: '))
|
|
.append(stylesSelect)
|
|
);
|
|
});
|