zcommand: Add /fluid-width and /fixed-width slash commands.

This commit is contained in:
Wyatt Hoodes
2020-03-11 20:51:47 -10:00
committed by Tim Abbott
parent 5cf8ddf630
commit 13f86f35d9
4 changed files with 106 additions and 0 deletions

View File

@@ -90,6 +90,50 @@ exports.enter_night_mode = function () {
});
};
exports.enter_fluid_mode = function () {
exports.send({
command: "/fluid-width",
on_success: function (data) {
scroll_bar.set_layout_width();
feedback_widget.show({
populate: function (container) {
const rendered_msg = marked(data.msg).trim();
container.html(rendered_msg);
},
on_undo: function () {
exports.send({
command: "/fixed-width",
});
},
title_text: i18n.t("Fluid width mode"),
undo_button_text: i18n.t("Fixed width"),
});
},
});
};
exports.enter_fixed_mode = function () {
exports.send({
command: "/fixed-width",
on_success: function (data) {
scroll_bar.set_layout_width();
feedback_widget.show({
populate: function (container) {
const rendered_msg = marked(data.msg).trim();
container.html(rendered_msg);
},
on_undo: function () {
exports.send({
command: "/fluid-width",
});
},
title_text: i18n.t("Fixed width mode"),
undo_button_text: i18n.t("Fluid width"),
});
},
});
};
exports.process = function (message_content) {
const content = message_content.trim();
@@ -122,6 +166,16 @@ exports.process = function (message_content) {
return true;
}
if (content === '/fluid-width') {
exports.enter_fluid_mode();
return true;
}
if (content === '/fixed-width') {
exports.enter_fixed_mode();
return true;
}
if (content === '/settings') {
hashchange.go_to_location('settings/your-account');
return true;