mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
js: Convert static/js/upload_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
a7b2e5ba03
commit
e64c7a9efe
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
const default_max_file_size = 5;
|
||||
|
||||
const supported_types = ["image/jpeg", "image/png", "image/gif", "image/tiff"];
|
||||
@@ -12,12 +10,17 @@ function is_image_format(file) {
|
||||
return supported_types.includes(type);
|
||||
}
|
||||
|
||||
exports.build_widget = function (
|
||||
get_file_input, // function returns a jQuery file input object
|
||||
file_name_field, // jQuery object to show file name
|
||||
input_error, // jQuery object for error text
|
||||
clear_button, // jQuery button to clear last upload choice
|
||||
upload_button, // jQuery button to open file dialog
|
||||
export function build_widget(
|
||||
// function returns a jQuery file input object
|
||||
get_file_input,
|
||||
// jQuery object to show file name
|
||||
file_name_field,
|
||||
// jQuery object for error text
|
||||
input_error,
|
||||
// jQuery button to clear last upload choice
|
||||
clear_button,
|
||||
// jQuery button to open file dialog
|
||||
upload_button,
|
||||
preview_text = null,
|
||||
preview_image = null,
|
||||
max_file_upload_size,
|
||||
@@ -110,11 +113,15 @@ exports.build_widget = function (
|
||||
// so you can release handlers.
|
||||
close,
|
||||
};
|
||||
};
|
||||
exports.build_direct_upload_widget = function (
|
||||
get_file_input, // function returns a jQuery file input object
|
||||
input_error, // jQuery object for error text
|
||||
upload_button, // jQuery button to open file dialog
|
||||
}
|
||||
|
||||
export function build_direct_upload_widget(
|
||||
// function returns a jQuery file input object
|
||||
get_file_input,
|
||||
// jQuery object for error text
|
||||
input_error,
|
||||
// jQuery button to open file dialog
|
||||
upload_button,
|
||||
upload_function,
|
||||
max_file_upload_size,
|
||||
) {
|
||||
@@ -177,6 +184,4 @@ exports.build_direct_upload_widget = function (
|
||||
get_file_input().trigger("click");
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
window.upload_widget = exports;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user