X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/74488bcce98f59ac255fa342ff61def2251ebdb5..9e020f2a463e49b2aa799d3d3305f82dd01bece1:/wolnelektury/static/sponsors/js/footer_admin.js?ds=sidebyside diff --git a/wolnelektury/static/sponsors/js/footer_admin.js b/wolnelektury/static/sponsors/js/footer_admin.js index 4cb5eb68c..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,19 +66,19 @@ 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. ') .data('obj_id', sponsors[i].id) @@ -86,12 +86,12 @@ } 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++) { $('
  3. ' + settings.sponsors[i].name + '
  4. ') .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);