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.formatter.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.formatter.js
198 lines
1 var NestedPages = NestedPages || {};
2
3 /**
4 * Formatting updates
5 * @package Nested Pages
6 * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7 */
8 NestedPages.Formatter = function()
9 {
10
11 var plugin = this;
12 var $ = jQuery;
13
14
15 // Update the Submenu Toggle Button State based on if the child menu is visible
16 plugin.updateSubMenuToggle = function()
17 {
18 var allButtons = $(NestedPages.selectors.childToggle);
19 for ( var i = 0; i < allButtons.length; i++ ){
20 var button = allButtons[i];
21 var row = $(button).parent('.row').parent('li');
22 if ( $(row).children('ol').length > 0 ){ // Row has a child menu
23
24 // Hide the toggle and child list if all items are in the trash
25 if ( $(row).children('ol').find('li.page-row').length < 1 ){
26 $(row).children('ol').hide();
27 continue;
28 }
29
30 var open = ( $(row).children('ol:visible').length > 0 ) ? true : false;
31
32 var html = '<div class="child-toggle-spacer"></div>';
33 html += '<a href="#"';
34 if ( open ) html += ' class="open"';
35 html += '><span class="np-icon-arrow"></span></a>';
36 $(button).html(html);
37
38 if ( ($(row).children('ol').children('.np-hide').length > 0) && ($(row).children('ol').children('.np-hide.shown').length === 0) ){
39 $(button).find('a').hide();
40 } else if ( ($(row).children('ol').children('.np-hide').length > 0) && ($(row).children('ol').children('.np-hide.shown').length > 0) ){
41 $(button).find('a').show();
42 }
43
44 // Bug fix for pages with child hidden pages, but other pages in the hierarchy are not hidden
45 if ( $(row).children('ol').find('.page-row').not('.np-hide').length > 0 ){
46 $(button).find('a').show();
47 }
48
49 continue;
50 }
51 $(button).empty().html('<div class="child-toggle-spacer"></div>'); // No Child Menu
52 }
53 }
54
55
56 // Fix :visible :first css limitation when toggling various options
57 plugin.setBorders = function()
58 {
59 $(NestedPages.selectors.rows).removeClass(NestedPages.cssClasses.noborder);
60 $.each($(NestedPages.selectors.lists), function(){
61 $(this).find('.page-row:visible:first').addClass(NestedPages.cssClasses.noborder);
62 });
63 }
64
65
66 // Adjust nested margins based on how deep the list is nested
67 plugin.setNestedMargins = function()
68 {
69 plugin.setIndent();
70 }
71
72 plugin.setIndent = function()
73 {
74 var amount = ( nestedpages.non_indent === '1' ) ? 20 : 30;
75 var indent_element = ( nestedpages.non_indent === '1' ) ? '.row-inner' : '.child-toggle';
76 $.each($(NestedPages.selectors.lists), function(i, v){
77 var parent_count = $(this).parents(NestedPages.selectors.lists).length;
78 var padding = 0;
79 if ( !NestedPages.jsData.sortable ) padding = 10;
80 if ( parent_count > 0 ){
81 var padding = ( parent_count * amount ) + padding;
82 $(this).find(indent_element).css('padding-left', padding + 'px');
83 return;
84 }
85 if ( parent_count < 1 ){
86 $(this).find(indent_element).css('padding-left', '0px');
87 }
88 if ( !NestedPages.jsData.sortable || $(this).hasClass('no-sort') ){
89 $(this).find('.row-inner').css('padding-left', '10px');
90 return;
91 }
92 $(this).find('.row-inner').css('padding-left', '0px');
93 });
94 }
95
96 plugin.setClassicIndent = function()
97 {
98 $.each($(NestedPages.selectors.lists), function(i, v){
99 var parent_count = $(this).parents(NestedPages.selectors.lists).length;
100 var padding = 0;
101 if ( !NestedPages.jsData.sortable ) padding = 10;
102 if ( parent_count > 0 ){
103 var padding = ( parent_count * 20 ) + padding;
104 $(this).find('.row-inner').css('padding-left', padding + 'px');
105 return;
106 }
107 if ( !NestedPages.jsData.sortable || $(this).hasClass('no-sort') ){
108 $(this).find('.row-inner').css('padding-left', '10px');
109 return;
110 }
111 $(this).find('.row-inner').css('padding-left', '0px');
112 });
113 }
114
115
116 // Update the width of the placeholder ( width changes depending on level of nesting )
117 plugin.updatePlaceholderWidth = function(ui)
118 {
119 if ( NestedPages.jsData.nestable ){
120 var parentCount = $(ui.placeholder).parents('ol').length;
121 var listWidth = $(NestedPages.selectors.sortable).width();
122 var offset = ( parentCount * 40 ) - 40;
123 var newWidth = listWidth - offset;
124 $(ui.placeholder).width(newWidth).css('margin-left', offset + 'px');
125 }
126 plugin.updateListVisibility(ui);
127 }
128
129
130 // Update the list visibility on sort (prevent lists from collapsing when nesting)
131 plugin.updateListVisibility = function(ui)
132 {
133 var parentList = $(ui.placeholder).parent('ol');
134 if ( !$(parentList).is(':visible') ){
135 $(parentList).addClass('nplist');
136 $(parentList).show();
137 }
138 }
139
140
141 // Remove the Quick Edit Overlay
142 plugin.removeQuickEdit = function()
143 {
144 $(NestedPages.selectors.quickEditOverlay).removeClass('active').remove();
145 $('.sortable .quick-edit').remove();
146 $('.row').show();
147 }
148
149
150 // Show the Quick Edit Overlay
151 plugin.showQuickEdit = function()
152 {
153 $('body').append('<div class="np-inline-overlay"></div>');
154 setTimeout(function(){
155 $('.np-inline-overlay').addClass('active');
156 }, 50);
157 }
158
159
160 // Flash an updated row
161 plugin.flashRow = function(row)
162 {
163 $(row).addClass('np-updated');
164 plugin.setBorders();
165 setTimeout(function(){
166 $(row).addClass('np-updated-show');
167 }, 1500);
168 }
169
170
171 // Show an error message
172 plugin.showAjaxError = function(message)
173 {
174 $(NestedPages.selectors.ajaxError).find('p').text(message);
175 $(NestedPages.selectors.ajaxError).show();
176 }
177
178
179 // Hide the error message
180 plugin.hideAjaxError = function(message)
181 {
182 $(NestedPages.selectors.ajaxError).hide();
183 }
184
185
186 // Size the link thumbnails to the same as the page/post thumbnails
187 plugin.sizeLinkThumbnails = function()
188 {
189 var thumbnail = $(NestedPages.selectors.thumbnailContainer).not(NestedPages.selectors.thumbnailContainerLink).first().find('img');
190 var width = $(thumbnail).width();
191 var height = $(thumbnail).height();
192 $.each($(NestedPages.selectors.thumbnailContainerLink), function(){
193 $(this).width(width);
194 $(this).height(height);
195 });
196 }
197
198 }