lint: Fix many no-unused-vars eslint rule violations.

These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
This commit is contained in:
Rafid Aslam
2016-12-02 20:06:06 +07:00
committed by Tim Abbott
parent 80ad28bab5
commit 45f39be37f
36 changed files with 127 additions and 219 deletions

View File

@@ -29,7 +29,7 @@ exports.init_viewport = function () {
casper.options.viewportSize = {width: 1280, height: 1024}; casper.options.viewportSize = {width: 1280, height: 1024};
}; };
exports.initialize_casper = function (viewport) { exports.initialize_casper = function () {
if (casper.zulip_initialized !== undefined) { if (casper.zulip_initialized !== undefined) {
return; return;
} }

View File

@@ -1,7 +1,6 @@
var common = require('../casper_lib/common.js').common; var common = require('../casper_lib/common.js').common;
var email = 'alice@test.example.com'; var email = 'alice@test.example.com';
var domain = 'test.example.com';
var subdomain = 'testsubdomain'; var subdomain = 'testsubdomain';
var organization_name = 'Awesome Organization'; var organization_name = 'Awesome Organization';
var REALMS_HAVE_SUBDOMAINS = casper.cli.get('subdomains'); var REALMS_HAVE_SUBDOMAINS = casper.cli.get('subdomains');

View File

@@ -435,7 +435,7 @@ var run = (function () {
}()); }());
run(function (override, capture, args) { run(function () {
// alert_words // alert_words
var event = event_fixtures.alert_words; var event = event_fixtures.alert_words;
dispatch(event); dispatch(event);
@@ -443,7 +443,7 @@ run(function (override, capture, args) {
}); });
run(function (override, capture, args) { run(function (override) {
// default_streams // default_streams
var event = event_fixtures.default_streams; var event = event_fixtures.default_streams;
override('admin', 'update_default_streams_table', noop); override('admin', 'update_default_streams_table', noop);
@@ -471,7 +471,7 @@ run(function (override, capture, args) {
}); });
run(function (override, capture, args) { run(function () {
// pointer // pointer
var event = event_fixtures.pointer; var event = event_fixtures.pointer;
global.pointer.furthest_read = 0; global.pointer.furthest_read = 0;
@@ -492,7 +492,7 @@ run(function (override, capture, args) {
}); });
run(function (override, capture, args) { run(function (override) {
// realm // realm
function test_realm_boolean(event, parameter_name) { function test_realm_boolean(event, parameter_name) {
page_params[parameter_name] = true; page_params[parameter_name] = true;
@@ -565,7 +565,7 @@ run(function (override, capture, args) {
}); });
run(function (override, capture, args) { run(function (override) {
// realm_filters // realm_filters
var event = event_fixtures.realm_filters; var event = event_fixtures.realm_filters;
page_params.realm_filters = []; page_params.realm_filters = [];
@@ -684,7 +684,7 @@ run(function (override, capture, args) {
}); });
run(function (override, capture, args) { run(function () {
// update_display_settings // update_display_settings
var event = event_fixtures.update_display_settings__default_language; var event = event_fixtures.update_display_settings__default_language;
page_params.default_language = 'en'; page_params.default_language = 'en';

View File

@@ -201,10 +201,6 @@ var _ = global._;
var search_term = 'a'; var search_term = 'a';
var users = people.get_rest_of_realm(); var users = people.get_rest_of_realm();
var filtered_people = people.filter_people_by_search_terms(users, [search_term]); var filtered_people = people.filter_people_by_search_terms(users, [search_term]);
var expected = [
{ email: 'athens@example.com', full_name: 'Maria Athens' },
{ email: 'ashton@example.com', full_name: 'Ashton Smith' },
];
assert.equal(filtered_people["ashton@example.com"], true); assert.equal(filtered_people["ashton@example.com"], true);
assert.equal(filtered_people["athens@example.com"], true); assert.equal(filtered_people["athens@example.com"], true);
assert.equal(_.keys(filtered_people).length, 2); assert.equal(_.keys(filtered_people).length, 2);

View File

@@ -123,12 +123,6 @@ var zero_counts = {
// Test defensive code. Trying to update a message we don't know // Test defensive code. Trying to update a message we don't know
// about should be a no-op. // about should be a no-op.
var unknown_message = {
id: 18,
type: 'stream',
stream: 'social',
subject: 'lunch',
};
event = { event = {
subject: 'brunch', subject: 'brunch',
}; };

View File

@@ -2,7 +2,6 @@ var admin = (function () {
var exports = {}; var exports = {};
var all_streams = []; var all_streams = [];
var user_row_to_deactivate;
exports.show_or_hide_menu_item = function () { exports.show_or_hide_menu_item = function () {
var item = $('.admin-menu-item').expectOne(); var item = $('.admin-menu-item').expectOne();
@@ -41,20 +40,16 @@ exports.update_user_full_name = function (email, new_full_name) {
user_row.show(); user_row.show();
}; };
function failed_listing_users(xhr, error) { function failed_listing_users(xhr) {
loading.destroy_indicator($('#subs_page_loading_indicator')); loading.destroy_indicator($('#subs_page_loading_indicator'));
ui.report_error(i18n.t("Error listing users or bots"), xhr, $("#administration-status")); ui.report_error(i18n.t("Error listing users or bots"), xhr, $("#administration-status"));
} }
function failed_listing_streams(xhr, error) { function failed_listing_streams(xhr) {
ui.report_error(i18n.t("Error listing streams"), xhr, $("#administration-status")); ui.report_error(i18n.t("Error listing streams"), xhr, $("#administration-status"));
} }
function failed_listing_emoji(xhr, error) { function failed_changing_name(xhr) {
ui.report_error(i18n.t("Error listing emoji"), xhr, $("#administration-status"));
}
function failed_changing_name(xhr, error) {
ui.report_error(i18n.t("Error changing name"), xhr, $("#administration-status")); ui.report_error(i18n.t("Error changing name"), xhr, $("#administration-status"));
} }
@@ -144,12 +139,11 @@ function make_stream_default(stream_name) {
var data = { var data = {
stream_name: stream_name stream_name: stream_name
}; };
var default_streams_table = $("#admin_default_streams_table").expectOne();
channel.put({ channel.put({
url: '/json/default_streams', url: '/json/default_streams',
data: data, data: data,
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
$(".active_stream_row button").closest("td").html( $(".active_stream_row button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)); $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg));
@@ -223,7 +217,7 @@ exports.populate_auth_methods = function (auth_methods) {
}; };
exports.set_up_deactivate_user_modal = function (row) { exports.set_up_deactivate_user_modal = function (row) {
$("#do_deactivate_user_button").expectOne().click(function (e) { $("#do_deactivate_user_button").expectOne().click(function () {
var email = row.find(".email").text(); var email = row.find(".email").text();
if ($("#deactivation_user_modal .email").html() !== email) { if ($("#deactivation_user_modal .email").html() !== email) {
blueslip.error("User deactivation canceled due to non-matching fields."); blueslip.error("User deactivation canceled due to non-matching fields.");
@@ -234,7 +228,7 @@ exports.set_up_deactivate_user_modal = function (row) {
row.find("button").prop("disabled", true).text("Working…"); row.find("button").prop("disabled", true).text("Working…");
channel.del({ channel.del({
url: '/json/users/' + email, url: '/json/users/' + email,
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
row.find("button").closest("td").html( row.find("button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
@@ -379,7 +373,7 @@ function _setup_page() {
channel.del({ channel.del({
url: '/json/default_streams'+ '?' + $.param({stream_name: stream_name}), url: '/json/default_streams'+ '?' + $.param({stream_name: stream_name}),
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
$(".active_default_stream_row button").closest("td").html( $(".active_default_stream_row button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)); $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg));
@@ -404,7 +398,7 @@ function _setup_page() {
$('.create_default_stream').typeahead({ $('.create_default_stream').typeahead({
items: 5, items: 5,
fixed: true, fixed: true,
source: function (query) { source: function () {
return get_non_default_streams_names(all_streams); return get_non_default_streams_names(all_streams);
}, },
highlight: true, highlight: true,
@@ -419,12 +413,11 @@ function _setup_page() {
var row = $(e.target).closest(".user_row"); var row = $(e.target).closest(".user_row");
var user_name = row.find('.user_name').text();
var email = get_email_for_user_row(row); var email = get_email_for_user_row(row);
channel.del({ channel.del({
url: '/json/bots/' + email, url: '/json/bots/' + email,
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
row.find("button").closest("td").html( row.find("button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
@@ -455,7 +448,7 @@ function _setup_page() {
channel.post({ channel.post({
url: '/json/users/' + email + "/reactivate", url: '/json/users/' + email + "/reactivate",
error: function (xhr, error_type) { error: function (xhr) {
var button = row.find("button"); var button = row.find("button");
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
button.closest("td").html( button.closest("td").html(
@@ -506,7 +499,6 @@ function _setup_page() {
var create_stream_by_admins_only_status = $("#admin-realm-create-stream-by-admins-only-status").expectOne(); var create_stream_by_admins_only_status = $("#admin-realm-create-stream-by-admins-only-status").expectOne();
var message_editing_status = $("#admin-realm-message-editing-status").expectOne(); var message_editing_status = $("#admin-realm-message-editing-status").expectOne();
var default_language_status = $("#admin-realm-default-language-status").expectOne(); var default_language_status = $("#admin-realm-default-language-status").expectOne();
var auth_methods_table = $('.admin_auth_methods_table');
name_status.hide(); name_status.hide();
restricted_to_domain_status.hide(); restricted_to_domain_status.hide();
invite_required_status.hide(); invite_required_status.hide();
@@ -626,7 +618,7 @@ function _setup_page() {
} }
} }
}, },
error: function (xhr, error) { error: function (xhr) {
var reason = $.parseJSON(xhr.responseText).reason; var reason = $.parseJSON(xhr.responseText).reason;
if (reason === "no authentication") { if (reason === "no authentication") {
ui.report_error(i18n.t("Failed!"), xhr, authentication_methods_status); ui.report_error(i18n.t("Failed!"), xhr, authentication_methods_status);
@@ -661,7 +653,7 @@ function _setup_page() {
button.removeClass("make-admin"); button.removeClass("make-admin");
button.text(i18n.t("Remove admin")); button.text(i18n.t("Remove admin"));
}, },
error: function (xhr, error) { error: function (xhr) {
var status = row.find(".admin-user-status"); var status = row.find(".admin-user-status");
ui.report_error(i18n.t("Failed!"), xhr, status); ui.report_error(i18n.t("Failed!"), xhr, status);
} }
@@ -692,7 +684,7 @@ function _setup_page() {
button.removeClass("remove-admin"); button.removeClass("remove-admin");
button.text(i18n.t("Make admin")); button.text(i18n.t("Make admin"));
}, },
error: function (xhr, error) { error: function (xhr) {
var status = row.find(".admin-user-status"); var status = row.find(".admin-user-status");
ui.report_error(i18n.t("Failed!"), xhr, status); ui.report_error(i18n.t("Failed!"), xhr, status);
} }
@@ -713,7 +705,7 @@ function _setup_page() {
user_row.hide(); user_row.hide();
form_row.show(); form_row.show();
reset_button.on("click", function (e) { reset_button.on("click", function () {
form_row.hide(); form_row.hide();
user_row.show(); user_row.show();
}); });
@@ -738,7 +730,7 @@ function _setup_page() {
}); });
}); });
$("#do_deactivate_stream_button").click(function (e) { $("#do_deactivate_stream_button").click(function () {
if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) { if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) {
blueslip.error("Stream deactivation canceled due to non-matching fields."); blueslip.error("Stream deactivation canceled due to non-matching fields.");
ui.report_message("Deactivation encountered an error. Please reload and try again.", ui.report_message("Deactivation encountered an error. Please reload and try again.",
@@ -748,7 +740,7 @@ function _setup_page() {
$(".active_stream_row button").prop("disabled", true).text("Working…"); $(".active_stream_row button").prop("disabled", true).text("Working…");
channel.del({ channel.del({
url: '/json/streams/' + encodeURIComponent($(".active_stream_row").find('.stream_name').text()), url: '/json/streams/' + encodeURIComponent($(".active_stream_row").find('.stream_name').text()),
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
$(".active_stream_row button").closest("td").html( $(".active_stream_row button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
@@ -771,7 +763,7 @@ function _setup_page() {
channel.del({ channel.del({
url: '/json/realm/emoji/' + encodeURIComponent(btn.attr('data-emoji-name')), url: '/json/realm/emoji/' + encodeURIComponent(btn.attr('data-emoji-name')),
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
btn.closest("td").html( btn.closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
@@ -804,7 +796,7 @@ function _setup_page() {
ui.report_success(i18n.t("Custom emoji added!"), emoji_status); ui.report_success(i18n.t("Custom emoji added!"), emoji_status);
$("form.admin-emoji-form input[type='text']").val(""); $("form.admin-emoji-form input[type='text']").val("");
}, },
error: function (xhr, error) { error: function (xhr) {
$('#admin-emoji-status').hide(); $('#admin-emoji-status').hide();
var errors = JSON.parse(xhr.responseText).msg; var errors = JSON.parse(xhr.responseText).msg;
xhr.responseText = JSON.stringify({msg: errors}); xhr.responseText = JSON.stringify({msg: errors});
@@ -820,7 +812,7 @@ function _setup_page() {
channel.del({ channel.del({
url: '/json/realm/filters/' + encodeURIComponent(btn.attr('data-filter-id')), url: '/json/realm/filters/' + encodeURIComponent(btn.attr('data-filter-id')),
error: function (xhr, error_type) { error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") { if (xhr.status.toString().charAt(0) === "4") {
btn.closest("td").html( btn.closest("td").html(
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg) $("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
@@ -857,7 +849,7 @@ function _setup_page() {
filter.id = data.id; filter.id = data.id;
ui.report_success(i18n.t("Custom filter added!"), filter_status); ui.report_success(i18n.t("Custom filter added!"), filter_status);
}, },
error: function (xhr, error) { error: function (xhr) {
var errors = $.parseJSON(xhr.responseText).errors; var errors = $.parseJSON(xhr.responseText).errors;
if (errors.pattern !== undefined) { if (errors.pattern !== undefined) {
xhr.responseText = JSON.stringify({msg: errors.pattern}); xhr.responseText = JSON.stringify({msg: errors.pattern});

View File

@@ -162,7 +162,7 @@ exports.build_direct_upload_widget = function (
upload_function upload_function
) { ) {
function accept(file) { function accept() {
input_error.hide(); input_error.hide();
upload_function(get_file_input()); upload_function(get_file_input());
} }

View File

@@ -272,10 +272,10 @@ $(function () {
popovers.register_click_handlers(); popovers.register_click_handlers();
notifications.register_click_handlers(); notifications.register_click_handlers();
$('.logout_button').click(function (e) { $('.logout_button').click(function () {
$('#logout_form').submit(); $('#logout_form').submit();
}); });
$('.restart_get_events_button').click(function (e) { $('.restart_get_events_button').click(function () {
server_events.restart_get_events({dont_block: true}); server_events.restart_get_events({dont_block: true});
}); });
@@ -289,10 +289,10 @@ $(function () {
); );
$('.compose_stream_button').click(function (e) { $('.compose_stream_button').click(function () {
compose.start('stream'); compose.start('stream');
}); });
$('.compose_private_button').click(function (e) { $('.compose_private_button').click(function () {
compose.start('private'); compose.start('private');
}); });
@@ -325,7 +325,7 @@ $(function () {
$("#compose_buttons").click(handle_compose_click); $("#compose_buttons").click(handle_compose_click);
$(".compose-content").click(handle_compose_click); $(".compose-content").click(handle_compose_click);
$("#compose_close").click(function (e) { $("#compose_close").click(function () {
compose.cancel(); compose.cancel();
}); });
@@ -333,7 +333,7 @@ $(function () {
// Keep these 2 feedback bot triggers separate because they have to // Keep these 2 feedback bot triggers separate because they have to
// propagate the event differently. // propagate the event differently.
$('.feedback').click(function (e) { $('.feedback').click(function () {
compose.start('private', {private_message_recipient: 'feedback@zulip.com', compose.start('private', {private_message_recipient: 'feedback@zulip.com',
trigger: 'feedback menu item'}); trigger: 'feedback menu item'});
@@ -372,10 +372,10 @@ $(function () {
channel.post({ channel.post({
url: "/accounts/webathena_kerberos_login/", url: "/accounts/webathena_kerberos_login/",
data: {cred: JSON.stringify(r.session)}, data: {cred: JSON.stringify(r.session)},
success: function (data, success) { success: function () {
$("#zephyr-mirror-error").hide(); $("#zephyr-mirror-error").hide();
}, },
error: function (data, success) { error: function () {
$("#zephyr-mirror-error").show(); $("#zephyr-mirror-error").show();
} }
}); });
@@ -388,11 +388,11 @@ $(function () {
// BANKRUPTCY // BANKRUPTCY
$(".bankruptcy_button").click(function (e) { $(".bankruptcy_button").click(function () {
unread.enable(); unread.enable();
}); });
$('#yes-bankrupt').click(function (e) { $('#yes-bankrupt').click(function () {
pointer.fast_forward_pointer(); pointer.fast_forward_pointer();
$("#yes-bankrupt").hide(); $("#yes-bankrupt").hide();
$("#no-bankrupt").hide(); $("#no-bankrupt").hide();
@@ -432,7 +432,7 @@ $(function () {
} }
}); });
$("#overlay .download").click(function (e) { $("#overlay .download").click(function () {
this.blur(); this.blur();
}); });
}()); }());

View File

@@ -403,8 +403,6 @@ function compose_error(error_text, bad_input) {
} }
} }
var send_options;
function send_message_ajax(request, success, error) { function send_message_ajax(request, success, error) {
channel.post({ channel.post({
url: '/json/messages', url: '/json/messages',

View File

@@ -238,10 +238,10 @@ exports.update_rendered_message_groups = function (message_groups, get_element)
}; };
$(function () { $(function () {
$(document).on('peer_subscribe.zulip', function (e) { $(document).on('peer_subscribe.zulip', function () {
exports.update_faded_users(); exports.update_faded_users();
}); });
$(document).on('peer_unsubscribe.zulip', function (e) { $(document).on('peer_unsubscribe.zulip', function () {
exports.update_faded_users(); exports.update_faded_users();
}); });
}); });

View File

@@ -165,7 +165,7 @@ function select_on_focus(field_id) {
// conditions in Chrome so we need to protect against infinite // conditions in Chrome so we need to protect against infinite
// recursion. // recursion.
var in_handler = false; var in_handler = false;
$("#" + field_id).focus(function (e) { $("#" + field_id).focus(function () {
if (in_handler) { if (in_handler) {
return; return;
} }
@@ -378,7 +378,7 @@ exports.initialize = function () {
// limit number of items so the list doesn't fall off the screen // limit number of items so the list doesn't fall off the screen
$( "#stream" ).typeahead({ $( "#stream" ).typeahead({
source: function (query, process) { source: function () {
return stream_data.subscribed_streams(); return stream_data.subscribed_streams();
}, },
items: 3, items: 3,
@@ -396,7 +396,7 @@ exports.initialize = function () {
}); });
$( "#subject" ).typeahead({ $( "#subject" ).typeahead({
source: function (query, process) { source: function () {
var stream_name = $("#stream").val(); var stream_name = $("#stream").val();
return exports.topics_seen_for(stream_name); return exports.topics_seen_for(stream_name);
}, },
@@ -450,7 +450,7 @@ exports.initialize = function () {
exports.initialize_compose_typeahead("#new_message_content", {mention: true, emoji: true, stream: true}); exports.initialize_compose_typeahead("#new_message_content", {mention: true, emoji: true, stream: true});
$( "#private_message_recipient" ).blur(function (event) { $( "#private_message_recipient" ).blur(function () {
var val = $(this).val(); var val = $(this).val();
var recipients = exports.get_cleaned_pm_recipients(val); var recipients = exports.get_cleaned_pm_recipients(val);
$(this).val(recipients.join(", ")); $(this).val(recipients.join(", "));

View File

@@ -140,7 +140,7 @@ exports.condense_and_collapse = function (elems) {
}; };
$(function () { $(function () {
$("#home").on("click", ".message_expander", function (e) { $("#home").on("click", ".message_expander", function () {
// Expanding a message can mean either uncollapsing or // Expanding a message can mean either uncollapsing or
// uncondensing it. // uncondensing it.
var row = $(this).closest(".message_row"); var row = $(this).closest(".message_row");
@@ -158,7 +158,7 @@ $(function () {
} }
}); });
$("#home").on("click", ".message_condenser", function (e) { $("#home").on("click", ".message_condenser", function () {
var row = $(this).closest(".message_row"); var row = $(this).closest(".message_row");
current_msg_list.get(rows.id(row)).condensed = true; current_msg_list.get(rows.id(row)).condensed = true;
condense_row(row); condense_row(row);

View File

@@ -36,7 +36,7 @@ function find_boundary_tr(initial_tr, iterate_row) {
} }
function copy_handler(e) { function copy_handler() {
var selection = window.getSelection(); var selection = window.getSelection();
var i; var i;
var range; var range;

View File

@@ -36,7 +36,7 @@ var exports = {};
subscriptions: JSON.stringify([stream_name]) subscriptions: JSON.stringify([stream_name])
} }
}).then( }).then(
function (data) { function () {
$status_message.hide(); $status_message.hide();
}, function (xhr) { }, function (xhr) {
ui.report_error(i18n.t("Error removing subscription"), xhr, $status_message); ui.report_error(i18n.t("Error removing subscription"), xhr, $status_message);

View File

@@ -415,7 +415,7 @@ exports.set_realm_filters = function set_realm_filters(realm_filters) {
$(function () { $(function () {
function disable_markdown_regex(rules, name) { function disable_markdown_regex(rules, name) {
rules[name] = {exec: function (_) { rules[name] = {exec: function () {
return false; return false;
} }
}; };
@@ -533,7 +533,7 @@ $(document).on('socket_loaded_requests.zulip', function (event, data) {
var msgs_to_insert = []; var msgs_to_insert = [];
var next_local_id = get_next_local_id(); var next_local_id = get_next_local_id();
_.each(data.requests, function (socket_msg, key) { _.each(data.requests, function (socket_msg) {
var msg = socket_msg.msg; var msg = socket_msg.msg;
// Check for any message objects, then insert them locally // Check for any message objects, then insert them locally
if (msg.stream === undefined || msg.local_id === undefined) { if (msg.stream === undefined || msg.local_id === undefined) {

View File

@@ -53,7 +53,7 @@ exports.initialize = function () {
$("#invite_user_form").ajaxForm({ $("#invite_user_form").ajaxForm({
dataType: 'json', dataType: 'json',
beforeSubmit: function (arr, $form, options) { beforeSubmit: function () {
reset_error_messages(); reset_error_messages();
// TODO: You could alternatively parse the textarea here, and return errors to // TODO: You could alternatively parse the textarea here, and return errors to
// the user if they don't match certain constraints (i.e. not real email addresses, // the user if they don't match certain constraints (i.e. not real email addresses,
@@ -63,7 +63,7 @@ exports.initialize = function () {
$('#submit-invitation').button('loading'); $('#submit-invitation').button('loading');
return true; return true;
}, },
success: function (resp, statusText, xhr, form) { success: function () {
$('#submit-invitation').button('reset'); $('#submit-invitation').button('reset');
invite_status.text(i18n.t('User invited successfully.', {count: (invitee_emails.val().match(/@/g) || [] ).length})) invite_status.text(i18n.t('User invited successfully.', {count: (invitee_emails.val().match(/@/g) || [] ).length}))
.addClass('alert-success') .addClass('alert-success')
@@ -77,7 +77,7 @@ exports.initialize = function () {
} }
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
$('#submit-invitation').button('reset'); $('#submit-invitation').button('reset');
var arr = JSON.parse(xhr.responseText); var arr = JSON.parse(xhr.responseText);
if (arr.errors === undefined) { if (arr.errors === undefined) {

View File

@@ -105,12 +105,12 @@ exports.save = function (row, from_topic_edited_only) {
channel.post({ channel.post({
url: '/json/update_message', url: '/json/update_message',
data: request, data: request,
success: function (data) { success: function () {
if (msg_list === current_msg_list) { if (msg_list === current_msg_list) {
row.find(".edit_error").text("Message successfully edited!").removeClass("alert-error").addClass("alert-success").show(); row.find(".edit_error").text("Message successfully edited!").removeClass("alert-error").addClass("alert-success").show();
} }
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
if (msg_list === current_msg_list) { if (msg_list === current_msg_list) {
var message = channel.xhr_error_message("Error saving edit", xhr); var message = channel.xhr_error_message("Error saving edit", xhr);
row.find(".edit_error").text(message).show(); row.find(".edit_error").text(message).show();
@@ -355,7 +355,7 @@ exports.maybe_show_edit = function (row, id) {
} }
}; };
$(document).on('narrow_deactivated.zulip', function (event) { $(document).on('narrow_deactivated.zulip', function () {
_.each(currently_editing_messages, function (elem, idx) { _.each(currently_editing_messages, function (elem, idx) {
if (current_msg_list.get(idx) !== undefined) { if (current_msg_list.get(idx) !== undefined) {
var row = current_msg_list.get_row(idx); var row = current_msg_list.get_row(idx);

View File

@@ -41,7 +41,7 @@ function batched_updater(flag, op, immediate) {
start = _.debounce(server_request, 1000); start = _.debounce(server_request, 1000);
} }
on_success = function on_success(data, status, jqXHR) { on_success = function on_success(data) {
if (data === undefined || data.messages === undefined) { if (data === undefined || data.messages === undefined) {
return; return;
} }

View File

@@ -634,7 +634,7 @@ exports.all = new exports.MessageList(
// doing something. Be careful, though, if you try to capture // doing something. Be careful, though, if you try to capture
// mousemove, then you will have to contend with the autoscroll // mousemove, then you will have to contend with the autoscroll
// itself generating mousemove events. // itself generating mousemove events.
$(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', function (event) { $(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', function () {
viewport.stop_auto_scrolling(); viewport.stop_auto_scrolling();
}); });

View File

@@ -130,8 +130,7 @@ MessageListView.prototype = {
} }
}, },
build_message_groups: function MessageListView__build_message_groups(message_containers, build_message_groups: function MessageListView__build_message_groups(message_containers) {
message_id_prefix) {
function start_group() { function start_group() {
return { return {
message_containers: [], message_containers: [],
@@ -399,10 +398,7 @@ MessageListView.prototype = {
// we we record if last_message_was_selected before updating the table // we we record if last_message_was_selected before updating the table
var last_message_was_selected = rows.id(rows.last_visible()) === list.selected_id(); var last_message_was_selected = rows.id(rows.last_visible()) === list.selected_id();
var orig_scrolltop_offset; var orig_scrolltop_offset;
var last_message_id;
var message_containers; var message_containers;
var first_msg;
var last_msg;
var self = this; var self = this;
@@ -582,7 +578,6 @@ MessageListView.prototype = {
// scroll up without moving the pointer out of the viewport, do so, by // scroll up without moving the pointer out of the viewport, do so, by
// up to the amount taken up by the new message. // up to the amount taken up by the new message.
var new_messages_height = 0; var new_messages_height = 0;
var distance_to_last_message_sent_by_me = 0;
var id_of_last_message_sent_by_us = -1; var id_of_last_message_sent_by_us = -1;
// C++ iterators would have made this less painful // C++ iterators would have made this less painful
@@ -593,14 +588,12 @@ MessageListView.prototype = {
new_messages_height += elem.height(); new_messages_height += elem.height();
// starting from the last message, ignore message heights that weren't sent by me. // starting from the last message, ignore message heights that weren't sent by me.
if (id_of_last_message_sent_by_us > -1) { if (id_of_last_message_sent_by_us > -1) {
distance_to_last_message_sent_by_me += elem.height();
return; return;
} }
var row_id = rows.id(elem); var row_id = rows.id(elem);
// check for `row_id` NaN in case we're looking at a date row or bookend row // check for `row_id` NaN in case we're looking at a date row or bookend row
if (row_id > -1 && if (row_id > -1 &&
util.is_current_user(this.get_message(row_id).sender_email)) { util.is_current_user(this.get_message(row_id).sender_email)) {
distance_to_last_message_sent_by_me += elem.height();
id_of_last_message_sent_by_us = rows.id(elem); id_of_last_message_sent_by_us = rows.id(elem);
} }
} }
@@ -803,13 +796,6 @@ MessageListView.prototype = {
rerender_messages: function MessageListView__rerender_messages(messages) { rerender_messages: function MessageListView__rerender_messages(messages) {
var self = this; var self = this;
// Only re-render the messages that are in this narrow
var own_messages = _.map(messages, function (message) {
return self.list.get(message.id);
});
own_messages = _.reject(own_messages, function (message) {
return message === undefined;
});
// Convert messages to list messages // Convert messages to list messages
var message_containers = _.map(messages, function (message) { var message_containers = _.map(messages, function (message) {
return self.message_containers[message.id]; return self.message_containers[message.id];
@@ -868,13 +854,10 @@ MessageListView.prototype = {
} }
}, },
rerender_the_whole_thing: function MessageListView__rerender_the_whole_thing(messages) { rerender_the_whole_thing: function MessageListView__rerender_the_whole_thing() {
// TODO: Figure out if we can unify this with this.list.rerender(). // TODO: Figure out if we can unify this with this.list.rerender().
this.clear_rendering_state(true); this.clear_rendering_state(true);
this.update_render_window(this.list.selected_idx(), false); this.update_render_window(this.list.selected_idx(), false);
this.render(this.list.all_messages().slice(this._render_win_start, this._render_win_end), 'bottom'); this.render(this.list.all_messages().slice(this._render_win_start, this._render_win_end), 'bottom');
}, },

View File

@@ -41,7 +41,7 @@ exports.get_private_message_recipient = function (message, attr, fallback_attr)
}; };
exports.process_message_for_recent_private_messages = exports.process_message_for_recent_private_messages =
function process_message_for_recent_private_messages(message, remove_message) { function process_message_for_recent_private_messages(message) {
var current_timestamp = 0; var current_timestamp = 0;
var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to); var user_ids_string = people.emails_strings_to_user_ids_string(message.reply_to);
@@ -219,7 +219,7 @@ function maybe_add_narrowed_messages(messages, msg_list, messages_are_new) {
notifications.possibly_notify_new_messages_outside_viewport(new_messages); notifications.possibly_notify_new_messages_outside_viewport(new_messages);
notifications.notify_messages_outside_current_search(elsewhere_messages); notifications.notify_messages_outside_current_search(elsewhere_messages);
}, },
error: function (xhr) { error: function () {
// We might want to be more clever here // We might want to be more clever here
setTimeout(function () { setTimeout(function () {
if (msg_list === current_msg_list) { if (msg_list === current_msg_list) {
@@ -496,7 +496,7 @@ exports.load_old_messages = function load_old_messages(opts) {
success: function (data) { success: function (data) {
get_old_messages_success(data, opts); get_old_messages_success(data, opts);
}, },
error: function (xhr, error_type, exn) { error: function (xhr) {
if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) { if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) {
// We unnarrowed before getting an error so don't // We unnarrowed before getting an error so don't
// bother trying again or doing further processing. // bother trying again or doing further processing.

View File

@@ -17,7 +17,6 @@ exports.rerender = function () {
}; };
exports.notify_with_undo_option = (function () { exports.notify_with_undo_option = (function () {
var event_added = false;
var meta = { var meta = {
stream: null, stream: null,
topic: null, topic: null,
@@ -26,12 +25,12 @@ exports.notify_with_undo_option = (function () {
$mute: null $mute: null
}; };
var animate = { var animate = {
fadeOut: function ($mute) { fadeOut: function () {
if (meta.$mute) { if (meta.$mute) {
meta.$mute.fadeOut(500).removeClass("show"); meta.$mute.fadeOut(500).removeClass("show");
} }
}, },
fadeIn: function ($mute) { fadeIn: function () {
if (meta.$mute) { if (meta.$mute) {
meta.$mute.fadeIn(500).addClass("show"); meta.$mute.fadeIn(500).addClass("show");
} }

View File

@@ -9,7 +9,6 @@ var notice_memory = {};
var window_has_focus = document.hasFocus && document.hasFocus(); var window_has_focus = document.hasFocus && document.hasFocus();
var asked_permission_already = false; var asked_permission_already = false;
var names;
var supports_sound; var supports_sound;
var unread_pms_favicon = '/static/images/favicon/favicon-pms.png'; var unread_pms_favicon = '/static/images/favicon/favicon-pms.png';

View File

@@ -521,7 +521,6 @@ exports.register_click_handlers = function () {
var stream = $(elt).parents('li').attr('data-name'); var stream = $(elt).parents('li').attr('data-name');
var ypos = $(elt).offset().top - viewport.scrollTop();
$(elt).popover({ $(elt).popover({
content: templates.render('stream_sidebar_actions', {stream: stream_data.get_sub(stream)}), content: templates.render('stream_sidebar_actions', {stream: stream_data.get_sub(stream)}),
trigger: "manual", trigger: "manual",
@@ -566,7 +565,7 @@ exports.register_click_handlers = function () {
$(e.target).hide(); $(e.target).hide();
}); });
$('.streams_popover').on('click', 'a.sp-cancel', function (e) { $('.streams_popover').on('click', 'a.sp-cancel', function () {
popovers.hide_stream_sidebar_popover(); popovers.hide_stream_sidebar_popover();
}); });
}); });

View File

@@ -93,7 +93,7 @@ $(function () {
} }
}); });
$("#referral-form input").on('blur', function (e) { $("#referral-form input").on('blur', function () {
if ($("#referral-form input").val() === '') { if ($("#referral-form input").val() === '') {
validator.resetForm(); validator.resetForm();
resize.resize_page_components(); resize.resize_page_components();

View File

@@ -15,8 +15,6 @@ function confine_to_range(lo, val, hi) {
} }
function size_blocks(blocks, usable_height) { function size_blocks(blocks, usable_height) {
var n = blocks.length;
var sum_height = 0; var sum_height = 0;
_.each(blocks, function (block) { _.each(blocks, function (block) {
sum_height += block.real_height; sum_height += block.real_height;
@@ -183,15 +181,6 @@ exports.resize_stream_filters_container = function (h) {
}; };
exports.resize_page_components = function () { exports.resize_page_components = function () {
var composebox = $("#compose");
var floating_recipient_bar = $("#floating_recipient_bar");
var desired_width;
if (ui.home_tab_obscured() === 'other_tab') {
desired_width = $("div.tab-pane.active").outerWidth();
} else {
desired_width = $("#main_div").outerWidth();
}
var h; var h;
var sidebar; var sidebar;
@@ -238,7 +227,7 @@ exports.resize_page_components = function () {
var _old_width = $(window).width(); var _old_width = $(window).width();
exports.handler = function (e) { exports.handler = function () {
var new_width = $(window).width(); var new_width = $(window).width();
if (new_width !== _old_width) { if (new_width !== _old_width) {

View File

@@ -60,7 +60,7 @@ exports.initialize = function () {
var obj = search_object[item]; var obj = search_object[item];
return obj.description; return obj.description;
}, },
matcher: function (item) { matcher: function () {
return true; return true;
}, },
updater: narrow_or_search_for_term, updater: narrow_or_search_for_term,

View File

@@ -356,7 +356,7 @@ function get_events(options) {
} }
get_events_timeout = setTimeout(get_events, 0); get_events_timeout = setTimeout(get_events, 0);
}, },
error: function (xhr, error_type, exn) { error: function (xhr, error_type) {
try { try {
get_events_xhr = undefined; get_events_xhr = undefined;
// If we are old enough to have messages outside of the // If we are old enough to have messages outside of the
@@ -458,7 +458,7 @@ exports.cleanup_event_queue = function cleanup_event_queue() {
}); });
}; };
window.addEventListener("beforeunload", function (event) { window.addEventListener("beforeunload", function () {
exports.cleanup_event_queue(); exports.cleanup_event_queue();
}); });

View File

@@ -187,7 +187,7 @@ function _setup_page() {
clear_password_change(); clear_password_change();
$('#api_key_button').click(function (e) { $('#api_key_button').click(function () {
if (page_params.password_auth_enabled !== false) { if (page_params.password_auth_enabled !== false) {
$("#get_api_key_box").show(); $("#get_api_key_box").show();
} else { } else {
@@ -237,7 +237,7 @@ function _setup_page() {
$("form.your-account-settings").ajaxForm({ $("form.your-account-settings").ajaxForm({
dataType: 'json', // This seems to be ignored. We still get back an xhr. dataType: 'json', // This seems to be ignored. We still get back an xhr.
beforeSubmit: function (arr, form, options) { beforeSubmit: function () {
if (page_params.password_auth_enabled !== false) { if (page_params.password_auth_enabled !== false) {
// FIXME: Check that the two password fields match // FIXME: Check that the two password fields match
// FIXME: Use the same jQuery validation plugin as the signup form? // FIXME: Use the same jQuery validation plugin as the signup form?
@@ -258,21 +258,20 @@ function _setup_page() {
} }
return true; return true;
}, },
success: function (resp, statusText, xhr, form) { success: function () {
settings_change_success("Updated settings!"); settings_change_success("Updated settings!");
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
settings_change_error("Error changing settings", xhr); settings_change_error("Error changing settings", xhr);
}, },
complete: function (xhr, statusText) { complete: function () {
// Whether successful or not, clear the password boxes. // Whether successful or not, clear the password boxes.
// TODO: Clear these earlier, while the request is still pending. // TODO: Clear these earlier, while the request is still pending.
clear_password_change(); clear_password_change();
} }
}); });
function update_notification_settings_success(resp, statusText, xhr, form) { function update_notification_settings_success(resp, statusText, xhr) {
var message = "Updated notification settings!";
var result = JSON.parse(xhr.responseText); var result = JSON.parse(xhr.responseText);
var notify_settings_status = $('#notify-settings-status').expectOne(); var notify_settings_status = $('#notify-settings-status').expectOne();
@@ -318,7 +317,7 @@ function _setup_page() {
ui.report_success(i18n.t("Updated notification settings!"), notify_settings_status); ui.report_success(i18n.t("Updated notification settings!"), notify_settings_status);
} }
function update_notification_settings_error(xhr, error_type, xhn) { function update_notification_settings_error(xhr) {
ui.report_error(i18n.t("Error changing settings"), xhr, $('#notify-settings-status').expectOne()); ui.report_error(i18n.t("Error changing settings"), xhr, $('#notify-settings-status').expectOne());
} }
@@ -376,22 +375,22 @@ function _setup_page() {
var control_group = notification_checkbox.closest(".control-group"); var control_group = notification_checkbox.closest(".control-group");
var checkbox_status = notification_checkbox.is(":checked"); var checkbox_status = notification_checkbox.is(":checked");
control_group.find(".propagate_stream_notifications_change").html(html); control_group.find(".propagate_stream_notifications_change").html(html);
control_group.find(".yes_propagate_notifications").on("click", function (e) { control_group.find(".yes_propagate_notifications").on("click", function () {
propagate_setting_function(checkbox_status); propagate_setting_function(checkbox_status);
control_group.find(".propagate_stream_notifications_change").empty(); control_group.find(".propagate_stream_notifications_change").empty();
}); });
control_group.find(".no_propagate_notifications").on("click", function (e) { control_group.find(".no_propagate_notifications").on("click", function () {
control_group.find(".propagate_stream_notifications_change").empty(); control_group.find(".propagate_stream_notifications_change").empty();
}); });
} }
$("#enable_stream_desktop_notifications").on("click", function (e) { $("#enable_stream_desktop_notifications").on("click", function () {
var notification_checkbox = $("#enable_stream_desktop_notifications"); var notification_checkbox = $("#enable_stream_desktop_notifications");
maybe_bulk_update_stream_notification_setting(notification_checkbox, maybe_bulk_update_stream_notification_setting(notification_checkbox,
update_desktop_notification_setting); update_desktop_notification_setting);
}); });
$("#enable_stream_sounds").on("click", function (e) { $("#enable_stream_sounds").on("click", function () {
var notification_checkbox = $("#enable_stream_sounds"); var notification_checkbox = $("#enable_stream_sounds");
maybe_bulk_update_stream_notification_setting(notification_checkbox, maybe_bulk_update_stream_notification_setting(notification_checkbox,
update_audible_notification_setting); update_audible_notification_setting);
@@ -411,11 +410,11 @@ function _setup_page() {
channel.patch({ channel.patch({
url: '/json/left_side_userlist', url: '/json/left_side_userlist',
data: data, data: data,
success: function (resp, statusText, xhr, form) { success: function () {
ui.report_success(i18n.t("User list will appear on the __side__ hand side! You will need to reload the window for your changes to take effect.", context), ui.report_success(i18n.t("User list will appear on the __side__ hand side! You will need to reload the window for your changes to take effect.", context),
$('#display-settings-status').expectOne()); $('#display-settings-status').expectOne());
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
ui.report_error(i18n.t("Error updating user list placement setting"), xhr, $('#display-settings-status').expectOne()); ui.report_error(i18n.t("Error updating user list placement setting"), xhr, $('#display-settings-status').expectOne());
} }
}); });
@@ -435,11 +434,11 @@ function _setup_page() {
channel.patch({ channel.patch({
url: '/json/time_setting', url: '/json/time_setting',
data: data, data: data,
success: function (resp, statusText, xhr, form) { success: function () {
ui.report_success(i18n.t("Time will be displayed in the __format__-hour format! You will need to reload the window for your changes to take effect", context), ui.report_success(i18n.t("Time will be displayed in the __format__-hour format! You will need to reload the window for your changes to take effect", context),
$('#display-settings-status').expectOne()); $('#display-settings-status').expectOne());
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
ui.report_error(i18n.t("Error updating time format setting"), xhr, $('#display-settings-status').expectOne()); ui.report_error(i18n.t("Error updating time format setting"), xhr, $('#display-settings-status').expectOne());
} }
}); });
@@ -464,11 +463,11 @@ function _setup_page() {
channel.patch({ channel.patch({
url: '/json/language_setting', url: '/json/language_setting',
data: data, data: data,
success: function (resp, statusText, xhr, form) { success: function () {
ui.report_success(i18n.t("__lang__ is now the default language! You will need to reload the window for your changes to take effect", context), ui.report_success(i18n.t("__lang__ is now the default language! You will need to reload the window for your changes to take effect", context),
$('#display-settings-status').expectOne()); $('#display-settings-status').expectOne());
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
ui.report_error(i18n.t("Error updating default language setting"), xhr, $('#display-settings-status').expectOne()); ui.report_error(i18n.t("Error updating default language setting"), xhr, $('#display-settings-status').expectOne());
} }
}); });
@@ -486,14 +485,14 @@ function _setup_page() {
$("#deactivate_self_modal").modal("show"); $("#deactivate_self_modal").modal("show");
}); });
$("#do_deactivate_self_button").on('click',function (e) { $("#do_deactivate_self_button").on('click',function () {
$("#deactivate_self_modal").modal("hide"); $("#deactivate_self_modal").modal("hide");
channel.del({ channel.del({
url: '/json/users/me', url: '/json/users/me',
success: function () { success: function () {
window.location.href = "/login"; window.location.href = "/login";
}, },
error: function (xhr, error_type) { error: function (xhr) {
ui.report_error(i18n.t("Error deactivating account"), xhr, $('#settings-status').expectOne()); ui.report_error(i18n.t("Error deactivating account"), xhr, $('#settings-status').expectOne());
} }
}); });
@@ -503,8 +502,7 @@ function _setup_page() {
$("#show_api_key_box").hide(); $("#show_api_key_box").hide();
$("#get_api_key_box form").ajaxForm({ $("#get_api_key_box form").ajaxForm({
dataType: 'json', // This seems to be ignored. We still get back an xhr. dataType: 'json', // This seems to be ignored. We still get back an xhr.
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr) {
var message = "Updated settings!";
var result = JSON.parse(xhr.responseText); var result = JSON.parse(xhr.responseText);
var settings_status = $('#settings-status').expectOne(); var settings_status = $('#settings-status').expectOne();
@@ -514,7 +512,7 @@ function _setup_page() {
$("#get_api_key_box").hide(); $("#get_api_key_box").hide();
settings_status.hide(); settings_status.hide();
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
ui.report_error(i18n.t("Error getting API key"), xhr, $('#settings-status').expectOne()); ui.report_error(i18n.t("Error getting API key"), xhr, $('#settings-status').expectOne());
$("#show_api_key_box").hide(); $("#show_api_key_box").hide();
$("#get_api_key_box").show(); $("#get_api_key_box").show();
@@ -595,17 +593,17 @@ function _setup_page() {
cache: false, cache: false,
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function () {
$('#bot_table_error').hide(); $('#bot_table_error').hide();
$('#create_bot_name').val(''); $('#create_bot_name').val('');
$('#create_bot_short_name').val(''); $('#create_bot_short_name').val('');
$('#create_bot_button').show(); $('#create_bot_button').show();
create_avatar_widget.clear(); create_avatar_widget.clear();
}, },
error: function (xhr, error_type, exn) { error: function (xhr) {
$('#bot_table_error').text(JSON.parse(xhr.responseText).msg).show(); $('#bot_table_error').text(JSON.parse(xhr.responseText).msg).show();
}, },
complete: function (xhr, status) { complete: function () {
$('#create_bot_button').val('Create bot').prop('disabled', false); $('#create_bot_button').val('Create bot').prop('disabled', false);
} }
}); });
@@ -678,7 +676,7 @@ function _setup_page() {
form.validate({ form.validate({
errorClass: 'text-error', errorClass: 'text-error',
success: function (label) { success: function () {
errors.hide(); errors.hide();
}, },
submitHandler: function () { submitHandler: function () {
@@ -720,7 +718,7 @@ function _setup_page() {
image.find('img').attr('src', data.avatar_url+'&v='+image_version.toString()); image.find('img').attr('src', data.avatar_url+'&v='+image_version.toString());
} }
}, },
error: function (xhr, error_type, exn) { error: function (xhr) {
loading.destroy_indicator(spinner); loading.destroy_indicator(spinner);
edit_button.show(); edit_button.show();
errors.text(JSON.parse(xhr.responseText).msg).show(); errors.text(JSON.parse(xhr.responseText).msg).show();
@@ -749,7 +747,7 @@ function _setup_page() {
)); ));
}); });
$("#show_api_key_box").on("click", "button.regenerate_api_key", function (e) { $("#show_api_key_box").on("click", "button.regenerate_api_key", function () {
channel.post({ channel.post({
url: '/json/users/me/api_key/regenerate', url: '/json/users/me/api_key/regenerate',
idempotent: true, idempotent: true,
@@ -762,9 +760,7 @@ function _setup_page() {
}); });
}); });
$("#ui-settings").on("click", "input[name='change_settings']", function (e) { $("#ui-settings").on("click", "input[name='change_settings']", function () {
e.preventDefault();
var labs_updates = {}; var labs_updates = {};
_.each(["autoscroll_forever", "default_desktop_notifications"], _.each(["autoscroll_forever", "default_desktop_notifications"],
function (setting) { function (setting) {
@@ -774,7 +770,7 @@ function _setup_page() {
channel.post({ channel.post({
url: '/json/ui_settings/change', url: '/json/ui_settings/change',
data: labs_updates, data: labs_updates,
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr) {
var message = i18n.t("Updated __product_name__ Labs settings!", page_params); var message = i18n.t("Updated __product_name__ Labs settings!", page_params);
var result = JSON.parse(xhr.responseText); var result = JSON.parse(xhr.responseText);
var ui_settings_status = $('#ui-settings-status').expectOne(); var ui_settings_status = $('#ui-settings-status').expectOne();
@@ -786,7 +782,7 @@ function _setup_page() {
ui.report_success(message, ui_settings_status); ui.report_success(message, ui_settings_status);
}, },
error: function (xhr, error_type, xhn) { error: function (xhr) {
ui.report_error(i18n.t("Error changing settings"), xhr, $('#ui-settings-status').expectOne()); ui.report_error(i18n.t("Error changing settings"), xhr, $('#ui-settings-status').expectOne());
} }
}); });

View File

@@ -2,7 +2,7 @@ $(function () {
// NB: this file is included on multiple pages. In each context, // NB: this file is included on multiple pages. In each context,
// some of the jQuery selectors below will return empty lists. // some of the jQuery selectors below will return empty lists.
$.validator.addMethod('password_strength', function (value, element) { $.validator.addMethod('password_strength', function (value) {
return password_quality(value); return password_quality(value);
}, 'Password is weak.'); }, 'Password is weak.');
@@ -38,7 +38,7 @@ $(function () {
$("#send_confirm").validate({ $("#send_confirm").validate({
errorElement: "p", errorElement: "p",
errorPlacement: function (error, element) { errorPlacement: function (error) {
$('#errors').empty(); $('#errors').empty();
error.appendTo("#errors") error.appendTo("#errors")
.addClass("text-error"); .addClass("text-error");

View File

@@ -370,9 +370,8 @@ exports.update_dom_with_unread_counts = function (counts) {
counts.mentioned_message_count); counts.mentioned_message_count);
}; };
exports.rename_stream = function (sub, new_name) { exports.rename_stream = function (sub) {
// TODO: we don't actually need new_name, since the sub // The sub object is expected to already have the updated name
// will have been updated
build_stream_sidebar_row(sub); build_stream_sidebar_row(sub);
exports.build_stream_list(); // big hammer exports.build_stream_list(); // big hammer
}; };

View File

@@ -232,7 +232,6 @@ function stream_audible_notifications_clicked(e) {
function stream_pin_clicked(e) { function stream_pin_clicked(e) {
var stream = get_stream_name(e.target); var stream = get_stream_name(e.target);
var sub = stream_data.get_sub(stream);
exports.toggle_pin_to_top_stream(stream); exports.toggle_pin_to_top_stream(stream);
} }
@@ -336,7 +335,7 @@ function show_subscription_settings(sub_row) {
list.append(elem); list.append(elem);
}); });
}, },
error: function (xhr) { error: function () {
loading.destroy_indicator(indicator_elem); loading.destroy_indicator(indicator_elem);
error_elem.removeClass("hide").text("Could not fetch subscriber list"); error_elem.removeClass("hide").text("Could not fetch subscriber list");
} }
@@ -365,19 +364,8 @@ function show_subscription_settings(sub_row) {
}); });
var colorpicker = sub_settings.find('.colorpicker'); var colorpicker = sub_settings.find('.colorpicker');
var color = stream_data.get_color(sub.name); var color = stream_data.get_color(sub.name);
stream_color.set_colorpicker_color(colorpicker, color); stream_color.set_colorpicker_color(colorpicker, color);
// To figure out the worst case for an expanded row's height, we do some math:
// .subscriber_list_container max-height,
// .subscriber_list_settings,
// .regular_subscription_settings
// .subscription_header line-height,
// .subscription_header padding
var expanded_row_size = 200 + 30 + 100 + 30 + 5;
var cover = sub_row.offset().top + expanded_row_size -
viewport.height() + viewport.scrollTop();
} }
exports.show_settings_for = function (stream_name) { exports.show_settings_for = function (stream_name) {
@@ -692,7 +680,7 @@ function ajaxSubscribe(stream) {
return channel.post({ return channel.post({
url: "/json/users/me/subscriptions", url: "/json/users/me/subscriptions",
data: {subscriptions: JSON.stringify([{name: stream}]) }, data: {subscriptions: JSON.stringify([{name: stream}]) },
success: function (resp, statusText, xhr, form) { success: function (resp, statusText, xhr) {
$("#create_stream_name").val(""); $("#create_stream_name").val("");
actually_filter_streams(); actually_filter_streams();
@@ -717,9 +705,7 @@ function ajaxUnsubscribe(stream) {
return channel.post({ return channel.post({
url: "/json/subscriptions/remove", url: "/json/subscriptions/remove",
data: {subscriptions: JSON.stringify([stream]) }, data: {subscriptions: JSON.stringify([stream]) },
success: function (resp, statusText, xhr, form) { success: function () {
var name;
var res = JSON.parse(xhr.responseText);
$("#subscriptions-status").hide(); $("#subscriptions-status").hide();
// The rest of the work is done via the unsubscribe event we will get // The rest of the work is done via the unsubscribe event we will get
}, },
@@ -739,7 +725,7 @@ function ajaxSubscribeForCreation(stream, description, principals, invite_only,
invite_only: JSON.stringify(invite_only), invite_only: JSON.stringify(invite_only),
announce: JSON.stringify(announce) announce: JSON.stringify(announce)
}, },
success: function (data) { success: function () {
$("#create_stream_name").val(""); $("#create_stream_name").val("");
$("#create_stream_description").val(""); $("#create_stream_description").val("");
$("#subscriptions-status").hide(); $("#subscriptions-status").hide();
@@ -808,7 +794,6 @@ exports.remove_user_from_stream = function (user_email, stream_name, success, fa
}; };
$(function () { $(function () {
var i;
stream_data.initialize_from_page_params(); stream_data.initialize_from_page_params();
stream_list.create_initial_sidebar_rows(); stream_list.create_initial_sidebar_rows();
@@ -963,11 +948,11 @@ $(function () {
$(e.target).removeClass("btn-danger").text(i18n.t("Subscribed")); $(e.target).removeClass("btn-danger").text(i18n.t("Subscribed"));
}); });
$(".subscriptions").on("click", "#close-subscriptions-status", function (e) { $(".subscriptions").on("click", "#close-subscriptions-status", function () {
$("#subscriptions-status").hide(); $("#subscriptions-status").hide();
}); });
$("#subscriptions_table").on("click", ".email-address", function (e) { $("#subscriptions_table").on("click", ".email-address", function () {
selectText(this); selectText(this);
}); });
@@ -1077,7 +1062,7 @@ $(function () {
} }
} }
function invite_failure(xhr) { function invite_failure() {
warning_elem.addClass("hide"); warning_elem.addClass("hide");
error_elem.removeClass("hide").text("Could not add user to this stream"); error_elem.removeClass("hide").text("Could not add user to this stream");
} }
@@ -1144,7 +1129,7 @@ $(function () {
} }
} }
function removal_failure(xhr) { function removal_failure() {
warning_elem.addClass("hide"); warning_elem.addClass("hide");
error_elem.removeClass("hide").text("Could not remove user from this stream"); error_elem.removeClass("hide").text("Could not remove user from this stream");
} }
@@ -1167,7 +1152,7 @@ $(function () {
// Stream names might contain unsafe characters so we must encode it first. // Stream names might contain unsafe characters so we must encode it first.
url: "/json/streams/" + encodeURIComponent(sub.name), url: "/json/streams/" + encodeURIComponent(sub.name),
data: {new_name: JSON.stringify(new_name)}, data: {new_name: JSON.stringify(new_name)},
success: function (data) { success: function () {
new_name_box.val(''); new_name_box.val('');
ui.report_success(i18n.t("The stream has been renamed!"), $("#subscriptions-status "), ui.report_success(i18n.t("The stream has been renamed!"), $("#subscriptions-status "),
'subscriptions-status'); 'subscriptions-status');
@@ -1181,8 +1166,6 @@ $(function () {
$('#subscriptions_table').on('submit', '.change-stream-description form', function (e) { $('#subscriptions_table').on('submit', '.change-stream-description form', function (e) {
e.preventDefault(); e.preventDefault();
var form = $(e.target);
var sub_settings = $(e.target).closest('.subscription_settings'); var sub_settings = $(e.target).closest('.subscription_settings');
var stream_name = get_stream_name(sub_settings); var stream_name = get_stream_name(sub_settings);
var description = sub_settings.find('input[name="description"]').val(); var description = sub_settings.find('input[name="description"]').val();
@@ -1247,7 +1230,7 @@ $(function () {
channel.post({ channel.post({
url: url, url: url,
data: data, data: data,
success: function (data) { success: function () {
sub = stream_data.get_sub_by_id(stream_id); sub = stream_data.get_sub_by_id(stream_id);
var stream_settings = settings_for_sub(sub); var stream_settings = settings_for_sub(sub);
var sub_row = $(".stream-row[data-stream-id='" + stream_id + "']"); var sub_row = $(".stream-row[data-stream-id='" + stream_id + "']");

View File

@@ -37,7 +37,6 @@ function make_tab_data() {
if (narrow.active() && narrow.operators().length > 0) { if (narrow.active() && narrow.operators().length > 0) {
var stream; var stream;
var ops = narrow.operators(); var ops = narrow.operators();
var hash = hashchange.operators_to_hash(ops);
// Second breadcrumb item // Second breadcrumb item
var hashed = hashchange.operators_to_hash(ops.slice(0, 1)); var hashed = hashchange.operators_to_hash(ops.slice(0, 1));
if (filter.has_operator("stream")) { if (filter.has_operator("stream")) {
@@ -150,10 +149,10 @@ function build_tab_bar() {
} }
$(function () { $(function () {
$(document).on('narrow_activated.zulip', function (event) { $(document).on('narrow_activated.zulip', function () {
build_tab_bar(); build_tab_bar();
}); });
$(document).on('narrow_deactivated.zulip', function (event) { $(document).on('narrow_deactivated.zulip', function () {
build_tab_bar(); build_tab_bar();
}); });

View File

@@ -131,10 +131,6 @@ exports.sort_by_pms = function (objs) {
return objs; return objs;
}; };
function identity(item) {
return item;
}
exports.sort_recipients = function (matches, query) { exports.sort_recipients = function (matches, query) {
var name_results = prefix_sort(query, matches, function (x) { return x.full_name; }); var name_results = prefix_sort(query, matches, function (x) { return x.full_name; });
var email_results = prefix_sort(query, name_results.rest, function (x) { return x.email; }); var email_results = prefix_sort(query, name_results.rest, function (x) { return x.email; });

View File

@@ -98,11 +98,9 @@ exports.replace_emoji_with_text = function (element) {
var current_message_hover; var current_message_hover;
function message_unhover() { function message_unhover() {
var message;
if (current_message_hover === undefined) { if (current_message_hover === undefined) {
return; return;
} }
message = current_msg_list.get(rows.id(current_message_hover));
current_message_hover.find('span.edit_content').html(""); current_message_hover.find('span.edit_content').html("");
current_message_hover.removeClass('message_hovered'); current_message_hover.removeClass('message_hovered');
current_message_hover = undefined; current_message_hover = undefined;
@@ -172,15 +170,6 @@ exports.report_success = function (response, status_box, type) {
ui.report_message(response, status_box, 'alert-success', type); ui.report_message(response, status_box, 'alert-success', type);
}; };
function need_skinny_mode() {
if (window.matchMedia !== undefined) {
return window.matchMedia("(max-width: 767px)").matches;
}
// IE<10 doesn't support window.matchMedia, so do this
// as best we can without it.
return window.innerWidth <= 767;
}
function update_message_in_all_views(message_id, callback) { function update_message_in_all_views(message_id, callback) {
_.each([message_list.all, home_msg_list, message_list.narrowed], function (list) { _.each([message_list.all, home_msg_list, message_list.narrowed], function (list) {
if (list === undefined) { if (list === undefined) {
@@ -315,7 +304,7 @@ exports.lightbox_photo = function (image, user) {
$(".image-actions .open, .image-actions .download").attr("href", url); $(".image-actions .open, .image-actions .download").attr("href", url);
}; };
exports.exit_lightbox_photo = function (image) { exports.exit_lightbox_photo = function () {
$("#overlay").removeClass("show"); $("#overlay").removeClass("show");
$(".player-container iframe").remove(); $(".player-container iframe").remove();
document.activeElement.blur(); document.activeElement.blur();
@@ -451,30 +440,30 @@ $(function () {
$("#navbar-buttons").addClass("right-userlist"); $("#navbar-buttons").addClass("right-userlist");
} }
$("#main_div").on("mouseover", ".message_row", function (e) { $("#main_div").on("mouseover", ".message_row", function () {
var row = $(this).closest(".message_row"); var row = $(this).closest(".message_row");
message_hover(row); message_hover(row);
}); });
$("#main_div").on("mouseleave", ".message_row", function (e) { $("#main_div").on("mouseleave", ".message_row", function () {
message_unhover(); message_unhover();
}); });
$("#main_div").on("mouseover", ".message_sender", function (e) { $("#main_div").on("mouseover", ".message_sender", function () {
var row = $(this).closest(".message_row"); var row = $(this).closest(".message_row");
row.addClass("sender_name_hovered"); row.addClass("sender_name_hovered");
}); });
$("#main_div").on("mouseout", ".message_sender", function (e) { $("#main_div").on("mouseout", ".message_sender", function () {
var row = $(this).closest(".message_row"); var row = $(this).closest(".message_row");
row.removeClass("sender_name_hovered"); row.removeClass("sender_name_hovered");
}); });
$("#subscriptions_table").on("mouseover", ".subscription_header", function (e) { $("#subscriptions_table").on("mouseover", ".subscription_header", function () {
$(this).addClass("active"); $(this).addClass("active");
}); });
$("#subscriptions_table").on("mouseout", ".subscription_header", function (e) { $("#subscriptions_table").on("mouseout", ".subscription_header", function () {
$(this).removeClass("active"); $(this).removeClass("active");
}); });
@@ -574,8 +563,6 @@ $(function () {
}); });
var scroll_start_message;
function scroll_finished() { function scroll_finished() {
actively_scrolling = false; actively_scrolling = false;
@@ -613,7 +600,7 @@ function scroll_finish() {
var saved_compose_cursor = 0; var saved_compose_cursor = 0;
$(function () { $(function () {
viewport.message_pane.scroll($.throttle(50, function (e) { viewport.message_pane.scroll($.throttle(50, function () {
unread.process_visible(); unread.process_visible();
scroll_finish(); scroll_finish();
})); }));

View File

@@ -327,7 +327,7 @@ exports.mark_message_as_read = function mark_message_as_read(message, options) {
// If we ever materially change the algorithm for this function, we // If we ever materially change the algorithm for this function, we
// may need to update notifications.received_messages as well. // may need to update notifications.received_messages as well.
exports.process_visible = function process_visible(update_cursor) { exports.process_visible = function process_visible() {
if (! notifications.window_has_focus()) { if (! notifications.window_has_focus()) {
return; return;
} }