diff --git a/static/js/compose.js b/static/js/compose.js index 5c8981f3b2..216630ab2b 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -741,11 +741,7 @@ exports.initialize = function () { resize.watch_manual_resize("#compose-textarea"); - // Run a feature test and decide whether to display - // the "Attach files" button - if (window.XMLHttpRequest && (new XMLHttpRequest()).upload) { - $("#compose #attach_files").removeClass("notdisplayed"); - } + upload.feature_check($("#compose #attach_files")); // Lazy load the Dropbox script, since it can slow our page load // otherwise, and isn't enabled for all users. Also, this Dropbox diff --git a/static/js/upload.js b/static/js/upload.js index 3fdd074577..03f9cd9803 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -21,6 +21,13 @@ function clear_out_file_list(jq_file_list) { // $("#file_input").val(""); } +// Show the upload button only if the browser supports it. +exports.feature_check = function (upload_button) { + if (window.XMLHttpRequest && (new XMLHttpRequest()).upload) { + upload_button.removeClass("notdisplayed"); + } +}; + exports.options = function (config) { var textarea; var send_button;