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.

giphy: Get message_id for `compose_giphy_logo` from `.message_row`.

Aman Agrawal4c605858207e
diff --git a/static/js/giphy.js b/static/js/giphy.js
index e5e89bf1a8c..18e59800ed5 100644
--- a/static/js/giphy.js
+++ b/static/js/giphy.js
@@ -10,6 +10,7 @@ import * as compose_ui from "./compose_ui";
import {media_breakpoints_num} from "./css_variables";
import {page_params} from "./page_params";
import * as popovers from "./popovers";
+import * as rows from "./rows";
import * as ui_util from "./ui_util";
const giphy_fetch = new GiphyFetch(page_params.giphy_api_key);
@@ -188,10 +189,13 @@ export function initialize() {
}
popovers.hide_all();
const $elt = $(e.target);
- // Store data-message-id value in global variable edit_message_id so that
- // its value can be further used to correctly find the message textarea element.
- // This will store `undefined` when called from compose box, by design.
- edit_message_id = $elt.attr("data-message-id");
+ if ($elt.parents(".message_edit_form").length === 1) {
+ // Store message id in global variable edit_message_id so that
+ // its value can be further used to correctly find the message textarea element.
+ edit_message_id = rows.id($elt.parents(".message_row"));
+ } else {
+ edit_message_id = undefined;
+ }
active_popover_element = $elt.closest("#compose_box_giphy_grid");
active_popover_element.popover({
diff --git a/static/templates/message_edit_form.hbs b/static/templates/message_edit_form.hbs
index e8076bf82a3..d3cbaa999e3 100644
--- a/static/templates/message_edit_form.hbs
+++ b/static/templates/message_edit_form.hbs
@@ -70,7 +70,7 @@
<a role="button" tabindex=0 class="emoji_map compose_control_button fa fa-smile-o" aria-label="{{t 'Add emoji' }}" title="{{t 'Add emoji' }}"></a>
{{#if giphy_api_available }}
<a role="button" class="compose_control_button" aria-label="{{t 'Add GIF' }}" id="compose_box_giphy_grid" title="{{t 'Add GIF' }}">
- <img class="compose_giphy_logo" tabindex=0 src="/static/images/GIPHY_logo.png" data-message-id="{{message_id}}" />
+ <img class="compose_giphy_logo" tabindex=0 src="/static/images/GIPHY_logo.png">
</a>
{{/if}}
<a role="button" tabindex=0 class="message-control-link" data-overlay-trigger="message-formatting" >{{t 'Help' }}</a>