2013-04-10 23:13:31 +00:00
|
|
|
define(["jquery", "google-helper", "github-helper"], function($, googleHelper, githubHelper) {
|
2013-04-09 07:58:06 +00:00
|
|
|
|
|
|
|
// Dependencies
|
2013-04-10 18:14:59 +00:00
|
|
|
var core = undefined;
|
2013-04-09 07:58:06 +00:00
|
|
|
var fileManager = undefined;
|
|
|
|
|
|
|
|
var publisher = {};
|
|
|
|
|
2013-04-10 23:13:31 +00:00
|
|
|
// Used to know if the current file has publications
|
|
|
|
var hasPublications = false;
|
2013-04-09 07:58:06 +00:00
|
|
|
|
2013-04-10 23:13:31 +00:00
|
|
|
// Allows external modules to update hasPublications flag
|
|
|
|
publisher.notifyCurrentFile = function(fileIndex) {
|
2013-04-10 18:14:59 +00:00
|
|
|
|
2013-04-10 23:13:31 +00:00
|
|
|
// Check that file has publications
|
|
|
|
if(localStorage[fileIndex + ".publish"].length === 1) {
|
|
|
|
hasPublications = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hasPublications = true;
|
|
|
|
}
|
|
|
|
publisher.updatePublishButton();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Used to enable/disable the publish button
|
|
|
|
publisher.updatePublishButton = function() {
|
|
|
|
if(publishRunning === true || hasPublications === false || core.isOffline) {
|
|
|
|
$(".action-force-publish").addClass("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(".action-force-publish").removeClass("disabled");
|
|
|
|
}
|
|
|
|
};
|
2013-04-09 07:58:06 +00:00
|
|
|
|
2013-04-10 23:13:31 +00:00
|
|
|
var publishRunning = false;
|
|
|
|
|
2013-04-10 18:14:59 +00:00
|
|
|
publisher.init = function(coreModule, fileManagerModule) {
|
|
|
|
core = coreModule;
|
2013-04-09 07:58:06 +00:00
|
|
|
fileManager = fileManagerModule;
|
|
|
|
};
|
|
|
|
|
|
|
|
return publisher;
|
|
|
|
});
|