{% load i18n%} $('.repo-transfer-btn').click(function(){ var btn_ct = $(this).parents('td'), repo_id = btn_ct.data('id'), repo_name = btn_ct.attr('data-name'), form = $('#repo-transfer-form'); form.modal({appendTo:'#main'}); $('#simplemodal-container').css({'width':'auto', 'height':'auto'}); var detail = $('.detail', form); detail.html(detail.html().replace('%(lib_name)s', '' + HTMLescape(repo_name) + '')); $('[name="email"]', form).select2($.extend({ width: '268px', maximumSelectionSize: 1, placeholder: "{% trans "Search user or enter email and press Enter" %}", formatInputTooShort: "{% trans "Please enter 1 or more character" %}", formatNoMatches: "{% trans "No matches" %}", formatSearching: "{% trans "Searching..." %}", formatAjaxError: "{% trans "Loading failed" %}", formatSelectionTooBig: "{% trans "You cannot select any more choices" %}" }, userInputOPtionsForSelect2('{% url 'search-user' %}'))); $('input[name="repo_id"]', form).val(repo_id); return false; }); $('#repo-transfer-form').submit(function() { var form = $(this), form_id = form.attr('id'), email = $.trim(form.children('[name="email"]').val()); if (!email) { return false; } }); $('#main-panel').removeClass('ovhd'); $('.repo-delete-btn').click(function() { var $tr = $(this).closest('tr'); var $td = $(this).closest('td'); var repo_id = $td.data('id'); var repo_name = $td.data('name'); var popupTitle = "{% trans "Delete Library" %}"; var popupContent = "{% trans "Are you sure you want to delete %s ?" %}".replace('%s', '' + HTMLescape(repo_name) + ''); var yesCallback = function() { $.ajax({ url: '{{SITE_ROOT}}api/v2.1/admin/libraries/' + encodeURIComponent(repo_id) + '/', type: 'DELETE', cache: false, beforeSend: prepareCSRFToken, dataType: 'json', success: function() { $tr.remove(); feedback("{% trans "Successfully deleted 1 item." %}", 'success'); }, error: function(xhr, textStatus, errorThrown) { ajaxErrorHandler(xhr, textStatus, errorThrown); }, complete: function() { $.modal.close(); } }); }; showConfirm(popupTitle, popupContent, yesCallback); return false; });