Created
May 29, 2014 03:56
-
-
Save drewfreyling/c0532071080af2a10132 to your computer and use it in GitHub Desktop.
Dropbox Chooser Require Shim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requirejs.config({ | |
paths: { | |
"dropboxchooser": ["https://www.dropbox.com/static/api/2/dropins"] | |
}, | |
//Remember: only use shim config for non-AMD scripts, | |
//scripts that do not already call define(). The shim | |
//config will not work correctly if used on AMD scripts, | |
//in particular, the exports and init config will not | |
//be triggered, and the deps config will be confusing | |
//for those cases. | |
shim: { | |
'dropboxchooser': { | |
deps: [], | |
exports: "Dropbox", | |
init: function () { | |
window.Dropbox.appKey = "53yzxaltk7ilg1u"; | |
return window.Dropbox; | |
} | |
} | |
} | |
}); | |
require(["dropboxchooser"], function(Dropbox) { | |
var options = { | |
// Required. Called when a user selects an item in the Chooser. | |
success: function(files) { | |
alert("Here's the file link: " + files[0].link) | |
}, | |
// Optional. Called when the user closes the dialog without selecting a file | |
// and does not include any parameters. | |
cancel: function() { | |
}, | |
// Optional. "preview" (default) is a preview link to the document for sharing, | |
// "direct" is an expiring link to download the contents of the file. For more | |
// information about link types, see Link types below. | |
linkType: "preview", // or "direct" | |
// Optional. A value of false (default) limits selection to a single file, while | |
// true enables multiple file selection. | |
multiselect: false, // or true | |
// Optional. This is a list of file extensions. If specified, the user will | |
// only be able to select files with these extensions. You may also specify | |
// file types, such as "video" or "images" in the list. For more information, | |
// see File types below. By default, all extensions are allowed. | |
extensions: ['.pdf', '.doc', '.docx'], | |
}; | |
var button = Dropbox.createChooseButton(options); | |
document.body.appendChild(button); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment