Add settings panel
This commit is contained in:
parent
5bd0925a2b
commit
6f69c07a71
@ -20,13 +20,11 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#wmd-input {
|
#wmd-input {
|
||||||
left: 20px;
|
|
||||||
font-family: "Courier New", Courier, monospace;
|
font-family: "Courier New", Courier, monospace;
|
||||||
resize: none;
|
resize: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wmd-preview {
|
#wmd-preview {
|
||||||
left: 50%;
|
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
45
index.html
45
index.html
@ -53,8 +53,8 @@
|
|||||||
href="javascript:void(0);" title="Create a local file"><i
|
href="javascript:void(0);" title="Create a local file"><i
|
||||||
class="icon-file"></i></a> <a class="btn" href="javascript:void(0);"
|
class="icon-file"></i></a> <a class="btn" href="javascript:void(0);"
|
||||||
title="Delete the current file locally" data-toggle="modal"
|
title="Delete the current file locally" data-toggle="modal"
|
||||||
data-target="#remove-file-confirm"><i class="icon-trash"></i></a> <a
|
data-target="#modal-remove-file-confirm"><i class="icon-trash"></i></a>
|
||||||
class="btn dropdown-toggle" data-toggle="dropdown" href="#"
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"
|
||||||
title="Open a local file"><i class="icon-folder-open"></i></a>
|
title="Open a local file"><i class="icon-folder-open"></i></a>
|
||||||
<ul id="file-selector" class="dropdown-menu">
|
<ul id="file-selector" class="dropdown-menu">
|
||||||
</ul></li>
|
</ul></li>
|
||||||
@ -67,10 +67,15 @@
|
|||||||
file</a></li>
|
file</a></li>
|
||||||
<li><a href="javascript:void(0);"
|
<li><a href="javascript:void(0);"
|
||||||
title="Delete the current file locally" data-toggle="modal"
|
title="Delete the current file locally" data-toggle="modal"
|
||||||
data-target="#remove-file-confirm"><i class="icon-trash"></i>
|
data-target="#modal-remove-file-confirm"><i
|
||||||
Remove file</a></li>
|
class="icon-trash"></i> Remove file</a></li>
|
||||||
<li><a id="drive-link" href="javascript:void(0);"><i
|
<li><a id="drive-link" href="javascript:void(0);"><i
|
||||||
class="icon-magnet"></i> Link with Google Drive</a></li>
|
class="icon-magnet"></i> Link with Google Drive</a></li>
|
||||||
|
<li class="divider"></li>
|
||||||
|
<li><a href="javascript:void(0);"
|
||||||
|
title="Modify your preferences" data-toggle="modal"
|
||||||
|
data-target="#modal-settings"><i class="icon-cog"></i>
|
||||||
|
Settings</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
@ -84,7 +89,8 @@
|
|||||||
<textarea id="wmd-input" class="ui-layout-center"></textarea>
|
<textarea id="wmd-input" class="ui-layout-center"></textarea>
|
||||||
<div class="ui-layout-east"></div>
|
<div class="ui-layout-east"></div>
|
||||||
<div class="ui-layout-south"></div>
|
<div class="ui-layout-south"></div>
|
||||||
<div id="remove-file-confirm" class="modal hide">
|
|
||||||
|
<div id="modal-remove-file-confirm" class="modal hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal"
|
<button type="button" class="close" data-dismiss="modal"
|
||||||
aria-hidden="true">×</button>
|
aria-hidden="true">×</button>
|
||||||
@ -102,5 +108,34 @@
|
|||||||
class="btn btn-primary action-remove-file" data-dismiss="modal">Delete</a>
|
class="btn btn-primary action-remove-file" data-dismiss="modal">Delete</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="modal-settings" class="modal hide">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"
|
||||||
|
aria-hidden="true">×</button>
|
||||||
|
<h3>Settings</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Layout orientation</dt>
|
||||||
|
<dd>
|
||||||
|
<label class="radio"> <input type="radio"
|
||||||
|
name="radio-layout-orientation"
|
||||||
|
id="radio-layout-orientation-horizontal">
|
||||||
|
Horizontal
|
||||||
|
</label> <label class="radio"> <input type="radio"
|
||||||
|
name="radio-layout-orientation"
|
||||||
|
id="radio-layout-orientation-vertical">
|
||||||
|
Vertical
|
||||||
|
</label>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="javascript:void(0);" class="btn action-load-settings" data-dismiss="modal">Cancel</a>
|
||||||
|
<a href="javascript:void(0);" class="btn btn-primary action-apply-settings"
|
||||||
|
data-dismiss="modal">OK</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
147
js/main.js
147
js/main.js
@ -56,7 +56,7 @@ var fileManager = (function($) {
|
|||||||
// Update the editor and the file title
|
// Update the editor and the file title
|
||||||
var fileIndex = localStorage["file.current"];
|
var fileIndex = localStorage["file.current"];
|
||||||
$("#wmd-input").val(localStorage[fileIndex + ".content"]);
|
$("#wmd-input").val(localStorage[fileIndex + ".content"]);
|
||||||
createEditor();
|
core.createEditor();
|
||||||
this.updateFileTitleUI();
|
this.updateFileTitleUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -222,70 +222,111 @@ var gdrive = (function($) {
|
|||||||
return gdrive;
|
return gdrive;
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
function createEditor() {
|
var core = (function($) {
|
||||||
$("#wmd-button-bar").empty();
|
var core = {};
|
||||||
var converter = Markdown.getSanitizingConverter();
|
|
||||||
var editor = new Markdown.Editor(converter);
|
|
||||||
editor.run();
|
|
||||||
|
|
||||||
$(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)")
|
core.init = function() {
|
||||||
.addClass("btn").css("left", 0).find("span").hide();
|
this.loadSettings();
|
||||||
$("#wmd-bold-button").append($("<i>").addClass("icon-bold"));
|
this.saveSettings();
|
||||||
$("#wmd-italic-button").append($("<i>").addClass("icon-italic"));
|
this.createLayout();
|
||||||
$("#wmd-link-button").append($("<i>").addClass("icon-globe"));
|
|
||||||
$("#wmd-quote-button").append($("<i>").addClass("icon-indent-left"));
|
|
||||||
$("#wmd-code-button").append($("<i>").addClass("icon-code"));
|
|
||||||
$("#wmd-image-button").append($("<i>").addClass("icon-picture"));
|
|
||||||
$("#wmd-olist-button").append($("<i>").addClass("icon-numbered-list"));
|
|
||||||
$("#wmd-ulist-button").append($("<i>").addClass("icon-list"));
|
|
||||||
$("#wmd-heading-button").append($("<i>").addClass("icon-text-height"));
|
|
||||||
$("#wmd-hr-button").append($("<i>").addClass("icon-hr"));
|
|
||||||
$("#wmd-undo-button").append($("<i>").addClass("icon-undo"));
|
|
||||||
$("#wmd-redo-button").append($("<i>").addClass("icon-share-alt"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var layoutOrientation = 0;
|
$(".action-apply-settings").click(function() {
|
||||||
var layout;
|
core.saveSettings();
|
||||||
function createLayout() {
|
fileManager.saveFile();
|
||||||
var layoutGlobalConfig = { closable : true, resizable : false,
|
location.reload();
|
||||||
slidable : false, livePaneResizing : true, spacing_open : 20,
|
});
|
||||||
spacing_closed : 20, togglerLength_open : 90,
|
};
|
||||||
togglerLength_closed : 90, center__minWidth : 100, center__minHeight : 100,
|
|
||||||
stateManagement__enabled : false, };
|
var settings = {};
|
||||||
if (layoutOrientation === 0) {
|
core.loadSettings = function() {
|
||||||
$(".ui-layout-east").addClass("well").attr("id", "wmd-preview");
|
if(localStorage.settings) {
|
||||||
layout = $('body').layout(
|
settings = JSON.parse(localStorage.settings);
|
||||||
$.extend(layoutGlobalConfig,
|
}
|
||||||
{ east__resizable : true, east__size : .5, east__minSize : 200,
|
|
||||||
south__closable : false, }));
|
// Layout orientation
|
||||||
} else if (layoutOrientation === 1) {
|
$("#radio-layout-orientation-horizontal").attr('checked', true);
|
||||||
$(".ui-layout-east").remove();
|
if(settings.layoutOrientation == "vertical") {
|
||||||
$(".ui-layout-south").addClass("well").attr("id", "wmd-preview");
|
$("#radio-layout-orientation-vertical").attr('checked', true);
|
||||||
layout = $('body').layout(
|
}
|
||||||
$.extend(layoutGlobalConfig, { south__resizable : true,
|
};
|
||||||
south__size : .5, south__minSize : 200, }));
|
|
||||||
}
|
core.saveSettings = function() {
|
||||||
$(".ui-layout-toggler-north").addClass("btn").append(
|
|
||||||
$("<b>").addClass("caret"));
|
// Layout orientation
|
||||||
$(".ui-layout-toggler-south").addClass("btn").append(
|
settings.layoutOrientation = "horizontal";
|
||||||
$("<b>").addClass("caret"));
|
if($("#radio-layout-orientation-vertical").is(":checked")) {
|
||||||
$(".ui-layout-toggler-east").addClass("btn").append(
|
settings.layoutOrientation = "vertical";
|
||||||
$("<b>").addClass("caret"));
|
}
|
||||||
}
|
|
||||||
|
localStorage.settings = JSON.stringify(settings);
|
||||||
|
};
|
||||||
|
|
||||||
|
core.createLayout = function() {
|
||||||
|
var layout = undefined;
|
||||||
|
var layoutGlobalConfig = { closable : true, resizable : false,
|
||||||
|
slidable : false, livePaneResizing : true, spacing_open : 20,
|
||||||
|
spacing_closed : 20, togglerLength_open : 90,
|
||||||
|
togglerLength_closed : 90, center__minWidth : 100, center__minHeight : 100,
|
||||||
|
stateManagement__enabled : false, };
|
||||||
|
if (settings.layoutOrientation == "horizontal") {
|
||||||
|
$(".ui-layout-east").addClass("well").attr("id", "wmd-preview");
|
||||||
|
layout = $('body').layout(
|
||||||
|
$.extend(layoutGlobalConfig,
|
||||||
|
{ east__resizable : true, east__size : .5, east__minSize : 200,
|
||||||
|
south__closable : false, }));
|
||||||
|
} else if (settings.layoutOrientation == "vertical") {
|
||||||
|
$(".ui-layout-east").remove();
|
||||||
|
$(".ui-layout-south").addClass("well").attr("id", "wmd-preview");
|
||||||
|
layout = $('body').layout(
|
||||||
|
$.extend(layoutGlobalConfig, { south__resizable : true,
|
||||||
|
south__size : .5, south__minSize : 200, }));
|
||||||
|
}
|
||||||
|
$(".ui-layout-toggler-north").addClass("btn").append(
|
||||||
|
$("<b>").addClass("caret"));
|
||||||
|
$(".ui-layout-toggler-south").addClass("btn").append(
|
||||||
|
$("<b>").addClass("caret"));
|
||||||
|
$(".ui-layout-toggler-east").addClass("btn").append(
|
||||||
|
$("<b>").addClass("caret"));
|
||||||
|
$("#navbar").click(function() {
|
||||||
|
layout.allowOverflow('north');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
core.createEditor = function() {
|
||||||
|
$("#wmd-button-bar").empty();
|
||||||
|
var converter = Markdown.getSanitizingConverter();
|
||||||
|
var editor = new Markdown.Editor(converter);
|
||||||
|
editor.run();
|
||||||
|
|
||||||
|
$(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)")
|
||||||
|
.addClass("btn").css("left", 0).find("span").hide();
|
||||||
|
$("#wmd-bold-button").append($("<i>").addClass("icon-bold"));
|
||||||
|
$("#wmd-italic-button").append($("<i>").addClass("icon-italic"));
|
||||||
|
$("#wmd-link-button").append($("<i>").addClass("icon-globe"));
|
||||||
|
$("#wmd-quote-button").append($("<i>").addClass("icon-indent-left"));
|
||||||
|
$("#wmd-code-button").append($("<i>").addClass("icon-code"));
|
||||||
|
$("#wmd-image-button").append($("<i>").addClass("icon-picture"));
|
||||||
|
$("#wmd-olist-button").append($("<i>").addClass("icon-numbered-list"));
|
||||||
|
$("#wmd-ulist-button").append($("<i>").addClass("icon-list"));
|
||||||
|
$("#wmd-heading-button").append($("<i>").addClass("icon-text-height"));
|
||||||
|
$("#wmd-hr-button").append($("<i>").addClass("icon-hr"));
|
||||||
|
$("#wmd-undo-button").append($("<i>").addClass("icon-undo"));
|
||||||
|
$("#wmd-redo-button").append($("<i>").addClass("icon-share-alt"));
|
||||||
|
};
|
||||||
|
|
||||||
|
return core;
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
createLayout();
|
core.init();
|
||||||
if (typeof (Storage) !== "undefined") {
|
if (typeof (Storage) !== "undefined") {
|
||||||
fileManager.init();
|
fileManager.init();
|
||||||
} else {
|
} else {
|
||||||
showError("Web storage is not available");
|
showError("Web storage is not available");
|
||||||
}
|
}
|
||||||
$("#navbar").click(function() {
|
|
||||||
layout.allowOverflow('north');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user