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"> <input type="checkbox" name="coloredNicks">
Enable colored nicknames Enable colored nicknames
</label> </label>
<label class="opt">
<input type="checkbox" name="autocomplete">
Enable autocomplete
</label>
</div> </div>
<div class="col-sm-12"> <div class="col-sm-12">
<h2>Theme</h2> <h2>Theme</h2>

View File

@ -267,7 +267,16 @@ $(function() {
chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing
}) })
.tab(completeNicks, {hint: false}) .tab(completeNicks, {hint: false})
.textcomplete([ .on("autocomplete:on", function() {
enableAutocomplete();
});
if (options.autocomplete) {
enableAutocomplete();
}
function enableAutocomplete() {
input.textcomplete([
emojiStrategy, nicksStrategy, chanStrategy, commandStrategy, emojiStrategy, nicksStrategy, chanStrategy, commandStrategy,
foregroundColorStrategy, backgroundColorStrategy foregroundColorStrategy, backgroundColorStrategy
], { ], {
@ -281,6 +290,7 @@ $(function() {
$(this).data("autocompleting", false); $(this).data("autocompleting", false);
} }
}); });
}
var focus = $.noop; var focus = $.noop;
if (!("ontouchstart" in window || navigator.maxTouchPoints > 0)) { 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 theme: $("#theme").attr("href").replace(/^themes\/(.*).css$/, "$1"), // Extracts default theme name, set on the server configuration
thumbnails: true, thumbnails: true,
userStyles: userStyles.text(), userStyles: userStyles.text(),
highlights: [] highlights: [],
autocomplete: true
}, JSON.parse(storage.get("settings"))); }, JSON.parse(storage.get("settings")));
module.exports = options; module.exports = options;
@ -94,6 +95,12 @@ settings.on("change", "input, select, textarea", function() {
chat.find(".msg > .time").each(function() { chat.find(".msg > .time").each(function() {
$(this).text(tz($(this).parent().data("time"))); $(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") }).find("input")
.trigger("change"); .trigger("change");