cloudcmd/lib/client/storage/_dropbox_chooser.js
2014-06-17 10:12:16 -04:00

52 lines
1.4 KiB
JavaScript

var Util, CloudCmd, DOM, Dropbox;
(function(Util, CloudCmd, DOM){
'use strict';
var CHOOSER_API = 'https://www.dropbox.com/static/api/1/dropbox.js',
DropBoxStore = {},
options = {
linkType: 'direct',
success: function(files) {
console.log('Here\'s the file link:' + files[0].link);
},
cancel: function() {
console.log('Chose something');
}
};
/* PRIVATE FUNCTIONS */
/**
* function loads dropbox.js
*/
function load(){
Util.time('dropbox load');
DOM.Files.get('config', function(error, config){
var element = DOM.load({
src : CHOOSER_API,
notAppend : true,
id : 'dropboxjs',
func : DropBoxStore.choose
});
var lDropBoxId = config.dropbox_chooser_key;
element.setAttribute('data-app-key', lDropBoxId);
document.body.appendChild(element);
Util.timeEnd('dropbox load');
});
}
DropBoxStore.choose = function(){
Dropbox.choose(options);
};
DropBoxStore.init = function(){
load();
};
CloudCmd.DropBox = DropBoxStore;
})(Util, CloudCmd, DOM);