Stackedit/js/publisher.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-04-10 18:14:59 +00:00
define(["jquery"], function($) {
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 = {};
var wizardProvider = undefined;
2013-04-10 18:14:59 +00:00
function initWizard(provider, defaultPublishFormat) {
defaultPublishFormat = defaultPublishFormat || "markdown";
2013-04-09 07:58:06 +00:00
wizardProvider = provider;
2013-04-10 18:14:59 +00:00
// Show/hide controls depending on provider
$('div[class*=" control-publish-"]').hide().filter(".control-publish-" + provider).show();
// Reset fields
$("#modal-publish input[type=text]").val("");
$("input:radio[name=radio-publish-format][value=" + defaultPublishFormat + "]").prop("checked", true);
// Open dialog box
$("#modal-publish").modal();
2013-04-09 07:58:06 +00:00
}
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;
2013-04-10 18:14:59 +00:00
$(".action-publish-github").click(function() {
2013-04-09 07:58:06 +00:00
initWizard("github");
});
2013-04-10 18:14:59 +00:00
$(".action-publish-blogger").click(function() {
initWizard("blogger", "html");
2013-04-09 07:58:06 +00:00
});
2013-04-10 18:14:59 +00:00
$(".action-publish-wordpress").click(function() {
2013-04-09 07:58:06 +00:00
initWizard("wordpress");
});
2013-04-10 18:14:59 +00:00
$(".action-publish-tumblr").click(function() {
2013-04-09 07:58:06 +00:00
initWizard("tumblr");
});
};
return publisher;
});