aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-09-01 13:57:45 +0200
committerMario Vavti <mario@mariovavti.com>2016-09-01 13:57:45 +0200
commit24192ff1eff7df9a46f13349a043507f8fd9034e (patch)
tree72d38e68db0f46d4ffc7ab9cada8c918af128692
parent6adb18091124cd51e1bf8a2efae31cb83a0db075 (diff)
downloadvolse-hubzilla-24192ff1eff7df9a46f13349a043507f8fd9034e.tar.gz
volse-hubzilla-24192ff1eff7df9a46f13349a043507f8fd9034e.tar.bz2
volse-hubzilla-24192ff1eff7df9a46f13349a043507f8fd9034e.zip
introduce checklist BBcode for checklists
-rw-r--r--include/bbcode.php6
-rw-r--r--view/css/conversation.css3
-rw-r--r--view/js/autocomplete.js13
3 files changed, 14 insertions, 8 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 9c65afc59..bc543ca48 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -768,13 +768,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
}
// Check for list text
$Text = str_replace("[*]", "<li>", $Text);
- $Text = str_replace("[]", "<li><input class=\"listcheckbox\" type=\"checkbox\" disabled=\"disabled\">", $Text);
- $Text = str_replace("[x]", "<li><input class=\"listcheckbox\" type=\"checkbox\" checked=\"checked\" disabled=\"disabled\">", $Text);
+ $Text = str_replace("[]", "<li><input type=\"checkbox\" disabled=\"disabled\">", $Text);
+ $Text = str_replace("[x]", "<li><input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\">", $Text);
// handle nested lists
$endlessloop = 0;
while ((((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)) ||
+ ((strpos($Text, "[/checklist]") !== false) && (strpos($Text, "[checklist]") !== false)) ||
((strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false)) ||
((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false)) ||
((strpos($Text, "[/dl]") !== false) && (strpos($Text, "[dl") !== false)) ||
@@ -786,6 +787,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '<ul class="listupperroman" style="list-style-type: upper-roman;">$2</ul>', $Text);
$Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$2</ul>', $Text);
$Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$2</ul>', $Text);
+ $Text = preg_replace("/\[checklist\](.*?)\[\/checklist\]/ism", '<ul class="checklist" style="list-style-type: none;">$1</ul>', $Text);
$Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>', $Text);
$Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>', $Text);
$Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>', $Text);
diff --git a/view/css/conversation.css b/view/css/conversation.css
index 6acca4b0d..4f2eee17d 100644
--- a/view/css/conversation.css
+++ b/view/css/conversation.css
@@ -320,7 +320,8 @@ img.smiley.emoji:hover {
height: 32px;
}
-input.listcheckbox {
+
+.checklist input {
margin: 0px;
vertical-align: middle;
}
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 63f1e9a13..62a3b6f06 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -102,8 +102,8 @@ function submit_form(e) {
function getWord(text, caretPos) {
var index = text.indexOf(caretPos);
- var postText = text.substring(caretPos, caretPos+8);
- if ((postText.indexOf('[/list]') > 0) || postText.indexOf('[/ul]') > 0 || postText.indexOf('[/ol]') > 0 || postText.indexOf('[/dl]') > 0) {
+ var postText = text.substring(caretPos, caretPos+13);
+ if (postText.indexOf('[/list]') > 0 || postText.indexOf('[/checklist]') > 0 || postText.indexOf('[/ul]') > 0 || postText.indexOf('[/ol]') > 0 || postText.indexOf('[/dl]') > 0) {
return postText;
}
}
@@ -140,10 +140,11 @@ function listNewLineAutocomplete(id) {
var text = document.getElementById(id);
var caretPos = getCaretPosition(text)
var word = getWord(text.value, caretPos);
+
if (word != null) {
var textBefore = text.value.substring(0, caretPos);
var textAfter = text.value.substring(caretPos, text.length);
- var textInsert = (word.indexOf('[/dl]') > 0) ? '\r\n[*=] ' : '\r\n[*] ';
+ var textInsert = (word.indexOf('[/dl]') > 0) ? '\r\n[*=] ' : (word.indexOf('[/checklist]') > 0) ? '\r\n[] ' : '\r\n[*] ';
var caretPositionDiff = (word.indexOf('[/dl]') > 0) ? 3 : 1;
$('#' + id).val(textBefore + textInsert + textAfter);
@@ -268,7 +269,7 @@ function string2bb(element) {
$.fn.bbco_autocomplete = function(type) {
if(type=='bbcode') {
- var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer'];
+ var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer'];
var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ];
var elements = open_close_elements.concat(open_elements);
@@ -300,7 +301,9 @@ function string2bb(element) {
element = string2bb(element);
if(open_elements.indexOf(element) < 0) {
if(element === 'list' || element === 'ol' || element === 'ul') {
- return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]'];
+ return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]'];
+ } else if(element === 'checklist') {
+ return ['\[' + element + '\]' + '\n\[\] ', '\n\[/' + element + '\]'];
} else if (element === 'dl') {
return ['\[' + element + '\]' + '\n\[*=Item name\] ', '\n\[/' + element + '\]'];
} else if(element === 'table') {