Permalink
Browse files

Cleaning up the code a little bit

  • Loading branch information...
1 parent c8a3572 commit b71b8f17fe2f9473dcfcfe7fb96a3fdbf3f4d05c @dmfrancisco committed Jul 12, 2011
Showing with 8 additions and 16 deletions.
  1. +8 −16 public/js/script.js
View
@@ -264,6 +264,7 @@ var escrito = function () {
// Return to saved scroll position of the preview mode
$preview.attr({ scrollTop: scrollPos });
+ $preview.focus();
}
function writeOn() {
@@ -450,9 +451,12 @@ var escrito = function () {
});
}
- /* While codemirror is being loaded */
- function whileLoading() {
+ function init() {
+ $preview = $('#preview');
+ $editbox = $('#editbox');
+
initTipsy();
+ dropdownMenus.init();
markdownConverter = new Showdown.converter();
// Set current parser being used
@@ -492,26 +496,15 @@ var escrito = function () {
initLanguageMenu(); // Manage click events on the language menu
initExportMenu(); // Manage click events on the export menu
dropFile(); // Allow drag-and-drop of text files
- }
- /* When codemirror is ready */
- function complete() {
// Handlers to show & hide toolbar
initToolbar();
// Iphone switch
$('#switch').iphoneSwitch("on", previewOn, writeOn,
$('textarea'), $('#import-button'), { switch_path: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAYCAYAAAAxkDmIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEc0lEQVRoBdVaSy8sQRQ+M5rBio3YEBbikSB2FmJBIpF4/Aj+gF9w7/1JbGY2LFja4A4hglgi8Vh4jMfM7a/uPX2P1nqqqnsmNZV06vWdU+dRp7qqujOTk5M/BwYGcuRguru7K83Ozv7Y3d2l7u5uymQyTkhZqVTo9vaWxsfHaXNz81dnZ6eT9js9PS15HR0dNDU1RS8vL8p4ra2tn8poRF+4XeIZgxw4ruvQxGF2dnbo/v6eVldXaWRkhGBYJDiay37Nb/naLjGyHIWX/bIcheXxj46OKJ/Pk8v2u7m5Ia+vry9wKIRnx9mUbWjixoNsMODg4CBdXl6CvTPJX/Vof3+fcrlcIptJ/aGcrCctw35ZZywWI4hUNAZW167X19e6jmc7mFcul8VyZ8umNnQs2/Pzc20GSM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2dWV4TDxILd/F+O6fDwkB4eHlwR7ZMckPEP561S77cf6FYAAAAASUVORK5CYII=' }); // switch_path: '/images/switch.png'
- }
-
- function init() {
- $preview = $('#preview');
- $editbox = $('#editbox');
- // $editbox.hide();
-
- dropdownMenus.init();
- whileLoading();
+ /* Configure and start the editor */
editor = ace.edit("editor");
editor.setReadOnly(true);
@@ -535,12 +528,11 @@ var escrito = function () {
window.doc = doc;
render(doc.snapshot);
+ $preview.focus();
doc.on('change', function () {
render(doc.snapshot);
});
});
-
- complete();
}
return { init : init };

0 comments on commit b71b8f1

Please sign in to comment.