mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
editing features, part 1
This commit is contained in:
8
app.js
8
app.js
@@ -20,11 +20,11 @@ global.configuration = {};
|
||||
if (data.categories.length === 0) {
|
||||
console.log('Setting up default categories...');
|
||||
|
||||
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) {
|
||||
categories = JSON.parse(categories);
|
||||
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) {
|
||||
default_categories = JSON.parse(default_categories);
|
||||
|
||||
for (var category in categories) {
|
||||
categories.create(categories[category]);
|
||||
for (var category in default_categories) {
|
||||
categories.create(default_categories[category]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -274,7 +274,33 @@ var socket,
|
||||
}, false);
|
||||
|
||||
// Posting
|
||||
var formattingBar = document.getElementById('formatting-bar'),
|
||||
postContentEl = document.getElementById('post_content');
|
||||
jQuery('#post_window').slideToggle(0);
|
||||
formattingBar.addEventListener('click', function(e) {
|
||||
if (e.target.nodeName === 'I') {
|
||||
switch(e.target.className) {
|
||||
case 'icon-bold':
|
||||
var cursorEnd = postContentEl.value.length;
|
||||
postContentEl.value = postContentEl.value + '**bolded text**';
|
||||
postContentEl.selectionStart = cursorEnd+2;
|
||||
postContentEl.selectionEnd = postContentEl.value.length - 2;
|
||||
break;
|
||||
case 'icon-italic':
|
||||
var cursorEnd = postContentEl.value.length;
|
||||
postContentEl.value = postContentEl.value + '*italicised text*';
|
||||
postContentEl.selectionStart = cursorEnd+1;
|
||||
postContentEl.selectionEnd = postContentEl.value.length - 1;
|
||||
break;
|
||||
case 'icon-list':
|
||||
var cursorEnd = postContentEl.value.length;
|
||||
postContentEl.value = postContentEl.value + "\n\n* list item";
|
||||
postContentEl.selectionStart = cursorEnd+4;
|
||||
postContentEl.selectionEnd = postContentEl.value.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@
|
||||
<div class="container">
|
||||
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<div class="btn-group" id="formatting-bar">
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-bold"></i></span>
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-italic"></i></span>
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-font"></i></span>
|
||||
<!-- <span class="btn btn-link" tabindex="-1"><i class="icon-font"></i></span> -->
|
||||
<span class="btn btn-link" tabindex="-1"><i class="icon-list"></i></span>
|
||||
</div>
|
||||
<div class="btn-group" style="float: right; margin-right: -12px">
|
||||
|
||||
Reference in New Issue
Block a user