diff --git a/webapp/web/js/account/accountProxyCommon.js b/webapp/web/js/account/accountProxyCommon.js index 85b053fde..d98e2088e 100644 --- a/webapp/web/js/account/accountProxyCommon.js +++ b/webapp/web/js/account/accountProxyCommon.js @@ -15,9 +15,8 @@ * profile associated with that individual. * ---------------------------------------------------------------------------- * The template must inlude - * 1) a link with attribute templatePart="remove" - * 2) a link with attribute templatePart="restore" - * 3) a hidden field with attribute templatePart="uriField" and value="%uri%" see below + * 1) a link with attribute templatePart="remove" and restoreText="[something]" + * 2) a hidden field with attribute templatePart="uriField" and value="%uri%" see below * * The template may include tokens to be replaced, from the following: * %uri% -- the URI of the individual being displayed @@ -45,45 +44,31 @@ function proxyInfoElement(template, uri, label, classLabel, imageUrl, existing) this.element = function() { var element = $("
" + content + "
"); var removeLink = $("[templatePart='remove']", element).first(); - var restoreLink = $("[templatePart='restore']", element).first(); + var removeText = removeLink.text(); + var restoreText = removeLink.attr('restoreText'); var proxyUriField = $("[templatePart='uriField']", element); - var setClass = function(r) { - if (r) { - element.removeClass('new existing').addClass('removed') - } else if (existed) { - element.removeClass('new removed').addClass('existing') - } else { - element.removeClass('removed existing').addClass('new') - } - } - - var setRemoved = function(r) { - removed = r; - if (r) { - removeLink.hide(); - restoreLink.show(); + var showRemoved = function() { + if (removed) { + removeLink.text(restoreText); proxyUriField.attr('disabled', 'disabled'); - setClass(r); + element.addClass('removed'); } else { - removeLink.show(); - restoreLink.hide(); + removeLink.text(removeText); proxyUriField.attr('disabled', ''); - setClass(r); + element.removeClass('removed'); } } removeLink.click(function(event) { - setRemoved(true); + removed = !removed; + showRemoved(); return false; }); - restoreLink.click(function(event) { - setRemoved(false); - return false; - }); - - setRemoved(removed); + element.removeClass('new existing removed'); + element.addClass(existed ? 'existing' : 'new') + showRemoved() return element; } diff --git a/webapp/web/js/account/accountProxyProxiesPanel.js b/webapp/web/js/account/accountProxyProxiesPanel.js index e65ca1157..f109cd290 100644 --- a/webapp/web/js/account/accountProxyProxiesPanel.js +++ b/webapp/web/js/account/accountProxyProxiesPanel.js @@ -126,7 +126,10 @@ function proxyAutocomplete(parent) { this.select = function(event, ui) { parent.proxyData.unshift(new proxyInfoElement(parent.templateHtml, ui.item.uri, ui.item.label, "", "", false)); parent.displayProxyData(); + event.preventDefault(); + event.target.value = ''; } + } $(document).ready(function() { diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl index 6516da127..0fd2006d4 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl @@ -44,8 +44,7 @@ ${stylesheets.add('remove - restore + remove