diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-04-04 17:12:23 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-04-04 17:12:23 +0200 |
commit | ec651f219e10c71a493e0cd2b4737077aee826dc (patch) | |
tree | 35beb43002ad4c57da0d19db821aa989b915a245 /view/js/autocomplete.js | |
parent | bba34a7a8e5b62017d917808d50165cfd9f3d2e7 (diff) | |
download | volse-hubzilla-ec651f219e10c71a493e0cd2b4737077aee826dc.tar.gz volse-hubzilla-ec651f219e10c71a493e0cd2b4737077aee826dc.tar.bz2 volse-hubzilla-ec651f219e10c71a493e0cd2b4737077aee826dc.zip |
a simple autocomplete for bbcode or comanche - partly implemented
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r-- | view/js/autocomplete.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 437425a0e..b6e81eb8c 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -197,3 +197,43 @@ function submit_form(e) { a.on('textComplete:select', function(e, value, strategy) { onselect(value); }); }; })( jQuery ); + +(function( $ ) { + $.fn.bbco_autocomplete = function(type) { + + if(type=='bbcode') { + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'observer']; + var open_elements = ['observer.photo', 'observer.name', 'observer.url']; + + var elements = open_close_elements.concat(open_elements); + } + + if(type=='comanche') { + var elements = ['region', 'widget', 'var', 'template', 'css', 'js']; + } + + bbco = { + match: /\[(\w*)$/, + search: function (term, callback) { + callback($.map(elements, function (element) { + return element.indexOf(term) === 0 ? element : null; + })); + }, + index: 1, + replace: function (element) { + if(open_elements.indexOf(element) < 0) { + return ['\[' + element + '\]', '\[/' + element + '\]']; + } + else { + return '\[' + element + '\] '; + } + } + }; + + this.attr('autocomplete','off'); + var a = this.textcomplete([bbco], {className:'acpopup', zIndex:1020}); + + a.on('textComplete:select', function(e, value, strategy) { value; }); + }; +})( jQuery ); + |