summaryrefslogtreecommitdiff
path: root/public/editor
diff options
context:
space:
mode:
Diffstat (limited to 'public/editor')
-rw-r--r--public/editor/editor.js35
-rw-r--r--public/editor/style.css23
2 files changed, 57 insertions, 1 deletions
diff --git a/public/editor/editor.js b/public/editor/editor.js
index 2d99674..17cc24e 100644
--- a/public/editor/editor.js
+++ b/public/editor/editor.js
@@ -29,8 +29,43 @@ $(function () {
$('.editable').focus(function(){
$('.placeholder').removeClass('placeholder');
});
+
+ $.post('/editor/test-login', {}, function(response) {
+ $('#publish_btn').text(response.logged_in ? 'Publish' : 'Sign In');
+ });
+
+ $('#publish_btn').click(function(){
+ if($('#publish_btn').text() == 'Publish') {
+
+ $.post('/editor/publish', {
+ name: $("#post-name").val(),
+ body: editor.serialize().content.value
+ }, function(response) {
+ if(response.location) {
+ reset_page().then(function(){
+ window.location = response.location;
+ });
+ }
+ });
+
+ } else {
+ var url = prompt("Enter your URL");
+ window.location = '/auth/start?me=' + encodeURIComponent(url) + '&redirect=/editor';
+ }
+ });
+
+ $('#new_btn').click(function(){
+ reset_page();
+ });
});
+function reset_page() {
+ $("#post-name").val('');
+ $("#content").html('<p class="placeholder">Write something nice...</p>');
+ $("#draft-status").text("New");
+ return localforage.setItem('currentdraft', {});
+}
+
/* ************************************************ */
/* autosave loop */
var autosaveTimeout = false;
diff --git a/public/editor/style.css b/public/editor/style.css
index 8b91825..8b0fae6 100644
--- a/public/editor/style.css
+++ b/public/editor/style.css
@@ -39,19 +39,40 @@ img { border: 0; }
}
.toolbar-right {
float: right;
+ margin-right: 40px;
}
.toolbar-left .item {
margin-right: 8px;
display: inline-block;
}
+.toolbar-left .logo {
+ vertical-align: middle;
+}
#draft-status {
- font-size: 18px;
color: #aaa;
+ font-family: sans-serif;
+ font-size: 16px;
}
.toolbar .clear {
clear: both;
}
+.toolbar .btn {
+ height: 38px;
+ -webkit-border-radius: 999px;
+ -moz-border-radius: 999px;
+ border-radius: 999px;
+ display: inline-block;
+ padding: 0 24px;
+ background: rgba(0,0,0,0);
+ font-size: 14px;
+ text-decoration: none;
+ text-align: center;
+ border: 1px #93dee5 solid;
+ color: #60b1b8;
+ vertical-align: middle;
+ cursor: pointer;
+}
/* ************************************** */
/* Editor CSS */