From 8c8d683348dc635926412c72c79e0cc26c72d466 Mon Sep 17 00:00:00 2001 From: Awal Garg Date: Mon, 3 Jul 2017 22:37:38 +0530 Subject: [PATCH] Allow opting out of autocomplete --- client/index.html | 4 ++++ client/js/lounge.js | 12 +++++++++++- client/js/options.js | 9 ++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/client/index.html b/client/index.html index cc6e4685..050897cc 100644 --- a/client/index.html +++ b/client/index.html @@ -266,6 +266,10 @@ Enable colored nicknames +

Theme

diff --git a/client/js/lounge.js b/client/js/lounge.js index 27faa8b8..2057c722 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -267,7 +267,16 @@ $(function() { chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing }) .tab(completeNicks, {hint: false}) - .textcomplete([ + .on("autocomplete:on", function() { + enableAutocomplete(); + }); + + if (options.autocomplete) { + enableAutocomplete(); + } + + function enableAutocomplete() { + input.textcomplete([ emojiStrategy, nicksStrategy, chanStrategy, commandStrategy, foregroundColorStrategy, backgroundColorStrategy ], { @@ -281,6 +290,7 @@ $(function() { $(this).data("autocompleting", false); } }); + } var focus = $.noop; if (!("ontouchstart" in window || navigator.maxTouchPoints > 0)) { diff --git a/client/js/options.js b/client/js/options.js index a0e1fa50..cd38b37f 100644 --- a/client/js/options.js +++ b/client/js/options.js @@ -25,7 +25,8 @@ const options = $.extend({ theme: $("#theme").attr("href").replace(/^themes\/(.*).css$/, "$1"), // Extracts default theme name, set on the server configuration thumbnails: true, userStyles: userStyles.text(), - highlights: [] + highlights: [], + autocomplete: true }, JSON.parse(storage.get("settings"))); module.exports = options; @@ -94,6 +95,12 @@ settings.on("change", "input, select, textarea", function() { chat.find(".msg > .time").each(function() { $(this).text(tz($(this).parent().data("time"))); }); + } else if (name === "autocomplete") { + if (self.prop("checked")) { + $("#input").trigger("autocomplete:on"); + } else { + $("#input").textcomplete("destroy"); + } } }).find("input") .trigger("change");