Browse files

Renamed TwoPanedEditor to EditorPanes, EditorWithToolbar to Editor.

  • Loading branch information...
1 parent 7c0f23f commit 2bed4783c13be597ee77b14374f4f2db8160f02a @toolness toolness committed Aug 28, 2012
View
4 css/editor.css
@@ -89,7 +89,7 @@
z-index: 2;
top: 0;
- height: 40px; /* corresponds with .friendlycode-editor.top */
+ height: 40px; /* corresponds with .friendlycode-panes.top */
width: 100%;
margin: 0;
padding: 0;
@@ -458,7 +458,7 @@
/* ------ CONTENT AREA ------ */
-.friendlycode-editor {
+.friendlycode-panes {
position: absolute;
top: 30px; /* corresponds to .friendlycode-toolbar.height */
left: 0;
View
16 examples/editor-with-toolbar.html → examples/editor-only.html
@@ -4,24 +4,24 @@
<meta charset="utf-8">
<base target="_blank">
- <title>Editor With Toolbar</title>
+ <title>Editor Only</title>
<link rel="stylesheet" href="../css/friendlycode.css">
</head>
<body style="margin: 0">
- <div id="ewt" class="friendlycode-loading"></div>
+ <div id="editor" class="friendlycode-loading"></div>
<script src="../js/require-config.js"></script>
<script src="../js/require.min.js"></script>
<script>
require([
"jquery",
- "fc/ui/editor-with-toolbar"
- ], function($, EditorWithToolbar) {
- var ewt = EditorWithToolbar({
- container: $("#ewt"),
- value: "<p>Just an editor with toolbar widget, no publishing.</p>"
+ "fc/ui/editor"
+ ], function($, Editor) {
+ var editor = Editor({
+ container: $("#editor"),
+ value: "<p>Just an editor widget, no publishing.</p>"
});
- ewt.editor.codeMirror.focus();
+ editor.panes.codeMirror.focus();
});
</script>
</body>
View
2 js/fc/ui/two-paned-editor.js → js/fc/ui/editor-panes.js
@@ -15,7 +15,7 @@ define(function(require) {
require('slowparse-errors');
require("codemirror/html");
- return function Editor(options) {
+ return function EditorPanes(options) {
var self = {},
div = options.container,
initialValue = options.value || "",
View
14 js/fc/ui/editor-toolbar.js
@@ -27,27 +27,27 @@ define(function(require) {
return function Toolbar(options) {
var self = {},
div = options.container,
- editor = options.editor,
+ panes = options.panes,
navOptions = $(NavOptionsTemplate()).appendTo(div),
publishButton = navOptions.find(".publish-button"),
undoNavItem = navOptions.find(".undo-nav-item"),
startPublish;
var historyUI = HistoryUI({
- codeMirror: editor.codeMirror,
+ codeMirror: panes.codeMirror,
undo: undoNavItem,
redo: navOptions.find(".redo-nav-item")
});
var textUI = TextUI({
- codeMirror: editor.codeMirror,
+ codeMirror: panes.codeMirror,
navItem: navOptions.find(".text-nav-item")
});
var hintsUI = HintsUI({
- cursorHelp: editor.cursorHelp,
+ cursorHelp: panes.cursorHelp,
navItem: navOptions.find(".hints-nav-item")
});
- editor.preview.on("refresh", function(event) {
+ panes.preview.on("refresh", function(event) {
var title = event.window.document.title;
if (title.length)
$(".preview-title", navOptions).text(title).show();
@@ -56,8 +56,8 @@ define(function(require) {
});
// If the editor has no content, disable the publish button.
- editor.codeMirror.on("change", function() {
- var codeLength = editor.codeMirror.getValue().trim().length;
+ panes.codeMirror.on("change", function() {
+ var codeLength = panes.codeMirror.getValue().trim().length;
publishButton.toggleClass("enabled", codeLength ? true : false);
});
publishButton.click(function(){
View
18 js/fc/ui/editor-with-toolbar.js → js/fc/ui/editor.js
@@ -1,32 +1,32 @@
define([
"jquery",
- "./two-paned-editor",
+ "./editor-panes",
"./editor-toolbar"
-], function($, TwoPanedEditor, EditorToolbar) {
- return function EditorWithToolbar(options) {
+], function($, EditorPanes, EditorToolbar) {
+ return function Editor(options) {
var value = options.value,
container = options.container.empty()
.addClass("friendlycode-base"),
toolbarDiv = $('<div class="friendlycode-toolbar"></div>')
.appendTo(container),
- editorDiv = $('<div class="friendlycode-editor"></div>')
+ panesDiv = $('<div class="friendlycode-panes"></div>')
.appendTo(container);
- var editor = TwoPanedEditor({
- container: editorDiv,
+ var panes = EditorPanes({
+ container: panesDiv,
value: value
});
var toolbar = EditorToolbar({
container: toolbarDiv,
- editor: editor
+ panes: panes
});
container.removeClass("friendlycode-loading");
- editor.codeMirror.refresh();
+ panes.codeMirror.refresh();
return {
container: container,
- editor: editor,
+ panes: panes,
toolbar: toolbar
};
};
View
32 js/friendlycode.js
@@ -1,6 +1,6 @@
define(function(require) {
var $ = require("jquery"),
- EditorWithToolbar = require("fc/ui/editor-with-toolbar"),
+ Editor = require("fc/ui/editor"),
Modals = require("fc/ui/modals"),
Parachute = require("fc/parachute"),
CurrentPageManager = require("fc/current-page-manager"),
@@ -15,7 +15,7 @@ define(function(require) {
remixURLTemplate = options.remixURLTemplate ||
location.protocol + "//" + location.host +
location.pathname + "#{{VIEW_URL}}",
- ewt = EditorWithToolbar({container: options.container}),
+ editor = Editor({container: options.container}),
ready = $.Deferred();
var modals = Modals({
@@ -25,35 +25,35 @@ define(function(require) {
var publisher = Publisher(publishURL);
var publishUI = PublishUI({
modals: modals,
- codeMirror: ewt.editor.codeMirror,
+ codeMirror: editor.panes.codeMirror,
publisher: publisher,
remixURLTemplate: remixURLTemplate
});
- var parachute = Parachute(window, ewt.editor.codeMirror);
+ var parachute = Parachute(window, editor.panes.codeMirror);
var pageManager = CurrentPageManager({
window: window,
currentPage: pageToLoad
});
function doneLoading() {
- ewt.container.removeClass("friendlycode-loading");
- ewt.editor.codeMirror.clearHistory();
- ewt.toolbar.refresh();
+ editor.container.removeClass("friendlycode-loading");
+ editor.panes.codeMirror.clearHistory();
+ editor.toolbar.refresh();
if (parachute.restore()) {
- ewt.toolbar.showDataRestoreHelp();
+ editor.toolbar.showDataRestoreHelp();
} else {
// Only save data on page unload if it's different from
// the URL we just (hopefully) loaded.
parachute.refresh();
}
- ewt.editor.codeMirror.reparse();
- ewt.editor.codeMirror.focus();
- ewt.editor.codeMirror.refresh();
+ editor.panes.codeMirror.reparse();
+ editor.panes.codeMirror.focus();
+ editor.panes.codeMirror.refresh();
ready.resolve();
}
- ewt.toolbar.setStartPublish(publishUI.start);
- ewt.container.addClass("friendlycode-loading");
+ editor.toolbar.setStartPublish(publishUI.start);
+ editor.container.addClass("friendlycode-loading");
publishUI.on("publish", function(info) {
// If the user clicks their back button, we don't want to show
// them the page they just published--we want to show them the
@@ -74,7 +74,7 @@ define(function(require) {
if (!pageManager.currentPage()) {
setTimeout(function() {
- ewt.editor.codeMirror.setValue(defaultContent);
+ editor.panes.codeMirror.setValue(defaultContent);
doneLoading();
}, 0);
} else
@@ -84,14 +84,14 @@ define(function(require) {
text: 'Sorry, an error occurred while trying to get the page.'
});
} else {
- ewt.editor.codeMirror.setValue(data);
+ editor.panes.codeMirror.setValue(data);
publishUI.setCurrentURL(url);
doneLoading();
}
});
return {
- codeMirror: ewt.editor.codeMirror,
+ codeMirror: editor.panes.codeMirror,
parachute: parachute,
ready: ready
};
View
20 test/test-editor-toolbar.js
@@ -2,18 +2,18 @@
defineTests([
"jquery",
- "fc/ui/two-paned-editor",
+ "fc/ui/editor-panes",
"fc/ui/editor-toolbar"
-], function($, TwoPanedEditor, EditorToolbar) {
- var parentDiv, editorDiv, toolbarDiv, editor, options;
+], function($, EditorPanes, EditorToolbar) {
+ var parentDiv, panesDiv, toolbarDiv, panes, options;
module("EditorToolbar", {
setup: function() {
parentDiv = $('<div></div>').appendTo("#qunit-fixture").hide();
- editorDiv = $('<div></div>').appendTo(parentDiv);
+ panesDiv = $('<div></div>').appendTo(parentDiv);
toolbarDiv = $('<div></div>').appendTo(parentDiv);
- editor = TwoPanedEditor({container: editorDiv});
- options = {editor: editor, container: toolbarDiv};
+ panes = EditorPanes({container: panesDiv});
+ options = {panes: panes, container: toolbarDiv};
},
teardown: function() {
parentDiv.remove();
@@ -22,8 +22,8 @@ defineTests([
test("shows page title when <title> is present", function() {
var toolbar = EditorToolbar(options);
- editor.codeMirror.setValue("<title>supdog</title>");
- editor.codeMirror.reparse();
+ panes.codeMirror.setValue("<title>supdog</title>");
+ panes.codeMirror.reparse();
ok(!$(".preview-title", toolbarDiv).attr("style"),
"navbar preview title is not hidden");
equal($(".preview-title", toolbarDiv).text(), "supdog",
@@ -32,8 +32,8 @@ defineTests([
test("doesn't show page title when <title> is absent", function() {
var toolbar = EditorToolbar(options);
- editor.codeMirror.setValue("<p>hello</p>");
- editor.codeMirror.reparse();
+ panes.codeMirror.setValue("<p>hello</p>");
+ panes.codeMirror.reparse();
ok($(".preview-title", toolbarDiv).attr("style").match(/display:\s*none/),
"navbar preview title is hidden");
});

0 comments on commit 2bed478

Please sign in to comment.