From eddff9e8634a89ea637da3c312ddf74b152c7ae2 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 17 Jan 2016 09:56:36 -0600 Subject: Added editor placeholder and auto set mode by content existence --- public/js/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 86771fde..3ba9ee5e 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -236,7 +236,8 @@ var editor = CodeMirror.fromTextArea(textit, { extraKeys: defaultExtraKeys, flattenSpans: true, addModeClass: true, - readOnly: true + readOnly: true, + placeholder: "← Start by enter title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)" }); var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor); defaultTextHeight = parseInt($(".CodeMirror").css('line-height')); @@ -1214,7 +1215,18 @@ socket.on('refresh', function (data) { updateLastChange(); updateLastChangeUser(data); if (!loaded) { + var nocontent = editor.getValue().length <= 0; + if (nocontent) { + if (visibleXS) + currentMode = modeType.edit; + else + currentMode = modeType.both; + } changeMode(currentMode); + if (nocontent) { + editor.focus(); + editor.refresh(); + } loaded = true; emitUserStatus(); //send first user status updateOnlineStatus(); //update first online status -- cgit v1.2.3