Files
zulip/static/js/realm_logo.js
Joshua Pan ad1df0ebeb settings: Add support for customizing the top-left logo.
This adds a new realm_logo field, which is a horizontal-format logo to
be displayed in the top-left corner of the webapp, and any other
places where we might want a wide-format branding of the organization.

Tweaked significantly by tabbott to rebase, fix styling, etc.

Fixing the styling of this feature's loading indicator caused me to
notice the loading indicator for the realm_icon feature was also ugly,
so I fixed that too.

Fixes #7995.
2018-12-18 12:44:52 -08:00

54 lines
1.7 KiB
JavaScript

/* eslint indent: "off" */
var realm_logo = (function () {
var exports = {};
exports.build_realm_logo_widget = function (upload_function) {
var get_file_input = function () {
return $('#realm_logo_file_input').expectOne();
};
if (page_params.realm_logo_source === 'D') {
$("#realm_logo_delete_button").hide();
} else {
$("#realm_logo_delete_button").show();
}
$("#realm_logo_delete_button").on('click', function (e) {
e.preventDefault();
e.stopPropagation();
channel.del({
url: '/json/realm/logo',
});
});
return upload_widget.build_direct_upload_widget(
get_file_input,
$("#realm_logo_file_input_error").expectOne(),
$("#realm_logo_upload_button").expectOne(),
upload_function,
page_params.max_logo_file_size
);
};
exports.rerender = function () {
$("#realm-settings-logo").attr("src", page_params.realm_logo_url);
$("#realm-logo").attr("src", page_params.realm_logo_url);
if (page_params.realm_logo_source === 'U') {
$("#realm_logo_delete_button").show();
} else {
$("#realm_logo_delete_button").hide();
// Need to clear input because of a small edge case
// where you try to upload the same image you just deleted.
var file_input = $("#realm_logo_file_input");
file_input.val('');
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = realm_logo;
}
window.realm_logo = realm_logo;