diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-04-04 17:13:10 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-04-04 17:13:10 +0200 |
commit | 1c9f7739009ceddf7dbc72af37f271767c1ad54d (patch) | |
tree | 924b09b899e8bf003438ae657d3cede5f9a53111 /view | |
parent | ee8a9384d5345becf04e52b33e32624570a27584 (diff) | |
parent | ec651f219e10c71a493e0cd2b4737077aee826dc (diff) | |
download | volse-hubzilla-1c9f7739009ceddf7dbc72af37f271767c1ad54d.tar.gz volse-hubzilla-1c9f7739009ceddf7dbc72af37f271767c1ad54d.tar.bz2 volse-hubzilla-1c9f7739009ceddf7dbc72af37f271767c1ad54d.zip |
Merge branch 'master' into dev
Diffstat (limited to 'view')
-rw-r--r-- | view/js/autocomplete.js | 40 | ||||
-rw-r--r-- | view/js/main.js | 2 | ||||
-rwxr-xr-x | view/tpl/jot-header.tpl | 1 |
3 files changed, 43 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 ); + diff --git a/view/js/main.js b/view/js/main.js index 04b317914..ba476b576 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -617,6 +617,8 @@ function updateConvItems(mode,data) { /* autocomplete @nicknames */ $(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1"); + /* autocomplete bbcode */ + $(".comment-edit-form textarea").bbco_autocomplete('bbcode'); var bimgs = ((preloadImages) ? false : $(".wall-item-body img").not(function() { return this.complete; })); var bimgcount = bimgs.length; diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 84fccc105..2b62f2407 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -11,6 +11,7 @@ function initEditor(cb){ if(plaintext == 'none') { $("#profile-jot-text-loading").spin(false).hide(); $("#profile-jot-text").css({ 'height': 200, 'color': '#000' }); + $("#profile-jot-text").bbco_autocomplete('bbcode'); // autocomplete bbcode if(typeof channelId === 'undefined') $("#profile-jot-text").editor_autocomplete(baseurl+"/acl"); else |