Added Google picker
This commit is contained in:
parent
932fc4afc7
commit
8e686968ac
@ -304,7 +304,7 @@ define(["jquery", "core", "gdrive", "synchronizer", "async-runner"], function($,
|
|||||||
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
|
var fileIndex = fileManager.getFileIndexFromSync(fileSyncIndex);
|
||||||
if(fileIndex !== undefined) {
|
if(fileIndex !== undefined) {
|
||||||
var title = localStorage[fileIndex + ".title"];
|
var title = localStorage[fileIndex + ".title"];
|
||||||
core.showError('"' + title + '" has already been imported');
|
core.showError('"' + title + '" was already imported');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
importIds.push(fileId);
|
importIds.push(fileId);
|
||||||
|
67
js/gdrive.js
67
js/gdrive.js
@ -408,49 +408,38 @@ define(["jquery", "core", "async-runner"], function($, core, asyncTaskRunner) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = [];
|
var view = new google.picker.View(google.picker.ViewId.DOCS);
|
||||||
var picker = undefined;
|
view.setMimeTypes("text/x-markdown,text/plain");
|
||||||
|
var pickerBuilder = new google.picker.PickerBuilder();
|
||||||
|
pickerBuilder.enableFeature(google.picker.Feature.NAV_HIDDEN);
|
||||||
|
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
|
||||||
|
pickerBuilder.setAppId(GOOGLE_DRIVE_APP_ID);
|
||||||
var token = gapi.auth.getToken();
|
var token = gapi.auth.getToken();
|
||||||
var asyncTask = {};
|
if(token) {
|
||||||
asyncTask.run = function() {
|
pickerBuilder.setOAuthToken(token.access_token);
|
||||||
var view = new google.picker.View(google.picker.ViewId.DOCS);
|
}
|
||||||
view.setMimeTypes("text/x-markdown,text/plain");
|
pickerBuilder.addView(view);
|
||||||
var pickerBuilder = new google.picker.PickerBuilder();
|
pickerBuilder.addView(new google.picker.DocsUploadView());
|
||||||
pickerBuilder.enableFeature(google.picker.Feature.NAV_HIDDEN);
|
pickerBuilder.setCallback(function(data) {
|
||||||
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
|
if (data.action == google.picker.Action.PICKED ||
|
||||||
pickerBuilder.setAppId(GOOGLE_DRIVE_APP_ID);
|
data.action == google.picker.Action.CANCEL) {
|
||||||
if(token) {
|
var ids = [];
|
||||||
pickerBuilder.setOAuthToken(token.access_token);
|
if(data.action == google.picker.Action.PICKED) {
|
||||||
}
|
for(var i=0; i<data.docs.length; i++) {
|
||||||
pickerBuilder.addView(view);
|
ids.push(data.docs[i].id);
|
||||||
pickerBuilder.addView(new google.picker.DocsUploadView());
|
|
||||||
pickerBuilder.setCallback(function(data) {
|
|
||||||
if (data.action == google.picker.Action.PICKED ||
|
|
||||||
data.action == google.picker.Action.CANCEL) {
|
|
||||||
if(data.action == google.picker.Action.PICKED) {
|
|
||||||
for(var i=0; i<data.docs.length; i++) {
|
|
||||||
ids.push(data.docs[i].id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
asyncTask.success();
|
}
|
||||||
}
|
$(".modal-backdrop, .picker").remove();
|
||||||
});
|
callback(ids);
|
||||||
picker = pickerBuilder.build();
|
}
|
||||||
$("body").append($("<div>").addClass("modal-backdrop"));
|
});
|
||||||
picker.setVisible(true);
|
var picker = pickerBuilder.build();
|
||||||
};
|
$("body").append($("<div>").addClass("modal-backdrop").click(function() {
|
||||||
asyncTask.onSuccess = function() {
|
picker.setVisible(false);
|
||||||
$(".modal-backdrop, .picker").remove();
|
|
||||||
callback(ids);
|
|
||||||
};
|
|
||||||
asyncTask.onError = function() {
|
|
||||||
if(picker !== undefined) {
|
|
||||||
picker.setVisible(false);
|
|
||||||
}
|
|
||||||
$(".modal-backdrop, .picker").remove();
|
$(".modal-backdrop, .picker").remove();
|
||||||
callback();
|
callback();
|
||||||
};
|
}));
|
||||||
asyncTaskRunner.addTask(asyncTask);
|
picker.setVisible(true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user