2013-08-02 01:21:15 +02:00
|
|
|
/*
|
|
|
|
* 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() {
|
2013-08-02 01:26:09 +02:00
|
|
|
var opt = $('<option></option>')
|
2013-08-02 06:18:02 +02:00
|
|
|
.html(this.innerHTML.replace(/(^\[|\]$)/g, ''))
|
2013-08-02 01:26:09 +02:00
|
|
|
.val(i);
|
|
|
|
if ($(this).hasClass('selected'))
|
|
|
|
opt.attr('selected', true);
|
|
|
|
stylesSelect.append(opt);
|
2013-08-02 01:21:15 +02:00
|
|
|
$(this).attr('id', 'style-select-' + i);
|
|
|
|
i++;
|
|
|
|
});
|
|
|
|
|
|
|
|
stylesSelect.change(function() {
|
|
|
|
$('#style-select-' + $(this).val()).click();
|
|
|
|
});
|
|
|
|
|
|
|
|
stylesDiv.hide();
|
|
|
|
|
|
|
|
stylesDiv.after(
|
2013-08-02 06:21:41 +02:00
|
|
|
$('<div id="style-select" style="float:right;margin-bottom:10px"></div>')
|
2013-08-02 01:21:15 +02:00
|
|
|
.text(_('Style: '))
|
|
|
|
.append(stylesSelect)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|