Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.

create a simple Bullet List plugin so we need less html #218

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ require.define("/lib/legacy.coffee", function (require, module, exports, __dirna
wiki.log('useLocalStorage', $(".login").length > 0);
return $(".login").length > 0;
};
textEditor = wiki.textEditor = function(div, item) {
textEditor = wiki.textEditor = function(div, item, help) {
var original, textarea, _ref;
textarea = $("<textarea>" + (original = (_ref = item.text) != null ? _ref : '') + "</textarea>").focusout(function() {
textarea = $("<textarea>" + (original = (_ref = item.text) != null ? _ref : '') + "</textarea>").attr('title', help || 'help').focusout(function() {
if (item.text = textarea.val()) {
plugin["do"](div.empty(), item);
if (item.text === original) return;
Expand Down
3 changes: 2 additions & 1 deletion client/lib/legacy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ $ ->
wiki.log 'useLocalStorage', $(".login").length > 0
$(".login").length > 0

textEditor = wiki.textEditor = (div, item) ->
textEditor = wiki.textEditor = (div, item, help) ->
textarea = $("<textarea>#{original = item.text ? ''}</textarea>")
.attr('title', help || 'edit paragraph')
.focusout ->
if item.text = textarea.val()
plugin.do div.empty(), item
Expand Down
14 changes: 14 additions & 0 deletions client/plugins/lists.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Simple bullet list editor
# renders a new bullet foreach line - blank lines are still a bullet
# spaces are lost

window.plugins.lists =
description: "Simple Bullet list editor"
help: "creates a new bullet point per line"
emit: (div, item) ->
wiki.log 'lists', item
for line in item.text.split "\n"
div.append $('<li/>').append(wiki.resolveLinks(line))
bind: (div, item) ->
div.dblclick -> wiki.textEditor div, item, window.plugins.lists.help

25 changes: 25 additions & 0 deletions client/plugins/lists.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/express/lib/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ module.exports = exports = (argv) ->
window.catalog = {
"ByteBeat": {"menu": "8-bit Music by Formula"},
"MathJax": {"menu": "TeX Formatted Equations"},
"Calculator": {"menu": "Running Sums for Expenses"}
"Calculator": {"menu": "Running Sums for Expenses"},
"Lists": {"menu": "create a list of items"}
};

"""
Expand Down