From 1d8eb4467710cf61503ec7e32e1f6c24a4479eb1 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 16 Apr 2014 22:41:57 +0200 Subject: [PATCH] Fix javascript error in calendar app Fix owncloud/calendar#409 If you haven't allowed to share items per email the element "email" will never appear and you will get a null exception. License: WTFPL --- core/js/share.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/core/js/share.js b/core/js/share.js index 03202c1a61..2813570f71 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -331,25 +331,27 @@ OC.Share={ .append( insert ) .appendTo( ul ); }; - $('#email').autocomplete({ - minLength: 1, - source: function (search, response) { - $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWithEmail', search: search.term }, function(result) { - if (result.status == 'success' && result.data.length > 0) { - response(result.data); - } - }); - }, - select: function( event, item ) { - $('#email').val(item.item.email); - return false; - } - }) - .data("ui-autocomplete")._renderItem = function( ul, item ) { - return $( "
  • " ) - .append( "" + item.displayname + "
    " + item.email + "
    " ) - .appendTo( ul ); - }; + if (link) { + $('#email').autocomplete({ + minLength: 1, + source: function (search, response) { + $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWithEmail', search: search.term }, function(result) { + if (result.status == 'success' && result.data.length > 0) { + response(result.data); + } + }); + }, + select: function( event, item ) { + $('#email').val(item.item.email); + return false; + } + }) + .data("ui-autocomplete")._renderItem = function( ul, item ) { + return $( "
  • " ) + .append( "" + item.displayname + "
    " + item.email + "
    " ) + .appendTo( ul ); + }; + } } else { html += '';