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 CACHE MANIFEST
#Date Sun Oct 13 2013 20:59:14 #Date Sun Oct 13 2013 22:12:51
CACHE: CACHE:
index.html index.html

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<script src="../lib/dropbox.min.js"></script> <script src="../libs/dropbox.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
Dropbox.AuthDriver.Popup.oauthReceiver(); Dropbox.AuthDriver.Popup.oauthReceiver();
</script> </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 // Shows a dialog to force the user to click a button before opening oauth popup
var oauthRedirectCallback = undefined; var redirectCallbackConfirm = undefined;
core.oauthRedirect = function(providerName, callback) { var redirectCallbackCancel = undefined;
oauthRedirectCallback = callback; core.redirectConfirm = function(message, callbackConfirm, callbackCancel) {
$('.oauth-redirect-provider').text(providerName); redirectCallbackConfirm = callbackConfirm;
$('.modal-oauth-redirect').modal("show"); redirectCallbackCancel = callbackCancel;
$('.modal-redirect-confirm .redirect-msg').html(message);
$('.modal-redirect-confirm').modal("show");
}; };
// Initialize multiple things and then fire eventMgr.onReady // Initialize multiple things and then fire eventMgr.onReady
@ -936,14 +938,12 @@ define([
show: false show: false
}); });
// OAuth redirect dialog $('.action-redirect-confirm').click(function() {
$('.modal-oauth-redirect').modal({ redirectCallbackCancel = undefined;
backdrop: "static", redirectCallbackConfirm();
keyboard: false,
show: false
}); });
$('.action-oauth-redirect').click(function() { $('.modal-redirect-confirm').on('hidden.bs.modal', function() {
oauthRedirectCallback(); redirectCallbackCancel && redirectCallbackCancel();
}); });
// Load images // Load images

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1078,18 +1078,19 @@
</div> </div>
<div class="modal modal-oauth-redirect"> <div class="modal modal-redirect-confirm">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h3 class="modal-title">Authorization</h3> <h3 class="modal-title">Redirection</h3>
</div> </div>
<div class="modal-body"> <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>
<div class="modal-footer"> <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> </div>
</div> </div>