1(function () { 2 'use strict'; 3 $.fn.extend({ 4 ajaxButton: function () { 5 $(this).each(function () { 6 var $btn = $(this); 7 $btn.off('click').on('click', function (e) { 8 e.preventDefault(); 9 var $notificationBlock = $btn.data('notification-block') !== undefined 10 ? $($btn.data('notification-block')) 11 : $('#notifications-block'); 12 13 var $remove = $btn.data('remove'); 14 if ($remove === true) { 15 $remove = $btn; 16 } else if (typeof $remove === 'string') { 17 $remove = $($remove); 18 } 19 20 if ($notificationBlock.length === 0) { 21 $notificationBlock = $('<div id="notifications-block"></div>'); 22 if (($remove instanceof $) && $remove.has($btn.closest('div'))) { 23 $notificationBlock.insertAfter($remove); 24 } else { 25 $notificationBlock.insertAfter($btn.closest('div')); 26 } 27 } 28 29 var $alert = $('<div class="alert"></div>').appendTo($notificationBlock); 30 31 $.ajax($btn.data('href'), { 32 data: $btn.data('params') || {}, 33 method: $btn.data('method') || 'get', 34 beforeSend: function () { 35 $btn.prop('disabled', true); 36 } 37 }).done(function (response) { 38 if (response.error) { 39 $alert.removeClass('alert-success').addClass('alert-danger'); 40 } else { 41 $alert.removeClass('alert-danger').addClass('alert-success'); 42 } 43 44 $alert.html(response.message); 45 $remove.remove(); 46 }).fail(function () { 47 $alert.removeClass('alert-success').addClass('alert-danger').html('Refresh page and try again.'); 48 }).always(function () { 49 50 }); 51 }); 52 }); 53 54 return $(this); 55 } 56 }); 57 58 $(document).ready(function () { 59 var ajaxButton = $('.ajax-button'); 60 61 if (ajaxButton.length) { 62 ajaxButton.ajaxButton(); 63 } 64 }); 65}()); 66 67
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.