Permalink
Browse files

load default title and content by js

  • Loading branch information...
1 parent 388938e commit 04dba95fe11736503ee9b3e1e93f574b3a4db35c @stegben stegben committed Apr 18, 2016
Showing with 26 additions and 35 deletions.
  1. +3 −29 index.html
  2. +2 −0 js/default.js
  3. +21 −6 js/editor.js
View
@@ -94,35 +94,8 @@
<section>
- <header contenteditable="true" class="header">
- This is ZenPen
- </header>
-
- <article contenteditable="true" class="content">
-
- <p>
- A minimalist writing zone, where you can block out all distractions and get to what's important. The writing!
- </p>
-
- <p>
- To get started, all you need to do is delete this text (seriously, just highlight it and hit delete), and fill the page with your own fantastic words. You can even change the title!
- </p>
-
- <p>
- You can use <b>bold</b>, <i>italics</i>, <b><i>both</i></b> and <a href="http://zenpen.io"> urls </a> just by highlighting the text and selecting them from the tiny options box that appears above it.
- </p>
-
- <blockquote>
- Quotes are easy to add too!
- </blockquote>
-
- <p>
- For <i>questions</i> and <b>open source info</b>, Click that little question mark at the bottom left of the screen.
- </p>
-
- <p>Happy Typing! ~ <b>Tim Holman (@twholman)</b></p>
-
- </article>
+ <header contenteditable="true" class="header"></header>
+ <article contenteditable="true" class="content"></article>
</section>
@@ -132,6 +105,7 @@
<script src="js/libs/screenfull.min.js"></script>
<!-- JS -->
+ <script src="js/default.js"></script>
<script src="js/utils.js"></script>
<script src="js/editor.js"></script>
<script src="js/ui.js"></script>
View
@@ -0,0 +1,2 @@
+var defaultTitle = 'This is ZenPen';
+var defaultContent = 'Hello World';
View
@@ -15,19 +15,21 @@ ZenPen.editor = (function() {
composing = false;
bindElements();
+ createEventBindings();
+
+ // Load state if storage is supported
+ if ( ZenPen.util.supportsHtmlStorage() ) {
+ loadState();
+ } else {
+ loadDefault();
+ }
// Set cursor position
var range = document.createRange();
var selection = window.getSelection();
range.setStart(headerField, 1);
selection.removeAllRanges();
selection.addRange(range);
- createEventBindings();
-
- // Load state if storage is supported
- if ( ZenPen.util.supportsHtmlStorage() ) {
- loadState();
- }
}
function createEventBindings() {
@@ -228,13 +230,26 @@ ZenPen.editor = (function() {
if ( localStorage[ 'header' ] ) {
headerField.innerHTML = localStorage[ 'header' ];
+ } else {
+ headerField.innerHTML = defaultTitle; // in default.js
}
if ( localStorage[ 'content' ] ) {
contentField.innerHTML = localStorage[ 'content' ];
+ } else {
+ loadDefaultContent()
}
}
+ function loadDefault() {
+ headerField.innerHTML = defaultTitle; // in default.js
+ loadDefaultContent();
+ }
+
+ function loadDefaultContent() {
+ contentField.innerHTML = defaultContent; // in default.js
+ }
+
function onBoldClick() {
document.execCommand( 'bold', false );
}

1 comment on commit 04dba95

@IamJowhar

Which font is used?

Please sign in to comment.