Fixed Dropbox choose popup blocked

This commit is contained in:
benweet 2013-10-13 22:13:27 +01:00
parent 59034d3404
commit ffad94a86f
10 changed files with 80 additions and 48 deletions

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
#Date Sun Oct 13 2013 20:59:14
#Date Sun Oct 13 2013 22:12:51
CACHE:
index.html

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../lib/dropbox.min.js"></script>
<script src="../libs/dropbox.min.js"></script>
<script type="text/javascript">
Dropbox.AuthDriver.Popup.oauthReceiver();
</script>

File diff suppressed because one or more lines are too long

View File

@ -591,11 +591,13 @@ define([
};
// Shows a dialog to force the user to click a button before opening oauth popup
var oauthRedirectCallback = undefined;
core.oauthRedirect = function(providerName, callback) {
oauthRedirectCallback = callback;
$('.oauth-redirect-provider').text(providerName);
$('.modal-oauth-redirect').modal("show");
var redirectCallbackConfirm = undefined;
var redirectCallbackCancel = undefined;
core.redirectConfirm = function(message, callbackConfirm, callbackCancel) {
redirectCallbackConfirm = callbackConfirm;
redirectCallbackCancel = callbackCancel;
$('.modal-redirect-confirm .redirect-msg').html(message);
$('.modal-redirect-confirm').modal("show");
};
// Initialize multiple things and then fire eventMgr.onReady
@ -936,14 +938,12 @@ define([
show: false
});
// OAuth redirect dialog
$('.modal-oauth-redirect').modal({
backdrop: "static",
keyboard: false,
show: false
$('.action-redirect-confirm').click(function() {
redirectCallbackCancel = undefined;
redirectCallbackConfirm();
});
$('.action-oauth-redirect').click(function() {
oauthRedirectCallback();
$('.modal-redirect-confirm').on('hidden.bs.modal', function() {
redirectCallbackCancel && redirectCallbackCancel();
});
// Load images

View File

@ -63,8 +63,10 @@ define([
}
var immediate = true;
function oauthRedirect() {
core.oauthRedirect('Dropbox', function() {
core.redirectConfirm('You are being redirected to <strong>Dropbox</strong> authorization page.', function() {
task.chain(localAuthenticate);
}, function() {
task.error(new Error('Operation canceled.'));
});
}
function localAuthenticate() {
@ -293,13 +295,20 @@ define([
task.chain();
return;
}
function chooserRedirect() {
core.redirectConfirm('You are being redirected to <strong>Dropbox Chooser</strong> page.', function() {
task.chain();
}, function() {
task.error(new Error('Operation canceled.'));
});
}
$.ajax({
url: "https://www.dropbox.com/static/api/1/dropbox.js",
dataType: "script",
timeout: AJAX_TIMEOUT
}).done(function() {
pickerLoaded = true;
task.chain();
task.chain(chooserRedirect);
}).fail(function(jqXHR) {
var error = {
status: jqXHR.status,
@ -333,7 +342,6 @@ define([
task.chain();
};
Dropbox.choose(options);
eventMgr.onMessage("Please make sure the Dropbox chooser popup is not blocked by your browser.");
});
task.onSuccess(function() {
callback(undefined, paths);

View File

@ -70,8 +70,10 @@ define([
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
var code = undefined;
function oauthRedirect() {
core.oauthRedirect('GitHub', function() {
core.redirectConfirm('You are being redirected to <strong>GitHub</strong> authorization page', function() {
task.chain(getCode);
}, function() {
task.error(new Error('Operation canceled.'));
});
}
function getCode() {

View File

@ -84,8 +84,10 @@ define([
}
var immediate = true;
function oauthRedirect() {
core.oauthRedirect('Google', function() {
core.redirectConfirm('You are being redirected to <strong>Google</strong> authorization page', function() {
task.chain(localAuthenticate);
}, function() {
task.error(new Error('Operation canceled.'));
});
}
function localAuthenticate() {

View File

@ -58,8 +58,10 @@ define([
});
}
function oauthRedirect() {
core.oauthRedirect('Tumblr', function() {
core.redirectConfirm('You are being redirected to <strong>Tumblr</strong> authorization page', function() {
task.chain(getVerifier);
}, function() {
task.error(new Error('Operation canceled.'));
});
}
function getVerifier() {

View File

@ -42,8 +42,10 @@ define([
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
var code = undefined;
function oauthRedirect() {
core.oauthRedirect('WordPress', function() {
core.redirectConfirm('You are being redirected to <strong>WordPress</strong> authorization page', function() {
task.chain(getCode);
}, function() {
task.error(new Error('Operation canceled.'));
});
}
function getCode() {

View File

@ -1078,18 +1078,19 @@
</div>
<div class="modal modal-oauth-redirect">
<div class="modal modal-redirect-confirm">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Authorization</h3>
<h3 class="modal-title">Redirection</h3>
</div>
<div class="modal-body">
<blockquote><b>NOTE:</b> You are being redirected to <span class="oauth-redirect-provider"></span> authorization page.</blockquote>
<blockquote><b>NOTE:</b> <span class="redirect-msg"></span></blockquote>
</div>
<div class="modal-footer">
<a class="btn btn-primary action-oauth-redirect" data-dismiss="modal">Continue</a>
<a class="btn btn-default" data-dismiss="modal">Cancel</a>
<a class="btn btn-primary action-redirect-confirm" data-dismiss="modal">OK</a>
</div>
</div>
</div>