").addClass("input-prepend input-append");
if (syncIndex.indexOf(SYNC_PROVIDER_GDRIVE) === 0) {
line.append($("
").addClass("add-on").prop("title", "Google Drive").html(
''));
line.append($("").prop("type", "text").prop(
"disabled", true).addClass("span5").val(
syncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
}
else if (syncIndex.indexOf(SYNC_PROVIDER_DROPBOX) === 0) {
line.append($("").addClass("add-on").prop("title", "Dropbox").html(
''));
line.append($("").prop("type", "text").prop(
"disabled", true).addClass("span5").val(
decodeURIComponent(syncIndex.substring(SYNC_PROVIDER_DROPBOX.length))));
}
line.append($("").addClass("btn").html(
'').prop("title",
"Remove this location").click(function() {
fileManager.removeSync(syncIndex);
fileManager.updateFileTitles();
}));
$("#manage-sync-list").append(line);
});
}
fileManager.init = function(coreModule) {
core = coreModule;
fileManager.selectFile();
$(".action-create-file").click(function() {
var fileIndex = fileManager.createFile();
fileManager.selectFile(fileIndex);
$("#file-title").click();
});
$(".action-remove-file").click(function() {
fileManager.deleteFile();
fileManager.selectFile();
});
$("#file-title").click(function() {
$(this).hide();
$("#file-title-input").show().focus();
});
$("#file-title-input").blur(function() {
var title = $.trim($(this).val());
if (title) {
var fileIndexTitle = fileManager.getCurrentFileIndex() + ".title";
if (title != localStorage[fileIndexTitle]) {
localStorage[fileIndexTitle] = title;
fileManager.updateFileTitles();
fileManager.saveFile();
}
}
$(this).hide();
$("#file-title").show();
});
$(".action-download-md").click(
function() {
var content = $("#wmd-input").val();
var uriContent = "data:application/octet-stream;base64,"
+ core.encodeBase64(content);
window.open(uriContent, 'file');
});
$(".action-download-html").click(
function() {
var content = $("#wmd-preview").html();
var uriContent = "data:application/octet-stream;base64,"
+ core.encodeBase64(content);
window.open(uriContent, 'file');
});
$(".action-download-template").click(
function() {
var content = publisher.applyTemplate();
var uriContent = "data:application/octet-stream;base64,"
+ core.encodeBase64(content);
window.open(uriContent, 'file');
});
// Synchronize actions
$(".action-upload-gdrive-root").click(function() {
uploadGdrive();
});
$(".action-upload-gdrive-select").click(function() {
// This action is not available because picker does not support
// folder selection
googleHelper.picker(function(ids) {
if(ids !== undefined && ids.length !== 0) {
uploadGdrive(undefined, ids[0]);
}
}, true);
});
$(".action-download-gdrive").click(function() {
googleHelper.picker(importGdrive);
});
$(".action-manual-gdrive").click(function(event) {
var fileId = core.getInputValue($("#manual-gdrive-fileid"), event);
manualGdrive(fileId);
});
$(".action-download-dropbox").click(function() {
dropboxHelper.picker(importDropbox);
});
$(".action-upload-dropbox").click(function(event) {
var path = core.getInputValue($("#upload-dropbox-path"), event);
manualDropbox(path);
});
$(".action-manual-dropbox").click(function(event) {
var path = core.getInputValue($("#manual-dropbox-path"), event);
manualDropbox(path);
});
};
return fileManager;
});