').append(callback()));
- });
-
- // Create extension preview buttons
- logger.log("onCreatePreviewButton");
- var onCreatePreviewButtonCallbackList = getExtensionCallbackList("onCreatePreviewButton");
- _.each(onCreatePreviewButtonCallbackList, function(callback) {
- $("#extension-preview-buttons").append($('
').append(callback()));
- });
-
- // Call extensions onReady callbacks
- var onReady = createHook("onReady");
- onReady();
- };
-
- // For extensions that need to call other extensions
- extensionMgr.onExtensionMgrCreated(extensionMgr);
- return extensionMgr;
-});
\ No newline at end of file
diff --git a/js/extensions/buttonHtmlCode.js b/js/extensions/buttonHtmlCode.js
index 3119065a..8836496c 100644
--- a/js/extensions/buttonHtmlCode.js
+++ b/js/extensions/buttonHtmlCode.js
@@ -21,13 +21,13 @@ define([
newConfig.template = utils.getInputValue("#textarea-html-code-template");
};
- var extensionMgr = undefined;
- buttonHtmlCode.onExtensionMgrCreated = function(extensionMgrParameter) {
- extensionMgr = extensionMgrParameter;
+ var eventMgr = undefined;
+ buttonHtmlCode.onEventMgrCreated = function(eventMgrParameter) {
+ eventMgr = eventMgrParameter;
};
buttonHtmlCode.onCreatePreviewButton = function() {
- return $(buttonHtmlCodeHTML);
+ return buttonHtmlCodeHTML;
};
var selectedFileDesc = undefined;
@@ -46,7 +46,7 @@ define([
textareaElt.value = htmlCode;
}
catch(e) {
- extensionMgr.onError(e);
+ eventMgr.onError(e);
return e.message;
}
};
diff --git a/js/extensions/buttonMarkdownSyntax.js b/js/extensions/buttonMarkdownSyntax.js
index 4480f9db..38e8a563 100644
--- a/js/extensions/buttonMarkdownSyntax.js
+++ b/js/extensions/buttonMarkdownSyntax.js
@@ -8,7 +8,7 @@ define([
buttonMarkdownSyntax.settingsBlock = '
Adds a "Markdown syntax" button over the preview.
';
buttonMarkdownSyntax.onCreatePreviewButton = function() {
- return $(buttonMarkdownSyntaxHTML);
+ return buttonMarkdownSyntaxHTML;
};
return buttonMarkdownSyntax;
diff --git a/js/extensions/buttonPublish.js b/js/extensions/buttonPublish.js
index 3ed9af77..de18bce5 100644
--- a/js/extensions/buttonPublish.js
+++ b/js/extensions/buttonPublish.js
@@ -38,7 +38,7 @@ define([
publisher.publish();
}
});
- return button;
+ return button[0];
};
buttonPublish.onPublishRunning = function(isRunning) {
diff --git a/js/extensions/buttonShare.js b/js/extensions/buttonShare.js
index a1b1f210..dbb831b1 100644
--- a/js/extensions/buttonShare.js
+++ b/js/extensions/buttonShare.js
@@ -10,7 +10,7 @@ define([
buttonShare.settingsBlock = '
Adds a "Share document" button in the navigation bar.
';
buttonShare.onCreateButton = function() {
- return $(buttonShareHTML);
+ return buttonShareHTML;
};
var fileDesc = undefined;
diff --git a/js/extensions/buttonStat.js b/js/extensions/buttonStat.js
index 296eb84d..bb284d37 100644
--- a/js/extensions/buttonStat.js
+++ b/js/extensions/buttonStat.js
@@ -41,7 +41,7 @@ define([
};
buttonStat.onCreatePreviewButton = function() {
- return $(_.template(buttonStatHTML, buttonStat.config));
+ return _.template(buttonStatHTML, buttonStat.config);
};
var previewContentsElt = undefined;
diff --git a/js/extensions/buttonSync.js b/js/extensions/buttonSync.js
index db642e80..3ed12bc6 100644
--- a/js/extensions/buttonSync.js
+++ b/js/extensions/buttonSync.js
@@ -59,7 +59,7 @@ define([
synchronizer.sync();
}
});
- return button;
+ return button[0];
};
buttonSync.onReady = updateButtonState;
diff --git a/js/extensions/buttonViewer.js b/js/extensions/buttonViewer.js
index db3be4c6..e824b874 100644
--- a/js/extensions/buttonViewer.js
+++ b/js/extensions/buttonViewer.js
@@ -8,7 +8,7 @@ define([
buttonViewer.settingsBlock = '
Adds a "Viewer" button over the preview.
';
buttonViewer.onCreatePreviewButton = function() {
- return $(buttonViewerHTML);
+ return buttonViewerHTML;
};
return buttonViewer;
diff --git a/js/extensions/dialogManagePublication.js b/js/extensions/dialogManagePublication.js
index 44aea9a7..0327f1b6 100644
--- a/js/extensions/dialogManagePublication.js
+++ b/js/extensions/dialogManagePublication.js
@@ -8,9 +8,9 @@ define([
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"');
dialogManagePublication.settingsBlock = '
Populates the "Manage publication" dialog box.
';
- var extensionMgr = undefined;
- dialogManagePublication.onExtensionMgrCreated = function(extensionMgrParameter) {
- extensionMgr = extensionMgrParameter;
+ var eventMgr = undefined;
+ dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {
+ eventMgr = eventMgrParameter;
};
var fileDesc = undefined;
@@ -41,7 +41,7 @@ define([
}));
lineElement.append($(removeButtonTemplate).click(function() {
fileDesc.removePublishLocation(publishAttributes);
- extensionMgr.onPublishRemoved(fileDesc, publishAttributes);
+ eventMgr.onPublishRemoved(fileDesc, publishAttributes);
}));
publishList.append(lineElement);
});
diff --git a/js/extensions/dialogManageSynchronization.js b/js/extensions/dialogManageSynchronization.js
index ff31a9a0..faf338d1 100644
--- a/js/extensions/dialogManageSynchronization.js
+++ b/js/extensions/dialogManageSynchronization.js
@@ -8,9 +8,9 @@ define([
var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"');
dialogManageSynchronization.settingsBlock = '
Populates the "Manage synchronization" dialog box.
';
- var extensionMgr = undefined;
- dialogManageSynchronization.onExtensionMgrCreated = function(extensionMgrParameter) {
- extensionMgr = extensionMgrParameter;
+ var eventMgr = undefined;
+ dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) {
+ eventMgr = eventMgrParameter;
};
var synchronizer = undefined;
@@ -44,7 +44,7 @@ define([
lineElement.append($(removeButtonTemplate).click(function() {
synchronizer.tryStopRealtimeSync();
fileDesc.removeSyncLocation(syncAttributes);
- extensionMgr.onSyncRemoved(fileDesc, syncAttributes);
+ eventMgr.onSyncRemoved(fileDesc, syncAttributes);
}));
syncList.append(lineElement);
});
diff --git a/js/extensions/dialogOpenHarddrive.js b/js/extensions/dialogOpenHarddrive.js
index 065dbabc..c41fc6b8 100644
--- a/js/extensions/dialogOpenHarddrive.js
+++ b/js/extensions/dialogOpenHarddrive.js
@@ -15,9 +15,9 @@ define([
fileMgr = fileMgrParameter;
};
- var extensionMgr = undefined;
- dialogOpenHarddrive.onExtensionMgrCreated = function(extensionMgrParameter) {
- extensionMgr = extensionMgrParameter;
+ var eventMgr = undefined;
+ dialogOpenHarddrive.onEventMgrCreated = function(eventMgrParameter) {
+ eventMgr = eventMgrParameter;
};
var contentWrapper = undefined;
@@ -39,12 +39,12 @@ define([
return function(e) {
var content = e.target.result;
if(content.match(/\uFFFD/)) {
- extensionMgr.onError(importedFile.name + " is a binary file.");
+ eventMgr.onError(importedFile.name + " is a binary file.");
return;
}
content = contentWrapper ? contentWrapper(content) : content;
if(content === undefined) {
- extensionMgr.onError(importedFile.name + " is not a valid HTML file.");
+ eventMgr.onError(importedFile.name + " is not a valid HTML file.");
return;
}
var title = importedFile.name;
@@ -96,7 +96,7 @@ define([
}
content = converter.makeMd(content);
if(content === undefined) {
- extensionMgr.onError("Invalid HTML code.");
+ eventMgr.onError("Invalid HTML code.");
return;
}
var fileDesc = fileMgr.createFile(undefined, content);
diff --git a/js/extensions/toc.js b/js/extensions/toc.js
index bbd0ede4..b5885bf6 100644
--- a/js/extensions/toc.js
+++ b/js/extensions/toc.js
@@ -26,7 +26,7 @@ define([
toc.onCreatePreviewButton = function() {
if(toc.config.button) {
- return $(buttonTocHTML);
+ return buttonTocHTML;
}
};
diff --git a/js/extensions/userCustom.js b/js/extensions/userCustom.js
index 8370f54a..e6f8d82e 100644
--- a/js/extensions/userCustom.js
+++ b/js/extensions/userCustom.js
@@ -29,9 +29,9 @@ define([
publisher = publisherParameter;
};
- var extensionMgr = undefined;
- userCustom.onExtensionMgrCreated = function(extensionMgrParameter) {
- extensionMgr = extensionMgrParameter;
+ var eventMgr = undefined;
+ userCustom.onEventMgrCreated = function(eventMgrParameter) {
+ eventMgr = eventMgrParameter;
};
userCustom.onLoadSettings = function() {
@@ -44,7 +44,7 @@ define([
eval(newConfig.code);
}
catch(e) {
- extensionMgr.onError(e);
+ eventMgr.onError(e);
// Mark the textarea as error
utils.getInputTextValue("#textarea-usercustom-code", event, /^$/);
}
diff --git a/js/fileMgr.js b/js/fileMgr.js
index c9d924e8..52a0c6f1 100644
--- a/js/fileMgr.js
+++ b/js/fileMgr.js
@@ -4,11 +4,11 @@ define([
"core",
"utils",
"settings",
- "extensionMgr",
+ "eventMgr",
"fileSystem",
"classes/FileDescriptor",
"text!../WELCOME.md"
-], function($, _, core, utils, settings, extensionMgr, fileSystem, FileDescriptor, welcomeContent) {
+], function($, _, core, utils, settings, eventMgr, fileSystem, FileDescriptor, welcomeContent) {
var fileMgr = {};
@@ -38,7 +38,7 @@ define([
fileDesc.selectTime = new Date().getTime();
// Notify extensions
- extensionMgr.onFileSelected(fileDesc);
+ eventMgr.onFileSelected(fileDesc);
// Hide the viewer pencil button
if(fileDesc.fileIndex == TEMPORARY_FILE_INDEX) {
@@ -93,7 +93,7 @@ define([
if(!isTemporary) {
utils.appendIndexToArray("file.list", fileIndex);
fileSystem[fileIndex] = fileDesc;
- extensionMgr.onFileCreated(fileDesc);
+ eventMgr.onFileCreated(fileDesc);
}
return fileDesc;
};
@@ -127,7 +127,7 @@ define([
localStorage.removeItem(fileDesc.fileIndex + ".sync");
localStorage.removeItem(fileDesc.fileIndex + ".publish");
- extensionMgr.onFileDeleted(fileDesc);
+ eventMgr.onFileDeleted(fileDesc);
};
// Get the file descriptor associated to a syncIndex
@@ -143,15 +143,6 @@ define([
return fileDesc && fileDesc.syncLocations[syncIndex];
};
- // Returns true if provider has locations to synchronize
- fileMgr.hasSync = function(provider) {
- return _.some(fileSystem, function(fileDesc) {
- return _.some(fileDesc.syncLocations, function(syncAttributes) {
- return syncAttributes.provider === provider;
- });
- });
- };
-
// Get the file descriptor associated to a publishIndex
fileMgr.getFileFromPublishIndex = function(publishIndex) {
return _.find(fileSystem, function(fileDesc) {
@@ -192,7 +183,7 @@ define([
var fileDesc = fileMgr.currentFile;
if(title && title != fileDesc.title) {
fileDesc.title = title;
- extensionMgr.onTitleChanged(fileDesc);
+ eventMgr.onTitleChanged(fileDesc);
}
input.val(fileDesc.title);
$("#wmd-input").focus();
@@ -224,6 +215,6 @@ define([
});
});
- extensionMgr.onFileMgrCreated(fileMgr);
+ eventMgr.onFileMgrCreated(fileMgr);
return fileMgr;
});
diff --git a/js/helpers/dropboxHelper.js b/js/helpers/dropboxHelper.js
index 30a2e97c..0b59cc05 100644
--- a/js/helpers/dropboxHelper.js
+++ b/js/helpers/dropboxHelper.js
@@ -2,9 +2,9 @@ define([
"jquery",
"underscore",
"core",
- "extensionMgr",
+ "eventMgr",
"classes/AsyncTask"
-], function($, _, core, extensionMgr, AsyncTask) {
+], function($, _, core, eventMgr, AsyncTask) {
var client = undefined;
var authenticated = false;
@@ -57,7 +57,7 @@ define([
var immediate = true;
function localAuthenticate() {
if(immediate === false) {
- extensionMgr.onMessage("Please make sure the Dropbox authorization popup is not blocked by your browser.");
+ 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;
@@ -320,7 +320,7 @@ define([
task.chain();
};
Dropbox.choose(options);
- extensionMgr.onMessage("Please make sure the Dropbox chooser popup is not blocked by your browser.");
+ eventMgr.onMessage("Please make sure the Dropbox chooser popup is not blocked by your browser.");
});
task.onSuccess(function() {
callback(undefined, paths);
diff --git a/js/helpers/githubHelper.js b/js/helpers/githubHelper.js
index 4fb96b24..f44b6bea 100644
--- a/js/helpers/githubHelper.js
+++ b/js/helpers/githubHelper.js
@@ -2,9 +2,9 @@ define([
"jquery",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"classes/AsyncTask"
-], function($, core, utils, extensionMgr, AsyncTask) {
+], function($, core, utils, eventMgr, AsyncTask) {
var connected = undefined;
var github = undefined;
@@ -58,7 +58,7 @@ define([
task.chain();
return;
}
- extensionMgr.onMessage("Please make sure the Github authorization popup is not blocked by your browser.");
+ eventMgr.onMessage("Please make sure the Github authorization popup is not blocked by your browser.");
var errorMsg = "Failed to retrieve a token from GitHub.";
// We add time for user to enter his credentials
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
diff --git a/js/helpers/googleHelper.js b/js/helpers/googleHelper.js
index 7febb083..b0421ffb 100644
--- a/js/helpers/googleHelper.js
+++ b/js/helpers/googleHelper.js
@@ -2,9 +2,9 @@ define([
"jquery",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"classes/AsyncTask"
-], function($, core, utils, extensionMgr, AsyncTask) {
+], function($, core, utils, eventMgr, AsyncTask) {
var connected = false;
var authenticated = false;
@@ -53,7 +53,7 @@ define([
var immediate = true;
function localAuthenticate() {
if(immediate === false) {
- extensionMgr.onMessage("Please make sure the Google authorization popup is not blocked by your browser.");
+ eventMgr.onMessage("Please make sure the Google 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;
diff --git a/js/helpers/tumblrHelper.js b/js/helpers/tumblrHelper.js
index de6dd1a6..9b8b62d5 100644
--- a/js/helpers/tumblrHelper.js
+++ b/js/helpers/tumblrHelper.js
@@ -2,9 +2,9 @@ define([
"jquery",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"classes/AsyncTask"
-], function($, core, utils, extensionMgr, AsyncTask) {
+], function($, core, utils, eventMgr, AsyncTask) {
var oauthParams = undefined;
@@ -36,7 +36,7 @@ define([
task.chain();
return;
}
- extensionMgr.onMessage("Please make sure the Tumblr authorization popup is not blocked by your browser.");
+ eventMgr.onMessage("Please make sure the Tumblr authorization popup is not blocked by your browser.");
var errorMsg = "Failed to retrieve a token from Tumblr.";
// We add time for user to enter his credentials
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
diff --git a/js/helpers/wordpressHelper.js b/js/helpers/wordpressHelper.js
index b3eef5cb..4c2fbb9b 100644
--- a/js/helpers/wordpressHelper.js
+++ b/js/helpers/wordpressHelper.js
@@ -2,9 +2,9 @@ define([
"jquery",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"classes/AsyncTask"
-], function($, core, utils, extensionMgr, AsyncTask) {
+], function($, core, utils, eventMgr, AsyncTask) {
var token = undefined;
@@ -31,7 +31,7 @@ define([
task.chain();
return;
}
- extensionMgr.onMessage("Please make sure the Wordpress authorization popup is not blocked by your browser.");
+ eventMgr.onMessage("Please make sure the Wordpress authorization popup is not blocked by your browser.");
var errorMsg = "Failed to retrieve a token from Wordpress.";
// We add time for user to enter his credentials
task.timeout = ASYNC_TASK_LONG_TIMEOUT;
diff --git a/js/html/settingsUserCustomExtensionTooltip.html b/js/html/settingsUserCustomExtensionTooltip.html
index 2dfd1833..3339c34c 100644
--- a/js/html/settingsUserCustomExtensionTooltip.html
+++ b/js/html/settingsUserCustomExtensionTooltip.html
@@ -6,7 +6,7 @@ Extension variable name:
userCustom.onPreviewFinished = function() {
- extensionMgr.onMessage("Finished!");
+ eventMgr.onMessage("Finished!");
};
diff --git a/js/main-min.js b/js/main-min.js
index 83516f28..aad9e925 100644
--- a/js/main-min.js
+++ b/js/main-min.js
@@ -4861,9 +4861,9 @@ define("config", function() {}), define("settings", [ "underscore", "config" ],
userCustom.onPublisherCreated = function(e) {
publisher = e;
};
- var extensionMgr = void 0;
- return userCustom.onExtensionMgrCreated = function(e) {
- extensionMgr = e;
+ var eventMgr = void 0;
+ return userCustom.oneventMgrCreated = function(e) {
+ eventMgr = e;
}, userCustom.onLoadSettings = function() {
utils.setInputValue("#textarea-usercustom-code", userCustom.config.code);
}, userCustom.onSaveSettings = function(newConfig, event) {
@@ -4871,7 +4871,7 @@ define("config", function() {}), define("settings", [ "underscore", "config" ],
try {
eval(newConfig.code);
} catch (e) {
- extensionMgr.onError(e), utils.getInputTextValue("#textarea-usercustom-code", event, /^$/);
+ eventMgr.onError(e), utils.getInputTextValue("#textarea-usercustom-code", event, /^$/);
}
}, userCustom.onInit = function() {
try {
@@ -4987,7 +4987,7 @@ define("config", function() {}), define("settings", [ "underscore", "config" ],
var o = new n("dialogManagePublication", 'Dialog "Manage publication"');
o.settingsBlock = '
Populates the "Manage publication" dialog box.
';
var r = void 0;
- o.onExtensionMgrCreated = function(e) {
+ o.oneventMgrCreated = function(e) {
r = e;
};
var s = void 0, a = '
', l = function(n) {
@@ -5017,7 +5017,7 @@ define("config", function() {}), define("settings", [ "underscore", "config" ],
var o = new n("dialogManageSynchronization", 'Dialog "Manage synchronization"');
o.settingsBlock = '
Populates the "Manage synchronization" dialog box.
';
var r = void 0;
- o.onExtensionMgrCreated = function(e) {
+ o.oneventMgrCreated = function(e) {
r = e;
};
var s = void 0;
@@ -5218,7 +5218,7 @@ define("config", function() {}), define("settings", [ "underscore", "config" ],
u = e;
};
var d = void 0;
- c.onExtensionMgrCreated = function(e) {
+ c.oneventMgrCreated = function(e) {
d = e;
};
var p = void 0, f = void 0, h = function(e) {
@@ -8414,7 +8414,7 @@ function(e) {
e.template = n.getInputValue("#textarea-html-code-template");
};
var a = void 0;
- s.onExtensionMgrCreated = function(e) {
+ s.oneventMgrCreated = function(e) {
a = e;
}, s.onCreatePreviewButton = function() {
return e(o);
@@ -9324,7 +9324,7 @@ function(e) {
});
});
};
-}(jQuery), define("libs/jquery.waitforimages", function() {}), define("extensionMgr", [ "jquery", "underscore", "utils", "classes/Extension", "settings", "text!html/settingsExtensionsAccordion.html", "extensions/partialRendering", "extensions/userCustom", "extensions/googleAnalytics", "extensions/dialogAbout", "extensions/dialogManagePublication", "extensions/dialogManageSynchronization", "extensions/dialogOpenHarddrive", "extensions/documentSelector", "extensions/documentTitle", "extensions/workingIndicator", "extensions/notifications", "extensions/markdownExtra", "extensions/toc", "extensions/mathJax", "extensions/emailConverter", "extensions/scrollLink", "extensions/buttonSync", "extensions/buttonPublish", "extensions/buttonShare", "extensions/buttonStat", "extensions/buttonHtmlCode", "extensions/buttonMarkdownSyntax", "extensions/buttonViewer", "libs/bootstrap", "libs/jquery.waitforimages" ], function(e, t, n, i, o, r) {
+}(jQuery), define("libs/jquery.waitforimages", function() {}), define("eventMgr", [ "jquery", "underscore", "utils", "classes/Extension", "settings", "text!html/settingsExtensionsAccordion.html", "extensions/partialRendering", "extensions/userCustom", "extensions/googleAnalytics", "extensions/dialogAbout", "extensions/dialogManagePublication", "extensions/dialogManageSynchronization", "extensions/dialogOpenHarddrive", "extensions/documentSelector", "extensions/documentTitle", "extensions/workingIndicator", "extensions/notifications", "extensions/markdownExtra", "extensions/toc", "extensions/mathJax", "extensions/emailConverter", "extensions/scrollLink", "extensions/buttonSync", "extensions/buttonPublish", "extensions/buttonShare", "extensions/buttonStat", "extensions/buttonHtmlCode", "extensions/buttonMarkdownSyntax", "extensions/buttonViewer", "libs/bootstrap", "libs/jquery.waitforimages" ], function(e, t, n, i, o, r) {
function s(e) {
return t.chain(d).map(function(t) {
return t.config.enabled && t[e];
@@ -9377,7 +9377,7 @@ function(e) {
});
}, l("onMessage"), l("onError"), l("onOfflineChanged"), l("onAsyncRunning", !0),
l("onPeriodicRun", !0), l("onFileMgrCreated"), l("onSynchronizerCreated"), l("onPublisherCreated"),
- l("onExtensionMgrCreated"), l("onFileCreated"), l("onFileDeleted"), l("onFileSelected"),
+ l("oneventMgrCreated"), l("onFileCreated"), l("onFileDeleted"), l("onFileSelected"),
l("onFileOpen"), l("onFileClosed"), l("onContentChanged"), l("onTitleChanged"),
l("onSyncRunning"), l("onSyncSuccess"), l("onSyncImportSuccess"), l("onSyncExportSuccess"),
l("onSyncRemoved"), l("onPublishRunning"), l("onPublishSuccess"), l("onNewPublishSuccess"),
@@ -9413,11 +9413,11 @@ function(e) {
});
var o = a("onReady");
o();
- }, u.onExtensionMgrCreated(u), u;
+ }, u.oneventMgrCreated(u), u;
}), define("text!html/settingsTemplateTooltip.html", [], function() {
return 'Available variables:\n
\n
\n - documentTitle: document title
\n - documentMarkdown: document in Markdown format
\n - documentHTML: document in HTML format
\n - publishAttributes: attributes of the publish location\n (undefined if not publishing)
\n
\n
Examples:\n
\n<title><%= documentTitle %></title>\n
\n<div><%- documentHTML %></div>\n
\n<%
\nif(publishAttributes.provider.providerId == "github")\nprint(documentMarkdown);
\n%>\n
\n
\n
More\n info';
}), define("text!html/settingsUserCustomExtensionTooltip.html", [], function() {
- return 'Extension variable name:\n
userCustom\n
\n
\n
Example:\n
\nuserCustom.onPreviewFinished = function() {\n
\n extensionMgr.onMessage("Finished!");\n
\n};\n
\n
\n
More\n info';
+ return 'Extension variable name:\n
userCustom\n
\n
\n
Example:\n
\nuserCustom.onPreviewFinished = function() {\n
\n eventMgr.onMessage("Finished!");\n
\n};\n
\n
\n
More\n info';
}), function(e, t) {
function n(t, n) {
var o, r, s, a = t.nodeName.toLowerCase();
@@ -13641,7 +13641,7 @@ function(e) {
}, y.doHorizontalRule = function(e) {
e.startTag = "----------\n", e.selection = "", e.skipLines(2, 1, !0);
};
-}(), define("libs/Markdown.Editor", function() {}), define("core", [ "jquery", "underscore", "utils", "settings", "extensionMgr", "mousetrap", "text!html/settingsTemplateTooltip.html", "text!html/settingsUserCustomExtensionTooltip.html", "storage", "config", "libs/bootstrap", "libs/layout", "libs/Markdown.Editor" ], function(e, t, n, i, o, r, s, a) {
+}(), define("libs/Markdown.Editor", function() {}), define("core", [ "jquery", "underscore", "utils", "settings", "eventMgr", "mousetrap", "text!html/settingsTemplateTooltip.html", "text!html/settingsUserCustomExtensionTooltip.html", "storage", "config", "libs/bootstrap", "libs/layout", "libs/Markdown.Editor" ], function(e, t, n, i, o, r, s, a) {
function l() {
v.isUserReal = !0, w = !0, k = n.currentTime;
}
@@ -13921,7 +13921,7 @@ function(e) {
}), v;
}), define("text!../WELCOME.md", [], function() {
return '\nWelcome to StackEdit! {#welcome}\n=====================\n\n\nHello, I am your first Markdown document within **StackEdit**[^stackedit]. Don\'t delete me, I can be helpful. I can be recovered anyway in the `Utils` tab of the
`Settings` dialog.\n\n----------\n\n\nDocuments\n---------\n\n**StackEdit** stores your documents in the browser local storage, which means all your documents are automatically saved locally and are accessible offline.\n\n####
Create a document\n\nYou can create a new document by clicking the
button in the navigation bar. This will switch from the current document to the new one.\n\n####
Switch to another document\n\nYou can list all your local documents and switch from one to another by clicking the
button in the navigation bar.\n\n####
Rename a document\n\nYou can rename the current document by clicking the document title in the navigation bar.\n\n####
Delete a document\n\nYou can delete the current document by clicking the
button in the navigation bar.\n\n----------\n\n\nSynchronization\n---------------\n\n**StackEdit** can be combined with **Google Drive** and **Dropbox** to have your documents centralized in the *Cloud*. The synchronization mechanism will take care of uploading your modifications or downloading the latest version of your documents.\n\n####
Import a document\n\nYou can import a document from the *Cloud* by going to the
`Google Drive` or the
`Dropbox` sub-menu and by clicking `Import from...`. Once imported, your document will be automatically synchronized with the **Google Drive** / **Dropbox** file.\n\n####
Export a document\n\nYou can export any document by going to the
`Google Drive` or the
`Dropbox` sub-menu and by clicking `Export to...`. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. **StackEdit** can synchronize one document with multiple locations.\n\n####
Synchronize a document\n\nOnce your document is linked to a **Google Drive** or a **Dropbox** file, **StackEdit** will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. Any conflict will be detected, and a local copy of your document will be created as a backup if necessary.\n\nIf you just have modified your document and you want to force the synchronization, click the
button in the navigation bar.\n\n> **NOTE:** The
button is disabled when:\n> \n> - you are offline,\n> - or the document is not synchronized with any location,\n> - or the document has not been modified since the last synchronization.\n\n####
Manage document synchronization\n\nSince one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking
`Manage synchronization` in the
menu. This will open a dialog box allowing you to add or remove synchronization links that are associated to your document.\n\n> **NOTE:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location.\n\n----------\n\n\nPublication\n-----------\n\nOnce you are happy with your document, you can publish it on different websites directly from **StackEdit**. As for now, **StackEdit** can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server.\n\n####
Publish a document\n\nYou can publish your document by going to the
`Publish on` sub-menu and by choosing a website. In the dialog box, you can choose the publication format:\n\n- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for instance),\n- HTML, to publish the document converted into HTML (on a blog for instance),\n- Template, to have a full control of the output.\n\n> **NOTE:** The default template is a simple webpage that wraps your document in HTML format. You can customize it in the `Publish` tab of the
`Settings` dialog.\n\n####
Update a publication\n\nAfter publishing, **StackEdit** will keep your document linked to that publish location so that you can update it easily. Once you have modified your document and you want to update your publication, click on the
button in the navigation bar.\n\n> **NOTE:** The
button is disabled when:\n> \n> - you are offline,\n> - or the document has not been published anywhere.\n\n####
Manage document publication\n\nSince one document can be published on multiple locations, you can list and manage publish locations by clicking
`Manage publication` in the
menu. This will open a dialog box allowing you to remove publication links that are associated to your document.\n\n> **NOTE:** In some cases, if you remove the file from the website or the post from the blog, the document will no longer be published on that location.\n\n----------\n\n\nMarkdown Extra\n--------------\n\n**StackEdit** supports **Markdown Extra**, which extends **Markdown** syntax with some nice features.\n\n\n### Tables\n\n**Markdown Extra** has a special syntax for tables:\n\nItem | Value\n--------- | -----\nComputer | \\$1600\nPhone | \\$12\nPipe | \\$1\n\nYou can specify column alignment with one or two colons:\n\n| Item | Value | Qty |\n| :-------- | ------:| :--: |\n| Computer | \\$1600 | 5 |\n| Phone | \\$12 | 12 |\n| Pipe | \\$1 | 234 |\n\n\n### Definition Lists\n\n**Markdown Extra** has a special syntax for definition lists too:\n\nTerm 1\nTerm 2\n: Definition A\n: Definition B\n\nTerm 3\n\n: Definition C\n\n: Definition D\n\n > part of definition D\n\n\n### Fenced code blocks\n\n**GitHub**\'s fenced code blocks are also supported with **Prettify** syntax highlighting:\n\n```\n// Foo\nvar bar = 0;\n```\n\n> **NOTE:** To use **Highlight.js** instead of **Prettify**, just configure the `Markdown Extra` extension in the
`Settings` dialog.\n\n\n### Special Attributes\n\nWith **Markdown Extra**, you can specify `class` and `id` attributes on headers and fenced code blocks just like this:\n\n##### Header example {#my-header}\n\n``` {#my-id .my-class}\nvar foo = bar;\n```\n\nThen you can create cross-references like this: [beginning of the document](#welcome).\n\n\n### Footnotes\n\nYou can create footnotes like this[^footnote].\n\n [^footnote]: Here is the *text* of the **footnote**.\n\n\n### Table of contents\n\nYou can insert a table of contents using the marker `[TOC]`:\n\n[TOC]\n\n\n### MathJax\n \nYou can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]:\n\nThe *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall\nn\\in\\mathbb N$ is via through the Euler integral\n\n$$\n\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,.\n$$\n\n\n> **NOTE:** You can find more information:\n>\n> - about **Markdown** syntax [here][2],\n> - about **Markdown Extra** extension [here][3],\n> - about **Prettify** syntax highlighting [here][4].\n> - about **Highlight.js** syntax highlighting [here][5].\n\n [^stackedit]: StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.\n\n\n [1]: http://math.stackexchange.com/\n [2]: http://daringfireball.net/projects/markdown/syntax "Markdown"\n [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra"\n [4]: https://code.google.com/p/google-code-prettify/\n [5]: http://softwaremaniacs.org/soft/highlight/en/';
-}), define("fileMgr", [ "jquery", "underscore", "core", "utils", "settings", "extensionMgr", "fileSystem", "classes/FileDescriptor", "text!../WELCOME.md" ], function(e, t, n, i, o, r, s, a, l) {
+}), define("fileMgr", [ "jquery", "underscore", "core", "utils", "settings", "eventMgr", "fileSystem", "classes/FileDescriptor", "text!../WELCOME.md" ], function(e, t, n, i, o, r, s, a, l) {
var c = {};
return c.currentFile = void 0, c.selectFile = function(i) {
if (i = i || c.currentFile, void 0 === i) {
@@ -14017,7 +14017,7 @@ function(e) {
this.providerId = e, this.providerName = t;
}
return e;
-}), define("classes/AsyncTask", [ "underscore", "core", "utils", "extensionMgr", "config", "libs/stacktrace" ], function(e, t, n, i) {
+}), define("classes/AsyncTask", [ "underscore", "core", "utils", "eventMgr", "config", "libs/stacktrace" ], function(e, t, n, i) {
function o() {
this.finished = !1, this.timeout = ASYNC_TASK_DEFAULT_TIMEOUT, this.retryCounter = 0,
this.runCallbacks = [], this.successCallbacks = [], this.errorCallbacks = [];
@@ -14072,7 +14072,7 @@ function(e) {
};
var l = !1, c = void 0, u = !1, d = 0;
return t.runPeriodically(r), o;
-}), define("helpers/dropboxHelper", [ "jquery", "underscore", "core", "extensionMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
+}), define("helpers/dropboxHelper", [ "jquery", "underscore", "core", "eventMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
function r(t) {
t.onRun(function() {
return n.isOffline === !0 ? (c = void 0, t.error(new Error("Operation not available in offline mode.|stopPublish")),
@@ -14226,7 +14226,7 @@ function(e) {
e(t);
}), n.enqueue();
}, d;
-}), define("providers/dropboxProvider", [ "underscore", "utils", "classes/Provider", "extensionMgr", "fileMgr", "helpers/dropboxHelper" ], function(e, t, n, i, o, r) {
+}), define("providers/dropboxProvider", [ "underscore", "utils", "classes/Provider", "eventMgr", "fileMgr", "helpers/dropboxHelper" ], function(e, t, n, i, o, r) {
function s(e) {
return void 0 === e ? void 0 : e.match(/^[^\\<>:"\|?\*]+$/) ? 0 !== e.indexOf("/") ? "/" + e : e : (i.onError('"' + e + '" contains invalid characters.'),
void 0);
@@ -14324,7 +14324,7 @@ function(e) {
var n = {};
return n.path = t.getInputTextValue("#input-publish-dropbox-path", e), e.isPropagationStopped() ? void 0 : n;
}, p;
-}), define("helpers/googleHelper", [ "jquery", "core", "utils", "extensionMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
+}), define("helpers/googleHelper", [ "jquery", "core", "utils", "eventMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
function r(n) {
n.onRun(function() {
return t.isOffline === !0 ? (c = !1, n.error(new Error("Operation not available in offline mode.|stopPublish")),
@@ -14683,7 +14683,7 @@ function(e) {
d(e);
}), p.enqueue();
}, d;
-}), define("providers/gdriveProvider", [ "underscore", "core", "utils", "classes/Provider", "settings", "extensionMgr", "fileMgr", "helpers/googleHelper" ], function(e, t, n, i, o, r, s, a) {
+}), define("providers/gdriveProvider", [ "underscore", "core", "utils", "classes/Provider", "settings", "eventMgr", "fileMgr", "helpers/googleHelper" ], function(e, t, n, i, o, r, s, a) {
function l(e) {
return "sync." + d + "." + e;
}
@@ -14851,7 +14851,7 @@ function(e) {
}), u(i);
}
}), p;
-}), define("synchronizer", [ "jquery", "underscore", "core", "utils", "extensionMgr", "fileSystem", "fileMgr", "classes/Provider", "providers/dropboxProvider", "providers/gdriveProvider" ], function(e, t, n, i, o, r, s, a) {
+}), define("synchronizer", [ "jquery", "underscore", "core", "utils", "eventMgr", "fileSystem", "fileMgr", "classes/Provider", "providers/dropboxProvider", "providers/gdriveProvider" ], function(e, t, n, i, o, r, s, a) {
function l(e) {
if (0 === y.length) return c(e), void 0;
var t = y.pop();
@@ -14990,7 +14990,7 @@ function(e) {
n(e);
}), s.enqueue();
}, o;
-}), define("helpers/githubHelper", [ "jquery", "core", "utils", "extensionMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
+}), define("helpers/githubHelper", [ "jquery", "core", "utils", "eventMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
function r(n) {
n.onRun(function() {
return t.isOffline === !0 ? (l = !1, n.error(new Error("Operation not available in offline mode.|stopPublish")),
@@ -15128,7 +15128,7 @@ function(e) {
}, i.importPublic = function(e, t) {
n.downloadGist(e.gistId, e.filename, t);
}, i;
-}), define("sharing", [ "jquery", "underscore", "core", "utils", "extensionMgr", "fileMgr", "classes/AsyncTask", "classes/Provider", "providers/downloadProvider", "providers/gistProvider" ], function(e, t, n, i, o, r, s, a) {
+}), define("sharing", [ "jquery", "underscore", "core", "utils", "eventMgr", "fileMgr", "classes/AsyncTask", "classes/Provider", "providers/downloadProvider", "providers/gistProvider" ], function(e, t, n, i, o, r, s, a) {
var l = {}, c = t.chain(arguments).map(function(e) {
return e instanceof a && [ e.providerId, e ];
}).compact().object().value();
@@ -15258,7 +15258,7 @@ function(e) {
n.password = e.getInputTextValue("#input-publish-ssh-password", t), n.path = e.getInputTextValue("#input-publish-file-path", t),
t.isPropagationStopped() ? void 0 : n;
}, i;
-}), define("helpers/tumblrHelper", [ "jquery", "core", "utils", "extensionMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
+}), define("helpers/tumblrHelper", [ "jquery", "core", "utils", "eventMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
function r(e) {
e.onRun(function() {
return t.isOffline === !0 ? (e.error(new Error("Operation not available in offline mode.|stopPublish")),
@@ -15357,7 +15357,7 @@ function(e) {
n.postId = e.getInputTextValue("#input-publish-postid"), n.tags = e.getInputTextValue("#input-publish-tags"),
t.isPropagationStopped() ? void 0 : n;
}, i;
-}), define("helpers/wordpressHelper", [ "jquery", "core", "utils", "extensionMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
+}), define("helpers/wordpressHelper", [ "jquery", "core", "utils", "eventMgr", "classes/AsyncTask" ], function(e, t, n, i, o) {
function r(e) {
e.onRun(function() {
return t.isOffline === !0 ? (e.error(new Error("Operation not available in offline mode.|stopPublish")),
@@ -15454,7 +15454,7 @@ function(e) {
n.postId = e.getInputTextValue("#input-publish-postid"), n.tags = e.getInputTextValue("#input-publish-tags"),
t.isPropagationStopped() ? void 0 : n;
}, i;
-}), define("publisher", [ "jquery", "underscore", "core", "utils", "settings", "extensionMgr", "fileSystem", "fileMgr", "sharing", "classes/Provider", "providers/bloggerProvider", "providers/dropboxProvider", "providers/gistProvider", "providers/githubProvider", "providers/gdriveProvider", "providers/sshProvider", "providers/tumblrProvider", "providers/wordpressProvider" ], function(e, t, n, i, o, r, s, a, l, c) {
+}), define("publisher", [ "jquery", "underscore", "core", "utils", "settings", "eventMgr", "fileSystem", "fileMgr", "sharing", "classes/Provider", "providers/bloggerProvider", "providers/dropboxProvider", "providers/gistProvider", "providers/githubProvider", "providers/gdriveProvider", "providers/sshProvider", "providers/tumblrProvider", "providers/wordpressProvider" ], function(e, t, n, i, o, r, s, a, l, c) {
function u(t, n, i) {
return void 0 === n.format && (n.format = e("input:radio[name=radio-publish-format]:checked").prop("value")),
"markdown" == n.format ? t.content : "html" == n.format ? i : g.applyTemplate(t, n, i);
@@ -15558,7 +15558,7 @@ function(e) {
i.saveAs(t, e.title + (-1 === o.template.indexOf("documentHTML") ? ".md" : ".html"));
});
}), r.onPublisherCreated(g), g;
-}), define("providers/gplusProvider", [ "underscore", "core", "utils", "classes/Provider", "extensionMgr", "helpers/googleHelper" ], function(e, t, n, i, o, r) {
+}), define("providers/gplusProvider", [ "underscore", "core", "utils", "classes/Provider", "eventMgr", "helpers/googleHelper" ], function(e, t, n, i, o, r) {
function s(t, n) {
var i = void 0;
return e.find(t.thumbnails, function(e) {
@@ -15596,7 +15596,7 @@ function(e) {
t && (i += ' "' + t + '"'), p(void 0, i), d = {}, e && (d.size = e), localStorage[l + ".importImagePreferences"] = JSON.stringify(d);
});
}), c;
-}), define("mediaImporter", [ "jquery", "underscore", "classes/Provider", "core", "extensionMgr", "providers/gplusProvider" ], function(e, t, n, i) {
+}), define("mediaImporter", [ "jquery", "underscore", "classes/Provider", "core", "eventMgr", "providers/gplusProvider" ], function(e, t, n, i) {
var o = {}, r = t.chain(arguments).map(function(e) {
return e instanceof n && [ e.providerId, e ];
}).compact().object().value();
diff --git a/js/mediaImporter.js b/js/mediaImporter.js
index 365852fb..9ec0e8e9 100644
--- a/js/mediaImporter.js
+++ b/js/mediaImporter.js
@@ -3,9 +3,9 @@ define([
"underscore",
"classes/Provider",
"core",
- "extensionMgr",
+ "eventMgr",
"providers/gplusProvider"
-], function($, _, Provider, core, extensionMgr) {
+], function($, _, Provider, core, eventMgr) {
var mediaImporter = {};
diff --git a/js/providers/dropboxProvider.js b/js/providers/dropboxProvider.js
index 83b76cc2..4f54ca1c 100644
--- a/js/providers/dropboxProvider.js
+++ b/js/providers/dropboxProvider.js
@@ -2,10 +2,10 @@ define([
"underscore",
"utils",
"classes/Provider",
- "extensionMgr",
+ "eventMgr",
"fileMgr",
"helpers/dropboxHelper"
-], function(_, utils, Provider, extensionMgr, fileMgr, dropboxHelper) {
+], function(_, utils, Provider, eventMgr, fileMgr, dropboxHelper) {
var PROVIDER_DROPBOX = "dropbox";
@@ -17,7 +17,7 @@ define([
return undefined;
}
if(!path.match(/^[^\\<>:"\|?\*]+$/)) {
- extensionMgr.onError('"' + path + '" contains invalid characters.');
+ eventMgr.onError('"' + path + '" contains invalid characters.');
return undefined;
}
if(path.indexOf("/") !== 0) {
@@ -59,7 +59,7 @@ define([
fileDescList.push(fileDesc);
});
if(fileDescList.length !== 0) {
- extensionMgr.onSyncImportSuccess(fileDescList, dropboxProvider);
+ eventMgr.onSyncImportSuccess(fileDescList, dropboxProvider);
}
});
});
@@ -75,7 +75,7 @@ define([
var syncIndex = createSyncIndex(path);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
- extensionMgr.onError('"' + fileDesc.title + '" was already imported.');
+ eventMgr.onError('"' + fileDesc.title + '" was already imported.');
return;
}
importPaths.push(path);
@@ -95,7 +95,7 @@ define([
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
var existingTitle = fileDesc.title;
- extensionMgr.onError('File path is already synchronized with "' + existingTitle + '".');
+ eventMgr.onError('File path is already synchronized with "' + existingTitle + '".');
callback(true);
return;
}
@@ -180,9 +180,9 @@ define([
var localTitle = fileDesc.title;
// File deleted
if(change.wasRemoved === true) {
- extensionMgr.onError('"' + localTitle + '" has been removed from Dropbox.');
+ eventMgr.onError('"' + localTitle + '" has been removed from Dropbox.');
fileDesc.removeSyncLocation(syncAttributes);
- extensionMgr.onSyncRemoved(fileDesc, syncAttributes);
+ eventMgr.onSyncRemoved(fileDesc, syncAttributes);
return;
}
var localContent = fileDesc.content;
@@ -194,13 +194,13 @@ define([
// Conflict detection
if(fileContentChanged === true && localContentChanged === true && remoteContentChanged === true) {
fileMgr.createFile(localTitle + " (backup)", localContent);
- extensionMgr.onMessage('Conflict detected on "' + localTitle + '". A backup has been created locally.');
+ eventMgr.onMessage('Conflict detected on "' + localTitle + '". A backup has been created locally.');
}
// If file content changed
if(fileContentChanged && remoteContentChanged === true) {
fileDesc.content = file.content;
- extensionMgr.onContentChanged(fileDesc);
- extensionMgr.onMessage('"' + localTitle + '" has been updated from Dropbox.');
+ eventMgr.onContentChanged(fileDesc);
+ eventMgr.onMessage('"' + localTitle + '" has been updated from Dropbox.');
if(fileMgr.currentFile === fileDesc) {
fileMgr.selectFile(); // Refresh editor
}
diff --git a/js/providers/gdriveProvider.js b/js/providers/gdriveProvider.js
index d85f6f80..de81a5dd 100644
--- a/js/providers/gdriveProvider.js
+++ b/js/providers/gdriveProvider.js
@@ -4,10 +4,10 @@ define([
"utils",
"classes/Provider",
"settings",
- "extensionMgr",
+ "eventMgr",
"fileMgr",
"helpers/googleHelper"
-], function(_, core, utils, Provider, settings, extensionMgr, fileMgr, googleHelper) {
+], function(_, core, utils, Provider, settings, eventMgr, fileMgr, googleHelper) {
var PROVIDER_GDRIVE = "gdrive";
@@ -52,7 +52,7 @@ define([
fileDescList.push(fileDesc);
});
if(fileDesc !== undefined) {
- extensionMgr.onSyncImportSuccess(fileDescList, gdriveProvider);
+ eventMgr.onSyncImportSuccess(fileDescList, gdriveProvider);
fileMgr.selectFile(fileDesc);
}
});
@@ -69,7 +69,7 @@ define([
var syncIndex = createSyncIndex(doc.id);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
- extensionMgr.onError('"' + fileDesc.title + '" was already imported.');
+ eventMgr.onError('"' + fileDesc.title + '" was already imported.');
return;
}
importIds.push(doc.id);
@@ -111,7 +111,7 @@ define([
var syncIndex = createSyncIndex(id);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
- extensionMgr.onError('File ID is already synchronized with "' + fileDesc.title + '".');
+ eventMgr.onError('File ID is already synchronized with "' + fileDesc.title + '".');
callback(true);
return;
}
@@ -188,9 +188,9 @@ define([
var localTitle = fileDesc.title;
// File deleted
if(change.deleted === true) {
- extensionMgr.onError('"' + localTitle + '" has been removed from Google Drive.');
+ eventMgr.onError('"' + localTitle + '" has been removed from Google Drive.');
fileDesc.removeSyncLocation(syncAttributes);
- extensionMgr.onSyncRemoved(fileDesc, syncAttributes);
+ eventMgr.onSyncRemoved(fileDesc, syncAttributes);
if(syncAttributes.isRealtime === true && fileMgr.currentFile === fileDesc) {
gdriveProvider.stopRealtimeSync();
}
@@ -209,19 +209,19 @@ define([
// Conflict detection
if((fileTitleChanged === true && localTitleChanged === true && remoteTitleChanged === true) || (!syncAttributes.isRealtime && fileContentChanged === true && localContentChanged === true && remoteContentChanged === true)) {
fileMgr.createFile(localTitle + " (backup)", localContent);
- extensionMgr.onMessage('Conflict detected on "' + localTitle + '". A backup has been created locally.');
+ eventMgr.onMessage('Conflict detected on "' + localTitle + '". A backup has been created locally.');
}
// If file title changed
if(fileTitleChanged && remoteTitleChanged === true) {
fileDesc.title = file.title;
- extensionMgr.onTitleChanged(fileDesc);
- extensionMgr.onMessage('"' + localTitle + '" has been renamed to "' + file.title + '" on Google Drive.');
+ eventMgr.onTitleChanged(fileDesc);
+ eventMgr.onMessage('"' + localTitle + '" has been renamed to "' + file.title + '" on Google Drive.');
}
// If file content changed
if(!syncAttributes.isRealtime && fileContentChanged && remoteContentChanged === true) {
fileDesc.content = file.content;
- extensionMgr.onContentChanged(fileDesc);
- extensionMgr.onMessage('"' + file.title + '" has been updated from Google Drive.');
+ eventMgr.onContentChanged(fileDesc);
+ eventMgr.onMessage('"' + file.title + '" has been updated from Google Drive.');
if(fileMgr.currentFile === fileDesc) {
fileMgr.selectFile(); // Refresh editor
}
@@ -263,7 +263,7 @@ define([
// Keep a link to the pagedown editor
var editor = undefined;
- extensionMgr.addHookCallback("onEditorConfigure", function(editorParam) {
+ eventMgr.addListener("onEditorConfigure", function(editorParam) {
editor = editorParam;
});
@@ -327,7 +327,7 @@ define([
if(remoteContentChanged === true) {
// Conflict detected
fileMgr.createFile(fileDesc.title + " (backup)", localContent);
- extensionMgr.onMessage('Conflict detected on "' + fileDesc.title + '". A backup has been created locally.');
+ eventMgr.onMessage('Conflict detected on "' + fileDesc.title + '". A backup has been created locally.');
}
else {
// Add local modifications if no collaborators change
@@ -371,13 +371,13 @@ define([
googleHelper.forceAuthenticate();
}
else if(err.type == "not_found") {
- extensionMgr.onError('"' + fileDesc.title + '" has been removed from Google Drive.');
+ eventMgr.onError('"' + fileDesc.title + '" has been removed from Google Drive.');
fileDesc.removeSyncLocation(syncAttributes);
- extensionMgr.onSyncRemoved(fileDesc, syncAttributes);
+ eventMgr.onSyncRemoved(fileDesc, syncAttributes);
gdriveProvider.stopRealtimeSync();
}
else if(err.isFatal) {
- extensionMgr.onError('An error has forced real time synchronization to stop.');
+ eventMgr.onError('An error has forced real time synchronization to stop.');
gdriveProvider.stopRealtimeSync();
}
});
@@ -417,7 +417,7 @@ define([
syncLocations[syncAttributes.syncIndex] = syncAttributes;
var fileDesc = fileMgr.createFile(file.title, file.content, syncLocations);
fileMgr.selectFile(fileDesc);
- extensionMgr.onMessage('"' + file.title + '" created successfully on Google Drive.');
+ eventMgr.onMessage('"' + file.title + '" created successfully on Google Drive.');
});
}
else if(state.action == "open") {
diff --git a/js/providers/gplusProvider.js b/js/providers/gplusProvider.js
index 8483e73e..d236bea8 100644
--- a/js/providers/gplusProvider.js
+++ b/js/providers/gplusProvider.js
@@ -3,9 +3,9 @@ define([
"core",
"utils",
"classes/Provider",
- "extensionMgr",
+ "eventMgr",
"helpers/googleHelper"
-], function(_, core, utils, Provider, extensionMgr, googleHelper) {
+], function(_, core, utils, Provider, eventMgr, googleHelper) {
var PROVIDER_GPLUS = "gplus";
@@ -28,7 +28,7 @@ define([
var importImagePreferences = utils.retrieveIgnoreError(PROVIDER_GPLUS + ".importImagePreferences");
function showImportImgDialog() {
if(!imageDoc.thumbnails) {
- extensionMgr.onError("Image " + imageDoc.name + " is not accessible.");
+ eventMgr.onError("Image " + imageDoc.name + " is not accessible.");
callback(true);
return;
}
diff --git a/js/publisher.js b/js/publisher.js
index ca772aab..af77dc43 100644
--- a/js/publisher.js
+++ b/js/publisher.js
@@ -4,7 +4,7 @@ define([
"core",
"utils",
"settings",
- "extensionMgr",
+ "eventMgr",
"fileSystem",
"fileMgr",
"sharing",
@@ -17,7 +17,7 @@ define([
"providers/sshProvider",
"providers/tumblrProvider",
"providers/wordpressProvider"
-], function($, _, core, utils, settings, extensionMgr, fileSystem, fileMgr, sharing, Provider) {
+], function($, _, core, utils, settings, eventMgr, fileSystem, fileMgr, sharing, Provider) {
var publisher = {};
@@ -46,7 +46,7 @@ define([
}
catch(e) {
// localStorage can be corrupted
- extensionMgr.onError(e);
+ eventMgr.onError(e);
// Remove publish location
utils.removeIndexFromArray(fileDesc.fileIndex + ".publish", publishIndex);
localStorage.removeItem(publishIndex);
@@ -65,7 +65,7 @@ define([
});
}
catch(e) {
- extensionMgr.onError(e);
+ eventMgr.onError(e);
return e.message;
}
};
@@ -110,7 +110,7 @@ define([
var errorMsg = error.toString();
if(errorMsg.indexOf("|removePublish") !== -1) {
publishFileDesc.removePublishLocation(publishAttributes);
- extensionMgr.onPublishRemoved(publishFileDesc, publishAttributes);
+ eventMgr.onPublishRemoved(publishFileDesc, publishAttributes);
}
if(errorMsg.indexOf("|stopPublish") !== -1) {
callback(error);
@@ -123,7 +123,7 @@ define([
// Get the html from the onPreviewFinished callback
var previewHtml = undefined;
- extensionMgr.addHookCallback("onPreviewFinished", function(html) {
+ eventMgr.addListener("onPreviewFinished", function(html) {
previewHtml = html;
});
@@ -136,15 +136,15 @@ define([
}
publishRunning = true;
- extensionMgr.onPublishRunning(true);
+ eventMgr.onPublishRunning(true);
publishFileDesc = fileMgr.currentFile;
publishHTML = previewHtml;
publishAttributesList = _.values(publishFileDesc.publishLocations);
publishLocation(function(errorFlag) {
publishRunning = false;
- extensionMgr.onPublishRunning(false);
+ eventMgr.onPublishRunning(false);
if(errorFlag === undefined) {
- extensionMgr.onPublishSuccess(publishFileDesc);
+ eventMgr.onPublishSuccess(publishFileDesc);
}
});
};
@@ -157,7 +157,7 @@ define([
} while (_.has(localStorage, publishIndex));
publishAttributes.publishIndex = publishIndex;
fileDesc.addPublishLocation(publishAttributes);
- extensionMgr.onNewPublishSuccess(fileDesc, publishAttributes);
+ eventMgr.onNewPublishSuccess(fileDesc, publishAttributes);
}
// Initialize the "New publication" dialog
@@ -251,6 +251,6 @@ define([
});
});
- extensionMgr.onPublisherCreated(publisher);
+ eventMgr.onPublisherCreated(publisher);
return publisher;
});
\ No newline at end of file
diff --git a/js/sharing.js b/js/sharing.js
index 119364da..1a49ede0 100644
--- a/js/sharing.js
+++ b/js/sharing.js
@@ -3,13 +3,13 @@ define([
"underscore",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"fileMgr",
"classes/AsyncTask",
"classes/Provider",
"providers/downloadProvider",
"providers/gistProvider"
-], function($, _, core, utils, extensionMgr, fileMgr, AsyncTask, Provider) {
+], function($, _, core, utils, eventMgr, fileMgr, AsyncTask, Provider) {
var sharing = {};
@@ -59,7 +59,7 @@ define([
attributes.sharingLink = shortUrl;
}
else {
- extensionMgr.onError("An error occured while creating sharing link.");
+ eventMgr.onError("An error occured while creating sharing link.");
attributes.sharingLink = url;
}
task.chain();
diff --git a/js/synchronizer.js b/js/synchronizer.js
index b096e4c3..2b9c34ec 100644
--- a/js/synchronizer.js
+++ b/js/synchronizer.js
@@ -3,13 +3,13 @@ define([
"underscore",
"core",
"utils",
- "extensionMgr",
+ "eventMgr",
"fileSystem",
"fileMgr",
"classes/Provider",
"providers/dropboxProvider",
"providers/gdriveProvider"
-], function($, _, core, utils, extensionMgr, fileSystem, fileMgr, Provider) {
+], function($, _, core, utils, eventMgr, fileSystem, fileMgr, Provider) {
var synchronizer = {};
@@ -38,7 +38,7 @@ define([
}
catch(e) {
// localStorage can be corrupted
- extensionMgr.onError(e);
+ eventMgr.onError(e);
// Remove sync location
utils.removeIndexFromArray(fileDesc.fileIndex + ".sync", syncIndex);
localStorage.removeItem(syncIndex);
@@ -47,9 +47,11 @@ define([
});
// Returns true if at least one file has synchronized location
- synchronizer.hasSync = function() {
- return _.some(providerMap, function(provider) {
- return fileMgr.hasSync(provider);
+ synchronizer.hasSync = function(provider) {
+ return _.some(fileSystem, function(fileDesc) {
+ return _.some(fileDesc.syncLocations, function(syncAttributes) {
+ return provider === undefined || syncAttributes.provider === provider;
+ });
});
};
@@ -148,7 +150,7 @@ define([
var provider = providerList.pop();
// Check that provider has files to sync
- if(!fileMgr.hasSync(provider)) {
+ if(!synchronizer.hasSync(provider)) {
providerDown(callback);
return;
}
@@ -177,13 +179,13 @@ define([
return false;
}
syncRunning = true;
- extensionMgr.onSyncRunning(true);
+ eventMgr.onSyncRunning(true);
uploadCycle = true;
function isError(error) {
if(error !== undefined) {
syncRunning = false;
- extensionMgr.onSyncRunning(false);
+ eventMgr.onSyncRunning(false);
return true;
}
return false;
@@ -198,8 +200,8 @@ define([
return;
}
syncRunning = false;
- extensionMgr.onSyncRunning(false);
- extensionMgr.onSyncSuccess();
+ eventMgr.onSyncRunning(false);
+ eventMgr.onSyncSuccess();
});
});
return true;
@@ -251,11 +253,11 @@ define([
}
};
- // Triggers realtime synchronization from extensionMgr events
+ // Triggers realtime synchronization from eventMgr events
if(viewerMode === false) {
- extensionMgr.addHookCallback("onFileOpen", onFileOpen);
- extensionMgr.addHookCallback("onFileClosed", synchronizer.tryStopRealtimeSync);
- extensionMgr.addHookCallback("onOfflineChanged", onOfflineChanged);
+ eventMgr.addListener("onFileOpen", onFileOpen);
+ eventMgr.addListener("onFileClosed", synchronizer.tryStopRealtimeSync);
+ eventMgr.addListener("onOfflineChanged", onOfflineChanged);
}
/***************************************************************************
@@ -297,7 +299,7 @@ define([
if(isRealtime) {
if(_.size(fileDesc.syncLocations) > 0) {
- extensionMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
+ eventMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
return;
}
// Perform the provider's real time export
@@ -307,7 +309,7 @@ define([
}
syncAttributes.isRealtime = true;
fileDesc.addSyncLocation(syncAttributes);
- extensionMgr.onSyncExportSuccess(fileDesc, syncAttributes);
+ eventMgr.onSyncExportSuccess(fileDesc, syncAttributes);
// Start the real time sync
realtimeFileDesc = fileDesc;
@@ -317,7 +319,7 @@ define([
}
else {
if(_.size(fileDesc.syncLocations) > 0 && _.first(_.values(fileDesc.syncLocations)).isRealtime) {
- extensionMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
+ eventMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
return;
}
// Perform the provider's standard export
@@ -326,7 +328,7 @@ define([
return;
}
fileDesc.addSyncLocation(syncAttributes);
- extensionMgr.onSyncExportSuccess(fileDesc, syncAttributes);
+ eventMgr.onSyncExportSuccess(fileDesc, syncAttributes);
});
}
@@ -342,7 +344,7 @@ define([
$(".action-sync-manual-" + provider.providerId).click(function(event) {
var fileDesc = fileMgr.currentFile;
if(_.size(fileDesc.syncLocations) > 0 && _.first(_.values(fileDesc.syncLocations)).isRealtime) {
- extensionMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
+ eventMgr.onError("Real time collaborative document can't be synchronized with multiple locations");
return;
}
provider.exportManual(event, fileDesc.title, fileDesc.content, function(error, syncAttributes) {
@@ -350,12 +352,12 @@ define([
return;
}
fileDesc.addSyncLocation(syncAttributes);
- extensionMgr.onSyncExportSuccess(fileDesc, syncAttributes);
+ eventMgr.onSyncExportSuccess(fileDesc, syncAttributes);
});
});
});
});
- extensionMgr.onSynchronizerCreated(synchronizer);
+ eventMgr.onSynchronizerCreated(synchronizer);
return synchronizer;
});