summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-08-01 19:21:15 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-08-01 19:21:15 -0400
commitcf0a20a5645e1e82a48ad00f9381813af3b4e658 (patch)
tree44cf1d36093b67d51a724b0e4370e4bb1bf1174f /js
parent5a44c50811ba9a927add4d54604307692492df8a (diff)
js/style-select.js: Changes the stylesheet chooser links to a <select>
Diffstat (limited to 'js')
-rw-r--r--js/style-select.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/style-select.js b/js/style-select.js
new file mode 100644
index 00000000..ac17c7ce
--- /dev/null
+++ b/js/style-select.js
@@ -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)
+ );
+});
+