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 var lis = $('ul > li > input[name^="username[]"]');
6 if (lis.length === 1) {
7 $("ul > li > a.remove_row").hide();
9 $("ul > li > a.remove_row:first").show();
13 SN_WHITELIST.resetRow = function(row) {
14 $("input", row).val('');
15 // Make sure the default domain is the first selection
16 $("select option:first", row).val();
17 $("a.remove_row", row).show();
20 SN_WHITELIST.addRow = function() {
21 var row = $(this).closest("li");
22 var newRow = row.clone();
23 SN_WHITELIST.resetRow(newRow);
24 $(newRow).insertAfter(row).show("blind", "slow", function() {
25 SN_WHITELIST.updateButtons();
29 SN_WHITELIST.removeRow = function() {
33 $("#confirm-dialog").dialog({
35 "Confirm" : function() {
36 $(this).dialog("close");
37 $(that).closest("li").hide("blind", "slow", function() {
39 SN_WHITELIST.updateButtons();
42 "Cancel" : function() {
43 $(this).dialog("close");
48 if ($(this).closest('li').find(':input[name^=username]').val()) {
49 $("#confirm-dialog").dialog("open");
51 $(that).closest("li").hide("blind", "slow", function() {
53 SN_WHITELIST.updateButtons();
58 $(document).ready(function() {
60 $("#confirm-dialog").dialog({
65 $('.add_row').live('click', SN_WHITELIST.addRow);
66 $('.remove_row').live('click', SN_WHITELIST.removeRow);