X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/362ea2e7f8ac4254398791139cc060090199f400..9e556c1938577b991edfcb0a0248fcca92d67f3e:/wolnelektury/static/sponsors/js/footer_admin.js diff --git a/wolnelektury/static/sponsors/js/footer_admin.js b/wolnelektury/static/sponsors/js/footer_admin.js index 2f2cd93da..33c794a3d 100644 --- a/wolnelektury/static/sponsors/js/footer_admin.js +++ b/wolnelektury/static/sponsors/js/footer_admin.js @@ -4,12 +4,12 @@ sponsors: [] }; $.extend(settings, options); - + var input = $(this).hide(); - + var container = $('
').appendTo(input.parent()); var groups = $.evalJSON(input.val()); - + var unusedDiv = $('
') .appendTo(container) .append('

dostępni sponsorzy

'); @@ -18,13 +18,13 @@ .sortable({ connectWith: '.sponsors-sponsor-group-list' }); - + // Edit group name inline function editNameInline(name) { name.unbind('click.sponsorsFooter'); var inlineInput = $('').val(name.html()); name.html(''); - + function endEditing() { name.html(inlineInput.val()); inlineInput.remove(); @@ -34,11 +34,11 @@ input.parents('form').unbind('submit.sponsorsFooter', endEditing); return false; } - + inlineInput.appendTo(name).focus().blur(endEditing); input.parents('form').bind('submit.sponsorsFooter', endEditing); } - + // Remove sponsor with passed id from sponsors array and return it function popSponsor(id) { for (var i=0; i < settings.sponsors.length; i++) { @@ -50,15 +50,15 @@ } return null; } - + // Create sponsor group and bind events function createGroup(name, sponsors) { if (!sponsors) { sponsors = []; } - + var groupDiv = $('
'); - + $('X') .click(function() { groupDiv.fadeOut('slow', function() { @@ -66,32 +66,32 @@ groupDiv.remove(); }); }).appendTo(groupDiv); - + $('

' + name + '

') .bind('click.sponsorsFooter', function() { editNameInline($(this)); }).appendTo(groupDiv); - + var groupList = $('
    ') .appendTo(groupDiv) .sortable({ connectWith: '.sponsors-sponsor-group-list' }); - - + + for (var i = 0; i < sponsors.length; i++) { - $('
  1. ' + sponsors[i].name + '
  2. ') + $('
  3. ' + sponsors[i].name + '
  4. ') .data('obj_id', sponsors[i].id) .appendTo(groupList); } return groupDiv; } - + // Create groups from data in input value for (var i = 0; i < groups.length; i++) { var group = groups[i]; var sponsors = []; - + for (var j = 0; j < group.sponsors.length; j++) { var s = popSponsor(group.sponsors[j]); if (s) { @@ -100,7 +100,7 @@ } createGroup(group.name, sponsors).appendTo(container); } - + // Serialize input value before submiting form input.parents('form').submit(function(event) { var groups = []; @@ -113,19 +113,19 @@ }); input.val($.toJSON(groups)); }); - + for (i = 0; i < settings.sponsors.length; i++) { - $('
  5. ' + settings.sponsors[i].name + '
  6. ') + $('
  7. ' + settings.sponsors[i].name + '
  8. ') .data('obj_id', settings.sponsors[i].id) .appendTo(unusedList); } - + $('') .click(function() { var newGroup = createGroup('').appendTo(container); editNameInline($('.sponsors-sponsor-group-name', newGroup)); }).prependTo(input.parent()); - + input.parent().append('
    '); }; })(jQuery);