mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-28 01:10:51 +01:00
js/style-select.js: Changes the stylesheet chooser links to a <select>
This commit is contained in:
parent
5a44c50811
commit
cf0a20a564
43
js/style-select.js
Normal file
43
js/style-select.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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>
|
||||
*
|
||||
* Usage:
|
||||
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||
* $config['additional_javascript'][] = 'js/style-select.js';
|
||||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
var stylesDiv = $('div.styles');
|
||||
var stylesSelect = $('<select></select>');
|
||||
|
||||
var i = 1;
|
||||
stylesDiv.children().each(function() {
|
||||
stylesSelect.append(
|
||||
$('<option></option>')
|
||||
.text(this.innerText.replace(/(^\[|\]$)/g, ''))
|
||||
.val(i)
|
||||
);
|
||||
$(this).attr('id', 'style-select-' + i);
|
||||
i++;
|
||||
});
|
||||
|
||||
stylesSelect.change(function() {
|
||||
$('#style-select-' + $(this).val()).click();
|
||||
});
|
||||
|
||||
stylesDiv.hide();
|
||||
|
||||
stylesDiv.after(
|
||||
$('<div style="float:right;margin-bottom:10px"></div>')
|
||||
.text(_('Style: '))
|
||||
.append(stylesSelect)
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user