diff --git a/static/js/feature_flags.js b/static/js/feature_flags.js
index c8510272bd..7a7e54ce7f 100644
--- a/static/js/feature_flags.js
+++ b/static/js/feature_flags.js
@@ -7,6 +7,7 @@ exports.mark_read_at_bottom = page_params.staging;
exports.summarize_read_while_narrowed = page_params.staging;
exports.twenty_four_hour_time = _.contains([],
page_params.email);
+exports.dropbox_integration = page_params.staging || _.contains(['dropbox.com'], page_params.domain);
return exports;
}());
diff --git a/static/js/ui.js b/static/js/ui.js
index 8d1b42dad1..a22ba7320f 100644
--- a/static/js/ui.js
+++ b/static/js/ui.js
@@ -1096,6 +1096,10 @@ $(function () {
if (window.XMLHttpRequest && (new XMLHttpRequest()).upload) {
$("#compose #attach_files").removeClass("notdisplayed");
}
+ if (feature_flags.dropbox_integration && Dropbox.isBrowserSupported()) {
+ $("#compose #attach_dropbox_files").removeClass("notdisplayed");
+ }
+
// Event bindings for "Compose" pane
@@ -1107,6 +1111,24 @@ $(function () {
$("#compose #file_input").trigger("click");
} );
+ $("#compose").on("click", "#attach_dropbox_files", function (e) {
+ e.preventDefault();
+ var options = {
+ // Required. Called when a user selects an item in the Chooser.
+ success: function (files) {
+ var textbox = $("#new_message_content");
+ var links = _.map(files, function (file) { return '[' + file.name + '](' + file.link +')'; })
+ .join(' ') + ' ';
+ textbox.val(textbox.val() + links);
+
+ },
+ // Optional. A value of false (default) limits selection to a single file, while
+ // true enables multiple file selection.
+ multiselect: true
+ };
+ Dropbox.choose(options);
+ });
+
$("#subscriptions_table").on("mouseover", ".subscription_header", function (e) {
$(this).addClass("active");
});
diff --git a/templates/zerver/base.html b/templates/zerver/base.html
index 5c9bcadf27..f9e76960c3 100644
--- a/templates/zerver/base.html
+++ b/templates/zerver/base.html
@@ -18,6 +18,7 @@
+
{# mixpanel #}