1 // XXX: Should I do crazy SN.X.Y.Z.A namespace instead?
2 var SN_WHITELIST = SN_WHITELIST || {};
4 SN_WHITELIST.updateButtons = function() {
5 $("ul > li > a.remove_row").show();
6 $("ul > li > a.add_row").hide();
8 var lis = $('ul > li > input[name^="username[]"]');
9 if (lis.length === 1) {
10 $("ul > li > a.remove_row").hide();
12 $("ul > li > a.remove_row:first").show();
14 $("ul > li > a.add_row:last").show();
17 SN_WHITELIST.resetRow = function(row) {
18 $("input", row).val('');
19 // Make sure the default domain is the first selection
20 $("select option:first", row).val();
21 $("a.remove_row", row).show();
24 SN_WHITELIST.addRow = function() {
25 var row = $(this).closest("li");
26 var newRow = row.clone();
27 SN_WHITELIST.resetRow(newRow);
28 $(newRow).insertAfter(row).show("blind", "slow", function() {
29 SN_WHITELIST.updateButtons();
33 SN_WHITELIST.removeRow = function() {
36 $("#confirm-dialog").dialog({
38 "Confirm" : function() {
39 $(this).dialog("close");
40 $(that).closest("li").hide("blind", "slow", function() {
42 SN_WHITELIST.updateButtons();
45 "Cancel" : function() {
46 $(this).dialog("close");
51 if ($(this).closest('li').find(':input[name^=username]').val()) {
52 $("#confirm-dialog").dialog("open");
54 $(that).closest("li").hide("blind", "slow", function() {
56 SN_WHITELIST.updateButtons();
61 $(document).ready(function() {
62 $("#confirm-dialog").dialog({
67 $('.add_row').live('click', SN_WHITELIST.addRow);
68 $('.remove_row').live('click', SN_WHITELIST.removeRow);
70 SN_WHITELIST.updateButtons();