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
1 year 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.settings-reset.js
91 lines
| 1 | var NestedPages = NestedPages || {}; |
| 2 | |
| 3 | /** |
| 4 | * Reset Settings to Default |
| 5 | * @package Nested Pages |
| 6 | * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages |
| 7 | */ |
| 8 | NestedPages.SettingsReset = function() |
| 9 | { |
| 10 | var plugin = this; |
| 11 | var $ = jQuery; |
| 12 | |
| 13 | plugin.selectors = { |
| 14 | resetButton : 'data-nestedpages-reset-settings', |
| 15 | resetForm : '.nestedpages-reset-settings', |
| 16 | formComplete : '.nestedpages-reset-settings-complete', |
| 17 | resetAdminMenu : 'data-nestedpages-reset-admin-menu' |
| 18 | } |
| 19 | |
| 20 | plugin.bindEvents = function() |
| 21 | { |
| 22 | $(document).on('click', '[' + plugin.selectors.resetButton + ']', function(e){ |
| 23 | e.preventDefault(); |
| 24 | plugin.resetSettings(); |
| 25 | }); |
| 26 | $(document).on('click', '[' + plugin.selectors.resetAdminMenu + ']', function(e){ |
| 27 | e.preventDefault(); |
| 28 | plugin.resetAdminMenu(); |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | plugin.resetSettings = function() |
| 33 | { |
| 34 | plugin.loading(true); |
| 35 | $.ajax({ |
| 36 | url: NestedPages.jsData.ajaxurl, |
| 37 | type: 'post', |
| 38 | datatype: 'json', |
| 39 | data: { |
| 40 | action : NestedPages.formActions.resetSettings, |
| 41 | nonce : NestedPages.jsData.nonce |
| 42 | }, |
| 43 | success: function(data){ |
| 44 | plugin.loading(false); |
| 45 | $(plugin.selectors.resetForm).hide(); |
| 46 | $(plugin.selectors.formComplete).show(); |
| 47 | if ( data.status !== 'success' ){ |
| 48 | console.log('There was an error saving toggled pages.'); |
| 49 | } |
| 50 | } |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | plugin.resetAdminMenu = function() |
| 55 | { |
| 56 | plugin.loading(true); |
| 57 | $.ajax({ |
| 58 | url: NestedPages.jsData.ajaxurl, |
| 59 | type: 'post', |
| 60 | datatype: 'json', |
| 61 | data: { |
| 62 | action : NestedPages.formActions.resetAdminMenuSettings, |
| 63 | nonce : NestedPages.jsData.nonce |
| 64 | }, |
| 65 | success: function(data){ |
| 66 | plugin.loading(false); |
| 67 | if ( data.status == 'success' ){ |
| 68 | location.reload(); |
| 69 | } |
| 70 | if ( data.status !== 'success' ){ |
| 71 | console.log('There was an error saving toggled pages.'); |
| 72 | } |
| 73 | } |
| 74 | }); |
| 75 | } |
| 76 | |
| 77 | plugin.loading = function(loading) |
| 78 | { |
| 79 | if ( loading ){ |
| 80 | $('[' + plugin.selectors.resetButton + ']').attr('disabled', true); |
| 81 | $('[' + plugin.selectors.resetAdminMenu + ']').attr('disabled', true); |
| 82 | return; |
| 83 | } |
| 84 | $('[' + plugin.selectors.resetButton + ']').removeAttr('disabled'); |
| 85 | $('[' + plugin.selectors.resetAdminMenu + ']').removeAttr('disabled'); |
| 86 | } |
| 87 | |
| 88 | return plugin.bindEvents(); |
| 89 | } |
| 90 | |
| 91 | new NestedPages.SettingsReset; |