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);
|
||||||
|
27
js/gdrive.js
27
js/gdrive.js
@ -408,17 +408,13 @@ define(["jquery", "core", "async-runner"], function($, core, asyncTaskRunner) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ids = [];
|
|
||||||
var picker = undefined;
|
|
||||||
var token = gapi.auth.getToken();
|
|
||||||
var asyncTask = {};
|
|
||||||
asyncTask.run = function() {
|
|
||||||
var view = new google.picker.View(google.picker.ViewId.DOCS);
|
var view = new google.picker.View(google.picker.ViewId.DOCS);
|
||||||
view.setMimeTypes("text/x-markdown,text/plain");
|
view.setMimeTypes("text/x-markdown,text/plain");
|
||||||
var pickerBuilder = new google.picker.PickerBuilder();
|
var pickerBuilder = new google.picker.PickerBuilder();
|
||||||
pickerBuilder.enableFeature(google.picker.Feature.NAV_HIDDEN);
|
pickerBuilder.enableFeature(google.picker.Feature.NAV_HIDDEN);
|
||||||
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
|
pickerBuilder.enableFeature(google.picker.Feature.MULTISELECT_ENABLED);
|
||||||
pickerBuilder.setAppId(GOOGLE_DRIVE_APP_ID);
|
pickerBuilder.setAppId(GOOGLE_DRIVE_APP_ID);
|
||||||
|
var token = gapi.auth.getToken();
|
||||||
if(token) {
|
if(token) {
|
||||||
pickerBuilder.setOAuthToken(token.access_token);
|
pickerBuilder.setOAuthToken(token.access_token);
|
||||||
}
|
}
|
||||||
@ -427,30 +423,23 @@ define(["jquery", "core", "async-runner"], function($, core, asyncTaskRunner) {
|
|||||||
pickerBuilder.setCallback(function(data) {
|
pickerBuilder.setCallback(function(data) {
|
||||||
if (data.action == google.picker.Action.PICKED ||
|
if (data.action == google.picker.Action.PICKED ||
|
||||||
data.action == google.picker.Action.CANCEL) {
|
data.action == google.picker.Action.CANCEL) {
|
||||||
|
var ids = [];
|
||||||
if(data.action == google.picker.Action.PICKED) {
|
if(data.action == google.picker.Action.PICKED) {
|
||||||
for(var i=0; i<data.docs.length; i++) {
|
for(var i=0; i<data.docs.length; i++) {
|
||||||
ids.push(data.docs[i].id);
|
ids.push(data.docs[i].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asyncTask.success();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
picker = pickerBuilder.build();
|
|
||||||
$("body").append($("<div>").addClass("modal-backdrop"));
|
|
||||||
picker.setVisible(true);
|
|
||||||
};
|
|
||||||
asyncTask.onSuccess = function() {
|
|
||||||
$(".modal-backdrop, .picker").remove();
|
$(".modal-backdrop, .picker").remove();
|
||||||
callback(ids);
|
callback(ids);
|
||||||
};
|
|
||||||
asyncTask.onError = function() {
|
|
||||||
if(picker !== undefined) {
|
|
||||||
picker.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
var picker = pickerBuilder.build();
|
||||||
|
$("body").append($("<div>").addClass("modal-backdrop").click(function() {
|
||||||
|
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