2018-05-06 21:43:17 +02:00
|
|
|
/* eslint indent: "off" */
|
2017-02-21 03:41:20 +01:00
|
|
|
var realm_icon = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
exports.build_realm_icon_widget = function (upload_function) {
|
|
|
|
var get_file_input = function () {
|
|
|
|
return $('#realm_icon_file_input').expectOne();
|
|
|
|
};
|
|
|
|
|
|
|
|
if (page_params.realm_icon_source === 'G') {
|
|
|
|
$("#realm_icon_delete_button").hide();
|
2017-02-26 20:35:23 +01:00
|
|
|
} else {
|
|
|
|
$("#realm_icon_delete_button").show();
|
2017-02-21 03:41:20 +01:00
|
|
|
}
|
|
|
|
$("#realm_icon_delete_button").on('click', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
channel.del({
|
|
|
|
url: '/json/realm/icon',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return upload_widget.build_direct_upload_widget(
|
|
|
|
get_file_input,
|
|
|
|
$("#realm_icon_file_input_error").expectOne(),
|
|
|
|
$("#realm_icon_upload_button").expectOne(),
|
2017-03-06 06:22:28 +01:00
|
|
|
upload_function,
|
|
|
|
page_params.max_icon_file_size
|
2017-02-21 03:41:20 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2017-02-26 20:35:23 +01:00
|
|
|
exports.rerender = function () {
|
|
|
|
$("#realm-settings-icon").attr("src", page_params.realm_icon_url);
|
2017-03-06 06:06:23 +01:00
|
|
|
if (page_params.realm_icon_source === 'U') {
|
2017-02-26 20:35:23 +01:00
|
|
|
$("#realm_icon_delete_button").show();
|
|
|
|
} else {
|
|
|
|
$("#realm_icon_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_icon_file_input");
|
|
|
|
file_input.val('');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
2017-02-21 03:41:20 +01:00
|
|
|
}());
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = realm_icon;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
window.realm_icon = realm_icon;
|