diff options
| author | czaks <marcin@6irc.net> | 2013-08-01 23:43:20 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-08-01 23:43:20 -0400 |
| commit | 1ed45ebe9e39724ec70098abfcd267d8ac478511 (patch) | |
| tree | da133b7426dedaf0785f64be752aa0437de7e80a /js/style-select.js | |
| parent | dc84ccc6a8e0b6fd3fc626eb1f321e4cf2d05511 (diff) | |
| parent | 40ab2e0c1728fab613bc16a19ab8fcb3fa78c1d4 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts:
stylesheets/dark.css
stylesheets/futaba+vichan.css
stylesheets/miku.css
stylesheets/stripes.css
stylesheets/testorange.css
stylesheets/wasabi.css
Diffstat (limited to 'js/style-select.js')
| -rw-r--r-- | js/style-select.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/js/style-select.js b/js/style-select.js new file mode 100644 index 00000000..33c1308b --- /dev/null +++ b/js/style-select.js @@ -0,0 +1,44 @@ +/* + * 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() { + var opt = $('<option></option>') + .text(this.innerText.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 style="float:right;margin-bottom:10px"></div>') + .text(_('Style: ')) + .append(stylesSelect) + ); +}); + |
