summaryrefslogtreecommitdiffstats
path: root/data/js/tabwidth-input.js
diff options
context:
space:
mode:
authorJoakim Reinert <mail@jreinert.com>2015-04-19 00:40:45 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-05-05 12:21:27 +0200
commit645ac23ebea2ff1fe6f585a4f8fea27c3928be0e (patch)
tree48a7a74ef530fbb2004fce50115505259cce1177 /data/js/tabwidth-input.js
parentfe68477d8b60bc9303dd2bcd542915ac05e3fac6 (diff)
Refactor tab width input
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;
+});
+})();