Allow opting out of autocomplete

This commit is contained in:
Awal Garg 2017-07-03 22:37:38 +05:30
parent 622c91b25a
commit 8c8d683348
3 changed files with 23 additions and 2 deletions

View file

@ -266,6 +266,10 @@
<input type="checkbox" name="coloredNicks">
Enable colored nicknames
</label>
<label class="opt">
<input type="checkbox" name="autocomplete">
Enable autocomplete
</label>
</div>
<div class="col-sm-12">
<h2>Theme</h2>

View file

@ -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)) {

View file

@ -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");