PluginProbe ʕ •ᴥ•ʔ
Nested Pages / trunk
Nested Pages vtrunk
3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / assets / js / lib / nestedpages.nesting.js
wp-nested-pages / assets / js / lib Last commit date
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.nesting.js
169 lines
1 var NestedPages = NestedPages || {};
2
3 /**
4 * Enables and Saves Nesting
5 * @package Nested Pages
6 * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7 */
8 NestedPages.Nesting = function()
9 {
10 var plugin = this;
11 var $ = jQuery;
12
13 plugin.formatter = new NestedPages.Formatter;
14
15 // Make the Menu sortable
16 plugin.initializeSortable = function()
17 {
18 if ( !NestedPages.jsData.nestable ) return plugin.initializeSortableFlat();
19 var maxLevels = 0;
20
21 // Set the max level if necessary
22 if ( typeof nestedpages.post_types[NestedPages.jsData.posttype] !== 'undefined' ){
23 var post_type = nestedpages.post_types[NestedPages.jsData.posttype];
24 if ( typeof post_type.enable_max_nesting !== 'undefined' && post_type.enable_max_nesting && typeof post_type.maximum_nesting !== 'undefined' && post_type.maximum_nesting > 1 ) maxLevels = post_type.maximum_nesting;
25 }
26
27 $(NestedPages.selectors.sortable).not(NestedPages.selectors.notSortable).nestedSortable({
28 items : NestedPages.selectors.rows,
29 toleranceElement: '> .row',
30 handle: NestedPages.selectors.handle,
31 placeholder: "ui-sortable-placeholder",
32 tabSize : 56,
33 maxLevels : maxLevels,
34 isAllowed: function(placeholder, placeholderParent, currentItem){
35 return ( $(placeholderParent).hasClass('post-type-np-redirect') && !$(currentItem).hasClass('post-type-np-redirect') ) ? false : true;
36 },
37 start: function(e, ui){
38 ui.placeholder.height(ui.item.height());
39 },
40 sort: function(e, ui){
41 plugin.formatter.updatePlaceholderWidth(ui);
42 },
43 stop: function(e, ui){
44 setTimeout(
45 function(){
46 plugin.formatter.updateSubMenuToggle();
47 plugin.formatter.setBorders();
48 plugin.formatter.setNestedMargins();
49 }, 100
50 );
51 plugin.syncNesting();
52 },
53 });
54 }
55
56 // Initialize Flat Sortable (Non-Hierarchical Post Types)
57 plugin.initializeSortableFlat = function()
58 {
59 var lists = $(NestedPages.selectors.lists).not(NestedPages.selectors.notSortable);
60 $.each(lists, function(){
61 $(this).sortable({
62 items : '>' + NestedPages.selectors.rows,
63 handle: NestedPages.selectors.handle,
64 placeholder: "ui-sortable-placeholder",
65 forcePlaceholderSize: true,
66 start: function(e, ui){
67 ui.placeholder.height(ui.item.height());
68 },
69 sort: function(e, ui){
70 plugin.formatter.updatePlaceholderWidth(ui);
71 },
72 stop: function(e, ui){
73 setTimeout(
74 function(){
75 plugin.formatter.updateSubMenuToggle();
76 plugin.formatter.setBorders();
77 plugin.formatter.setNestedMargins();
78 }, 100
79 );
80 plugin.syncNesting();
81 },
82 });
83 });
84 }
85
86 // Disable Nesting
87 plugin.disableNesting = function()
88 {
89 $(NestedPages.selectors.sortable).sortable('destroy');
90 }
91
92
93 // Sync Nesting
94 plugin.syncNesting = function(manual, callback)
95 {
96 var list,
97 filtered;
98
99 if ( nestedpages.manual_order_sync === '1' && !manual) return;
100 $(NestedPages.selectors.errorDiv).hide();
101 $(NestedPages.selectors.loadingIndicator).show();
102 filtered = ( $(NestedPages.selectors.lists).first().hasClass('filtered') ) ? true : false;
103 if ( NestedPages.jsData.nestable && !filtered ){
104 list = $(NestedPages.selectors.sortable).nestedSortable('toHierarchy', {startDepthCount: 0});
105 } else {
106 list = plugin.setNestingArray();
107 }
108 plugin.disableNesting();
109
110 var syncmenu = NestedPages.jsData.syncmenu;
111 if ( nestedpages.manual_menu_sync === '1' ) syncmenu = 'nosync';
112
113 $.ajax({
114 url: ajaxurl,
115 type: 'post',
116 datatype: 'json',
117 data: {
118 action : NestedPages.formActions.syncNesting,
119 nonce : NestedPages.jsData.nonce,
120 list : list,
121 post_type : NestedPages.jsData.posttype,
122 syncmenu : syncmenu,
123 filtered : filtered
124 },
125 success: function(data, callback){
126 plugin.initializeSortable();
127 if (data.status === 'error'){
128 $(NestedPages.selectors.errorDiv).text(data.message).show();
129 $(NestedPages.selectors.loadingIndicator).hide();
130 } else {
131 if ( callback && typeof callback === 'function') {
132 callback();
133 return;
134 }
135 $(NestedPages.selectors.loadingIndicator).hide();
136 }
137 }
138 });
139 }
140
141 plugin.setNestingArray = function(list)
142 {
143 ret = [];
144 $(NestedPages.selectors.lists).first().children('li.page-row').each(function() {
145 var level = plugin.recursiveNesting(this);
146 ret.push(level);
147 });
148 return ret;
149 }
150
151 plugin.recursiveNesting = function(item) {
152 var id = $(item).attr('id');
153 var currentItem;
154 if (id) {
155 id = id.replace('menuItem_', '');
156 currentItem = {
157 "id": id
158 };
159 if ($(item).children(NestedPages.selectors.lists).children(NestedPages.selectors.rows).length > 0) {
160 currentItem.children = [];
161 $(item).children(NestedPages.selectors.lists).children(NestedPages.selectors.rows).each(function() {
162 var level = plugin.recursiveNesting(this);
163 currentItem.children.push(level);
164 });
165 }
166 return currentItem;
167 }
168 }
169 }