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.sync-menu-setting.js
62 lines
| 1 | var NestedPages = NestedPages || {}; |
| 2 | |
| 3 | /** |
| 4 | * Sync the "sync menu" setting |
| 5 | * @package Nested Pages |
| 6 | * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages |
| 7 | */ |
| 8 | NestedPages.SyncMenuSetting = function() |
| 9 | { |
| 10 | var plugin = this; |
| 11 | var $ = jQuery; |
| 12 | |
| 13 | plugin.formatter = new NestedPages.Formatter; |
| 14 | |
| 15 | plugin.init = function() |
| 16 | { |
| 17 | plugin.bindEvents(); |
| 18 | } |
| 19 | |
| 20 | plugin.bindEvents = function() |
| 21 | { |
| 22 | $(document).ready(function(){ // catches trash updates |
| 23 | if ( nestedpages.manual_menu_sync === '1' ) return; |
| 24 | if ( nestedpages.syncmenu === '1' ) plugin.syncSetting(); |
| 25 | }); |
| 26 | $(document).on('change', NestedPages.selectors.syncCheckbox, function(){ |
| 27 | plugin.syncSetting(); |
| 28 | }); |
| 29 | } |
| 30 | |
| 31 | // Sync the "Sync menu" preference / setting |
| 32 | plugin.syncSetting = function() |
| 33 | { |
| 34 | |
| 35 | if ( NestedPages.jsData.posttype !== 'page' ) return; |
| 36 | if ($(NestedPages.selectors.syncCheckbox).length === 0) return; |
| 37 | |
| 38 | NestedPages.jsData.syncmenu = ( $(NestedPages.selectors.syncCheckbox).is(':checked') ) ? 'sync' : 'nosync'; |
| 39 | |
| 40 | $.ajax({ |
| 41 | url: NestedPages.jsData.ajaxurl, |
| 42 | type: 'post', |
| 43 | datatype: 'json', |
| 44 | data: { |
| 45 | action : NestedPages.formActions.syncMenu, |
| 46 | nonce : NestedPages.jsData.nonce, |
| 47 | post_type : NestedPages.jsData.posttype, |
| 48 | syncmenu : NestedPages.jsData.syncmenu |
| 49 | }, |
| 50 | success: function(data){ |
| 51 | if (data.status === 'error'){ |
| 52 | plugin.formatter.showAjaxError(data.message); |
| 53 | } |
| 54 | }, |
| 55 | error: function(data){ |
| 56 | console.log(data); |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | return plugin.bindEvents(); |
| 62 | } |