Enable drag & upload in code2 and prepare filepicker

This commit is contained in:
yflory
2017-08-31 16:32:26 +02:00
parent 885282ddea
commit 89b7b644f3
13 changed files with 797 additions and 118 deletions

View File

@@ -7,12 +7,13 @@ define([
'/common/sframe-common-title.js',
'/common/sframe-common-interface.js',
'/common/sframe-common-history.js',
'/common/sframe-common-file.js',
'/common/metadata-manager.js',
'/customize/application_config.js',
'/common/cryptpad-common.js',
'/common/common-realtime.js'
], function ($, nThen, Messages, CpNfInner, SFrameChannel, Title, UI, History, MetadataMgr,
], function ($, nThen, Messages, CpNfInner, SFrameChannel, Title, UI, History, File, MetadataMgr,
AppConfig, Cryptpad, CommonRealtime) {
// Chainpad Netflux Inner
@@ -36,6 +37,9 @@ define([
funcs.getCryptpadCommon = function () {
return Cryptpad;
};
funcs.getSframeChannel = function () {
return ctx.sframeChan;
};
var isLoggedIn = funcs.isLoggedIn = function () {
if (!ctx.cpNfInner) { throw new Error("cpNfInner is not ready!"); }
@@ -51,6 +55,7 @@ define([
// UI
funcs.createUserAdminMenu = UI.createUserAdminMenu;
funcs.displayAvatar = UI.displayAvatar;
funcs.createFileDialog = UI.createFileDialog;
// History
funcs.getHistory = function (config) { return History.create(funcs, config); };
@@ -118,11 +123,15 @@ define([
ctx.sframeChan.query('Q_SET_PAD_ATTRIBUTE', {
key: key,
value: value
}, function (err, data) {
cb();
});
}, cb);
};
// Files
funcs.uploadFile = function (data, cb) {
ctx.sframeChan.query('Q_UPLOAD_FILE', data, cb);
};
funcs.createFileManager = function (config) { return File.create(funcs, config); };
// Friends
var pendingFriends = [];
funcs.getPendingFriends = function () {
@@ -149,7 +158,7 @@ define([
url: href,
});
};
var prepareFeedback = function (key) {
var prepareFeedback = funcs.prepareFeedback = function (key) {
if (typeof(key) !== 'string') { return $.noop; }
var type = ctx.metadataMgr.getMetadata().type;
@@ -304,6 +313,14 @@ define([
return button;
};
// Can, only be called by the filepicker app
funcs.getFilesList = function (cb) {
ctx.sframeChan.query('Q_GET_FILES_LIST', null, function (err, data) {
cb(err || data.error, data.data);
});
};
/* funcs.storeLinkToClipboard = function (readOnly, cb) {
ctx.sframeChan.query('Q_STORE_LINK_TO_CLIPBOARD', readOnly, function (err) {
if (cb) { cb(err); }