From f89860b77e8da259c294d7553df930db61c7d631 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Mon, 31 Jan 2011 14:15:01 -0500 Subject: reduce scope of remove link it was global https://fedorahosted.org/freeipa/ticket/212 --- install/ui/details.js | 72 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'install/ui/details.js') diff --git a/install/ui/details.js b/install/ui/details.js index a5613b5a..eadc4f2e 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -129,6 +129,40 @@ IPA.details_field = function (spec) { } }; + + /* creates a Remove link for deleting attribute values */ + function create_remove_link(attr, param_info){ + function remove_on_click(obj){ + var jobj = $(obj); + var attr = jobj.attr('title'); + var par = jobj.parent(); + var input = par.find('input'); + if (input.is('.strikethrough')){ + input.removeClass('strikethrough'); + jobj.text("Remove"); + }else{ + input.addClass('strikethrough'); + jobj.text("Undo"); + } + return (false); + } + + if (param_info){ + /* check if the param is required or of the Password type + * if it is, then we don't want people to be able to remove it */ + if ((param_info['required']) || + (param_info['class'] == 'Password')){ + return (''); + } + } + return $('',{ + href:"jslink", + click: function (){return (remove_on_click(this));}, + title: attr, + text: 'Remove'}); + } + + /* create an HTML element for displaying/editing an attribute * arguments: * attr - LDAP attribute name @@ -155,7 +189,7 @@ IPA.details_field = function (spec) { var input = that.create_input(value, param_info, rights, index); if (param_info) { if (param_info['multivalue'] || param_info['class'] == 'List') { - input.append(_ipa_create_remove_link(that.name, param_info)); + input.append(create_remove_link(that.name, param_info)); } } @@ -903,23 +937,6 @@ IPA.create_other_dd = function (field_name, content){ }; -/* creates a Remove link for deleting attribute values */ -function _ipa_create_remove_link(attr, param_info) -{ - if (param_info){ - /* check if the param is required or of the Password type - * if it is, then we don't want people to be able to remove it */ - if ((param_info['required']) || (param_info['class'] == 'Password')){ - return (''); - } - } - return $('',{ - href:"jslink", - click: function (){return (_ipa_remove_on_click(this));}, - title: attr, - text: 'Remove'}); - -} IPA.details_field_create_add_link = function (title, rights, index) { @@ -947,22 +964,3 @@ IPA.details_field_create_add_link = function (title, rights, index) { return link; }; - - -function _ipa_remove_on_click(obj) -{ - var jobj = $(obj); - var attr = jobj.attr('title'); - var par = jobj.parent(); - - var input = par.find('input'); - - if (input.is('.strikethrough')){ - input.removeClass('strikethrough'); - jobj.text("Remove"); - }else{ - input.addClass('strikethrough'); - jobj.text("Undo"); - } - return (false); -} -- cgit