Using hash bang in sharing location

This commit is contained in:
benweet 2013-10-13 20:58:42 +01:00
parent 1f513d7218
commit 428ff1c691
13 changed files with 39 additions and 57 deletions

View File

@ -7,13 +7,14 @@ define([
var taskQueue = []; var taskQueue = [];
function AsyncTask() { function AsyncTask(force) {
this.finished = false; this.finished = false;
this.timeout = ASYNC_TASK_DEFAULT_TIMEOUT; this.timeout = ASYNC_TASK_DEFAULT_TIMEOUT;
this.retryCounter = 0; this.retryCounter = 0;
this.runCallbacks = []; this.runCallbacks = [];
this.successCallbacks = []; this.successCallbacks = [];
this.errorCallbacks = []; this.errorCallbacks = [];
this.force = force;
} }
/** /**
@ -132,45 +133,36 @@ define([
// Run the next task in the queue if any and no other running // Run the next task in the queue if any and no other running
function runTask() { function runTask() {
// Wait for user first interaction before running first task // If there is a task currently running
if(isUserReal === false) { if(currentTaskRunning === true) {
return // If the current task takes too long
if(currentTaskStartTime + currentTask.timeout < utils.currentTime) {
currentTask.error(new Error("A timeout occurred."));
}
return;
} }
// Use defer to avoid stack overflow
//_.defer(function() {
// If there is a task currently running if(currentTask === undefined) {
if(currentTaskRunning === true) { // If no task in the queue or user has never interacted
// If the current task takes too long if(taskQueue.length === 0 || (!taskQueue[0].force && isUserReal === false)) {
if(currentTaskStartTime + currentTask.timeout < utils.currentTime) {
currentTask.error(new Error("A timeout occurred."));
}
return; return;
} }
if(currentTask === undefined) { // Dequeue an enqueued task
// If no task in the queue currentTask = taskQueue.shift();
if(taskQueue.length === 0) { currentTaskStartTime = utils.currentTime;
return; if(asyncRunning === false) {
} asyncRunning = true;
eventMgr.onAsyncRunning(true);
// Dequeue an enqueued task
currentTask = taskQueue.shift();
currentTaskStartTime = utils.currentTime;
if(asyncRunning === false) {
asyncRunning = true;
eventMgr.onAsyncRunning(true);
}
} }
}
// Run the task // Run the task
if(currentTaskStartTime <= utils.currentTime) { if(currentTaskStartTime <= utils.currentTime) {
currentTaskRunning = true; currentTaskRunning = true;
currentTask.chain(); currentTask.chain();
} }
//});
} }
// Call runTask periodically // Call runTask periodically

View File

@ -45,7 +45,7 @@ define([
} }
function isUserActive() { function isUserActive() {
if(userActive === true && utils.currentTime - userLastActivity > USER_IDLE_THRESHOLD) { if(utils.currentTime - userLastActivity > USER_IDLE_THRESHOLD) {
userActive = false; userActive = false;
} }
return userActive && windowUnique; return userActive && windowUnique;
@ -875,14 +875,14 @@ define([
// Tooltips // Tooltips
$(".tooltip-lazy-rendering").tooltip({ $(".tooltip-lazy-rendering").tooltip({
container: '.modal-settings .modal-dialog', container: '.modal-settings',
placement: 'right', placement: 'right',
trigger: 'hover', trigger: 'hover',
title: 'Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity.' title: 'Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity.'
}); });
$(".tooltip-default-content").tooltip({ $(".tooltip-default-content").tooltip({
html: true, html: true,
container: '.modal-settings .modal-dialog', container: '.modal-settings',
placement: 'right', placement: 'right',
trigger: 'hover', trigger: 'hover',
title: 'Thanks for supporting StackEdit by adding a backlink in your documents!' title: 'Thanks for supporting StackEdit by adding a backlink in your documents!'
@ -890,7 +890,7 @@ define([
var tooltipOpen = false; var tooltipOpen = false;
$(".tooltip-usercustom-extension").tooltip({ $(".tooltip-usercustom-extension").tooltip({
html: true, html: true,
container: '.modal-settings .modal-dialog', container: '.modal-settings',
placement: 'right', placement: 'right',
trigger: 'manual', trigger: 'manual',
title: settingsUserCustomExtensionTooltipHTML title: settingsUserCustomExtensionTooltipHTML
@ -908,7 +908,7 @@ define([
var $tooltipElt = $(tooltipElt); var $tooltipElt = $(tooltipElt);
$tooltipElt.tooltip({ $tooltipElt.tooltip({
html: true, html: true,
container: $tooltipElt.parents('.modal-dialog'), container: $tooltipElt.parents('.modal'),
placement: 'right', placement: 'right',
trigger: 'manual', trigger: 'manual',
title: settingsTemplateTooltipHTML title: settingsTemplateTooltipHTML
@ -962,7 +962,6 @@ define([
}, ''); }, '');
document.getElementById('input-settings-theme').innerHTML = themeOptions; document.getElementById('input-settings-theme').innerHTML = themeOptions;
} }
}); });
return core; return core;

View File

@ -69,7 +69,6 @@ define([
} }
function localAuthenticate() { function localAuthenticate() {
if(immediate === false) { if(immediate === false) {
eventMgr.onMessage("Please make sure the Dropbox authorization popup is not blocked by your browser.");
// If not immediate we add time for user to enter his // If not immediate we add time for user to enter his
// credentials // credentials
task.timeout = ASYNC_TASK_LONG_TIMEOUT; task.timeout = ASYNC_TASK_LONG_TIMEOUT;

View File

@ -75,7 +75,6 @@ define([
}); });
} }
function getCode() { function getCode() {
eventMgr.onMessage("Please make sure the Github authorization popup is not blocked by your browser.");
localStorage.removeItem("githubCode"); localStorage.removeItem("githubCode");
authWindow = utils.popupWindow('html/github-oauth-client.html?client_id=' + GITHUB_CLIENT_ID, 'stackedit-github-oauth', 960, 600); authWindow = utils.popupWindow('html/github-oauth-client.html?client_id=' + GITHUB_CLIENT_ID, 'stackedit-github-oauth', 960, 600);
authWindow.focus(); authWindow.focus();
@ -205,7 +204,7 @@ define([
}; };
githubHelper.downloadGist = function(gistId, filename, callback) { githubHelper.downloadGist = function(gistId, filename, callback) {
var task = new AsyncTask(); var task = new AsyncTask(true);
connect(task); connect(task);
// No need for authentication // No need for authentication
var title = undefined; var title = undefined;

View File

@ -90,7 +90,6 @@ define([
} }
function localAuthenticate() { function localAuthenticate() {
if(immediate === false) { if(immediate === false) {
eventMgr.onMessage("Please make sure the Google authorization popup is not blocked by your browser.");
task.timeout = ASYNC_TASK_LONG_TIMEOUT; task.timeout = ASYNC_TASK_LONG_TIMEOUT;
} }
gapi.auth.authorize({ gapi.auth.authorize({

View File

@ -63,7 +63,6 @@ define([
}); });
} }
function getVerifier() { function getVerifier() {
eventMgr.onMessage("Please make sure the Tumblr authorization popup is not blocked by your browser.");
localStorage.removeItem("tumblrVerifier"); localStorage.removeItem("tumblrVerifier");
authWindow = utils.popupWindow('html/tumblr-oauth-client.html?oauth_token=' + oauth_object.oauth_token, 'stackedit-tumblr-oauth', 800, 600); authWindow = utils.popupWindow('html/tumblr-oauth-client.html?oauth_token=' + oauth_object.oauth_token, 'stackedit-tumblr-oauth', 800, 600);
authWindow.focus(); authWindow.focus();

View File

@ -47,7 +47,6 @@ define([
}); });
} }
function getCode() { function getCode() {
eventMgr.onMessage("Please make sure the Wordpress authorization popup is not blocked by your browser.");
localStorage.removeItem("wordpressCode"); localStorage.removeItem("wordpressCode");
authWindow = utils.popupWindow('html/wordpress-oauth-client.html?client_id=' + WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600); authWindow = utils.popupWindow('html/wordpress-oauth-client.html?client_id=' + WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600);
authWindow.focus(); authWindow.focus();

View File

@ -846,7 +846,7 @@
<div class="msg-no-publish hide"> <div class="msg-no-publish hide">
"<span class="file-title"></span>" is not published yet. <br /> <br /> "<span class="file-title"></span>" is not published yet. <br /> <br />
</div> </div>
<b>NOTE:</b> You can add publications using "Publish on" sub-menu. <b>NOTE:</b> You can add publications using the <i class="icon-share"></i> <code>Publish on</code> sub-menu.
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -11,7 +11,7 @@
</p> </p>
<blockquote> <blockquote>
<b>NOTE:</b> You can open any URL within StackEdit using <a <b>NOTE:</b> You can open any URL within StackEdit using <a
href="viewer.html?url=https://raw.github.com/benweet/stackedit/master/README.md" href="viewer.html#!url=https://raw.github.com/benweet/stackedit/master/README.md"
title="Sharing example">viewer.html?url=...</a> title="Sharing example"><code>viewer.html#!url=...</code></a>
</blockquote> </blockquote>
</div> </div>

View File

@ -15,7 +15,7 @@ define([
downloadProvider.importPublic = function(importParameters, callback) { downloadProvider.importPublic = function(importParameters, callback) {
var title = undefined; var title = undefined;
var content = undefined; var content = undefined;
var task = new AsyncTask(); var task = new AsyncTask(true);
task.onRun(function() { task.onRun(function() {
var url = importParameters.url; var url = importParameters.url;
var slashUrl = url.lastIndexOf("/"); var slashUrl = url.lastIndexOf("/");

View File

@ -45,7 +45,7 @@ define([
} }
var url = [ var url = [
MAIN_URL, MAIN_URL,
'viewer.html?provider=', 'viewer.html#!provider=',
provider.providerId provider.providerId
]; ];
_.each(provider.sharingAttributes, function(attributeName) { _.each(provider.sharingAttributes, function(attributeName) {

View File

@ -138,10 +138,6 @@ a {
.transition(~"background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s"); .transition(~"background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s");
} }
.close {
.transition(opacity ease-in-out .15s);
}
.list-group .nav { .list-group .nav {
border-left: 10px solid @blockquote-border-color; border-left: 10px solid @blockquote-border-color;
margin-left: 10px; margin-left: 10px;
@ -1076,7 +1072,6 @@ ul,ol {
font-weight: @close-font-weight; font-weight: @close-font-weight;
text-shadow: @close-text-shadow; text-shadow: @close-text-shadow;
.opacity(.3); .opacity(.3);
.transition(~"opacity ease-in-out .15s");
&:before { &:before {
content: '\d7'; content: '\d7';
} }

View File

@ -11,9 +11,10 @@ define([
// Return a parameter from the URL // Return a parameter from the URL
utils.getURLParameter = function(name) { utils.getURLParameter = function(name) {
var regex = new RegExp(name + "=(.+?)(&|$)"); // Parameter can be either a search parameter (&name=...) or a hash fragment parameter (#!name=...)
var regex = new RegExp("(?:\\?|\\#\\!|&)" + name + "=(.+?)(?:&|\\#|$)");
try { try {
return decodeURIComponent(regex.exec(location.search)[1]); return decodeURIComponent(regex.exec(location.search + location.hash)[1]);
} }
catch(e) { catch(e) {
return undefined; return undefined;