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 $(row).find('a.add_row').hide();
28 SN_WHITELIST.resetRow(newRow);
29 $(newRow).insertAfter(row).show("blind", "fast", function () {
30 SN_WHITELIST.updateButtons();
34 SN_WHITELIST.removeRow = function () {
37 $("#confirm-dialog").dialog({
39 "Confirm" : function () {
40 $(this).dialog("close");
41 $(that).closest("li").hide("blind", "fast", function () {
43 SN_WHITELIST.updateButtons();
46 "Cancel" : function () {
47 $(this).dialog("close");
52 if ($(this).closest('li').find(':input[name^=username]').val()) {
53 $("#confirm-dialog").dialog("open");
55 $(that).closest("li").hide("blind", "fast", function () {
57 SN_WHITELIST.updateButtons();
62 $(document).ready(function () {
63 $("#confirm-dialog").dialog({
68 $(document).on('click', '.add_row', SN_WHITELIST.addRow);
69 $(document).on('click', '.remove_row', SN_WHITELIST.removeRow);
71 SN_WHITELIST.updateButtons();