summaryrefslogtreecommitdiffstats
path: root/public_html/data/js/tabwidth-input.js
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-06-04 23:10:31 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-06-05 21:23:49 +0200
commitd088234d67f3aa422796d922e08a07949dc53d83 (patch)
treea964821b6b725dd26becbb3e91acf8d7dd5e0014 /public_html/data/js/tabwidth-input.js
parent048410164d2a17bbb588e43351e44eeb81610960 (diff)
Move public files to ./public_html
./data/local is not moved because it contains likely untracked files and moving it would throw an error when updating. Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'public_html/data/js/tabwidth-input.js')
-rw-r--r--public_html/data/js/tabwidth-input.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/public_html/data/js/tabwidth-input.js b/public_html/data/js/tabwidth-input.js
new file mode 100644
index 000000000..9cc37516d
--- /dev/null
+++ b/public_html/data/js/tabwidth-input.js
@@ -0,0 +1,37 @@
+(function () {
+'use strict';
+define(['jquery', 'underscore', 'util'], function ($, _, Util) {
+ var PrivateFunctions = {
+ setupEvents: function () {
+ $('.tabwidth-toggle').on('click', _.bind(function (event) {
+ Util.focusDropdownInput(event.target);
+ }, Util));
+
+ $('form.tabwidth-form input').on('click', function (event) {
+ // Suppress blur event on dropdown toggle
+ event.stopImmediatePropagation();
+ });
+
+ $('form.tabwidth-form').on('submit', function (event) {
+ var value = $(event.target).find('input').val();
+ Util.setTabwidth(value);
+ $(event.target).parents('.open').removeClass('open');
+ event.preventDefault();
+ });
+
+ $('form.tabwidth-form input').on('change', function (event) {
+ var value = $(event.target).val();
+ Util.setTabwidth(value);
+ event.preventDefault();
+ });
+ }
+ };
+ var TabwidthInput = {
+ initialize: function () {
+ PrivateFunctions.setupEvents();
+ }
+ };
+
+ return TabwidthInput;
+});
+})();