| 1 |
jQuery(document).ready( function($) { |
| 2 |
// Импортировать выбранный сниппет из списка |
| 3 |
$( '.wbcr-inp-enable-snippet-button' ).click( function() { |
| 4 |
if ( confirm(winp_snippet_library.is_import) ) { |
| 5 |
if ($(this).hasClass('disabled')) return; |
| 6 |
|
| 7 |
$(this).addClass('disabled'); |
| 8 |
|
| 9 |
$.post( |
| 10 |
ajaxurl, |
| 11 |
{ |
| 12 |
action: 'winp_snippet_create', |
| 13 |
winp_ajax_custom_list_nonce: $('#winp_ajax_custom_list_nonce').val(), |
| 14 |
snippet_id: $(this).data('snippet'), |
| 15 |
common: $(this).data('common') |
| 16 |
}, |
| 17 |
function(data) { |
| 18 |
if (data) { |
| 19 |
window.location = 'post.php?post=' + data + '&action=edit'; |
| 20 |
} else { |
| 21 |
$( '.wbcr-inp-enable-snippet-button' ).removeClass('disabled'); |
| 22 |
alert(winp_snippet_library.import_failed); |
| 23 |
} |
| 24 |
} |
| 25 |
); |
| 26 |
} |
| 27 |
}); |
| 28 |
|
| 29 |
// Удалить выбранный сниппет из списка |
| 30 |
$( '.wbcr-inp-delete-snippet-button' ).click( function() { |
| 31 |
if ( confirm(winp_snippet_library.is_delete) ) { |
| 32 |
if ($(this).hasClass('disabled')) return; |
| 33 |
|
| 34 |
$(this).addClass('disabled'); |
| 35 |
var snippet_id = $(this).data('snippet'); |
| 36 |
|
| 37 |
$.post( |
| 38 |
ajaxurl, |
| 39 |
{ |
| 40 |
action: 'winp_snippet_delete', |
| 41 |
winp_ajax_snippet_delete_nonce: $('#winp_ajax_snippet_delete_' + snippet_id).val(), |
| 42 |
snippet_id: snippet_id |
| 43 |
}, |
| 44 |
function(data) { |
| 45 |
if (data) { |
| 46 |
window.location.reload(); |
| 47 |
} else { |
| 48 |
$( '.wbcr-inp-enable-snippet-button' ).removeClass('disabled'); |
| 49 |
alert(winp_snippet_library.delete_failed); |
| 50 |
} |
| 51 |
} |
| 52 |
); |
| 53 |
} |
| 54 |
}); |
| 55 |
}); |