").addClass("input-append");
if (fileSyncIndex.indexOf(SYNC_PROVIDER_GDRIVE) === 0) {
line.append($("
").prop("type", "text").prop(
"disabled", true).addClass("span5").val(
"Google Drive, FileID="
+ fileSyncIndex.substring(SYNC_PROVIDER_GDRIVE.length)));
line.append($("
").addClass("btn").html(
'').prop("title",
"Remove this synchronized location").click(function() {
fileManager.removeSync(fileSyncIndex);
fileManager.updateFileTitles();
refreshManageSync();
}));
}
$("#manage-sync-list").append(line);
})(fileSyncIndex);
}
}
return fileManager;
})(jQuery);
var core = (function($) {
var core = {};
core.init = function() {
this.loadSettings();
this.createLayout();
$(".action-load-settings").click(function() {
core.loadSettings();
});
$(".action-apply-settings").click(function() {
core.saveSettings();
fileManager.saveFile();
location.reload();
});
};
var settings = { layoutOrientation : "horizontal" };
core.loadSettings = function() {
if (localStorage.settings) {
$.extend(settings, JSON.parse(localStorage.settings));
}
// Layout orientation
$(
"input:radio[name=radio-layout-orientation][value="
+ settings.layoutOrientation + "]").prop("checked", true);
};
core.saveSettings = function() {
// Layout orientation
settings.layoutOrientation = $(
"input:radio[name=radio-layout-orientation]:checked").prop("value");
localStorage.settings = JSON.stringify(settings);
};
core.createLayout = function() {
var layout = undefined;
var layoutGlobalConfig = { closable : true, resizable : false,
slidable : false, livePaneResizing : true,
enableCursorHotkey : false, spacing_open : 15, spacing_closed : 15,
togglerLength_open : 90, togglerLength_closed : 90,
center__minWidth : 100, center__minHeight : 100,
stateManagement__enabled : false, };
if (settings.layoutOrientation == "horizontal") {
$(".ui-layout-south").remove();
$(".ui-layout-east").addClass("well").prop("id", "wmd-preview");
layout = $('body').layout(
$.extend(layoutGlobalConfig, { east__resizable : true,
east__size : .5, east__minSize : 200 }));
} else if (settings.layoutOrientation == "vertical") {
$(".ui-layout-east").remove();
$(".ui-layout-south").addClass("well").prop("id", "wmd-preview");
layout = $('body').layout(
$.extend(layoutGlobalConfig, { south__resizable : true,
south__size : .5, south__minSize : 200 }));
}
$(".ui-layout-toggler-north").addClass("btn").append(
$("").addClass("caret"));
$(".ui-layout-toggler-south").addClass("btn").append(
$("").addClass("caret"));
$(".ui-layout-toggler-east").addClass("btn").append(
$("").addClass("caret"));
$("#navbar").click(function() {
layout.allowOverflow('north');
});
};
core.createEditor = function(onTextChange) {
$("#wmd-button-bar").empty();
var converter = Markdown.getSanitizingConverter();
var firstChange = true;
converter.hooks.chain("preConversion", function(text) {
if (!firstChange) {
onTextChange();
}
return text;
});
var editor = new Markdown.Editor(converter);
editor.run();
firstChange = false;
$(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)")
.addClass("btn").css("left", 0).find("span").hide();
$("#wmd-bold-button").append($("").addClass("icon-bold"));
$("#wmd-italic-button").append($("").addClass("icon-italic"));
$("#wmd-link-button").append($("").addClass("icon-globe"));
$("#wmd-quote-button").append($("").addClass("icon-indent-left"));
$("#wmd-code-button").append($("").addClass("icon-code"));
$("#wmd-image-button").append($("").addClass("icon-picture"));
$("#wmd-olist-button").append($("").addClass("icon-numbered-list"));
$("#wmd-ulist-button").append($("").addClass("icon-list"));
$("#wmd-heading-button").append($("").addClass("icon-text-height"));
$("#wmd-hr-button").append($("").addClass("icon-hr"));
$("#wmd-undo-button").append($("").addClass("icon-undo"));
$("#wmd-redo-button").append($("").addClass("icon-share-alt"));
};
return core;
})(jQuery);
(function($) {
$(function() {
// jGrowl configuration
$.jGrowl.defaults.life = 5000;
$.jGrowl.defaults.closer = false;
$.jGrowl.defaults.closeTemplate = '';
$.jGrowl.defaults.position = 'bottom-right';
core.init();
// listen to online/offline events
$(window).on('offline', onOffline);
$(window).on('online', onOnline);
if (navigator.onLine === false) {
onOffline();
}
if (typeof (Storage) !== "undefined") {
fileManager.init();
} else {
showError("Local storage is not available");
}
});
})(jQuery);