Small fixes

This commit is contained in:
benweet 2014-08-19 09:17:59 +01:00
parent 1231b26710
commit 4b875e798a
4 changed files with 342 additions and 352 deletions

View File

@ -16,7 +16,7 @@ define([
};
var monetize = new MonetizeJS({
applicationID: 'iklMbzDI7dvMEScb'
applicationID: 'ESTHdCYOi18iLhhO'
});
dialogAbout.onReady = function() {

View File

@ -48,7 +48,6 @@ define([
utils.setInputChecked("#input-markdownextra-intraword", markdownExtra.config.intraword);
utils.setInputChecked("#input-markdownextra-comments", markdownExtra.config.comments);
utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter);
utils.setInputChecked("#input-markdownextra-diagrams", markdownExtra.config.diagrams);
};
markdownExtra.onSaveSettings = function(newConfig) {
@ -64,7 +63,6 @@ define([
newConfig.intraword = utils.getInputChecked("#input-markdownextra-intraword");
newConfig.comments = utils.getInputChecked("#input-markdownextra-comments");
newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter");
newConfig.diagrams = utils.getInputChecked("#input-markdownextra-diagrams");
};
var eventMgr;

View File

@ -63,8 +63,7 @@ define([
element: '.navbar-inner',
title: 'StackEdit 4 is out!',
content: [
'<p>I\'m very pleased to welcome you here!</p>',
'<p>StackEdit keeps getting better and I hope you appreciate it.</p>',
'<p>I\'m very pleased to welcome you here! StackEdit keeps getting better and I hope you appreciate it.</p>',
'Please click <b>Next</b> to take a quick tour.'
].join(""),
placement: 'bottom'
@ -97,20 +96,20 @@ define([
'<b>Tip:</b> Reopen the Welcome Document from Settings>Utils to discover other new features.'
].join(""),
placement: 'right',
reflex: true,
reflex: true
},
{
element: '.navbar-inner',
title: 'Happy StackWriting!',
content: [
'<p>Enjoy, and don\'t forget to rate 5 stars on the <a target="_blank" href="https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg/reviews">Chrome Web Store</a>...</p>',
'<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://stackedit.io" data-text="Great #markdown editor!" data-via="stackedit" data-size="large"></a>',
'<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://stackedit.io" data-text="Great #markdown editor!" data-via="stackedit" data-size="large"></a>'
].join(""),
placement: 'bottom',
onShown: function() {
eventMgr.onTweet();
}
},
}
]);
if(!_.has(storage, 'welcomeTour')) {
tour.start();

View File

@ -9,7 +9,7 @@ define([
"logger",
"settings",
"eventMgr",
"classes/AsyncTask",
"classes/AsyncTask"
], function($, _, constants, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
var client;
@ -28,12 +28,10 @@ define([
task.onRun(function() {
if(isOffline === true) {
client = undefined;
task.error(new Error("Operation not available in offline mode.|stopPublish"));
return;
return task.error(new Error("Operation not available in offline mode.|stopPublish"));
}
if(client !== undefined) {
task.chain();
return;
return task.chain();
}
$.ajax({
url: "libs/dropbox.min.js",
@ -63,10 +61,10 @@ define([
function authenticate(task) {
task.onRun(function() {
if(authenticated === true) {
task.chain();
return;
return task.chain();
}
var immediate = true;
function oauthRedirect() {
utils.redirectConfirm('You are being redirected to <strong>Dropbox</strong> authorization page.', function() {
task.chain(localAuthenticate);
@ -74,6 +72,7 @@ define([
task.error(new Error('Operation canceled.'));
});
}
function localAuthenticate() {
if(immediate === false) {
// If not immediate we add time for user to enter his
@ -89,19 +88,18 @@ define([
// Success
if(client.isAuthenticated() === true) {
authenticated = true;
task.chain();
return;
return task.chain();
}
// If immediate did not work retry without immediate flag
if(immediate === true) {
immediate = false;
task.chain(oauthRedirect);
return;
return task.chain(oauthRedirect);
}
// Error
task.error(new Error("Access to Dropbox account is not authorized."));
});
}
task.chain(localAuthenticate);
});
}
@ -115,8 +113,7 @@ define([
client.writeFile(path, content, function(error, stat) {
if(!error) {
result = stat;
task.chain();
return;
return task.chain();
}
// Handle error
if(error.status === 400) {
@ -144,8 +141,7 @@ define([
function retrievePageOfChanges() {
client.pullChanges(newChangeId, function(error, pullChanges) {
if(error) {
handleError(error, task);
return;
return handleError(error, task);
}
// Retrieve success
newChangeId = pullChanges.cursor();
@ -160,6 +156,7 @@ define([
}
});
}
task.chain(retrievePageOfChanges);
});
task.onSuccess(function() {
@ -179,20 +176,19 @@ define([
task.onRun(function() {
function recursiveDownloadMetadata() {
if(paths.length === 0) {
task.chain();
return;
return task.chain();
}
var path = paths[0];
client.stat(path, function(error, stat) {
if(stat) {
result.push(stat);
paths.shift();
task.chain(recursiveDownloadMetadata);
return;
return task.chain(recursiveDownloadMetadata);
}
handleError(error, task);
});
}
task.chain(recursiveDownloadMetadata);
});
task.onSuccess(function() {
@ -212,8 +208,7 @@ define([
task.onRun(function() {
function recursiveDownloadContent() {
if(objects.length === 0) {
task.chain();
return;
return task.chain();
}
var object = objects[0];
result.push(object);
@ -228,19 +223,18 @@ define([
}
if(!file) {
objects.shift();
task.chain(recursiveDownloadContent);
return;
return task.chain(recursiveDownloadContent);
}
client.readFile(file.path, function(error, data) {
if(_.isString(data)) {
file.content = data;
objects.shift();
task.chain(recursiveDownloadContent);
return;
return task.chain(recursiveDownloadContent);
}
handleError(error, task);
});
}
task.chain(recursiveDownloadContent);
});
task.onSuccess(function() {
@ -266,8 +260,7 @@ define([
if(error.status === 401 || error.status === 403) {
authenticated = false;
errorMsg = "Access to Dropbox account is not authorized.";
task.retry(new Error(errorMsg), 1);
return;
return task.retry(new Error(errorMsg), 1);
}
else if(error.status === 400 && error.responseText.indexOf("oauth_nonce") !== -1) {
// A bug I guess...
@ -279,8 +272,7 @@ define([
}
});
authenticated = false;
task.retry(new Error(errorMsg), 1);
return;
return task.retry(new Error(errorMsg), 1);
}
else if(error.status <= 0) {
client = undefined;
@ -294,11 +286,11 @@ define([
}
var pickerLoaded = false;
function loadPicker(task) {
task.onRun(function() {
if(pickerLoaded === true) {
task.chain();
return;
return task.chain();
}
function chooserRedirect() {
utils.redirectConfirm('You are being redirected to <strong>Dropbox Chooser</strong> page.', function() {
@ -307,6 +299,7 @@ define([
task.error(new Error('Operation canceled.'));
});
}
$.ajax({
url: "https://www.dropbox.com/static/api/1/dropbox.js",
dataType: "script",