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({ var monetize = new MonetizeJS({
applicationID: 'iklMbzDI7dvMEScb' applicationID: 'ESTHdCYOi18iLhhO'
}); });
dialogAbout.onReady = function() { dialogAbout.onReady = function() {

View File

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

View File

@ -63,8 +63,7 @@ define([
element: '.navbar-inner', element: '.navbar-inner',
title: 'StackEdit 4 is out!', title: 'StackEdit 4 is out!',
content: [ content: [
'<p>I\'m very pleased to welcome you here!</p>', '<p>I\'m very pleased to welcome you here! StackEdit keeps getting better and I hope you appreciate it.</p>',
'<p>StackEdit keeps getting better and I hope you appreciate it.</p>',
'Please click <b>Next</b> to take a quick tour.' 'Please click <b>Next</b> to take a quick tour.'
].join(""), ].join(""),
placement: 'bottom' placement: 'bottom'
@ -97,20 +96,20 @@ define([
'<b>Tip:</b> Reopen the Welcome Document from Settings>Utils to discover other new features.' '<b>Tip:</b> Reopen the Welcome Document from Settings>Utils to discover other new features.'
].join(""), ].join(""),
placement: 'right', placement: 'right',
reflex: true, reflex: true
}, },
{ {
element: '.navbar-inner', element: '.navbar-inner',
title: 'Happy StackWriting!', title: 'Happy StackWriting!',
content: [ 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>', '<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(""), ].join(""),
placement: 'bottom', placement: 'bottom',
onShown: function() { onShown: function() {
eventMgr.onTweet(); eventMgr.onTweet();
} }
}, }
]); ]);
if(!_.has(storage, 'welcomeTour')) { if(!_.has(storage, 'welcomeTour')) {
tour.start(); tour.start();

View File

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