Add publish providers icons beside document title

This commit is contained in:
benweet 2013-04-29 00:08:54 +01:00
parent 859f347974
commit 7ed11598fb
4 changed files with 18 additions and 4 deletions

View File

@ -137,6 +137,7 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
function composeTitle(fileIndex) { function composeTitle(fileIndex) {
var result = " " + localStorage[fileIndex + ".title"]; var result = " " + localStorage[fileIndex + ".title"];
var providerIdList = synchronizer.getSyncProvidersFromFile(fileIndex); var providerIdList = synchronizer.getSyncProvidersFromFile(fileIndex);
providerIsList = _.extend(providerIdList, publisher.getPublishProvidersFromFile(fileIndex));
_.each(providerIdList, function(providerId) { _.each(providerIdList, function(providerId) {
result = '<i class="icon-' + providerId + '"></i>' + result; result = '<i class="icon-' + providerId + '"></i>' + result;
}); });

View File

@ -93,6 +93,7 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
var errorMsg = error.toString(); var errorMsg = error.toString();
if(errorMsg.indexOf("|removePublish") !== -1) { if(errorMsg.indexOf("|removePublish") !== -1) {
core.fileManager.removePublish(publishIndex); core.fileManager.removePublish(publishIndex);
core.fileManager.updateFileTitles();
core.showMessage(provider.providerName + " publish location has been removed."); core.showMessage(provider.providerName + " publish location has been removed.");
} }
if(errorMsg.indexOf("|stopPublish") !== -1) { if(errorMsg.indexOf("|stopPublish") !== -1) {
@ -168,6 +169,7 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
publishAttributes.provider = provider.providerId; publishAttributes.provider = provider.providerId;
createPublishIndex(fileIndex, publishAttributes); createPublishIndex(fileIndex, publishAttributes);
publisher.notifyPublish(); publisher.notifyPublish();
core.fileManager.updateFileTitles();
core.showMessage('"' + title core.showMessage('"' + title
+ '" is now published on ' + provider.providerName + '.'); + '" is now published on ' + provider.providerName + '.');
} }
@ -200,11 +202,22 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
})); }));
lineElement.append($(removeButtonTemplate).click(function() { lineElement.append($(removeButtonTemplate).click(function() {
core.fileManager.removePublish(publishIndex); core.fileManager.removePublish(publishIndex);
core.fileManager.updateFileTitles();
})); }));
$("#manage-publish-list").append(lineElement); $("#manage-publish-list").append(lineElement);
}); });
}; };
publisher.getPublishProvidersFromFile = function(fileIndex) {
var publishIndexList = _.compact(localStorage[fileIndex + ".publish"].split(";"));
var providerIdList = {};
_.each(publishIndexList, function(publishIndex) {
var publishAttributes = JSON.parse(localStorage[publishIndex]);
providerIdList[publishAttributes.provider] = publishAttributes.provider;
});
return providerIdList;
};
core.onReady(function() { core.onReady(function() {
// Init each provider // Init each provider
_.each(providerMap, function(provider) { _.each(providerMap, function(provider) {

View File

@ -218,7 +218,7 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
}); });
}; };
// Used to enable/disable providers' synchronization // Used to enable/disable provider synchronization
synchronizer.resetSyncFlags = function() { synchronizer.resetSyncFlags = function() {
_.each(providerMap, function(provider) { _.each(providerMap, function(provider) {
provider.useSync = false; provider.useSync = false;
@ -226,11 +226,11 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
}; };
synchronizer.getSyncProvidersFromFile = function(fileIndex) { synchronizer.getSyncProvidersFromFile = function(fileIndex) {
var sync = localStorage[fileIndex + ".sync"]; var sync = localStorage[fileIndex + ".sync"];
var providerIdList = []; var providerIdList = {};
_.each(providerMap, function(provider) { _.each(providerMap, function(provider) {
if (sync.indexOf(";sync." + provider.providerId + ".") !== -1) { if (sync.indexOf(";sync." + provider.providerId + ".") !== -1) {
provider.useSync = true; provider.useSync = true;
providerIdList.push(provider.providerId); providerIdList[provider.providerId] = provider.providerId;
} }
}); });
return providerIdList; return providerIdList;

View File

@ -121,7 +121,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
}; };
// Handle error // Handle error
if(error.code === 404 && postId !== undefined) { if(error.code === 404 && postId !== undefined) {
error = 'Post ' + postId + ' not found on Blogger.|removePublish'; error = 'Post ' + postId + ' not found on Tumblr.|removePublish';
} }
handleError(error, task); handleError(error, task);
}); });