diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-04-26 15:40:59 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-04-26 15:40:59 +0200 |
commit | 63c76eae0c87a07e5ee0fc7b88a3e6c56bba6969 (patch) | |
tree | 3fd023b6dc4e5190c17932cf7c0f7332b30eeed7 | |
parent | 94317854665bc64c53271daada2ada15d238c988 (diff) | |
download | volse-hubzilla-63c76eae0c87a07e5ee0fc7b88a3e6c56bba6969.tar.gz volse-hubzilla-63c76eae0c87a07e5ee0fc7b88a3e6c56bba6969.tar.bz2 volse-hubzilla-63c76eae0c87a07e5ee0fc7b88a3e6c56bba6969.zip |
a better way to deal with js errors in autocomplete plugins if the object is not available
-rw-r--r-- | view/js/autocomplete.js | 19 | ||||
-rw-r--r-- | view/js/mod_network.js | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 7bbcd6451..5fbdab27b 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -180,6 +180,10 @@ function string2bb(element) { */ (function( $ ) { $.fn.editor_autocomplete = function(backend_url, extra_channels) { + + if(! this.length) + return; + if (typeof extra_channels === 'undefined') extra_channels = false; // Autocomplete contacts @@ -240,6 +244,10 @@ function string2bb(element) { */ (function( $ ) { $.fn.search_autocomplete = function(backend_url) { + + if(! this.length) + return; + // Autocomplete contacts contacts = { match: /(^@)([^\n]{3,})$/, @@ -285,6 +293,10 @@ function string2bb(element) { (function( $ ) { $.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) { + + if(! this.length) + return; + if(typeof typ === 'undefined') typ = ''; if(typeof autosubmit === 'undefined') autosubmit = false; @@ -317,6 +329,10 @@ function string2bb(element) { (function( $ ) { $.fn.name_autocomplete = function(backend_url, typ, autosubmit, onselect) { + + if(! this.length) + return; + if(typeof typ === 'undefined') typ = ''; if(typeof autosubmit === 'undefined') autosubmit = false; @@ -349,6 +365,9 @@ function string2bb(element) { (function( $ ) { $.fn.bbco_autocomplete = function(type) { + if(! this.length) + return; + if(type=='bbcode') { 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', 'observer.language','embed', 'highlight', 'url', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; diff --git a/view/js/mod_network.js b/view/js/mod_network.js index 22a5e9ba6..2899bbacd 100644 --- a/view/js/mod_network.js +++ b/view/js/mod_network.js @@ -1,5 +1,4 @@ $(document).ready(function() { - if($("#search-text").length) - $("#search-text").contact_autocomplete(baseurl + '/search_ac','',true); + $("#search-text").contact_autocomplete(baseurl + '/search_ac','',true); }); |