2014-03-14 15:30:29 +01:00
|
|
|
var click_handlers = (function () {
|
|
|
|
|
|
|
|
// We don't actually export anything yet; this is just for consistency.
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
// You won't find every click handler here, but it's a good place to start!
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
|
|
// MOUSE MOVING DETECTION
|
|
|
|
var clicking = false;
|
|
|
|
var mouse_moved = false;
|
|
|
|
|
2016-11-01 22:32:10 +01:00
|
|
|
var meta = {};
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
function mousedown() {
|
|
|
|
mouse_moved = false;
|
|
|
|
clicking = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function mousemove() {
|
|
|
|
if (clicking) {
|
|
|
|
mouse_moved = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#main_div").on("mousedown", ".messagebox", mousedown);
|
|
|
|
$("#main_div").on("mousemove", ".messagebox", mousemove);
|
|
|
|
|
|
|
|
// MESSAGE CLICKING
|
|
|
|
|
|
|
|
function is_clickable_message_element(target) {
|
|
|
|
return target.is("a") || target.is("img.message_inline_image") || target.is("img.twitter-avatar") ||
|
|
|
|
target.is("div.message_length_controller") || target.is("textarea") || target.is("input") ||
|
|
|
|
target.is("i.edit_content_button");
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#main_div").on("click", ".messagebox", function (e) {
|
|
|
|
if (is_clickable_message_element($(e.target))) {
|
|
|
|
// If this click came from a hyperlink, don't trigger the
|
|
|
|
// reply action. The simple way of doing this is simply
|
|
|
|
// to call e.stopPropagation() from within the link's
|
|
|
|
// click handler.
|
|
|
|
//
|
|
|
|
// Unfortunately, on Firefox, this breaks Ctrl-click and
|
|
|
|
// Shift-click, because those are (apparently) implemented
|
|
|
|
// by adding an event listener on link clicks, and
|
|
|
|
// stopPropagation prevents them from being called.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(clicking && mouse_moved)) {
|
|
|
|
// Was a click (not a click-and-drag).
|
|
|
|
var row = $(this).closest(".message_row");
|
|
|
|
var id = rows.id(row);
|
|
|
|
|
|
|
|
if (message_edit.is_editing(id)) {
|
|
|
|
// Clicks on a message being edited shouldn't trigger a reply.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_msg_list.select_id(id);
|
2016-06-29 00:27:50 +02:00
|
|
|
compose.respond_to_message({trigger: 'message click'});
|
2014-03-14 15:30:29 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
}
|
|
|
|
mouse_moved = false;
|
|
|
|
clicking = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
function toggle_star(message_id) {
|
|
|
|
// Update the message object pointed to by the various message
|
|
|
|
// lists.
|
|
|
|
var message = ui.find_message(message_id);
|
|
|
|
|
|
|
|
unread.mark_message_as_read(message);
|
|
|
|
ui.update_starred(message.id, message.starred !== true);
|
|
|
|
message_flags.send_starred([message], message.starred);
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#main_div").on("click", ".star", function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
toggle_star(rows.id($(this).closest(".message_row")));
|
|
|
|
});
|
|
|
|
|
2016-12-02 13:23:23 +01:00
|
|
|
$("#main_div").on("click", ".message_reaction", function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
var emoji_name = $(this).attr('data-emoji-name');
|
|
|
|
var message_id = $(this).parent().attr('data-message-id');
|
|
|
|
reactions.message_reaction_on_click(message_id, emoji_name);
|
|
|
|
});
|
|
|
|
|
2016-11-18 10:18:08 +01:00
|
|
|
$("#main_div").on("click", "a.stream", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var stream = stream_data.get_sub_by_id($(this).attr('data-stream-id'));
|
|
|
|
if (stream) {
|
|
|
|
window.location.href = '/#narrow/stream/' + hashchange.encodeHashComponent(stream.name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
window.location.href = $(this).attr('href');
|
|
|
|
});
|
|
|
|
|
2016-12-28 03:41:20 +01:00
|
|
|
// NOTIFICATION CLICK
|
|
|
|
|
|
|
|
$('body').on('click', '.notification', function () {
|
|
|
|
var payload = $(this).data("narrow");
|
|
|
|
ui.change_tab_to('#home');
|
|
|
|
narrow.activate(payload.raw_operators, payload.opts_notif);
|
|
|
|
});
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
// MESSAGE EDITING
|
|
|
|
|
|
|
|
$('body').on('click', '.edit_content_button', function (e) {
|
|
|
|
var row = current_msg_list.get_row(rows.id($(this).closest(".message_row")));
|
|
|
|
current_msg_list.select_id(rows.id(row));
|
|
|
|
message_edit.start(row);
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
$('body').on('click','.always_visible_topic_edit,.on_hover_topic_edit', function (e) {
|
|
|
|
var recipient_row = $(this).closest(".recipient_row");
|
|
|
|
message_edit.start_topic_edit(recipient_row);
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
$("body").on("click", ".topic_edit_save", function (e) {
|
|
|
|
var recipient_row = $(this).closest(".recipient_row");
|
2016-10-26 01:12:12 +02:00
|
|
|
message_edit.save(recipient_row, true);
|
2014-03-14 15:30:29 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
$("body").on("click", ".topic_edit_cancel", function (e) {
|
|
|
|
var recipient_row = $(this).closest(".recipient_row");
|
|
|
|
current_msg_list.hide_edit_topic(recipient_row);
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
$("body").on("click", ".message_edit_save", function (e) {
|
|
|
|
var row = $(this).closest(".message_row");
|
2016-10-26 01:12:12 +02:00
|
|
|
message_edit.save(row, false);
|
2014-03-14 15:30:29 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
$("body").on("click", ".message_edit_cancel", function (e) {
|
|
|
|
var row = $(this).closest(".message_row");
|
|
|
|
message_edit.end(row);
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
2016-10-22 02:38:56 +02:00
|
|
|
$("body").on("click", ".message_edit_close", function (e) {
|
|
|
|
var row = $(this).closest(".message_row");
|
|
|
|
message_edit.end(row);
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
2016-12-15 07:26:09 +01:00
|
|
|
$("body").on("click", "a", function () {
|
2016-12-14 23:34:08 +01:00
|
|
|
if (document.activeElement === this) {
|
|
|
|
ui.blur_active_element();
|
|
|
|
}
|
|
|
|
});
|
2014-03-14 15:30:29 +01:00
|
|
|
|
2016-12-15 07:26:09 +01:00
|
|
|
$(window).on("focus", function () {
|
2016-11-01 22:32:10 +01:00
|
|
|
meta.focusing = true;
|
|
|
|
});
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
// RECIPIENT BARS
|
|
|
|
|
|
|
|
function get_row_id_for_narrowing(narrow_link_elem) {
|
|
|
|
var group = rows.get_closest_group(narrow_link_elem);
|
|
|
|
var msg_id = rows.id_for_recipient_row(group);
|
|
|
|
|
|
|
|
var nearest = current_msg_list.get(msg_id);
|
|
|
|
var selected = current_msg_list.selected_message();
|
|
|
|
if (util.same_recipient(nearest, selected)) {
|
|
|
|
return selected.id;
|
|
|
|
}
|
2016-12-02 21:34:35 +01:00
|
|
|
return nearest.id;
|
2014-03-14 15:30:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#home").on("click", ".narrows_by_recipient", function (e) {
|
|
|
|
if (e.metaKey || e.ctrlKey) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
var row_id = get_row_id_for_narrowing(this);
|
|
|
|
narrow.by_recipient(row_id, {trigger: 'message header'});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#home").on("click", ".narrows_by_subject", function (e) {
|
|
|
|
if (e.metaKey || e.ctrlKey) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
var row_id = get_row_id_for_narrowing(this);
|
|
|
|
narrow.by_subject(row_id, {trigger: 'message header'});
|
|
|
|
});
|
|
|
|
|
|
|
|
// SIDEBARS
|
|
|
|
|
|
|
|
$("#userlist-toggle-button").on("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
var sidebarHidden = !$(".app-main .column-right").hasClass("expanded");
|
|
|
|
popovers.hide_all();
|
|
|
|
if (sidebarHidden) {
|
|
|
|
popovers.show_userlist_sidebar();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#streamlist-toggle-button").on("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
var sidebarHidden = !$(".app-main .column-left").hasClass("expanded");
|
|
|
|
popovers.hide_all();
|
|
|
|
if (sidebarHidden) {
|
|
|
|
popovers.show_streamlist_sidebar();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#user_presences').expectOne().on('click', '.selectable_sidebar_block', function (e) {
|
2016-11-17 23:16:29 +01:00
|
|
|
var user_id = $(e.target).parents('li').attr('data-user-id');
|
|
|
|
var email = people.get_person_from_user_id(user_id).email;
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
narrow.by('pm-with', email, {select_first_unread: true, trigger: 'sidebar'});
|
|
|
|
// The preventDefault is necessary so that clicking the
|
|
|
|
// link doesn't jump us to the top of the page.
|
|
|
|
e.preventDefault();
|
|
|
|
// The stopPropagation is necessary so that we don't
|
|
|
|
// see the following sequence of events:
|
|
|
|
// 1. This click "opens" the composebox
|
|
|
|
// 2. This event propagates to the body, which says "oh, hey, the
|
|
|
|
// composebox is open and you clicked out of it, you must want to
|
|
|
|
// stop composing!"
|
|
|
|
e.stopPropagation();
|
|
|
|
// Since we're stopping propagation we have to manually close any
|
|
|
|
// open popovers.
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#group-pms').expectOne().on('click', '.selectable_sidebar_block', function (e) {
|
2016-11-17 23:16:29 +01:00
|
|
|
var user_ids_string = $(e.target).parents('li').attr('data-user-ids');
|
|
|
|
var emails = people.user_ids_string_to_emails_string(user_ids_string);
|
2014-03-14 15:30:29 +01:00
|
|
|
narrow.by('pm-with', emails, {select_first_unread: true, trigger: 'sidebar'});
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
|
|
|
});
|
|
|
|
|
2016-11-01 22:32:10 +01:00
|
|
|
$("#subscriptions_table").on("click", ".exit, #subscription_overlay", function (e) {
|
|
|
|
if (meta.focusing) {
|
|
|
|
meta.focusing = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($(e.target).is(".exit, .exit-sign, #subscription_overlay, #subscription_overlay > .flex")) {
|
|
|
|
$("#subscription_overlay").fadeOut(500);
|
|
|
|
subs.remove_miscategorized_streams();
|
2014-03-14 15:30:29 +01:00
|
|
|
|
2016-11-01 22:32:10 +01:00
|
|
|
hashchange.exit_settings();
|
|
|
|
}
|
|
|
|
});
|
2014-03-14 15:30:29 +01:00
|
|
|
// HOME
|
|
|
|
|
|
|
|
// Capture both the left-sidebar Home click and the tab breadcrumb Home
|
|
|
|
$(document).on('click', "li[data-name='home']", function (e) {
|
|
|
|
ui.change_tab_to('#home');
|
|
|
|
narrow.deactivate();
|
|
|
|
// We need to maybe scroll to the selected message
|
|
|
|
// once we have the proper viewport set up
|
2016-05-25 13:24:33 +02:00
|
|
|
setTimeout(navigate.maybe_scroll_to_selected, 0);
|
2014-03-14 15:30:29 +01:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
// This is obsolete, I believe.
|
|
|
|
$(".brand").on('click', function (e) {
|
|
|
|
if (ui.home_tab_obscured()) {
|
|
|
|
ui.change_tab_to('#home');
|
|
|
|
} else {
|
|
|
|
narrow.restore_home_state();
|
|
|
|
}
|
2016-05-25 13:24:33 +02:00
|
|
|
navigate.maybe_scroll_to_selected();
|
2014-03-14 15:30:29 +01:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
// MISC
|
|
|
|
|
2016-09-29 21:56:50 +02:00
|
|
|
(function () {
|
|
|
|
var sel = ["#group-pm-list", "#stream_filters", "#global_filters", "#user_presences"].join(", ");
|
|
|
|
|
|
|
|
$(sel).on("click", "a", function () {
|
|
|
|
this.blur();
|
|
|
|
});
|
|
|
|
}());
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
popovers.register_click_handlers();
|
|
|
|
notifications.register_click_handlers();
|
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$('.logout_button').click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
$('#logout_form').submit();
|
|
|
|
});
|
2016-12-02 14:06:06 +01:00
|
|
|
$('.restart_get_events_button').click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
server_events.restart_get_events({dont_block: true});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// COMPOSE
|
|
|
|
|
|
|
|
// NB: This just binds to current elements, and won't bind to elements
|
|
|
|
// created after ready() is called.
|
|
|
|
$('#send-status .send-status-close').click(
|
|
|
|
function () { $('#send-status').stop(true).fadeOut(500); }
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$('.compose_stream_button').click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
compose.start('stream');
|
|
|
|
});
|
2016-12-02 14:06:06 +01:00
|
|
|
$('.compose_private_button').click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
compose.start('private');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.empty_feed_compose_stream').click(function (e) {
|
|
|
|
compose.start('stream', {trigger: 'empty feed message'});
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
$('.empty_feed_compose_private').click(function (e) {
|
|
|
|
compose.start('private', {trigger: 'empty feed message'});
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
function handle_compose_click(e) {
|
2015-10-15 22:34:30 +02:00
|
|
|
// Emoji clicks should be handled by their own click handler in popover.js
|
2016-11-17 00:04:30 +01:00
|
|
|
if ($(e.target).is("#emoji_map, .emoji_popover, .emoji_popover.inner, img.emoji, .drag")) {
|
2015-10-15 22:34:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-03-14 15:30:29 +01:00
|
|
|
// Don't let clicks in the compose area count as
|
|
|
|
// "unfocusing" our compose -- in other words, e.g.
|
|
|
|
// clicking "Press enter to send" should not
|
|
|
|
// trigger the composebox-closing code above.
|
|
|
|
// But do allow our formatting link.
|
|
|
|
if (!$(e.target).is("a")) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
// Still hide the popovers, however
|
|
|
|
popovers.hide_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#compose_buttons").click(handle_compose_click);
|
|
|
|
$(".compose-content").click(handle_compose_click);
|
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$("#compose_close").click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
compose.cancel();
|
|
|
|
});
|
|
|
|
|
|
|
|
// FEEDBACK
|
|
|
|
|
|
|
|
// Keep these 2 feedback bot triggers separate because they have to
|
|
|
|
// propagate the event differently.
|
2016-12-02 14:06:06 +01:00
|
|
|
$('.feedback').click(function () {
|
2016-12-03 03:39:03 +01:00
|
|
|
compose.start('private', {private_message_recipient: 'feedback@zulip.com',
|
|
|
|
trigger: 'feedback menu item'});
|
2014-03-14 15:30:29 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
$('#feedback_button').click(function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
popovers.hide_all();
|
2016-12-03 03:39:03 +01:00
|
|
|
compose.start('private', {private_message_recipient: 'feedback@zulip.com',
|
|
|
|
trigger: 'feedback button'});
|
2014-03-14 15:30:29 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// WEBATHENA
|
|
|
|
|
|
|
|
$('#right-sidebar, #top_navbar').on('click', '.webathena_login', function (e) {
|
|
|
|
$("#zephyr-mirror-error").hide();
|
|
|
|
var principal = ["zephyr", "zephyr"];
|
|
|
|
WinChan.open({
|
|
|
|
url: "https://webathena.mit.edu/#!request_ticket_v1",
|
|
|
|
relay_url: "https://webathena.mit.edu/relay.html",
|
|
|
|
params: {
|
|
|
|
realm: "ATHENA.MIT.EDU",
|
2017-01-12 00:17:43 +01:00
|
|
|
principal: principal,
|
|
|
|
},
|
2014-03-14 15:30:29 +01:00
|
|
|
}, function (err, r) {
|
|
|
|
if (err) {
|
|
|
|
blueslip.warn(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (r.status !== "OK") {
|
|
|
|
blueslip.warn(r);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
channel.post({
|
|
|
|
url: "/accounts/webathena_kerberos_login/",
|
|
|
|
data: {cred: JSON.stringify(r.session)},
|
2016-12-02 14:06:06 +01:00
|
|
|
success: function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
$("#zephyr-mirror-error").hide();
|
|
|
|
},
|
2016-12-02 14:06:06 +01:00
|
|
|
error: function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
$("#zephyr-mirror-error").show();
|
2017-01-12 00:17:43 +01:00
|
|
|
},
|
2014-03-14 15:30:29 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#settings-dropdown').dropdown("toggle");
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
// End Webathena code
|
|
|
|
|
|
|
|
// BANKRUPTCY
|
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$(".bankruptcy_button").click(function () {
|
2014-03-14 15:30:29 +01:00
|
|
|
unread.enable();
|
|
|
|
});
|
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$('#yes-bankrupt').click(function () {
|
2016-04-12 17:38:47 +02:00
|
|
|
pointer.fast_forward_pointer();
|
2014-03-14 15:30:29 +01:00
|
|
|
$("#yes-bankrupt").hide();
|
|
|
|
$("#no-bankrupt").hide();
|
|
|
|
$(this).after($("<div>").addClass("alert alert-info settings_committed")
|
|
|
|
.text("Bringing you to your latest messages…"));
|
|
|
|
});
|
|
|
|
|
2016-09-22 02:05:24 +02:00
|
|
|
(function () {
|
|
|
|
$("#main_div").on("click", ".message_inline_image a", function (e) {
|
2016-12-02 17:09:31 +01:00
|
|
|
var img = e.target;
|
|
|
|
var row = rows.id($(img).closest(".message_row"));
|
|
|
|
var user = current_msg_list.get(row).sender_full_name;
|
|
|
|
var $target = $(this);
|
2016-09-22 02:05:24 +02:00
|
|
|
|
|
|
|
// prevent the link from opening in a new page.
|
|
|
|
e.preventDefault();
|
|
|
|
// prevent the message compose dialog from happening.
|
|
|
|
e.stopPropagation();
|
|
|
|
|
2016-10-17 22:02:25 +02:00
|
|
|
if ($target.parent().hasClass("youtube-video")) {
|
|
|
|
ui.lightbox({
|
|
|
|
type: "youtube",
|
2017-01-12 00:17:43 +01:00
|
|
|
id: $target.data("id"),
|
2016-10-17 22:02:25 +02:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
ui.lightbox({
|
|
|
|
type: "photo",
|
|
|
|
image: img,
|
2017-01-12 00:17:43 +01:00
|
|
|
user: user,
|
2016-10-17 22:02:25 +02:00
|
|
|
});
|
|
|
|
}
|
2016-09-22 02:05:24 +02:00
|
|
|
});
|
|
|
|
|
2016-10-25 23:26:28 +02:00
|
|
|
$("#overlay .exit, #overlay .image-preview").click(function (e) {
|
|
|
|
if ($(e.target).is(".exit, .image-preview")) {
|
|
|
|
ui.exit_lightbox_photo();
|
|
|
|
}
|
2016-09-22 02:05:24 +02:00
|
|
|
});
|
2016-09-29 22:33:08 +02:00
|
|
|
|
2016-12-02 14:06:06 +01:00
|
|
|
$("#overlay .download").click(function () {
|
2016-09-29 22:33:08 +02:00
|
|
|
this.blur();
|
|
|
|
});
|
2016-09-22 02:05:24 +02:00
|
|
|
}());
|
|
|
|
|
2014-03-14 15:30:29 +01:00
|
|
|
// MAIN CLICK HANDLER
|
|
|
|
|
|
|
|
$(document).on('click', function (e) {
|
2016-10-15 07:21:30 +02:00
|
|
|
if (e.button !== 0 || $(e.target).is(".drag")) {
|
2014-03-14 15:30:29 +01:00
|
|
|
// Firefox emits right click events on the document, but not on
|
|
|
|
// the child nodes, so the #compose stopPropagation doesn't get a
|
|
|
|
// chance to capture right clicks.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dismiss popovers if the user has clicked outside them
|
|
|
|
if ($('.popover-inner').has(e.target).length === 0) {
|
|
|
|
popovers.hide_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unfocus our compose area if we click out of it. Don't let exits out
|
|
|
|
// of modals or selecting text (for copy+paste) trigger cancelling.
|
2016-10-15 07:21:30 +02:00
|
|
|
if (compose.composing() && !$(e.target).is("a") &&
|
2014-03-14 15:30:29 +01:00
|
|
|
($(e.target).closest(".modal").length === 0) &&
|
2015-10-15 22:34:30 +02:00
|
|
|
window.getSelection().toString() === "" &&
|
|
|
|
($(e.target).closest('#emoji_map').length === 0)) {
|
2014-03-14 15:30:29 +01:00
|
|
|
compose.cancel();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Workaround for Bootstrap issue #5900, which basically makes dropdowns
|
|
|
|
// unclickable on mobile devices.
|
|
|
|
// https://github.com/twitter/bootstrap/issues/5900
|
|
|
|
$('a.dropdown-toggle, .dropdown-menu a').on('touchstart', function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
2016-12-04 08:59:56 +01:00
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = click_handlers;
|
|
|
|
}
|