PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 3.0.6
Nested Pages v3.0.6
3.3.1 3.2.15 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.settings.js
wp-nested-pages / assets / js / lib Last commit date
jquery.mjs.nestedSortable.js 11 years ago jquery.ui.touch-punch.min.js 11 years ago nestedpages-factory.js 8 years ago nestedpages.bulk-actions.js 8 years ago nestedpages.check-all.js 9 years ago nestedpages.clone.js 8 years ago nestedpages.confirm-delete.js 8 years ago nestedpages.dropdowns.js 8 years ago nestedpages.formatter.js 8 years ago nestedpages.hidden-item-count.js 9 years ago nestedpages.manual-sync.js 9 years ago nestedpages.menu-links.js 8 years ago nestedpages.menu-search.js 11 years ago nestedpages.menu-toggle.js 8 years ago nestedpages.modals.js 8 years ago nestedpages.move-post.js 8 years ago nestedpages.nesting.js 8 years ago nestedpages.new-post.js 8 years ago nestedpages.page-toggle.js 9 years ago nestedpages.post-search.js 9 years ago nestedpages.quickedit-link.js 8 years ago nestedpages.quickedit-post.js 8 years ago nestedpages.settings-reset.js 8 years ago nestedpages.settings.js 8 years ago nestedpages.sync-menu-setting.js 8 years ago nestedpages.tabs.js 11 years ago nestedpages.trash.js 8 years ago nestedpages.wpml.js 8 years ago
nestedpages.settings.js
282 lines
1 var NestedPages = NestedPages || {};
2
3 /**
4 * Settings
5 * @package Nested Pages
6 * @author Kyle Phillips - https://github.com/kylephillips/wp-nested-pages
7 */
8 NestedPages.Settings = function()
9 {
10 var plugin = this;
11 var $ = jQuery;
12
13 plugin.selectors = {
14 postTypeToggle : '[data-toggle-nestedpages-pt-settings]', // Toggle Button for Post Type Settings
15 postTypeCheckbox : '[data-nestedpages-settings-row-checkbox]', // Checkbox for enabling post type
16 customFieldsCheckbox : '[data-toggle-nestedpages-cf-settings]', // Checkbox for toggling custom fields settings
17 standardFieldsCheckbox : '[data-toggle-nestedpages-sf-settings]', // Checkbox for toggling standard field settings
18 taxonomiesFieldCheckbox : '[data-hide-taxonomies]', // Checkbox for disabling taxonomies from quick edit
19 thumbnailsCheckbox : '[data-enable-thumbnails]', // Checkbox for enabling thumbnails in sort view
20 menuEnabledOption : '[data-menu-enabled-option]', // Options when the menu is enabled
21 disableMenuCheckbox : '[data-disable-menu-checkbox]', // Checkbox for disabling menus completely
22 disableAutoCheckbox : '[data-menu-disable-auto-checkbox]', // Checkbox for disabling auto menu sync
23
24 // Page Assignment for Post Types
25 assignPostTypeCheckbox : '[data-nestedpages-assign-post-type]', // Checkbox for assigning a post type to a page
26 assignPostTypeId : '[data-nested-pages-assign-post-type-id]', // Hidden field containing the assigned page id
27 assignPostTypeTitle : '[data-nested-pages-assign-post-type-title]', // Hidden field containing the assigned page title
28 assignPostTypeOption : '[data-assignment-page-id]', // Option within the listing to select page for post type assignment
29 assignPostTypeRemove : '[data-nestedpages-page-pt-assignment-remove]', // Link to remove the assigned page for the post type,
30 assignPostTypeSelection : '[data-nestedpages-page-pt-assignment-selection]', // The div displaying the selection
31
32 // Sort Options for Post Types
33 sortOptionCheckbox : '[data-nestedpages-sort-option-checkbox]', // Checkbox for enabling a sort option
34 defaultSortOptions : '[data-nestedpages-sort-option-default]', // Default sort options (containing div)
35 }
36
37 plugin.bindEvents = function()
38 {
39 $(document).ready(function(){
40 plugin.toggleAllSettingsButtons();
41 plugin.toogleAllFieldSettings('.custom-fields');
42 plugin.toogleAllFieldSettings('.standard-fields');
43 plugin.toggleMenuCheckboxes();
44 plugin.toggleHideCheckbox();
45 plugin.toggleAssignPostType();
46 plugin.toggleAllDefaultSortOptions();
47 });
48 $(document).on('click', plugin.selectors.postTypeToggle, function(e){
49 e.preventDefault();
50 plugin.toggleRow($(this));
51 });
52 $(document).on('change', plugin.selectors.postTypeCheckbox, function(){
53 plugin.toggleSettingsButton($(this));
54 });
55 $(document).on('change', plugin.selectors.customFieldsCheckbox, function(){
56 plugin.toogleFieldSettings($(this), '.custom-fields');
57 });
58 $(document).on('change', plugin.selectors.standardFieldsCheckbox, function(){
59 plugin.toogleFieldSettings($(this), '.standard-fields');
60 });
61 $(document).on('change', plugin.selectors.taxonomiesFieldCheckbox, function(){
62 plugin.toggleTaxonomyCheckboxes($(this));
63 });
64 $(document).on('change', plugin.selectors.thumbnailsCheckbox, function(){
65 plugin.toggleThumbnailSettings($(this));
66 });
67 $(document).on('change', plugin.selectors.disableMenuCheckbox, function(){
68 plugin.toggleMenuCheckboxes();
69 });
70 $(document).on('change', plugin.selectors.disableAutoCheckbox, function(){
71 plugin.toggleHideCheckbox();
72 });
73 $(document).on('change', plugin.selectors.assignPostTypeCheckbox, function(){
74 plugin.toggleAssignPostType();
75 });
76 $(document).on('click', plugin.selectors.assignPostTypeOption, function(e){
77 e.preventDefault();
78 plugin.chooseAssignPostType($(this));
79 });
80 $(document).on('click', plugin.selectors.assignPostTypeRemove, function(e){
81 e.preventDefault();
82 plugin.removeAssignPostType($(this));
83 });
84 $(document).on('change', plugin.selectors.sortOptionCheckbox, function(){
85 plugin.toggleDefaultSortOptions($(this));
86 });
87 }
88
89 /**
90 * Toggle Individual Post Type Settings
91 */
92 plugin.toggleRow = function(button)
93 {
94 $(button).parent('.head').siblings('.body').toggle();
95 $(button).parents('.row-container').toggleClass('active');
96 }
97
98 /**
99 * Show/Hide the settings toggle button for enabled/disabled post types
100 */
101 plugin.toggleSettingsButton = function(checkbox)
102 {
103 var button = $(checkbox).parents('.head').find(plugin.selectors.postTypeToggle);
104 if ( $(checkbox).is(':checked') ){
105 $(button).show();
106 $(button).parents('.head').siblings('.body').find('input[type="hidden"]').attr('disabled', false);
107 return;
108 }
109 $(button).hide();
110 $(button).parents('.head').siblings('.body').hide();
111 $(button).parents('.row-container').removeClass('active');
112 $(button).parents('.head').siblings('.body').find('input[type="checkbox"]').attr('checked', false);
113 $(button).parents('.head').siblings('.body').find('input[type="hidden"]').attr('disabled', true);
114 $(button).parents('.head').siblings('.body').find('select').val(false);
115 }
116
117 /**
118 * Toggle all the settings toggle buttons
119 */
120 plugin.toggleAllSettingsButtons = function()
121 {
122 var checkboxes = $(plugin.selectors.postTypeCheckbox);
123 $.each(checkboxes, function(){
124 plugin.toggleSettingsButton($(this));
125 });
126 }
127
128 /**
129 * Toggle Custom Field Choices
130 */
131 plugin.toogleFieldSettings = function(checkbox, fieldGroupClass)
132 {
133 var choices = $(checkbox).parents('.body').find(fieldGroupClass);
134 if ( $(checkbox).is(':checked') ){
135 $(choices).show();
136 return;
137 }
138 $(choices).hide();
139 }
140
141 /**
142 * Toggle All the Custom Field Choices
143 */
144 plugin.toogleAllFieldSettings = function(fieldGroupClass)
145 {
146 var checkboxes = $(plugin.selectors.customFieldsCheckbox);
147 if ( fieldGroupClass == '.standard-fields' ){
148 var checkboxes = $(plugin.selectors.standardFieldsCheckbox);
149 }
150 $.each(checkboxes, function(){
151 plugin.toogleFieldSettings($(this), fieldGroupClass);
152 });
153 }
154
155 /**
156 * Toggle Taxonomy Checkboxes
157 */
158 plugin.toggleTaxonomyCheckboxes = function(checkbox)
159 {
160 var choices = $(checkbox).parents('ul').find($('*[data-taxonomy-single]'));
161 if ( $(checkbox).is(':checked') ){
162 $(choices).hide();
163 return;
164 }
165 $(choices).show();
166 }
167
168 /**
169 * Toggle the Thumbnail Settings
170 */
171 plugin.toggleThumbnailSettings = function(checkbox)
172 {
173 var settings = $(checkbox).parents('.field').find($('*[data-thumbnail-options]'));
174 if ( $(checkbox).is(':checked') ){
175 $(settings).show();
176 return;
177 }
178 $(settings).hide();
179 }
180
181 /**
182 * Toggle the Menu Checkboxes
183 */
184 plugin.toggleMenuCheckboxes = function()
185 {
186 var checkbox = $(plugin.selectors.disableMenuCheckbox);
187 var menuCheckboxes = $(plugin.selectors.menuEnabledOption);
188 if ( $(checkbox).is(':checked') ){
189 $(menuCheckboxes).hide();
190 return;
191 }
192 $(menuCheckboxes).show();
193 }
194
195 /**
196 * Toggle the hide checkbox option
197 */
198 plugin.toggleHideCheckbox = function()
199 {
200 var checkbox = $(plugin.selectors.disableAutoCheckbox);
201 var hideCheckboxOption = $('[data-menu-hide-checkbox]');
202 if ( $(checkbox).is(':checked') ){
203 $(hideCheckboxOption).hide();
204 return;
205 }
206 $(hideCheckboxOption).show();
207 }
208
209 /**
210 * Toggle the Assign Page to a Post Type Listing
211 */
212 plugin.toggleAssignPostType = function()
213 {
214 var checkboxes = $(plugin.selectors.assignPostTypeCheckbox);
215 $.each(checkboxes, function(){
216 var checkbox = $(this);
217 var listing = $(this).parents('.field').find('.nestedpages-assignment-display');
218 if ( $(checkbox).is(':checked') ){
219 $(listing).show();
220 } else {
221 $(listing).hide();
222 }
223 });
224 }
225
226 /**
227 * Choose a page assignment
228 */
229 plugin.chooseAssignPostType = function(element)
230 {
231 var pageId = $(element).attr('data-assignment-page-id');
232 var pageTitle = $(element).attr('data-assignment-page-title');
233 var container = $(element).parents('.field');
234 var html = nestedpages.currently_assigned_to + ' ' + pageTitle + ' <a href="#" data-nestedpages-page-pt-assignment-remove>(' + nestedpages.remove + ')</a>';
235 $(container).find(plugin.selectors.assignPostTypeId).val(pageId);
236 $(container).find(plugin.selectors.assignPostTypeTitle).val(pageTitle);
237 $(container).find(plugin.selectors.assignPostTypeSelection).html(html).show();
238 $(container).find('[data-nestedpages-post-search-form]').hide();
239 }
240
241 /**
242 * Remove a page assignment
243 */
244 plugin.removeAssignPostType = function(element)
245 {
246 var container = $(element).parents('.field');
247 $(container).find(plugin.selectors.assignPostTypeSelection).hide();
248 $(container).find('[data-nestedpages-post-search-form]').show();
249 $(container).find(plugin.selectors.assignPostTypeId).val('');
250 $(container).find(plugin.selectors.assignPostTypeTitle).val('');
251 }
252
253 /**
254 * Toggle all the default sort options
255 */
256 plugin.toggleAllDefaultSortOptions = function()
257 {
258 var checkboxes = $(plugin.selectors.sortOptionCheckbox);
259 $.each(checkboxes, function(){
260 plugin.toggleDefaultSortOptions($(this));
261 });
262 }
263
264 /**
265 * Toggle the default sort options
266 */
267 plugin.toggleDefaultSortOptions = function(checkbox)
268 {
269 var checked = ( $(checkbox).is(':checked') ) ? true : false;
270 var options = $(checkbox).parent('label').next(plugin.selectors.defaultSortOptions);
271 if ( $(options).length < 1 ) return;
272 if ( checked ) {
273 $(options).show();
274 return;
275 }
276 $(options).hide();
277 }
278
279 return plugin.bindEvents();
280 }
281
282 new NestedPages.Settings;