Add publish providers icons beside document title
This commit is contained in:
parent
859f347974
commit
7ed11598fb
@ -137,6 +137,7 @@ define(["jquery", "core", "synchronizer", "publisher", "text!../WELCOME.md", "un
|
||||
function composeTitle(fileIndex) {
|
||||
var result = " " + localStorage[fileIndex + ".title"];
|
||||
var providerIdList = synchronizer.getSyncProvidersFromFile(fileIndex);
|
||||
providerIsList = _.extend(providerIdList, publisher.getPublishProvidersFromFile(fileIndex));
|
||||
_.each(providerIdList, function(providerId) {
|
||||
result = '<i class="icon-' + providerId + '"></i>' + result;
|
||||
});
|
||||
|
@ -93,6 +93,7 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
|
||||
var errorMsg = error.toString();
|
||||
if(errorMsg.indexOf("|removePublish") !== -1) {
|
||||
core.fileManager.removePublish(publishIndex);
|
||||
core.fileManager.updateFileTitles();
|
||||
core.showMessage(provider.providerName + " publish location has been removed.");
|
||||
}
|
||||
if(errorMsg.indexOf("|stopPublish") !== -1) {
|
||||
@ -168,6 +169,7 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
|
||||
publishAttributes.provider = provider.providerId;
|
||||
createPublishIndex(fileIndex, publishAttributes);
|
||||
publisher.notifyPublish();
|
||||
core.fileManager.updateFileTitles();
|
||||
core.showMessage('"' + title
|
||||
+ '" is now published on ' + provider.providerName + '.');
|
||||
}
|
||||
@ -200,11 +202,22 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
|
||||
}));
|
||||
lineElement.append($(removeButtonTemplate).click(function() {
|
||||
core.fileManager.removePublish(publishIndex);
|
||||
core.fileManager.updateFileTitles();
|
||||
}));
|
||||
$("#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() {
|
||||
// Init each provider
|
||||
_.each(providerMap, function(provider) {
|
||||
|
@ -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() {
|
||||
_.each(providerMap, function(provider) {
|
||||
provider.useSync = false;
|
||||
@ -226,11 +226,11 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
|
||||
};
|
||||
synchronizer.getSyncProvidersFromFile = function(fileIndex) {
|
||||
var sync = localStorage[fileIndex + ".sync"];
|
||||
var providerIdList = [];
|
||||
var providerIdList = {};
|
||||
_.each(providerMap, function(provider) {
|
||||
if (sync.indexOf(";sync." + provider.providerId + ".") !== -1) {
|
||||
provider.useSync = true;
|
||||
providerIdList.push(provider.providerId);
|
||||
providerIdList[provider.providerId] = provider.providerId;
|
||||
}
|
||||
});
|
||||
return providerIdList;
|
||||
|
@ -121,7 +121,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
|
||||
};
|
||||
// Handle error
|
||||
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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user