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", "guard-for-in": "error",
"indent": ["error", 4, { "indent": ["error", 4, {
"ArrayExpression": "first", "ArrayExpression": "first",
"outerIIFEBody": 0,
"ObjectExpression": "first", "ObjectExpression": "first",
"SwitchCase": 0, "SwitchCase": 0,
"CallExpression": {"arguments": "first"}, "CallExpression": {"arguments": "first"},

View File

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

View File

@ -1,7 +1,4 @@
var util = require("util"); var util = require("util");
var common = (function () {
var exports = {};
var test_credentials = require('../../var/casper/test_credentials.js').test_credentials; var test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
@ -382,14 +379,3 @@ exports.un_narrow = function () {
} }
common.keypress(27); // Esc 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 email = 'alice@test.example.com';
var subdomain = 'testsubdomain'; 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/"; var realm_url = "http://zulip.zulipdev.com:9981/";
// Start of test script. // Start of test script.

View File

@ -8,7 +8,7 @@
// Provides a few utility functions. // Provides a few utility functions.
// See http://casperjs.org/api.html#utils // See http://casperjs.org/api.html#utils
// For example, utils.dump() prints an Object with nice formatting. // 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(); 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(); 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(); 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(); 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 test_credentials = require('../../var/casper/test_credentials.js').test_credentials;
var OUTGOING_WEBHOOK_BOT_TYPE = '3'; var OUTGOING_WEBHOOK_BOT_TYPE = '3';
var GENERIC_BOT_TYPE = '1'; 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() { function star_count() {
return casper.evaluate(function () { 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(); 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. // 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(); 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(); 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) { function heading(heading_str) {
casper.then(function () { 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(); 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) { function waitWhileDraftsVisible(then) {
casper.waitFor(function () { 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(); 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(); common.start_and_log_in();

View File

@ -1,7 +1,3 @@
var finder = (function () {
var exports = {};
var _ = require('underscore/underscore.js'); var _ = require('underscore/underscore.js');
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
@ -47,8 +43,3 @@ exports.find_files_to_run = function () {
return files; 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"); const templates_path = path.resolve(__dirname, "../../static/templates");
let render; let render;
module.exports.make_handlebars = () => { exports.make_handlebars = () => {
// Create a new Handlebars instance. // Create a new Handlebars instance.
const Handlebars = require("handlebars/dist/cjs/handlebars.js"); const Handlebars = require("handlebars/dist/cjs/handlebars.js");
const hb = Handlebars.create(); const hb = Handlebars.create();
@ -40,7 +40,7 @@ module.exports.make_handlebars = () => {
return hb; return hb;
}; };
module.exports.stub_templates = stub => { exports.stub_templates = stub => {
render = (filename, ...args) => { render = (filename, ...args) => {
const name = path.relative(templates_path, filename).slice(0, -".hbs".length); const name = path.relative(templates_path, filename).slice(0, -".hbs".length);
return stub(name, ...args); return stub(name, ...args);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,6 @@
var render_group_pms = require('../templates/group_pms.hbs'); var render_group_pms = require('../templates/group_pms.hbs');
var Dict = require('./dict').Dict; var Dict = require('./dict').Dict;
var activity = (function () {
var exports = {};
/* /*
Helpers for detecting user activity and managing user idle states 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.user_filter.text();
}; };
return exports; window.activity = exports;
}());
if (typeof module !== 'undefined') {
module.exports = activity;
}
window.activity = activity;

View File

@ -1,9 +1,5 @@
var render_admin_tab = require('../templates/admin_tab.hbs'); var render_admin_tab = require('../templates/admin_tab.hbs');
var admin = (function () {
var exports = {};
var admin_settings_label = { var admin_settings_label = {
// Organization settings // Organization settings
realm_allow_community_topic_editing: i18n.t("Users can edit the topic of any message"), 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'); settings_toggle.highlight_toggle('organization');
}; };
return exports; window.admin = exports;
}());
if (typeof module !== 'undefined') {
module.exports = admin;
}
window.admin = admin;

View File

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

View File

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

View File

@ -1,9 +1,5 @@
var render_archive_message_group = require('../templates/archive_message_group.hbs'); 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) { function should_separate_into_groups(current_msg_time, next_msg_time) {
var current_time = new XDate(current_msg_time * 1000); var current_time = new XDate(current_msg_time * 1000);
var next_time = new XDate(next_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(); all_message_timestamps_to_human_readable();
}; };
return exports; exports.current_msg_list = {
}());
var current_msg_list = {
selected_row: function () { selected_row: function () {
return $('.message_row').last(); return $('.message_row').last();
}, },
}; };
var rows = { exports.rows = {
get_message_recipient_row: function (message_row) { get_message_recipient_row: function (message_row) {
return $(message_row).parent('.recipient_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; var scroll_timer;
function scroll_finish() { function scroll_finish() {
clearTimeout(scroll_timer); clearTimeout(scroll_timer);
@ -141,5 +127,5 @@ $(function () {
$('.app').scroll(_.throttle(function () { $('.app').scroll(_.throttle(function () {
scroll_finish(); scroll_finish();
}, 50)); }, 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_settings_upload_space_stats = require("../templates/settings/upload_space_stats.hbs");
var render_uploaded_files_list = require("../templates/uploaded_files_list.hbs"); var render_uploaded_files_list = require("../templates/uploaded_files_list.hbs");
var attachments_ui = (function () {
var exports = {};
var attachments; var attachments;
var upload_space_used; var upload_space_used;
@ -39,7 +35,7 @@ function set_upload_space_stats() {
var args = { var args = {
show_upgrade_message: page_params.realm_plan_type === 2, show_upgrade_message: page_params.realm_plan_type === 2,
percent_used: exports.percentage_used_space(upload_space_used), 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); var rendered_upload_stats_html = render_settings_upload_space_stats(args);
$("#attachment-stats-holder").html(rendered_upload_stats_html); $("#attachment-stats-holder").html(rendered_upload_stats_html);
@ -158,10 +154,4 @@ exports.set_up_attachments = function () {
}); });
}; };
return exports; window.attachments_ui = exports;
}());
if (typeof module !== 'undefined') {
module.exports = attachments_ui;
}
window.attachments_ui = attachments_ui;

View File

@ -1,7 +1,3 @@
var avatar = (function () {
var exports = {};
exports.build_bot_create_widget = function () { exports.build_bot_create_widget = function () {
// We have to do strange gyrations with the file input to clear it, // 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; window.avatar = exports;
}());
if (typeof module !== 'undefined') {
module.exports = avatar;
}
window.avatar = avatar;

View File

@ -1,6 +1,3 @@
var billing = (function () {
var exports = {};
exports.initialize = function () { exports.initialize = function () {
helpers.set_tab("billing"); helpers.set_tab("billing");
@ -29,15 +26,8 @@ exports.initialize = function () {
}); });
}; };
return exports; window.billing = exports;
}());
if (typeof module !== 'undefined') {
module.exports = billing;
}
window.billing = billing;
$(function () { $(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) { exports.create_ajax_request = function (url, form_name, stripe_token = null) {
var form = $("#" + form_name + "-form"); var form = $("#" + form_name + "-form");
var form_loading_indicator = "#" + form_name + "_loading_indicator"; var form_loading_indicator = "#" + form_name + "_loading_indicator";
@ -107,11 +104,4 @@ exports.is_valid_input = function (elem) {
return elem[0].checkValidity(); return elem[0].checkValidity();
}; };
return exports; window.helpers = exports;
}());
if (typeof module !== 'undefined') {
module.exports = helpers;
}
window.helpers = helpers;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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! // You won't find every click handler here, but it's a good place to start!
exports.initialize = function () { exports.initialize = function () {
@ -889,11 +884,4 @@ exports.initialize = function () {
}); });
}; };
return exports; window.click_handlers = exports;
}());
if (typeof module !== 'undefined') {
module.exports = click_handlers;
}
window.click_handlers = click_handlers;

View File

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

View File

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

View File

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

View File

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

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_not_subscribed = require("../templates/compose_not_subscribed.hbs");
var render_compose_private_stream_alert = require("../templates/compose_private_stream_alert.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 // 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 /* 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 stream before the warning will go away. If they try to send before explicitly dismissing the
warning, they will get an error message too. 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. // Topics are optional, and we provide a placeholder if one isn't given.
var topic = compose_state.topic(); var topic = compose_state.topic();
if (topic === "") { if (topic === "") {
topic = compose.empty_topic_placeholder(); topic = exports.empty_topic_placeholder();
} }
var content = make_uploads_relative(compose_state.message_content()); var content = make_uploads_relative(compose_state.message_content());
@ -354,7 +351,7 @@ exports.finish = function () {
return; return;
} }
if (!compose.validate()) { if (!exports.validate()) {
return false; return false;
} }
@ -434,7 +431,7 @@ function validate_stream_message_mentions(stream_name) {
// check if @all or @everyone is in the message // check if @all or @everyone is in the message
if (util.is_all_or_everyone_mentioned(compose_state.message_content()) && 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 || if (user_acknowledged_all_everyone === undefined ||
user_acknowledged_all_everyone === false) { user_acknowledged_all_everyone === false) {
// user has not seen a warning message yet if undefined // 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; var stream_count = stream_data.get_subscriber_count(stream_name) || 0;
if (stream_name === "announce" && if (stream_name === "announce" &&
stream_count > compose.announce_warn_threshold) { stream_count > exports.announce_warn_threshold) {
if (user_acknowledged_announce === undefined || if (user_acknowledged_announce === undefined ||
user_acknowledged_announce === false) { user_acknowledged_announce === false) {
// user has not seen a warning message yet if undefined // user has not seen a warning message yet if undefined
@ -797,7 +794,7 @@ exports.initialize = function () {
$("#compose form").on("submit", function (e) { $("#compose form").on("submit", function (e) {
e.preventDefault(); e.preventDefault();
compose.finish(); exports.finish();
}); });
resize.watch_manual_resize("#compose-textarea"); resize.watch_manual_resize("#compose-textarea");
@ -861,7 +858,7 @@ exports.initialize = function () {
$(event.target).parents('.compose-all-everyone').remove(); $(event.target).parents('.compose-all-everyone').remove();
user_acknowledged_all_everyone = true; user_acknowledged_all_everyone = true;
exports.clear_all_everyone_warnings(); exports.clear_all_everyone_warnings();
compose.finish(); exports.finish();
}); });
$("#compose-announce").on('click', '.compose-announce-confirm', function (event) { $("#compose-announce").on('click', '.compose-announce-confirm', function (event) {
@ -870,7 +867,7 @@ exports.initialize = function () {
$(event.target).parents('.compose-announce').remove(); $(event.target).parents('.compose-announce').remove();
user_acknowledged_announce = true; user_acknowledged_announce = true;
exports.clear_announce_warnings(); exports.clear_announce_warnings();
compose.finish(); exports.finish();
}); });
$("#compose-send-status").on('click', '.sub_unsub_button', function (event) { $("#compose-send-status").on('click', '.sub_unsub_button', function (event) {
@ -1093,10 +1090,4 @@ exports.initialize = function () {
} }
}; };
return exports; window.compose = exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose;
}
window.compose = compose;

View File

@ -1,9 +1,5 @@
var autosize = require('autosize'); var autosize = require('autosize');
var compose_actions = (function () {
var exports = {};
function update_lock_icon_for_stream(stream_name) { function update_lock_icon_for_stream(stream_name) {
var icon = $("#compose-lock-icon"); var icon = $("#compose-lock-icon");
var streamfield = $("#stream_message_recipient_stream"); var streamfield = $("#stream_message_recipient_stream");
@ -109,7 +105,7 @@ function clear_box() {
exports.autosize_message_content = function () { exports.autosize_message_content = function () {
autosize($("#compose-textarea"), { autosize($("#compose-textarea"), {
callback: function () { 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(); exports.cancel();
}; };
return exports; window.compose_actions = exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_actions;
}
window.compose_actions = compose_actions;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,5 @@
var render_confirm_dialog = require("../templates/confirm_dialog.hbs"); var render_confirm_dialog = require("../templates/confirm_dialog.hbs");
var confirm_dialog = (function () {
var exports = {};
/* /*
Look for confirm_dialog in settings_user_groups Look for confirm_dialog in settings_user_groups
to see an example of how to use this widget. It's 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'); overlays.open_modal('confirm_dialog_modal');
}; };
return exports; window.confirm_dialog = exports;
}());
if (typeof module !== 'undefined') {
module.exports = confirm_dialog;
}
window.confirm_dialog = confirm_dialog;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,3 @@
var emoji = (function () {
var exports = {};
// `emojis_by_name` is the central data source that is supposed to be // `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 // 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. // 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 = { emoji_dict = {
name: emoji_name, name: emoji_name,
display_name: emoji_name, display_name: emoji_name,
aliases: emoji.default_emoji_aliases[codepoint], aliases: exports.default_emoji_aliases[codepoint],
is_realm_emoji: false, is_realm_emoji: false,
emoji_code: codepoint, emoji_code: codepoint,
has_reacted: false, has_reacted: false,
@ -194,9 +190,4 @@ exports.translate_emoticons_to_names = function translate_emoticons_to_names(tex
return translated; return translated;
}; };
return exports; window.emoji = exports;
}());
if (typeof module !== 'undefined') {
module.exports = emoji;
}
window.emoji = emoji;

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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. // This function subscribes the newly created bot to the stream specified by the user.
function subscribe_to_stream(bot_email, stream_name) { function subscribe_to_stream(bot_email, stream_name) {
var bot_user_id = people.get_user_id(bot_email); 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); stream_name, api_url, integration_url, on_create_bot_success);
}; };
return exports; window.integration_bot_widget = exports;
}());
if (typeof module !== 'undefined') {
module.exports = integration_bot_widget;
}
window.integration_bot_widget = integration_bot_widget;

View File

@ -4,10 +4,6 @@ var render_settings_dev_env_email_access = require('../templates/settings/dev_en
var autosize = require('autosize'); var autosize = require('autosize');
var invite = (function () {
var exports = {};
function reset_error_messages() { function reset_error_messages() {
$('#invite_status').hide().text('').removeClass(common.status_classes); $('#invite_status').hide().text('').removeClass(common.status_classes);
$('#multiuse_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; window.invite = exports;
}());
if (typeof module !== 'undefined') {
module.exports = invite;
}
window.invite = invite;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

@ -1,5 +1,3 @@
var message_flags = (function () {
var exports = {};
function send_flag_update(message, flag, op) { function send_flag_update(message, flag, op) {
channel.post({ channel.post({
url: '/json/messages/flags', url: '/json/messages/flags',
@ -30,7 +28,7 @@ exports.send_read = (function () {
return; 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 // 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. // call finishes, they will be handled in the success callback.
@ -130,10 +128,4 @@ exports.unstar_all_messages = function () {
}); });
}; };
return exports; window.message_flags = exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_flags;
}
window.message_flags = message_flags;

View File

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

View File

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

View File

@ -19,8 +19,6 @@ function MessageListView(list, table_name, collapse_messages) {
this._render_win_end = 0; this._render_win_end = 0;
} }
(function () {
function get_user_id_for_mention_button(elem) { function get_user_id_for_mention_button(elem) {
var user_id = $(elem).attr('data-user-id'); var user_id = $(elem).attr('data-user-id');
// Handle legacy markdown that was rendered before we cut // Handle legacy markdown that was rendered before we cut
@ -1357,9 +1355,5 @@ MessageListView.prototype = {
}, },
}; };
}()); module.exports = MessageListView;
if (typeof module !== 'undefined') {
module.exports = MessageListView;
}
window.MessageListView = 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) { exports.update_stream_name = function (stream_id, new_name) {
_.each([home_msg_list, message_list.narrowed, message_list.all], function (list) { _.each([home_msg_list, message_list.narrowed, message_list.all], function (list) {
if (list === undefined) { if (list === undefined) {
@ -32,11 +28,4 @@ exports.update_avatar = function (user_id, avatar_url) {
}); });
}; };
return exports; window.message_live_update = exports;
}());
if (typeof module !== 'undefined') {
module.exports = message_live_update;
}
window.message_live_update = message_live_update;

View File

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

View File

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

View File

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

View File

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

View File

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

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