Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

user_status: Migrate to handlebars.

Ganesh Pawarc220c01ad2a8
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 8cdb0c7832d..cd8409d1dcf 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -43,7 +43,6 @@ import * as stream_popover from "./stream_popover";
import * as topic_list from "./topic_list";
import * as ui_util from "./ui_util";
import * as unread_ops from "./unread_ops";
-import * as user_status_ui from "./user_status_ui";
import * as util from "./util";
export function initialize() {
@@ -268,16 +267,6 @@ export function initialize() {
window.location.href = $(this).attr("href");
});
- // USER STATUS MODAL
-
- $(".user-status-value").on("click", (e) => {
- e.stopPropagation();
- const user_status_value = $(e.currentTarget).text();
- $("input.user_status").val(user_status_value);
- user_status_ui.toggle_clear_message_button();
- user_status_ui.update_button();
- });
-
// MESSAGE EDITING
$("body").on("click", ".edit_content_button", function (e) {
diff --git a/static/js/user_status_ui.js b/static/js/user_status_ui.js
index 73047839d3d..b27dd4d06dd 100644
--- a/static/js/user_status_ui.js
+++ b/static/js/user_status_ui.js
@@ -1,5 +1,7 @@
import $ from "jquery";
+import render_set_status_overlay from "../templates/set_status_overlay.hbs";
+
import * as overlays from "./overlays";
import * as people from "./people";
import * as user_status from "./user_status";
@@ -84,6 +86,17 @@ export function clear_message() {
}
export function initialize() {
+ const rendered_set_status_overlay = render_set_status_overlay();
+ $(".app").append(rendered_set_status_overlay);
+
+ $("body").on("click", ".user-status-value", (event) => {
+ event.stopPropagation();
+ const user_status_value = $(event.currentTarget).text();
+ $("input.user_status").val(user_status_value);
+ toggle_clear_message_button();
+ update_button();
+ });
+
$("body").on("click", ".user_status_overlay .set_user_status", () => {
submit_new_status();
});
@@ -101,7 +114,7 @@ export function initialize() {
toggle_clear_message_button();
});
- $("#clear_status_message_button").on("click", () => {
+ $("body").on("click", "#clear_status_message_button", () => {
clear_message();
update_button();
});
diff --git a/static/templates/set_status_overlay.hbs b/static/templates/set_status_overlay.hbs
new file mode 100644
index 00000000000..71c04c85735
--- /dev/null
+++ b/static/templates/set_status_overlay.hbs
@@ -0,0 +1,30 @@
+<div class="user_status_overlay overlay new-style" data-overlay="user_status_overlay" aria-hidden="true">
+ <div class="overlay-content modal-bg">
+ <div class="user-status-header">
+ <h1>{{t "Set a status" }}</h1>
+ <div class="exit">
+ <span class="exit-sign">&times;</span>
+ </div>
+ </div>
+ <div class="modal-body">
+ <label for="user_status">{{t "Status message" }}</label>
+ <input type="text" class="user_status" maxlength="60" />
+ <button type="button" class="btn clear_search_button" id="clear_status_message_button" disabled="disabled">
+ <i class="fa fa-remove" aria-hidden="true"></i>
+ </button>
+ </div>
+ <div class="user-status-options">
+ <button type="button" class="button no-style user-status-value">{{t "In a meeting" }}</button>
+ <button type="button" class="button no-style user-status-value">{{t "Commuting" }}</button>
+ <button type="button" class="button no-style user-status-value">{{t "Out sick" }}</button>
+ <button type="button" class="button no-style user-status-value">{{t "Vacationing" }}</button>
+ <button type="button" class="button no-style user-status-value">{{t "Working remotely" }}</button>
+ </div>
+ <div class="modal-footer">
+ <button class="button exit small rounded">{{t "Cancel" }}</button>
+ <button class="sea-green small rounded button set_user_status">
+ {{t "Save" }}
+ </button>
+ </div>
+ </div>
+</div>
diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.html
index d5c461048d7..1a19536867e 100644
--- a/templates/zerver/app/index.html
+++ b/templates/zerver/app/index.html
@@ -145,36 +145,6 @@
</div>
</div>
</div>
- <div class="user_status_overlay overlay new-style" data-overlay="user_status_overlay" aria-hidden="true">
- <div class="overlay-content modal-bg">
- <div class="user-status-header">
- <h1>{{ _("Set a status") }}</h1>
- <div class="exit">
- <span class="exit-sign">&times;</span>
- </div>
- </div>
- <div class="modal-body">
- <label for="user_status">{{ _("Status message") }}</label>
- <input type="text" class="user_status" maxlength="60" />
- <button type="button" class="btn clear_search_button" id="clear_status_message_button" disabled="disabled">
- <i class="fa fa-remove" aria-hidden="true"></i>
- </button>
- </div>
- <div class="user-status-options">
- <button type="button" class="button no-style user-status-value">{{ _("In a meeting") }}</button>
- <button type="button" class="button no-style user-status-value">{{ _("Commuting") }}</button>
- <button type="button" class="button no-style user-status-value">{{ _("Out sick") }}</button>
- <button type="button" class="button no-style user-status-value">{{ _("Vacationing") }}</button>
- <button type="button" class="button no-style user-status-value">{{ _("Working remotely") }}</button>
- </div>
- <div class="modal-footer">
- <button class="button exit small rounded">{{ _("Cancel") }}</button>
- <button class="sea-green small rounded button set_user_status">
- {{ _("Save") }}
- </button>
- </div>
- </div>
- </div>
<div class="hidden">
<form id="logout_form" action="/accounts/logout/" method="POST">{{ csrf_input }}
</form>