summaryrefslogtreecommitdiffstats
path: root/data/js/tabwidth-input.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/js/tabwidth-input.js')
-rw-r--r--data/js/tabwidth-input.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/data/js/tabwidth-input.js b/data/js/tabwidth-input.js
new file mode 100644
index 000000000..62e2bb3f2
--- /dev/null
+++ b/data/js/tabwidth-input.js
@@ -0,0 +1,37 @@
+(function () {
+'use strict';
+define(['jquery', '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;
+});
+})();