js: Purge useless IIFEs.

With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-10-25 00:45:13 -07:00 committed by Tim Abbott
parent 5f590d3500
commit d17b577d0c
209 changed files with 345 additions and 2140 deletions

View File

@ -251,7 +251,6 @@
"guard-for-in": "error",
"indent": ["error", 4, {
"ArrayExpression": "first",
"outerIIFEBody": 0,
"ObjectExpression": "first",
"SwitchCase": 0,
"CallExpression": {"arguments": "first"},

View File

@ -146,16 +146,14 @@ relevant background as well.
### Primary build process
Most of the existing JS in Zulip is written in
[IIFE](https://www.google.com/#q=iife)-wrapped modules, one per file
in the `static/js` directory. We will over time migrate these to
Typescript modules. Stylesheets are written in the Sass extension of
CSS (with the scss syntax), they are converted from plain CSS and we
have yet to take full advantage of the features Sass offers. We use
Webpack to transpile and build JS and CSS bundles that the browser can
understand, one for each entry points specifed in
`tools/webpack.assets.json`; source maps are generated in the process
for better debugging experience.
Zulip's frontend is primarily JavaScript in the `static/js` directory;
we are working on migrating these to Typescript modules. Stylesheets
are written in the Sass extension of CSS (with the scss syntax), they
are converted from plain CSS and we have yet to take full advantage of
the features Sass offers. We use Webpack to transpile and build JS
and CSS bundles that the browser can understand, one for each entry
points specifed in `tools/webpack.assets.json`; source maps are
generated in the process for better debugging experience.
In development mode, bundles are built and served on the fly using
webpack-dev-server with live reloading. In production mode (and when creating a

View File

@ -1,7 +1,4 @@
var util = require("util");
var common = (function () {
var exports = {};
var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
@ -382,14 +379,3 @@ exports.un_narrow = function () {
}
common.keypress(27); // Esc
};
return exports;
}());
// For inclusion with CasperJS
try {
exports.common = common;
} catch (e) {
// continue regardless of error
}

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
var email = 'alice@test.example.com';
var subdomain = 'testsubdomain';

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
var realm_url = "http://zulip.zulipdev.com:9981/";
// Start of test script.

View File

@ -8,7 +8,7 @@
// Provides a few utility functions.
// See http://casperjs.org/api.html#utils
// For example, utils.dump() prints an Object with nice formatting.
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
var OUTGOING_WEBHOOK_BOT_TYPE = '3';
var GENERIC_BOT_TYPE = '1';

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
function star_count() {
return casper.evaluate(function () {

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
// Test basic tab navigation.

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
function heading(heading_str) {
casper.then(function () {

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
function waitWhileDraftsVisible(then) {
casper.waitFor(function () {

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,4 +1,4 @@
var common = require('../casper_lib/common.js').common;
var common = require('../casper_lib/common.js');
common.start_and_log_in();

View File

@ -1,7 +1,3 @@
var finder = (function () {
var exports = {};
var _ = require('underscore/underscore.js');
var fs = require('fs');
var path = require('path');
@ -47,8 +43,3 @@ exports.find_files_to_run = function () {
return files;
};
return exports;
}());
module.exports = finder;

View File

@ -4,7 +4,7 @@ const path = require("path");
const templates_path = path.resolve(__dirname, "../../static/templates");
let render;
module.exports.make_handlebars = () => {
exports.make_handlebars = () => {
// Create a new Handlebars instance.
const Handlebars = require("handlebars/dist/cjs/handlebars.js");
const hb = Handlebars.create();
@ -40,7 +40,7 @@ module.exports.make_handlebars = () => {
return hb;
};
module.exports.stub_templates = stub => {
exports.stub_templates = stub => {
render = (filename, ...args) => {
const name = path.relative(templates_path, filename).slice(0, -".hbs".length);
return stub(name, ...args);

View File

@ -1,6 +1,4 @@
var i18n = {};
i18n.t = function (str, context) {
exports.t = function (str, context) {
// We are currently assuming that we will receive context in form of a Dict
// of key value pairs and string will be having substitution for keywords
// like these "__keyword__".
@ -28,5 +26,3 @@ i18n.t = function (str, context) {
});
return 'translated: ' + str;
};
module.exports = i18n;

View File

@ -1,7 +1,4 @@
var namespace = (function () {
var _ = require('underscore/underscore.js');
var exports = {};
var dependencies = [];
var requires = [];
@ -91,9 +88,3 @@ exports.with_overrides = function (test_function) {
f();
});
};
return exports;
}());
module.exports = namespace;

View File

@ -1,7 +1,4 @@
var stub = (function () {
var _ = require('underscore/underscore.js');
var exports = {};
// Stubs don't do any magical modifications to your namespace. They
// just provide you a function that records what arguments get passed
@ -46,7 +43,3 @@ exports.with_stub = function (f) {
assert.equal(args.n, 42);
});
}());
return exports;
}());
module.exports = stub;

View File

@ -1,5 +1,3 @@
var exports = {};
exports.make_zblueslip = function (opts) {
var lib = {};
@ -83,5 +81,3 @@ exports.make_zblueslip = function (opts) {
return lib;
};
module.exports = exports;

View File

@ -1,7 +1,5 @@
var noop = function () {};
var exports = {};
exports.make_event_store = (selector) => {
/*
@ -550,5 +548,3 @@ exports.make_zjquery = function (opts) {
return zjquery;
};
module.exports = exports;

View File

@ -1,9 +1,6 @@
var render_group_pms = require('../templates/group_pms.hbs');
var Dict = require('./dict').Dict;
var activity = (function () {
var exports = {};
/*
Helpers for detecting user activity and managing user idle states
*/
@ -495,10 +492,4 @@ exports.get_filter_text = function () {
return exports.user_filter.text();
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = activity;
}
window.activity = activity;
window.activity = exports;

View File

@ -1,9 +1,5 @@
var render_admin_tab = require('../templates/admin_tab.hbs');
var admin = (function () {
var exports = {};
var admin_settings_label = {
// Organization settings
realm_allow_community_topic_editing: i18n.t("Users can edit the topic of any message"),
@ -112,11 +108,4 @@ exports.launch = function (section) {
settings_toggle.highlight_toggle('organization');
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = admin;
}
window.admin = admin;
window.admin = exports;

View File

@ -1,7 +1,3 @@
var alert_words = (function () {
var exports = {};
exports.words = page_params.alert_words;
exports.set_words = function (value) {
exports.words = value;
@ -59,10 +55,4 @@ exports.notifies = function (message) {
return !people.is_current_user(message.sender_email) && message.alerted;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = alert_words;
}
window.alert_words = alert_words;
window.alert_words = exports;

View File

@ -1,9 +1,5 @@
var render_alert_word_settings_item = require('../templates/alert_word_settings_item.hbs');
var alert_words_ui = (function () {
var exports = {};
exports.render_alert_words_ui = function () {
var words = alert_words.words;
var word_list = $('#alert_words_list');
@ -109,10 +105,4 @@ exports.set_up_alert_words = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = alert_words_ui;
}
window.alert_words_ui = alert_words_ui;
window.alert_words_ui = exports;

View File

@ -1,9 +1,5 @@
var render_archive_message_group = require('../templates/archive_message_group.hbs');
var archive = (function () {
var exports = {};
function should_separate_into_groups(current_msg_time, next_msg_time) {
var current_time = new XDate(current_msg_time * 1000);
var next_time = new XDate(next_msg_time * 1000);
@ -98,16 +94,12 @@ exports.initialize = function () {
all_message_timestamps_to_human_readable();
};
return exports;
}());
var current_msg_list = {
exports.current_msg_list = {
selected_row: function () {
return $('.message_row').last();
},
};
var rows = {
exports.rows = {
get_message_recipient_row: function (message_row) {
return $(message_row).parent('.recipient_row');
},
@ -119,12 +111,6 @@ var rows = {
},
};
if (typeof module !== 'undefined') {
module.exports.current_msg_list = current_msg_list;
module.exports.rows = rows;
module.exports = archive;
}
var scroll_timer;
function scroll_finish() {
clearTimeout(scroll_timer);
@ -141,5 +127,5 @@ $(function () {
$('.app').scroll(_.throttle(function () {
scroll_finish();
}, 50));
archive.initialize();
exports.initialize();
});

View File

@ -1,10 +1,6 @@
var render_settings_upload_space_stats = require("../templates/settings/upload_space_stats.hbs");
var render_uploaded_files_list = require("../templates/uploaded_files_list.hbs");
var attachments_ui = (function () {
var exports = {};
var attachments;
var upload_space_used;
@ -39,7 +35,7 @@ function set_upload_space_stats() {
var args = {
show_upgrade_message: page_params.realm_plan_type === 2,
percent_used: exports.percentage_used_space(upload_space_used),
upload_quota: attachments_ui.bytes_to_size(page_params.realm_upload_quota, true),
upload_quota: exports.bytes_to_size(page_params.realm_upload_quota, true),
};
var rendered_upload_stats_html = render_settings_upload_space_stats(args);
$("#attachment-stats-holder").html(rendered_upload_stats_html);
@ -158,10 +154,4 @@ exports.set_up_attachments = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = attachments_ui;
}
window.attachments_ui = attachments_ui;
window.attachments_ui = exports;

View File

@ -1,7 +1,3 @@
var avatar = (function () {
var exports = {};
exports.build_bot_create_widget = function () {
// We have to do strange gyrations with the file input to clear it,
@ -81,11 +77,4 @@ exports.build_user_avatar_widget = function (upload_function) {
);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = avatar;
}
window.avatar = avatar;
window.avatar = exports;

View File

@ -1,6 +1,3 @@
var billing = (function () {
var exports = {};
exports.initialize = function () {
helpers.set_tab("billing");
@ -29,15 +26,8 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = billing;
}
window.billing = billing;
window.billing = exports;
$(function () {
billing.initialize();
exports.initialize();
});

View File

@ -1,6 +1,3 @@
var helpers = (function () {
var exports = {};
exports.create_ajax_request = function (url, form_name, stripe_token = null) {
var form = $("#" + form_name + "-form");
var form_loading_indicator = "#" + form_name + "_loading_indicator";
@ -107,11 +104,4 @@ exports.is_valid_input = function (elem) {
return elem[0].checkValidity();
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = helpers;
}
window.helpers = helpers;
window.helpers = exports;

View File

@ -1,6 +1,3 @@
var upgrade = (function () {
var exports = {};
exports.initialize = () => {
helpers.set_tab("upgrade");
@ -61,15 +58,8 @@ exports.initialize = () => {
helpers.update_charged_amount(prices, $('input[type=radio][name=schedule]:checked').val());
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = upgrade;
}
window.upgrade = upgrade;
window.upgrade = exports;
$(function () {
upgrade.initialize();
exports.initialize();
});

View File

@ -4,10 +4,6 @@
// in order to be able to report exceptions that occur during their
// execution.
var blueslip = (function () {
var exports = {};
if (Error.stackTraceLimit !== undefined) {
Error.stackTraceLimit = 100000;
}
@ -305,10 +301,4 @@ exports.preview_node = function (node) {
return node_preview;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = blueslip;
}
window.blueslip = blueslip;
window.blueslip = exports;

View File

@ -1,6 +1,3 @@
var bot_data = (function () {
var exports = {};
var bots = {};
var bot_fields = ['api_key', 'avatar_url', 'default_all_public_streams',
'default_events_register_stream', 'default_sending_stream',
@ -90,9 +87,4 @@ exports.initialize = function () {
delete page_params.realm_bots;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = bot_data;
}
window.bot_data = bot_data;
window.bot_data = exports;

View File

@ -1,7 +1,3 @@
var buddy_data = (function () {
var exports = {};
/*
This is the main model code for building the buddy list.
@ -307,10 +303,4 @@ exports.huddle_fraction_present = function (huddle) {
return false;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = buddy_data;
}
window.buddy_data = buddy_data;
window.buddy_data = exports;

View File

@ -1,8 +1,6 @@
var render_user_presence_row = require('../templates/user_presence_row.hbs');
var render_user_presence_rows = require('../templates/user_presence_rows.hbs');
var buddy_list = (function () {
function buddy_list_conf() {
var conf = {};
@ -339,13 +337,8 @@ function buddy_list_create() {
return self;
}
var exports = buddy_list_create();
var buddy_list = buddy_list_create();
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = buddy_list;
}
window.buddy_list = buddy_list;

View File

@ -1,6 +1,3 @@
var channel = (function () {
var exports = {};
var pending_requests = [];
function add_pending_request(jqXHR) {
@ -112,11 +109,4 @@ exports.xhr_error_message = function (message, xhr) {
return message;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = channel;
}
window.channel = channel;
window.channel = exports;

View File

@ -1,8 +1,3 @@
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!
exports.initialize = function () {
@ -889,11 +884,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = click_handlers;
}
window.click_handlers = click_handlers;
window.click_handlers = exports;

View File

@ -1,9 +1,5 @@
var Dict = require('./dict').Dict;
var color_data = (function () {
var exports = {};
// These colors are used now for streams.
var stream_colors = [
"#76ce90", "#fae589", "#a6c7e5", "#e79ab5",
@ -60,10 +56,4 @@ exports.pick_color = function () {
return color;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = color_data;
}
window.color_data = color_data;
window.color_data = exports;

View File

@ -1,7 +1,3 @@
var colorspace = (function () {
var exports = {};
// Convert an sRGB value in [0, 255] to a linear intensity
// value in [0, 1].
//
@ -53,10 +49,4 @@ exports.getHexColor = function (rgb) {
parseInt(rgb.b, 10).toString(16);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = colorspace;
}
window.colorspace = colorspace;
window.colorspace = exports;

View File

@ -3,10 +3,6 @@ if (module.hot) {
module.hot.accept();
}
var common = (function () {
var exports = {};
exports.status_classes = 'alert-error alert-success alert-info alert-warning';
exports.autofocus = function (selector) {
@ -135,11 +131,4 @@ exports.adjust_mac_shortcuts = function (key_elem_class, require_cmd_style) {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = common;
}
window.common = common;
window.common = exports;

View File

@ -1,7 +1,3 @@
var components = (function () {
var exports = {};
/* USAGE:
Toggle x = components.toggle({
selected: Integer selected_index,
@ -137,10 +133,4 @@ exports.toggle = function (opts) {
return prototype;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = components;
}
window.components = components;
window.components = exports;

View File

@ -4,11 +4,8 @@ var render_compose_invite_users = require("../templates/compose_invite_users.hbs
var render_compose_not_subscribed = require("../templates/compose_not_subscribed.hbs");
var render_compose_private_stream_alert = require("../templates/compose_private_stream_alert.hbs");
var compose = (function () {
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
var exports = {};
/* Track the state of the @all warning. The user must acknowledge that they are spamming the entire
stream before the warning will go away. If they try to send before explicitly dismissing the
warning, they will get an error message too.
@ -162,7 +159,7 @@ function create_message_object() {
// Topics are optional, and we provide a placeholder if one isn't given.
var topic = compose_state.topic();
if (topic === "") {
topic = compose.empty_topic_placeholder();
topic = exports.empty_topic_placeholder();
}
var content = make_uploads_relative(compose_state.message_content());
@ -354,7 +351,7 @@ exports.finish = function () {
return;
}
if (!compose.validate()) {
if (!exports.validate()) {
return false;
}
@ -434,7 +431,7 @@ function validate_stream_message_mentions(stream_name) {
// check if @all or @everyone is in the message
if (util.is_all_or_everyone_mentioned(compose_state.message_content()) &&
stream_count > compose.all_everyone_warn_threshold) {
stream_count > exports.all_everyone_warn_threshold) {
if (user_acknowledged_all_everyone === undefined ||
user_acknowledged_all_everyone === false) {
// user has not seen a warning message yet if undefined
@ -458,7 +455,7 @@ function validate_stream_message_announce(stream_name) {
var stream_count = stream_data.get_subscriber_count(stream_name) || 0;
if (stream_name === "announce" &&
stream_count > compose.announce_warn_threshold) {
stream_count > exports.announce_warn_threshold) {
if (user_acknowledged_announce === undefined ||
user_acknowledged_announce === false) {
// user has not seen a warning message yet if undefined
@ -797,7 +794,7 @@ exports.initialize = function () {
$("#compose form").on("submit", function (e) {
e.preventDefault();
compose.finish();
exports.finish();
});
resize.watch_manual_resize("#compose-textarea");
@ -861,7 +858,7 @@ exports.initialize = function () {
$(event.target).parents('.compose-all-everyone').remove();
user_acknowledged_all_everyone = true;
exports.clear_all_everyone_warnings();
compose.finish();
exports.finish();
});
$("#compose-announce").on('click', '.compose-announce-confirm', function (event) {
@ -870,7 +867,7 @@ exports.initialize = function () {
$(event.target).parents('.compose-announce').remove();
user_acknowledged_announce = true;
exports.clear_announce_warnings();
compose.finish();
exports.finish();
});
$("#compose-send-status").on('click', '.sub_unsub_button', function (event) {
@ -1093,10 +1090,4 @@ exports.initialize = function () {
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose;
}
window.compose = compose;
window.compose = exports;

View File

@ -1,9 +1,5 @@
var autosize = require('autosize');
var compose_actions = (function () {
var exports = {};
function update_lock_icon_for_stream(stream_name) {
var icon = $("#compose-lock-icon");
var streamfield = $("#stream_message_recipient_stream");
@ -109,7 +105,7 @@ function clear_box() {
exports.autosize_message_content = function () {
autosize($("#compose-textarea"), {
callback: function () {
compose_actions.maybe_scroll_up_selected_message();
exports.maybe_scroll_up_selected_message();
},
});
};
@ -491,10 +487,4 @@ exports.on_narrow = function (opts) {
exports.cancel();
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_actions;
}
window.compose_actions = compose_actions;
window.compose_actions = exports;

View File

@ -1,7 +1,3 @@
var compose_fade = (function () {
var exports = {};
var focused_recipient;
var normal_display = false;
@ -254,11 +250,4 @@ exports.initialize = function () {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_fade;
}
window.compose_fade = compose_fade;
window.compose_fade = exports;

View File

@ -1,7 +1,3 @@
var compose_pm_pill = (function () {
var exports = {};
exports.initialize_pill = function () {
var pill;
var container = $("#private_message_recipient").parent();
@ -65,10 +61,4 @@ exports.get_typeahead_items = function () {
return user_pill.typeahead_source(exports.widget);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_pm_pill;
}
window.compose_pm_pill = compose_pm_pill;
window.compose_pm_pill = exports;

View File

@ -1,7 +1,3 @@
var compose_state = (function () {
var exports = {};
var message_type = false; // 'stream', 'private', or false-y
exports.set_message_type = function (msg_type) {
@ -57,10 +53,4 @@ exports.has_message_content = function () {
return exports.message_content() !== "";
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_state;
}
window.compose_state = compose_state;
window.compose_state = exports;

View File

@ -1,9 +1,5 @@
var autosize = require('autosize');
var compose_ui = (function () {
var exports = {};
exports.autosize_textarea = function () {
autosize.update($("#compose-textarea"));
};
@ -116,10 +112,4 @@ exports.compute_placeholder_text = function (opts) {
return i18n.t("Compose your message here");
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_ui;
}
window.compose_ui = compose_ui;
window.compose_ui = exports;

View File

@ -1,7 +1,5 @@
var autosize = require('autosize');
var composebox_typeahead = (function () {
//************************************
// AN IMPORTANT NOTE ABOUT TYPEAHEADS
//************************************
@ -13,8 +11,6 @@ var composebox_typeahead = (function () {
// highlighter that escapes (i.e. one that calls
// typeahead_helper.highlight_with_escaping).
var exports = {};
exports.emoji_collection = [];
exports.update_emoji_data = function () {
@ -917,10 +913,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = composebox_typeahead;
}
window.composebox_typeahead = composebox_typeahead;
window.composebox_typeahead = exports;

View File

@ -12,10 +12,6 @@ This library implements two related, similar concepts:
var Dict = require('./dict').Dict;
var condense = (function () {
var exports = {};
var _message_content_height_cache = new Dict();
function show_more_link(row) {
@ -134,7 +130,7 @@ exports.toggle_collapse = function (message) {
exports.show_message_expander(row);
row.find(".message_condenser").hide();
}
condense.uncollapse(row);
exports.uncollapse(row);
} else {
if (is_condensed) {
message.condensed = false;
@ -142,7 +138,7 @@ exports.toggle_collapse = function (message) {
exports.hide_message_expander(row);
row.find(".message_condenser").show();
} else {
condense.collapse(row);
exports.collapse(row);
}
}
};
@ -246,10 +242,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = condense;
}
window.condense = condense;
window.condense = exports;

View File

@ -1,9 +1,5 @@
var render_confirm_dialog = require("../templates/confirm_dialog.hbs");
var confirm_dialog = (function () {
var exports = {};
/*
Look for confirm_dialog in settings_user_groups
to see an example of how to use this widget. It's
@ -79,10 +75,4 @@ exports.launch = function (conf) {
overlays.open_modal('confirm_dialog_modal');
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = confirm_dialog;
}
window.confirm_dialog = confirm_dialog;
window.confirm_dialog = exports;

View File

@ -1,7 +1,3 @@
var copy_and_paste = (function () {
var exports = {};
function find_boundary_tr(initial_tr, iterate_row) {
var j;
var skip_same_td_check = false;
@ -349,10 +345,4 @@ exports.initialize = function () {
$('body').on('paste', '#message_edit_form', exports.paste_handler);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = copy_and_paste;
}
window.copy_and_paste = copy_and_paste;
window.copy_and_paste = exports;

View File

@ -1,9 +1,5 @@
var render_draft_table_body = require('../templates/draft_table_body.hbs');
var drafts = (function () {
var exports = {};
var draft_model = (function () {
var exports = {};
@ -120,7 +116,7 @@ function draft_notify() {
}
exports.update_draft = function () {
var draft = drafts.snapshot_message();
var draft = exports.snapshot_message();
var draft_id = $("#compose-textarea").data("draft-id");
if (draft_id !== undefined) {
@ -288,7 +284,7 @@ function remove_draft(draft_row) {
// Deletes the draft and removes it from the list
var draft_id = draft_row.data("draft-id");
drafts.draft_model.deleteDraft(draft_id);
exports.draft_model.deleteDraft(draft_id);
draft_row.remove();
@ -508,10 +504,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = drafts;
}
window.drafts = drafts;
window.drafts = exports;

View File

@ -1,8 +1,5 @@
var echo = (function () {
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
var exports = {};
var waiting_for_id = {};
var waiting_for_ack = {};
@ -290,10 +287,4 @@ exports.initialize = function () {
on_failed_action('refresh', resend_message);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = echo;
}
window.echo = echo;
window.echo = exports;

View File

@ -1,7 +1,3 @@
var emoji = (function () {
var exports = {};
// `emojis_by_name` is the central data source that is supposed to be
// used by every widget in the webapp for gathering data for displaying
// emojis. Emoji picker uses this data to derive data for its own use.
@ -111,7 +107,7 @@ exports.build_emoji_data = function (realm_emojis) {
emoji_dict = {
name: emoji_name,
display_name: emoji_name,
aliases: emoji.default_emoji_aliases[codepoint],
aliases: exports.default_emoji_aliases[codepoint],
is_realm_emoji: false,
emoji_code: codepoint,
has_reacted: false,
@ -194,9 +190,4 @@ exports.translate_emoticons_to_names = function translate_emoticons_to_names(tex
return translated;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = emoji;
}
window.emoji = emoji;
window.emoji = exports;

View File

@ -3,10 +3,6 @@ var render_emoji_popover_content = require('../templates/emoji_popover_content.h
var render_emoji_popover_search_results = require('../templates/emoji_popover_search_results.hbs');
var render_emoji_showcase = require("../templates/emoji_showcase.hbs");
var emoji_picker = (function () {
var exports = {};
// Emoji picker is of fixed width and height. Update these
// whenever these values are changed in `reactions.css`.
var APPROX_HEIGHT = 375;
@ -281,7 +277,7 @@ function maybe_select_emoji(e) {
e.preventDefault();
var first_emoji = get_rendered_emoji(0, 0);
if (first_emoji) {
if (emoji_picker.is_composition(first_emoji)) {
if (exports.is_composition(first_emoji)) {
first_emoji.click();
} else {
toggle_reaction(first_emoji.data("emoji-name"));
@ -553,7 +549,7 @@ function register_popover_events(popover) {
var $emoji_map = popover.find('.emoji-popover-emoji-map');
ui.get_scroll_element($emoji_map).on("scroll", function () {
emoji_picker.emoji_select_tab(ui.get_scroll_element($emoji_map));
exports.emoji_select_tab(ui.get_scroll_element($emoji_map));
});
$('.emoji-popover-filter').on('input', filter_emojis);
@ -637,7 +633,7 @@ exports.toggle_emoji_popover = function (element, id) {
if (elt.data('popover') === undefined) {
// Keep the element over which the popover is based off visible.
elt.addClass("reaction_button_visible");
emoji_picker.render_emoji_popover(elt, id);
exports.render_emoji_popover(elt, id);
}
reset_emoji_showcase();
};
@ -668,7 +664,7 @@ exports.register_click_handlers = function () {
compose_ui.insert_syntax_and_focus(emoji_text);
}
e.stopPropagation();
emoji_picker.hide_emoji_popover();
exports.hide_emoji_popover();
});
$("body").on("click", "#emoji_map", function (e) {
@ -684,14 +680,14 @@ exports.register_click_handlers = function () {
} else {
edit_message_id = null;
}
emoji_picker.toggle_emoji_popover(this);
exports.toggle_emoji_popover(this);
});
$("#main_div").on("click", ".reaction_button", function (e) {
e.stopPropagation();
var message_id = rows.get_message_id(this);
emoji_picker.toggle_emoji_popover(this, message_id);
exports.toggle_emoji_popover(this, message_id);
});
$("#main_div").on("mouseenter", ".reaction_button", function (e) {
@ -724,7 +720,7 @@ exports.register_click_handlers = function () {
// element is not present, we use the message's
// .fa-chevron-down element as the base for the popover.
var elem = $(".selected_message .actions_hover")[0];
emoji_picker.toggle_emoji_popover(elem, message_id);
exports.toggle_emoji_popover(elem, message_id);
});
$("body").on("click", ".emoji-popover-tab-item", function (e) {
@ -759,11 +755,4 @@ exports.initialize = function () {
exports.generate_emoji_picker_data(emoji.active_realm_emojis);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = emoji_picker;
}
window.emoji_picker = emoji_picker;
window.emoji_picker = exports;

View File

@ -1,7 +1,3 @@
var favicon = (function () {
var exports = {};
var favicon_selector = 'link[rel="shortcut icon"]';
// We need to reset the favicon after changing the
@ -28,9 +24,4 @@ exports.set = function (url) {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = favicon;
}
window.favicon = favicon;
window.favicon = exports;

View File

@ -1,18 +1,7 @@
var feature_flags = (function () {
var exports = {};
// The features below have all settled into their final states and can
// be removed when we get a chance
exports.propagate_topic_edits = true;
exports.clicking_notification_causes_narrow = true;
exports.reminders_in_message_action_menu = false;
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = feature_flags;
}
window.feature_flags = feature_flags;
window.feature_flags = exports;

View File

@ -1,9 +1,5 @@
var render_feedback_container = require('../templates/feedback_container.hbs');
var feedback_widget = (function () {
var exports = {};
/*
This code lets you show something like this:
@ -140,10 +136,4 @@ exports.show = function (opts) {
animate.fadeIn();
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = feedback_widget;
}
window.feedback_widget = feedback_widget;
window.feedback_widget = exports;

View File

@ -1,7 +1,3 @@
var fenced_code = (function () {
var exports = {};
// Parsing routine that can be dropped in to message parsing
// and formats code blocks
//
@ -189,10 +185,4 @@ exports.process_fenced_code = function (content) {
return output.join('\n');
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = fenced_code;
}
window.fenced_code = fenced_code;
window.fenced_code = exports;

View File

@ -46,7 +46,5 @@ var FetchStatus = function () {
return self;
};
if (typeof module !== 'undefined') {
module.exports = FetchStatus;
}
window.FetchStatus = FetchStatus;

View File

@ -1,5 +1,3 @@
var Filter = (function () {
function zephyr_stream_name_match(message, operand) {
// Zephyr users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
// (unsocial, ununsocial, social.d, etc)
@ -715,11 +713,6 @@ Filter.describe = function (operators) {
return Handlebars.Utils.escapeExpression(describe_unescaped(operators));
};
return Filter;
}());
if (typeof module !== 'undefined') {
module.exports = Filter;
}
window.Filter = Filter;

View File

@ -1,8 +1,3 @@
var floating_recipient_bar = (function () {
var exports = {};
var is_floating_recipient_bar_showing = false;
function top_offset(elem) {
@ -332,10 +327,4 @@ exports.update = function () {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = floating_recipient_bar;
}
window.floating_recipient_bar = floating_recipient_bar;
window.floating_recipient_bar = exports;

View File

@ -1,7 +1,3 @@
var gear_menu = (function () {
var exports = {};
/*
For various historical reasons there isn't one
single chunk of code that really makes our gear
@ -140,10 +136,4 @@ exports.close = function () {
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = gear_menu;
}
window.gear_menu = gear_menu;
window.gear_menu = exports;

View File

@ -1,7 +1,3 @@
var hash_util = (function () {
var exports = {};
exports.get_hash_category = function (hash) {
// given "#streams/subscribed", returns "streams"
return hash ? hash.replace(/^#/, "").split(/\//)[0] : "";
@ -181,10 +177,4 @@ exports.parse_narrow = function (hash) {
return operators;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = hash_util;
}
window.hash_util = hash_util;
window.hash_util = exports;

View File

@ -1,9 +1,5 @@
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
// or locally: docs/subsystems/hashchange-system.md
var hashchange = (function () {
var exports = {};
var changing_hash = false;
function get_full_url(hash) {
@ -313,10 +309,4 @@ exports.exit_overlay = function (callback) {
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = hashchange;
}
window.hashchange = hashchange;
window.hashchange = exports;

View File

@ -1,7 +1,3 @@
var hotkeys = (function () {
var exports = {};
function do_narrow_action(action) {
action(current_msg_list.selected_id(), {trigger: 'hotkey'});
return true;
@ -819,11 +815,4 @@ $(document).keypress(function (e) {
}
});
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = hotkeys;
}
window.hotkey = hotkeys;
window.hotkey = exports;

View File

@ -1,10 +1,6 @@
var render_hotspot_overlay = require('../templates/hotspot_overlay.hbs');
var render_intro_reply_hotspot = require('../templates/intro_reply_hotspot.hbs');
var hotspots = (function () {
var exports = {};
// popover orientations
var TOP = 'top';
var LEFT = 'left';
@ -257,9 +253,4 @@ exports.initialize = function () {
exports.load_new(page_params.hotspots);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = hotspots;
}
window.hotspots = hotspots;
window.hotspots = exports;

View File

@ -1,7 +1,3 @@
var info_overlay = (function () {
var exports = {};
// Make it explicit that our toggler is undefined until
// set_up_toggler is called.
exports.toggler = undefined;
@ -80,10 +76,4 @@ exports.maybe_show_keyboard_shortcuts = function () {
exports.show("keyboard-shortcuts");
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = info_overlay;
}
window.info_overlay = info_overlay;
window.info_overlay = exports;

View File

@ -1,10 +1,6 @@
var render_input_pill = require('../templates/input_pill.hbs');
// See https://zulip.readthedocs.io/en/latest/subsystems/input-pills.html
var input_pill = (function () {
var exports = {};
exports.random_id = function () {
return Math.random().toString(16);
};
@ -389,11 +385,4 @@ exports.create = function (opts) {
return prototype;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = input_pill;
}
window.input_pill = input_pill;
window.input_pill = exports;

View File

@ -1,7 +1,3 @@
var integration_bot_widget = (function () {
var exports = {};
// This function subscribes the newly created bot to the stream specified by the user.
function subscribe_to_stream(bot_email, stream_name) {
var bot_user_id = people.get_user_id(bot_email);
@ -74,11 +70,4 @@ exports.set_integration_bot_url = function (
stream_name, api_url, integration_url, on_create_bot_success);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = integration_bot_widget;
}
window.integration_bot_widget = integration_bot_widget;
window.integration_bot_widget = exports;

View File

@ -4,10 +4,6 @@ var render_settings_dev_env_email_access = require('../templates/settings/dev_en
var autosize = require('autosize');
var invite = (function () {
var exports = {};
function reset_error_messages() {
$('#invite_status').hide().text('').removeClass(common.status_classes);
$('#multiuse_invite_status').hide().text('').removeClass(common.status_classes);
@ -197,11 +193,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = invite;
}
window.invite = invite;
window.invite = exports;

View File

@ -1,7 +1,3 @@
var keydown_util = (function () {
var exports = {};
/*
See hotkey.js for handlers that are more app-wide.
*/
@ -41,10 +37,4 @@ exports.handle = function (opts) {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = keydown_util;
}
window.keydown_util = keydown_util;
window.keydown_util = exports;

View File

@ -1,6 +1,3 @@
var lightbox = (function () {
var exports = {};
var is_open = false;
// the asset map is a map of all retrieved images and YouTube videos that are
// memoized instead of being looked up multiple times.
@ -276,9 +273,9 @@ exports.initialize = function () {
var direction = $(this).attr("data-direction");
if (direction === 'next') {
lightbox.next();
exports.next();
} else if (direction === 'prev') {
lightbox.prev();
exports.prev();
}
});
@ -316,10 +313,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = lightbox;
}
window.lightbox = lightbox;
window.lightbox = exports;

View File

@ -1,4 +1,3 @@
var LightboxCanvas = (function () {
var events = {
documentMouseup: [],
windowResize: [],
@ -259,7 +258,7 @@ var funcs = {
};
// a class w/ prototype to create a new `LightboxCanvas` instance.
var __LightboxCanvas = function (el) {
var LightboxCanvas = function (el) {
var self = this;
this.meta = {
@ -302,7 +301,7 @@ var __LightboxCanvas = function (el) {
funcs.attachEvents(this.canvas, this.context, self.meta);
};
__LightboxCanvas.prototype = {
LightboxCanvas.prototype = {
// set the speed at which scrolling zooms in on a photo.
speed: function (speed) {
this.meta.speed = speed;
@ -327,10 +326,5 @@ __LightboxCanvas.prototype = {
},
};
return __LightboxCanvas;
}());
if (typeof module !== 'undefined') {
module.exports = LightboxCanvas;
}
window.LightboxCanvas = LightboxCanvas;

View File

@ -139,7 +139,5 @@ var list_cursor = function (opts) {
return self;
};
if (typeof module !== 'undefined') {
module.exports = list_cursor;
}
window.list_cursor = list_cursor;

View File

@ -1,7 +1,3 @@
var list_render = (function () {
var exports = {};
var DEFAULTS = {
INITIAL_RENDER_COUNT: 80,
LOAD_COUNT: 20,
@ -361,7 +357,7 @@ exports.handle_sort = function () {
var prop_name = $this.data("sort-prop");
var list_name = $this.closest(".progressive-table-wrapper").data("list-render");
var list = list_render.get(list_name);
var list = exports.get(list_name);
if (!list) {
blueslip.error("Error. This `.progressive-table-wrapper` has no `data-list-render` attribute.");
@ -388,11 +384,4 @@ exports.handle_sort = function () {
$this.addClass("active");
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = list_render;
}
window.list_render = list_render;
window.list_render = exports;

View File

@ -1,7 +1,3 @@
var list_util = (function () {
var exports = {};
var list_selectors = ["#group-pm-list", "#stream_filters", "#global_filters", "#user_presences"];
exports.inside_list = function (e) {
@ -20,11 +16,4 @@ exports.go_up = function (e) {
$target.closest("li").prev().find("a").focus();
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = list_util;
}
window.list_util = list_util;
window.list_util = exports;

View File

@ -1,9 +1,5 @@
var render_loader = require("../templates/loader.hbs");
var loading = (function () {
var exports = {};
exports.make_indicator = function (outer_container, opts) {
opts = opts || {};
var container = outer_container;
@ -69,9 +65,4 @@ exports.destroy_indicator = function (container) {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = loading;
}
window.loading = loading;
window.loading = exports;

View File

@ -1,7 +1,3 @@
var local_message = (function () {
var exports = {};
function truncate_precision(float) {
return parseFloat(float.toFixed(3));
}
@ -57,11 +53,4 @@ exports.get_next_id = (function () {
};
}());
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = local_message;
}
window.local_message = local_message;
window.local_message = exports;

View File

@ -1,5 +1,3 @@
var localstorage = (function () {
var ls = {
// parse JSON without throwing an error.
parseJSON: function (str) {
@ -89,7 +87,7 @@ var ls = {
};
// return a new function instance that has instance-scoped variables.
var exports = function () {
var localstorage = function () {
var _data = {
VERSION: 1,
expires: Infinity,
@ -164,7 +162,7 @@ var exports = function () {
var warned_of_localstorage = false;
exports.supported = function supports_localstorage() {
localstorage.supported = function supports_localstorage() {
try {
return window.hasOwnProperty('localStorage') && window.localStorage !== null;
} catch (e) {
@ -176,10 +174,5 @@ exports.supported = function supports_localstorage() {
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = localstorage;
}
window.localstorage = localstorage;

View File

@ -4,11 +4,8 @@
// static/third/marked/lib/marked.js, which we have significantly
// modified from the original implementation.
var markdown = (function () {
// Docs: https://zulip.readthedocs.io/en/latest/subsystems/markdown.html
var exports = {};
var realm_filter_map = {};
var realm_filter_list = [];
@ -442,10 +439,4 @@ exports.initialize = function () {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = markdown;
}
window.markdown = markdown;
window.markdown = exports;

View File

@ -2,8 +2,6 @@ var render_message_edit_form = require('../templates/message_edit_form.hbs');
var render_message_edit_history = require('../templates/message_edit_history.hbs');
var render_topic_edit_form = require('../templates/topic_edit_form.hbs');
var message_edit = (function () {
var exports = {};
var currently_editing_messages = {};
var currently_deleting_messages = [];
@ -157,7 +155,7 @@ exports.save = function (row, from_topic_edited_only) {
echo.edit_locally(message, new_content, topic_changed ? new_topic : undefined);
row = current_msg_list.get_row(message_id);
}
message_edit.end(row);
exports.end(row);
return;
}
@ -177,7 +175,7 @@ exports.save = function (row, from_topic_edited_only) {
}
if (!changed) {
// If they didn't change anything, just cancel it.
message_edit.end(row);
exports.end(row);
return;
}
channel.patch({
@ -245,7 +243,7 @@ function handle_edit_keydown(from_topic_edited_only, e) {
}
e.stopPropagation();
e.preventDefault();
message_edit.save(row, from_topic_edited_only);
exports.save(row, from_topic_edited_only);
}
function timer_text(seconds_left) {
@ -277,8 +275,8 @@ function edit_message(row, raw_content) {
// zerver.views.messages.update_message_backend
var seconds_left_buffer = 5;
var editability = get_editability(message, seconds_left_buffer);
var is_editable = editability === message_edit.editability_types.TOPIC_ONLY ||
editability === message_edit.editability_types.FULL;
var is_editable = editability === exports.editability_types.TOPIC_ONLY ||
editability === exports.editability_types.FULL;
var max_file_upload_size = page_params.max_file_upload_size;
var file_upload_enabled = false;
@ -290,7 +288,7 @@ function edit_message(row, raw_content) {
is_stream: message.type === 'stream',
message_id: message.id,
is_editable: is_editable,
is_content_editable: editability === message_edit.editability_types.FULL,
is_content_editable: editability === exports.editability_types.FULL,
has_been_editable: editability !== editability_types.NO,
topic: util.get_message_topic(message),
content: raw_content,
@ -560,7 +558,7 @@ exports.edit_last_sent_message = function () {
// Finally do the real work!
compose_actions.cancel();
message_edit.start(msg_row, function () {
exports.start(msg_row, function () {
$('#message_edit_content').focus();
});
};
@ -693,10 +691,4 @@ exports.handle_narrow_deactivated = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_edit;
}
window.message_edit = message_edit;
window.message_edit = exports;

View File

@ -1,7 +1,3 @@
var message_events = (function () {
var exports = {};
function maybe_add_narrowed_messages(messages, msg_list) {
var ids = [];
_.each(messages, function (elem) {
@ -282,10 +278,4 @@ exports.update_messages = function update_messages(events) {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_events;
}
window.message_events = message_events;
window.message_events = exports;

View File

@ -1,7 +1,3 @@
var message_fetch = (function () {
var exports = {};
var consts = {
backfill_idle_time: 10 * 1000,
error_retry_time: 5000,
@ -220,7 +216,7 @@ exports.load_messages = function (opts) {
exports.load_messages_for_narrow = function (opts) {
var msg_list = message_list.narrowed;
message_fetch.load_messages({
exports.load_messages({
anchor: opts.then_select_id.toFixed(),
num_before: consts.narrow_before,
num_after: consts.narrow_after,
@ -381,10 +377,4 @@ exports.initialize = function () {
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_fetch;
}
window.message_fetch = message_fetch;
window.message_fetch = exports;

View File

@ -1,5 +1,3 @@
var message_flags = (function () {
var exports = {};
function send_flag_update(message, flag, op) {
channel.post({
url: '/json/messages/flags',
@ -30,7 +28,7 @@ exports.send_read = (function () {
return;
}
var real_msg_ids_batch = real_msg_ids.slice(0, message_flags._unread_batch_size);
var real_msg_ids_batch = real_msg_ids.slice(0, exports._unread_batch_size);
// We have some real IDs. If there are any left in the queue when this
// call finishes, they will be handled in the success callback.
@ -130,10 +128,4 @@ exports.unstar_all_messages = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_flags;
}
window.message_flags = message_flags;
window.message_flags = exports;

View File

@ -1,9 +1,5 @@
var autosize = require('autosize');
var message_list = (function () {
var exports = {};
exports.narrowed = undefined;
exports.set_narrowed = function (value) {
exports.narrowed = value;
@ -449,10 +445,4 @@ $(document).on('message_selected.zulip wheel', function () {
message_viewport.stop_auto_scrolling();
});
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_list;
}
window.message_list = message_list;
window.message_list = exports;

View File

@ -570,8 +570,6 @@ MessageListData.prototype = {
},
};
if (typeof module !== 'undefined') {
module.exports = MessageListData;
}
window.MessageListData = MessageListData;

View File

@ -19,8 +19,6 @@ function MessageListView(list, table_name, collapse_messages) {
this._render_win_end = 0;
}
(function () {
function get_user_id_for_mention_button(elem) {
var user_id = $(elem).attr('data-user-id');
// Handle legacy markdown that was rendered before we cut
@ -1357,9 +1355,5 @@ MessageListView.prototype = {
},
};
}());
if (typeof module !== 'undefined') {
module.exports = MessageListView;
}
window.MessageListView = MessageListView;

View File

@ -1,7 +1,3 @@
var message_live_update = (function () {
var exports = {};
exports.update_stream_name = function (stream_id, new_name) {
_.each([home_msg_list, message_list.narrowed, message_list.all], function (list) {
if (list === undefined) {
@ -32,11 +28,4 @@ exports.update_avatar = function (user_id, avatar_url) {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_live_update;
}
window.message_live_update = message_live_update;
window.message_live_update = exports;

View File

@ -1,7 +1,3 @@
var message_scroll = (function () {
var exports = {};
var actively_scrolling = false;
var loading_more_messages_indicator_showing = false;
@ -80,10 +76,4 @@ exports.initialize = function () {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_scroll;
}
window.message_scroll = message_scroll;
window.message_scroll = exports;

View File

@ -1,6 +1,3 @@
var message_store = (function () {
var exports = {};
var stored_messages = {};
exports.get = function get(message_id) {
@ -194,10 +191,4 @@ exports.reify_message_id = function (opts) {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_store;
}
window.message_store = message_store;
window.message_store = exports;

View File

@ -1,7 +1,3 @@
var message_util = (function () {
var exports = {};
exports.do_unread_count_updates = function do_unread_count_updates(messages) {
unread.process_loaded_messages(messages);
unread_ui.update_unread_counts();
@ -29,10 +25,4 @@ exports.add_new_messages = function (messages, msg_list) {
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_util;
}
window.message_util = message_util;
window.message_util = exports;

View File

@ -1,6 +1,3 @@
var message_viewport = (function () {
var exports = {};
var jwindow;
var dimensions = {};
var in_stoppable_autoscroll = false;
@ -226,7 +223,7 @@ exports.scrollTop = function viewport_scrollTop(target_scrollTop) {
}
var ret = exports.message_pane.scrollTop(target_scrollTop);
var new_scrollTop = exports.message_pane.scrollTop();
var space_to_scroll = $("#bottom_whitespace").offset().top - message_viewport.height();
var space_to_scroll = $("#bottom_whitespace").offset().top - exports.height();
// Check whether our scrollTop didn't move even though one could have scrolled down
if (space_to_scroll > 0 && target_scrollTop > 0 &&
@ -359,12 +356,12 @@ exports.keep_pointer_in_view = function () {
return;
}
var info = message_viewport.message_viewport_info();
var info = exports.message_viewport_info();
var top_threshold = info.visible_top + 1 / 10 * info.visible_height;
var bottom_threshold = info.visible_top + 9 / 10 * info.visible_height;
function message_is_far_enough_down() {
if (message_viewport.at_top()) {
if (exports.at_top()) {
return true;
}
@ -390,7 +387,7 @@ exports.keep_pointer_in_view = function () {
}
function message_is_far_enough_up() {
return message_viewport.at_bottom() ||
return exports.at_bottom() ||
next_row.offset().top <= bottom_threshold;
}
@ -433,10 +430,4 @@ exports.initialize = function () {
});
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_viewport;
}
window.message_viewport = message_viewport;
window.message_viewport = exports;

View File

@ -1,9 +1,5 @@
var Dict = require('./dict').Dict;
var muting = (function () {
var exports = {};
var muted_topics = new Dict();
exports.add_muted_topic = function (stream_id, topic) {
@ -62,9 +58,4 @@ exports.initialize = function () {
exports.set_muted_topics(page_params.muted_topics);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = muting;
}
window.muting = muting;
window.muting = exports;

Some files were not shown because too many files have changed in this diff Show More