diff options
author | redmatrix <mike@macgirvin.com> | 2016-09-01 12:45:13 -0700 |
---|---|---|
committer | redmatrix <mike@macgirvin.com> | 2016-09-01 12:45:13 -0700 |
commit | 2940f9591b201e5014f3967a90a402c96ae08ac4 (patch) | |
tree | cca4f2de4ff6a76e165c5db9769e3f9fd51c2982 /view/js/autocomplete.js | |
parent | 2ebb8851f684be467ae768fdac0eead1a636805c (diff) | |
parent | 24192ff1eff7df9a46f13349a043507f8fd9034e (diff) | |
download | volse-hubzilla-2940f9591b201e5014f3967a90a402c96ae08ac4.tar.gz volse-hubzilla-2940f9591b201e5014f3967a90a402c96ae08ac4.tar.bz2 volse-hubzilla-2940f9591b201e5014f3967a90a402c96ae08ac4.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r-- | view/js/autocomplete.js | 13 |
1 files changed, 8 insertions, 5 deletions
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') { |