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 = [];
function AsyncTask() {
function AsyncTask(force) {
this.finished = false;
this.timeout = ASYNC_TASK_DEFAULT_TIMEOUT;
this.retryCounter = 0;
this.runCallbacks = [];
this.successCallbacks = [];
this.errorCallbacks = [];
this.force = force;
}
/**
@ -133,14 +134,6 @@ define([
// Run the next task in the queue if any and no other running
function runTask() {
// Wait for user first interaction before running first task
if(isUserReal === false) {
return
}
// Use defer to avoid stack overflow
//_.defer(function() {
// If there is a task currently running
if(currentTaskRunning === true) {
// If the current task takes too long
@ -151,8 +144,8 @@ define([
}
if(currentTask === undefined) {
// If no task in the queue
if(taskQueue.length === 0) {
// If no task in the queue or user has never interacted
if(taskQueue.length === 0 || (!taskQueue[0].force && isUserReal === false)) {
return;
}
@ -170,7 +163,6 @@ define([
currentTaskRunning = true;
currentTask.chain();
}
//});
}
// Call runTask periodically

View File

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

View File

@ -69,7 +69,6 @@ define([
}
function localAuthenticate() {
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
// credentials
task.timeout = ASYNC_TASK_LONG_TIMEOUT;

View File

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

View File

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

View File

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

View File

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

View File

@ -846,7 +846,7 @@
<div class="msg-no-publish hide">
"<span class="file-title"></span>" is not published yet. <br /> <br />
</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>
</div>
<div class="modal-footer">

View File

@ -11,7 +11,7 @@
</p>
<blockquote>
<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"
title="Sharing example">viewer.html?url=...</a>
href="viewer.html#!url=https://raw.github.com/benweet/stackedit/master/README.md"
title="Sharing example"><code>viewer.html#!url=...</code></a>
</blockquote>
</div>

View File

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

View File

@ -45,7 +45,7 @@ define([
}
var url = [
MAIN_URL,
'viewer.html?provider=',
'viewer.html#!provider=',
provider.providerId
];
_.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");
}
.close {
.transition(opacity ease-in-out .15s);
}
.list-group .nav {
border-left: 10px solid @blockquote-border-color;
margin-left: 10px;
@ -1076,7 +1072,6 @@ ul,ol {
font-weight: @close-font-weight;
text-shadow: @close-text-shadow;
.opacity(.3);
.transition(~"opacity ease-in-out .15s");
&:before {
content: '\d7';
}

View File

@ -11,9 +11,10 @@ define([
// Return a parameter from the URL
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 {
return decodeURIComponent(regex.exec(location.search)[1]);
return decodeURIComponent(regex.exec(location.search + location.hash)[1]);
}
catch(e) {
return undefined;