]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/DomainWhitelist/js/whitelistinvite.js
Fancier invitation form for whitelisted domains
[quix0rs-gnu-social.git] / plugins / DomainWhitelist / js / whitelistinvite.js
1 // XXX: Should I do crazy SN.X.Y.Z.A namespace instead?
2 var SN_WHITELIST = SN_WHITELIST || {};
3
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();
8     } else {
9         $("ul > li > a.remove_row:first").show();
10     }
11 };
12
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();
18 };
19
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();
26         });
27 };
28
29 SN_WHITELIST.removeRow = function() {
30     $(this).closest("li").hide("blind", "slow", function() {
31         $(this).remove();
32         SN_WHITELIST.updateButtons();
33     });
34 };
35
36 $(document).ready(function() {
37     $('.add_row').live('click', SN_WHITELIST.addRow);
38     $('.remove_row').live('click', SN_WHITELIST.removeRow);
39 });
40