From ffad94a86f19b2d247cb7707c8e16bda368fa3bd Mon Sep 17 00:00:00 2001 From: benweet Date: Sun, 13 Oct 2013 22:13:27 +0100 Subject: [PATCH] Fixed Dropbox choose popup blocked --- public/cache.manifest | 2 +- public/html/dropbox-oauth-receiver.html | 2 +- public/res-min/main.js | 61 +++++++++++++++---------- public/res/core.js | 24 +++++----- public/res/helpers/dropboxHelper.js | 14 ++++-- public/res/helpers/githubHelper.js | 4 +- public/res/helpers/googleHelper.js | 4 +- public/res/helpers/tumblrHelper.js | 4 +- public/res/helpers/wordpressHelper.js | 4 +- public/res/html/bodyIndex.html | 9 ++-- 10 files changed, 80 insertions(+), 48 deletions(-) diff --git a/public/cache.manifest b/public/cache.manifest index 4729efe7..84b75556 100644 --- a/public/cache.manifest +++ b/public/cache.manifest @@ -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 diff --git a/public/html/dropbox-oauth-receiver.html b/public/html/dropbox-oauth-receiver.html index badb5519..eb60e4ad 100644 --- a/public/html/dropbox-oauth-receiver.html +++ b/public/html/dropbox-oauth-receiver.html @@ -1,7 +1,7 @@ - + diff --git a/public/res-min/main.js b/public/res-min/main.js index 112ece08..5c0ac377 100644 --- a/public/res-min/main.js +++ b/public/res-min/main.js @@ -22364,7 +22364,7 @@ if (hljs.LANGUAGES.glsl = function(e) { }); }, r; }), define("text!html/bodyIndex.html", [], function() { - return '\n
\n
\n
\n
\n\n\n\n\n
\n \n \n
\n
\n
\n
\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
'; + return '\n
\n
\n
\n
\n\n\n\n\n
\n \n \n
\n
\n
\n
\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
'; }), define("text!html/bodyViewer.html", [], function() { return '\n\n
\n
\n
\n\n\n\n
\n \n \n
\n
\n
\n
\n
\n\n\n'; }), define("text!html/settingsTemplateTooltip.html", [], function() { @@ -26307,11 +26307,11 @@ if (hljs.LANGUAGES.glsl = function(e) { var b = e(".wmd-button-group4"); e("#wmd-undo-button").append(e('')).appendTo(b), e("#wmd-redo-button").append(e('')).appendTo(b); }; - var U = void 0; - E.oauthRedirect = function(t, n) { - U = n, e(".oauth-redirect-provider").text(t), e(".modal-oauth-redirect").modal("show"); + var U = void 0, G = void 0; + E.redirectConfirm = function(t, n, i) { + U = n, G = i, e(".modal-redirect-confirm .redirect-msg").html(t), e(".modal-redirect-confirm").modal("show"); }; - var G = !1, V = !1; + var V = !1, K = !1; return E.onReady = function() { document.body.innerHTML = viewerMode === !0 ? u : c, a.addSettingEntries(), e(window).on("offline", E.setOffline), e(window).on("online", m), navigator.onLine === !1 && E.setOffline(), e(document).mousemove(p).keypress(p), @@ -26322,9 +26322,9 @@ if (hljs.LANGUAGES.glsl = function(e) { }); var t = void 0; M.on("show.bs.collapse", function(e) { - e.target === M[0] ? (V = !0, t = o.createBackdrop("collapse", ".menu-panel"), M.addClass("move-to-front")) : M.find(".in").collapse("hide"); + e.target === M[0] ? (K = !0, t = o.createBackdrop("collapse", ".menu-panel"), M.addClass("move-to-front")) : M.find(".in").collapse("hide"); }).on("hide.bs.collapse", function(e) { - e.target === M[0] && (V = !1, t.parentNode.removeChild(t), M.removeClass("move-to-front"), + e.target === M[0] && (K = !1, t.parentNode.removeChild(t), M.removeClass("move-to-front"), N && N.focus() || j.focus()); }).on("hidden.bs.collapse", function(e) { e.target === M[0] && M.find(".in").collapse("hide"); @@ -26333,10 +26333,10 @@ if (hljs.LANGUAGES.glsl = function(e) { }); var n = void 0; R.on("show.bs.collapse", function(e) { - e.target === R[0] ? (G = !0, n = o.createBackdrop("collapse", ".document-panel"), + e.target === R[0] ? (V = !0, n = o.createBackdrop("collapse", ".document-panel"), R.addClass("move-to-front")) : R.find(".in").collapse("hide"); }).on("hide.bs.collapse", function(e) { - e.target === R[0] && (G = !1, n.parentNode.removeChild(n), R.removeClass("move-to-front"), + e.target === R[0] && (V = !1, n.parentNode.removeChild(n), R.removeClass("move-to-front"), N && N.focus() || j.focus()); }).on("hidden.bs.collapse", function(e) { e.target === R[0] && R.find(".in").collapse("hide"); @@ -26374,7 +26374,7 @@ if (hljs.LANGUAGES.glsl = function(e) { }), e(".collapse-save-as a").click(function() { M.collapse("hide"); }), l.stopCallback = function(t, n) { - return V || G || i || e(n).is("input, select, textarea:not(.ace_text-input)"); + return K || V || i || e(n).is("input, select, textarea:not(.ace_text-input)"); }, e(".action-insert-link").click(function(t) { var n = o.getInputTextValue(e("#input-insert-link"), t); void 0 !== n && (E.insertLinkCallback(n), E.insertLinkCallback = void 0); @@ -26467,12 +26467,10 @@ if (hljs.LANGUAGES.glsl = function(e) { backdrop: "static", keyboard: !1, show: !1 - }), e(".modal-oauth-redirect").modal({ - backdrop: "static", - keyboard: !1, - show: !1 - }), e(".action-oauth-redirect").click(function() { - U(); + }), e(".action-redirect-confirm").click(function() { + G = void 0, U(); + }), e(".modal-redirect-confirm").on("hidden.bs.modal", function() { + G && G(); }), t.each(document.querySelectorAll("img"), function(t) { var n = e(t), i = n.data("stackeditSrc"); i && n.attr("src", baseDir + "/img/" + i); @@ -26670,8 +26668,10 @@ if (hljs.LANGUAGES.glsl = function(e) { function s(e) { e.onRun(function() { function t() { - n.oauthRedirect("Dropbox", function() { + n.redirectConfirm("You are being redirected to Dropbox authorization page.", function() { e.chain(i); + }, function() { + e.error(new Error("Operation canceled.")); }); } function i() { @@ -26702,12 +26702,19 @@ if (hljs.LANGUAGES.glsl = function(e) { } function l(t) { t.onRun(function() { + function i() { + n.redirectConfirm("You are being redirected to Dropbox Chooser page.", function() { + t.chain(); + }, function() { + t.error(new Error("Operation canceled.")); + }); + } return p === !0 ? (t.chain(), void 0) : (e.ajax({ url: "https://www.dropbox.com/static/api/1/dropbox.js", dataType: "script", timeout: AJAX_TIMEOUT }).done(function() { - p = !0, t.chain(); + p = !0, t.chain(i); }).fail(function(e) { var n = { status: e.status, @@ -26795,7 +26802,7 @@ if (hljs.LANGUAGES.glsl = function(e) { n.chain(); }, e.cancel = function() { n.chain(); - }, Dropbox.choose(e), i.onMessage("Please make sure the Dropbox chooser popup is not blocked by your browser."); + }, Dropbox.choose(e); }), n.onSuccess(function() { e(void 0, t); }), n.onError(function(t) { @@ -26918,8 +26925,10 @@ if (hljs.LANGUAGES.glsl = function(e) { function l(t, i) { t.onRun(function() { function r() { - n.oauthRedirect("Google", function() { + n.redirectConfirm("You are being redirected to Google authorization page", function() { t.chain(s); + }, function() { + t.error(new Error("Operation canceled.")); }); } function s() { @@ -27661,8 +27670,10 @@ if (hljs.LANGUAGES.glsl = function(e) { var o = void 0, r = void 0; i.onRun(function() { function s() { - t.oauthRedirect("GitHub", function() { + t.redirectConfirm("You are being redirected to GitHub authorization page", function() { i.chain(a); + }, function() { + i.error(new Error("Operation canceled.")); }); } function a() { @@ -27932,8 +27943,10 @@ if (hljs.LANGUAGES.glsl = function(e) { }); } function a() { - t.oauthRedirect("Tumblr", function() { + t.redirectConfirm("You are being redirected to Tumblr authorization page", function() { i.chain(c); + }, function() { + i.error(new Error("Operation canceled.")); }); } function c() { @@ -28033,8 +28046,10 @@ if (hljs.LANGUAGES.glsl = function(e) { var o = void 0, r = void 0; i.onRun(function() { function s() { - t.oauthRedirect("WordPress", function() { + t.redirectConfirm("You are being redirected to WordPress authorization page", function() { i.chain(a); + }, function() { + i.error(new Error("Operation canceled.")); }); } function a() { diff --git a/public/res/core.js b/public/res/core.js index eabb3b6e..2885301c 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -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 diff --git a/public/res/helpers/dropboxHelper.js b/public/res/helpers/dropboxHelper.js index ab93fc13..2074d9f8 100644 --- a/public/res/helpers/dropboxHelper.js +++ b/public/res/helpers/dropboxHelper.js @@ -63,8 +63,10 @@ define([ } var immediate = true; function oauthRedirect() { - core.oauthRedirect('Dropbox', function() { + core.redirectConfirm('You are being redirected to Dropbox 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 Dropbox Chooser 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); diff --git a/public/res/helpers/githubHelper.js b/public/res/helpers/githubHelper.js index e29e89c1..cd98e71d 100644 --- a/public/res/helpers/githubHelper.js +++ b/public/res/helpers/githubHelper.js @@ -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 GitHub authorization page', function() { task.chain(getCode); + }, function() { + task.error(new Error('Operation canceled.')); }); } function getCode() { diff --git a/public/res/helpers/googleHelper.js b/public/res/helpers/googleHelper.js index 9ea59f30..0be69962 100644 --- a/public/res/helpers/googleHelper.js +++ b/public/res/helpers/googleHelper.js @@ -84,8 +84,10 @@ define([ } var immediate = true; function oauthRedirect() { - core.oauthRedirect('Google', function() { + core.redirectConfirm('You are being redirected to Google authorization page', function() { task.chain(localAuthenticate); + }, function() { + task.error(new Error('Operation canceled.')); }); } function localAuthenticate() { diff --git a/public/res/helpers/tumblrHelper.js b/public/res/helpers/tumblrHelper.js index 470c37a2..4f9e94e1 100644 --- a/public/res/helpers/tumblrHelper.js +++ b/public/res/helpers/tumblrHelper.js @@ -58,8 +58,10 @@ define([ }); } function oauthRedirect() { - core.oauthRedirect('Tumblr', function() { + core.redirectConfirm('You are being redirected to Tumblr authorization page', function() { task.chain(getVerifier); + }, function() { + task.error(new Error('Operation canceled.')); }); } function getVerifier() { diff --git a/public/res/helpers/wordpressHelper.js b/public/res/helpers/wordpressHelper.js index 4275515f..b08f3ba5 100644 --- a/public/res/helpers/wordpressHelper.js +++ b/public/res/helpers/wordpressHelper.js @@ -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 WordPress authorization page', function() { task.chain(getCode); + }, function() { + task.error(new Error('Operation canceled.')); }); } function getCode() { diff --git a/public/res/html/bodyIndex.html b/public/res/html/bodyIndex.html index 98b0cf0a..81f438e5 100644 --- a/public/res/html/bodyIndex.html +++ b/public/res/html/bodyIndex.html @@ -1078,18 +1078,19 @@ -