jquery.mjs.nestedSortable.js
4 years ago
jquery.ui.touch-punch.min.js
11 years ago
nestedpages-factory.js
3 years ago
nestedpages.bulk-actions.js
4 years ago
nestedpages.check-all.js
9 years ago
nestedpages.clone.js
3 years ago
nestedpages.confirm-delete.js
8 years ago
nestedpages.dropdowns.js
8 years ago
nestedpages.formatter.js
3 years ago
nestedpages.hidden-item-count.js
9 years ago
nestedpages.manual-sync.js
9 years ago
nestedpages.menu-links.js
3 years ago
nestedpages.menu-search.js
4 days ago
nestedpages.menu-toggle.js
8 years ago
nestedpages.modals.js
8 years ago
nestedpages.move-post.js
8 years ago
nestedpages.nesting.js
3 years ago
nestedpages.new-post.js
6 years ago
nestedpages.page-toggle.js
4 years ago
nestedpages.post-search.js
9 years ago
nestedpages.quickedit-link.js
8 years ago
nestedpages.quickedit-post.js
3 years ago
nestedpages.settings-admin-customization.js
6 years ago
nestedpages.settings-reset.js
6 years ago
nestedpages.settings.js
3 years ago
nestedpages.sync-menu-setting.js
8 years ago
nestedpages.tabs.js
6 years ago
nestedpages.trash-with-children.js
6 years ago
nestedpages.trash.js
8 years ago
nestedpages.userprefs-reset.js
7 years ago
nestedpages.wpml.js
8 years ago
nestedpages.confirm-delete.js
70 lines
| 1 | var NestedPages = NestedPages || {}; |
| 2 | |
| 3 | /** |
| 4 | * Confirm deletion of links |
| 5 | * @package Nested Pages |
| 6 | * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages |
| 7 | */ |
| 8 | NestedPages.ConfirmDelete = function() |
| 9 | { |
| 10 | var plugin = this; |
| 11 | var $ = jQuery; |
| 12 | |
| 13 | // JS Data |
| 14 | plugin.deleteLink = ''; // Link for deleting the item |
| 15 | |
| 16 | plugin.bindEvents = function() |
| 17 | { |
| 18 | $(document).on('click', NestedPages.selectors.linkDeleteButton, function(e){ |
| 19 | e.preventDefault(); |
| 20 | plugin.confirmSingle($(this)); |
| 21 | }); |
| 22 | $(document).on('click', NestedPages.selectors.linkDeleteConfirmationButton, function(e){ |
| 23 | e.preventDefault(); |
| 24 | if ( !$(this).hasClass('bulk') ){ |
| 25 | plugin.deleteSingle(); |
| 26 | return; |
| 27 | } |
| 28 | plugin.deleteMultiple(); |
| 29 | }); |
| 30 | $(document).on('submit', NestedPages.selectors.bulkActionsForm, function(e){ |
| 31 | plugin.confirmMultiple(e); |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | // Confirm a single link deletion |
| 36 | plugin.confirmSingle = function(button) |
| 37 | { |
| 38 | plugin.deleteLink = $(button).attr('href'); |
| 39 | $(NestedPages.selectors.linkDeleteConfirmationModalText).text(nestedpages.link_delete_confirmation_singular); |
| 40 | $(NestedPages.selectors.linkDeleteConfirmationButton).text(nestedpages.delete).removeClass('bulk'); |
| 41 | $(document).trigger('open-modal-manual', NestedPages.selectors.linkDeleteConfirmationModal); |
| 42 | } |
| 43 | |
| 44 | // Confirm Multiple link deletion |
| 45 | plugin.confirmMultiple = function(event) |
| 46 | { |
| 47 | if ( $('select[name="np_bulk_action"]').val() !== 'trash' ) return; |
| 48 | var linkCount = $(NestedPages.selectors.bulkActionRedirectIds).val(); |
| 49 | if ( linkCount === '' ) return; |
| 50 | event.preventDefault(); |
| 51 | $(NestedPages.selectors.linkDeleteConfirmationModalText).text(nestedpages.link_delete_confirmation); |
| 52 | $(NestedPages.selectors.linkDeleteConfirmationButton).text(nestedpages.trash_delete_links).addClass('bulk'); |
| 53 | $(document).trigger('open-modal-manual', [NestedPages.selectors.linkDeleteConfirmationModal]); |
| 54 | } |
| 55 | |
| 56 | // Submit the form to delete multiple |
| 57 | plugin.deleteMultiple = function() |
| 58 | { |
| 59 | $(NestedPages.selectors.bulkActionsForm)[0].submit(); |
| 60 | } |
| 61 | |
| 62 | // Delete the single |
| 63 | plugin.deleteSingle = function() |
| 64 | { |
| 65 | window.location.replace(plugin.deleteLink); |
| 66 | } |
| 67 | |
| 68 | return plugin.bindEvents(); |
| 69 | } |
| 70 |