PluginProbe
WP Ultimate Post Grid / 2.7.0
WP Ultimate Post Grid v2.7.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / js / admin_form.js

admin_form.js in WP Ultimate Post Grid 2.7.0, at js/admin_form.js

737 lines 31.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var WPUltimatePostGrid = WPUltimatePostGrid || {};
2
3 WPUltimatePostGrid.post_type = null;
4 WPUltimatePostGrid.filter_possible = false;
5 WPUltimatePostGrid.premium_features_used = [];
6
7 WPUltimatePostGrid.initForm = function() {
8 // General selects
9 jQuery('.wpupg-select2').select2wpupg({
10 width: '100%'
11 });
12
13 // Multiselect with order
14 jQuery('select.wpupg_filter_taxonomy').on('select2wpupg:select', function (evt) {
15 var element = evt.params.data.element;
16 var $element = jQuery(element);
17
18 $element.detach();
19 jQuery(this).append($element);
20 jQuery(this).trigger('change');
21 });
22
23 // Datepicker
24 jQuery('#wpupg_rules').find('.wpupg-date').datepicker();
25
26 // Sliders
27 var slider_args = {
28 start: 1,
29 step: 1,
30 range: {
31 'min': 1,
32 'max': 500
33 },
34 behaviour: 'tap-drag',
35 format: wNumb({
36 decimals: 0
37 })
38 };
39
40 var posts_per_page = jQuery('#wpupg_pagination_pages_posts_per_page');
41 slider_args.start = posts_per_page.val();
42 jQuery('#wpupg_pagination_pages_posts_per_page_slider').noUiSlider(slider_args).Link('lower').to(posts_per_page);
43
44 var infinite_posts = jQuery('#wpupg_pagination_infinite_load_initial_posts');
45 slider_args.start = infinite_posts.val();
46 jQuery('#wpupg_pagination_infinite_load_initial_posts_slider').noUiSlider(slider_args).Link('lower').to(infinite_posts);
47
48 var posts_on_scroll = jQuery('#wpupg_pagination_infinite_load_posts_on_scroll');
49 slider_args.start = posts_on_scroll.val();
50 jQuery('#wpupg_pagination_infinite_load_posts_on_scroll_slider').noUiSlider(slider_args).Link('lower').to(posts_on_scroll);
51
52 var initial_posts = jQuery('#wpupg_pagination_load_more_initial_posts');
53 slider_args.start = initial_posts.val();
54 jQuery('#wpupg_pagination_load_more_initial_posts_slider').noUiSlider(slider_args).Link('lower').to(initial_posts);
55
56 var posts_on_click = jQuery('#wpupg_pagination_load_more_posts_on_click');
57 slider_args.start = posts_on_click.val();
58 jQuery('#wpupg_pagination_load_more_posts_on_click_slider').noUiSlider(slider_args).Link('lower').to(posts_on_click);
59
60 var initial_posts_filter = jQuery('#wpupg_pagination_load_filter_initial_posts');
61 slider_args.start = initial_posts_filter.val();
62 jQuery('#wpupg_pagination_load_filter_initial_posts_slider').noUiSlider(slider_args).Link('lower').to(initial_posts_filter);
63
64 slider_args = {
65 start: 0,
66 step: 1,
67 range: {
68 'min': 0,
69 'max': 50
70 },
71 behaviour: 'tap-drag',
72 format: wNumb({
73 decimals: 0
74 })
75 };
76
77 var isotope_margin_vertical = jQuery('#wpupg_isotope_filter_style_margin_vertical');
78 slider_args.start = isotope_margin_vertical.val();
79 jQuery('#wpupg_isotope_filter_style_margin_vertical_slider').noUiSlider(slider_args).on({
80 slide: function() {
81 WPUltimatePostGrid.changedIsotopeFilterStyle();
82 }
83 }).Link('lower').to(isotope_margin_vertical);
84
85 var isotope_margin_horizontal = jQuery('#wpupg_isotope_filter_style_margin_horizontal');
86 slider_args.start = isotope_margin_horizontal.val();
87 jQuery('#wpupg_isotope_filter_style_margin_horizontal_slider').noUiSlider(slider_args).on({
88 slide: function() {
89 WPUltimatePostGrid.changedIsotopeFilterStyle();
90 }
91 }).Link('lower').to(isotope_margin_horizontal);
92
93 var isotope_padding_vertical = jQuery('#wpupg_isotope_filter_style_padding_vertical');
94 slider_args.start = isotope_padding_vertical.val();
95 jQuery('#wpupg_isotope_filter_style_padding_vertical_slider').noUiSlider(slider_args).on({
96 slide: function() {
97 WPUltimatePostGrid.changedIsotopeFilterStyle();
98 }
99 }).Link('lower').to(isotope_padding_vertical);
100
101 var isotope_padding_horizontal = jQuery('#wpupg_isotope_filter_style_padding_horizontal');
102 slider_args.start = isotope_padding_horizontal.val();
103 jQuery('#wpupg_isotope_filter_style_padding_horizontal_slider').noUiSlider(slider_args).on({
104 slide: function() {
105 WPUltimatePostGrid.changedIsotopeFilterStyle();
106 }
107 }).Link('lower').to(isotope_padding_horizontal);
108
109 var isotope_border_width = jQuery('#wpupg_isotope_filter_style_border_width');
110 slider_args.start = isotope_border_width.val();
111 jQuery('#wpupg_isotope_filter_style_border_width_slider').noUiSlider(slider_args).on({
112 slide: function() {
113 WPUltimatePostGrid.changedIsotopeFilterStyle();
114 }
115 }).Link('lower').to(isotope_border_width);
116
117
118 var pagination_margin_vertical = jQuery('#wpupg_pagination_style_margin_vertical');
119 slider_args.start = pagination_margin_vertical.val();
120 jQuery('#wpupg_pagination_style_margin_vertical_slider').noUiSlider(slider_args).on({
121 slide: function() {
122 WPUltimatePostGrid.changedPaginationStyle();
123 }
124 }).Link('lower').to(pagination_margin_vertical);
125
126 var pagination_margin_horizontal = jQuery('#wpupg_pagination_style_margin_horizontal');
127 slider_args.start = pagination_margin_horizontal.val();
128 jQuery('#wpupg_pagination_style_margin_horizontal_slider').noUiSlider(slider_args).on({
129 slide: function() {
130 WPUltimatePostGrid.changedPaginationStyle();
131 }
132 }).Link('lower').to(pagination_margin_horizontal);
133
134 var pagination_padding_vertical = jQuery('#wpupg_pagination_style_padding_vertical');
135 slider_args.start = pagination_padding_vertical.val();
136 jQuery('#wpupg_pagination_style_padding_vertical_slider').noUiSlider(slider_args).on({
137 slide: function() {
138 WPUltimatePostGrid.changedPaginationStyle();
139 }
140 }).Link('lower').to(pagination_padding_vertical);
141
142 var pagination_padding_horizontal = jQuery('#wpupg_pagination_style_padding_horizontal');
143 slider_args.start = pagination_padding_horizontal.val();
144 jQuery('#wpupg_pagination_style_padding_horizontal_slider').noUiSlider(slider_args).on({
145 slide: function() {
146 WPUltimatePostGrid.changedPaginationStyle();
147 }
148 }).Link('lower').to(pagination_padding_horizontal);
149
150 var pagination_border_width = jQuery('#wpupg_pagination_style_border_width');
151 slider_args.start = pagination_border_width.val();
152 jQuery('#wpupg_pagination_style_border_width_slider').noUiSlider(slider_args).on({
153 slide: function() {
154 WPUltimatePostGrid.changedPaginationStyle();
155 }
156 }).Link('lower').to(pagination_border_width);
157
158 // Color Pickers
159 jQuery('#wpupg_isotope_filter_style_background_color').wpColorPicker({
160 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
161 });
162 jQuery('#wpupg_isotope_filter_style_background_active_color').wpColorPicker({
163 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
164 });
165 jQuery('#wpupg_isotope_filter_style_background_hover_color').wpColorPicker({
166 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
167 });
168 jQuery('#wpupg_isotope_filter_style_text_color').wpColorPicker({
169 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
170 });
171 jQuery('#wpupg_isotope_filter_style_text_active_color').wpColorPicker({
172 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
173 });
174 jQuery('#wpupg_isotope_filter_style_text_hover_color').wpColorPicker({
175 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
176 });
177 jQuery('#wpupg_isotope_filter_style_border_color').wpColorPicker({
178 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
179 });
180 jQuery('#wpupg_isotope_filter_style_border_active_color').wpColorPicker({
181 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
182 });
183 jQuery('#wpupg_isotope_filter_style_border_hover_color').wpColorPicker({
184 change: function () { WPUltimatePostGrid.changedIsotopeFilterStyle(); }
185 });
186
187 jQuery('#wpupg_pagination_style_background_color').wpColorPicker({
188 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
189 });
190 jQuery('#wpupg_pagination_style_background_active_color').wpColorPicker({
191 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
192 });
193 jQuery('#wpupg_pagination_style_background_hover_color').wpColorPicker({
194 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
195 });
196 jQuery('#wpupg_pagination_style_text_color').wpColorPicker({
197 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
198 });
199 jQuery('#wpupg_pagination_style_text_active_color').wpColorPicker({
200 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
201 });
202 jQuery('#wpupg_pagination_style_text_hover_color').wpColorPicker({
203 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
204 });
205 jQuery('#wpupg_pagination_style_border_color').wpColorPicker({
206 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
207 });
208 jQuery('#wpupg_pagination_style_border_active_color').wpColorPicker({
209 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
210 });
211 jQuery('#wpupg_pagination_style_border_hover_color').wpColorPicker({
212 change: function () { WPUltimatePostGrid.changedPaginationStyle(); }
213 });
214
215 // Initial State
216 WPUltimatePostGrid.changedType();
217 WPUltimatePostGrid.changedPostType();
218 WPUltimatePostGrid.changedTaxonomy();
219 WPUltimatePostGrid.changedOrderBy();
220 WPUltimatePostGrid.changedLimitPosts();
221 WPUltimatePostGrid.changedLimitTerms();
222 WPUltimatePostGrid.initRules();
223 WPUltimatePostGrid.changedFilterType();
224 WPUltimatePostGrid.changedShowCount();
225 WPUltimatePostGrid.changedMultiselect();
226 WPUltimatePostGrid.changedLimitFilterTerms();
227 WPUltimatePostGrid.changedDropdownLabels();
228 WPUltimatePostGrid.changedIsotopeFilterStyle();
229 WPUltimatePostGrid.changedIsotopeFilterText();
230 WPUltimatePostGrid.changedLayoutMode();
231 WPUltimatePostGrid.changedPaginationStyle();
232 WPUltimatePostGrid.changedPaginationType();
233 WPUltimatePostGrid.changedPaginationText();
234
235 // Events
236 jQuery('#wpupg_type').on('change', function() { WPUltimatePostGrid.changedType(); });
237 jQuery('#wpupg_post_types').on('change', function() { WPUltimatePostGrid.changedPostType(); });
238 jQuery('#wpupg_taxonomies').on('change', function() { WPUltimatePostGrid.changedTaxonomy(); });
239 jQuery('#wpupg_order_by').on('change', function() { WPUltimatePostGrid.changedOrderBy(); });
240 jQuery('#wpupg_limit_posts').on('change', function() { WPUltimatePostGrid.changedLimitPosts(); });
241 jQuery('#wpupg_limit_terms').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); });
242 jQuery('#wpupg_add_rule').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.addRule(); });
243 jQuery('.wpupg_rule_delete').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.removeRule(jQuery(this).parents('tr').attr('data-rule')); });
244 jQuery('.wpupg_rule_field').on('change', function(e) { WPUltimatePostGrid.changedRuleField(jQuery(this).parents('tr').attr('data-rule')); });
245 jQuery('.rule_container_wpupg_general_date').find('select').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); });
246 jQuery('.wpupg-date').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); });
247 jQuery('#wpupg_filter_type').on('change', function() { WPUltimatePostGrid.changedFilterType(); });
248 jQuery('#wpupg_filter_count').on('change', function() { WPUltimatePostGrid.changedShowCount(); });
249 jQuery('#wpupg_filter_multiselect').on('change', function() { WPUltimatePostGrid.changedMultiselect(); });
250 jQuery('.wpupg_filter_taxonomy').on('change', function() { WPUltimatePostGrid.changedLimitFilterTerms(); WPUltimatePostGrid.changedDropdownLabels(); });
251 jQuery('#wpupg_filter_limit').on('change', function() { WPUltimatePostGrid.changedLimitFilterTerms(); });
252 jQuery('#wpupg_layout_mode').on('change', function() { WPUltimatePostGrid.changedLayoutMode(); });
253 jQuery('#wpupg_pagination_type').on('change', function() { WPUltimatePostGrid.changedPaginationType(); });
254 jQuery('#wpupg_pagination_load_more_button_text').on('change keyup', function() { WPUltimatePostGrid.changedPaginationText(); });
255
256 isotope_margin_vertical.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
257 isotope_margin_horizontal.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
258 isotope_padding_vertical.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
259 isotope_padding_horizontal.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
260 isotope_border_width.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
261 jQuery('#wpupg_isotope_filter_style_alignment').on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
262 jQuery('#wpupg_isotope_filter_style_all_button_text').on('change keyup', function() { WPUltimatePostGrid.changedIsotopeFilterText(); });
263
264 pagination_margin_vertical.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
265 pagination_margin_horizontal.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
266 pagination_padding_vertical.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
267 pagination_padding_horizontal.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
268 pagination_border_width.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
269 jQuery('#wpupg_pagination_style_alignment').on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
270
271 jQuery('.wpupg-filter-isotope-term').hover(function() {
272 if(!jQuery(this).hasClass('active')) {
273 var background_hover_color = jQuery('#wpupg_isotope_filter_style_background_hover_color').wpColorPicker('color');
274 var text_hover_color = jQuery('#wpupg_isotope_filter_style_text_hover_color').wpColorPicker('color');
275 var border_hover_color = jQuery('#wpupg_isotope_filter_style_border_hover_color').wpColorPicker('color');
276
277 jQuery(this)
278 .css('background-color', background_hover_color)
279 .css('color', text_hover_color)
280 .css('border-color', border_hover_color)
281 ;
282 }
283 }, function() {
284 if(!jQuery(this).hasClass('active')) {
285 var background_color = jQuery('#wpupg_isotope_filter_style_background_color').wpColorPicker('color');
286 var text_color = jQuery('#wpupg_isotope_filter_style_text_color').wpColorPicker('color');
287 var border_color = jQuery('#wpupg_isotope_filter_style_border_color').wpColorPicker('color');
288
289 jQuery(this)
290 .css( 'background-color', background_color )
291 .css( 'color', text_color)
292 .css( 'border-color', border_color )
293 ;
294 }
295 });
296
297 jQuery('.wpupg-pagination-term').hover(function() {
298 if(!jQuery(this).hasClass('active')) {
299 var background_hover_color = jQuery('#wpupg_pagination_style_background_hover_color').wpColorPicker('color');
300 var text_hover_color = jQuery('#wpupg_pagination_style_text_hover_color').wpColorPicker('color');
301 var border_hover_color = jQuery('#wpupg_pagination_style_border_hover_color').wpColorPicker('color');
302
303 jQuery(this)
304 .css('background-color', background_hover_color)
305 .css('color', text_hover_color)
306 .css('border-color', border_hover_color)
307 ;
308 }
309 }, function() {
310 if(!jQuery(this).hasClass('active')) {
311 var background_color = jQuery('#wpupg_pagination_style_background_color').wpColorPicker('color');
312 var text_color = jQuery('#wpupg_pagination_style_text_color').wpColorPicker('color');
313 var border_color = jQuery('#wpupg_pagination_style_border_color').wpColorPicker('color');
314
315 jQuery(this)
316 .css( 'background-color', background_color )
317 .css( 'color', text_color)
318 .css( 'border-color', border_color )
319 ;
320 }
321 });
322 };
323
324 WPUltimatePostGrid.changedType = function() {
325 var type = jQuery('#wpupg_type').find(':selected').val();
326
327 if( type == 'terms' ) {
328 WPUltimatePostGrid.checkPremiumFeatures('type', true);
329 jQuery('#wpupg_meta_box_data_source_terms').show();
330
331 jQuery('#wpupg_meta_box_data_source').hide();
332 jQuery('#wpupg_meta_box_limit_terms').show();
333 jQuery('#wpupg_meta_box_limit_posts').hide();
334 jQuery('#wpupg_meta_box_filter').hide();
335 jQuery('#wpupg_meta_box_isotope_filter').hide();
336 jQuery('#wpupg_meta_box_pagination').hide();
337 jQuery('#wpupg_meta_box_pagination_style').hide();
338
339 WPUltimatePostGrid.changedLimitTerms();
340 } else {
341 WPUltimatePostGrid.checkPremiumFeatures('type', false);
342 jQuery('#wpupg_meta_box_data_source_terms').hide();
343
344 jQuery('#wpupg_meta_box_data_source').show();
345 jQuery('#wpupg_meta_box_limit_terms').hide();
346 jQuery('#wpupg_meta_box_limit_posts').show();
347 jQuery('#wpupg_meta_box_filter').show();
348 jQuery('#wpupg_meta_box_isotope_filter').show();
349 jQuery('#wpupg_meta_box_pagination').show();
350 jQuery('#wpupg_meta_box_pagination_style').show();
351
352 WPUltimatePostGrid.changedLimitPosts();
353 WPUltimatePostGrid.changedFilterType();
354 WPUltimatePostGrid.changedPaginationType();
355 }
356 };
357
358 WPUltimatePostGrid.changedTaxonomy = function() {
359 var taxonomy = jQuery('#wpupg_taxonomies').find(':selected').val();
360
361 jQuery('#wpupg_form_limit_terms').find('tr').hide();
362 jQuery('#wpupg_form_limit_terms').find('tr#wpupg_form_limit_terms_' + taxonomy).show();
363 };
364
365 WPUltimatePostGrid.changedPostType = function() {
366 var post_type = jQuery('#wpupg_post_types').find(':selected').val();
367
368 jQuery('.wpupg_filter_taxonomy_container').hide();
369 var container = jQuery('#wpupg_filter_taxonomy_' + post_type + '_container');
370
371 if(container.length > 0) {
372 jQuery('#wpupg_no_taxonomies').hide();
373 jQuery('#wpupg_form_filter').show();
374 container.show();
375 WPUltimatePostGrid.filter_possible = true;
376 } else {
377 jQuery('#wpupg_no_taxonomies').show();
378 jQuery('#wpupg_form_filter').hide();
379 WPUltimatePostGrid.filter_possible = false;
380 }
381
382 WPUltimatePostGrid.changedFilterType();
383 WPUltimatePostGrid.changedLimitFilterTerms();
384 WPUltimatePostGrid.changedDropdownLabels();
385 };
386
387 WPUltimatePostGrid.changedOrderBy = function() {
388 var order_by = jQuery('#wpupg_order_by').find(':selected').val();
389
390 if(order_by == 'custom') {
391 WPUltimatePostGrid.checkPremiumFeatures('order_by', true);
392 jQuery('.wpupg_order_custom_key_container').show();
393 } else {
394 WPUltimatePostGrid.checkPremiumFeatures('order_by', false);
395 jQuery('.wpupg_order_custom_key_container').hide();
396 }
397 };
398
399 WPUltimatePostGrid.changedLimitTerms = function() {
400 if(jQuery('#wpupg_limit_terms').is(':checked')) {
401 jQuery('#wpupg_meta_box_limit_terms').show();
402 } else {
403 jQuery('#wpupg_meta_box_limit_terms').hide();
404 }
405 };
406
407 WPUltimatePostGrid.changedLimitPosts = function() {
408 if(jQuery('#wpupg_limit_posts').is(':checked')) {
409 WPUltimatePostGrid.checkPremiumFeatures('limit_posts', true);
410 jQuery('#wpupg_meta_box_limit_posts').show();
411 } else {
412 WPUltimatePostGrid.checkPremiumFeatures('limit_posts', false);
413 jQuery('#wpupg_meta_box_limit_posts').hide();
414 }
415 };
416
417 WPUltimatePostGrid.initRules = function() {
418 jQuery('#wpupg_rules').find('tr').each(function() {
419 var rule = jQuery(this);
420
421 rule
422 .find('select')
423 .select2wpupg({
424 width: '100%'
425 })
426 ;
427
428 WPUltimatePostGrid.changedRuleField(rule.attr('data-rule'));
429 });
430 };
431
432 WPUltimatePostGrid.addRule = function() {
433 var rules = jQuery('#wpupg_rules');
434 var rule_id = rules.find('tr:last').attr('data-rule');
435 rule_id = rule_id == undefined ? 1 : parseInt(rule_id) + 1;
436
437 var new_rule = jQuery('#wpupg_rule_placeholder').find('tr').first().clone(true);
438
439 new_rule
440 .appendTo(rules)
441 .attr('id', function(index, val) {
442 return val.replace(/(\d+)/, rule_id);
443 })
444 .attr('data-rule', function(index, val) {
445 return val.replace(/(\d+)/, rule_id);
446 })
447 .find('select, input')
448 .attr('name', function(index, val) {
449 return val.replace(/(\d+)/, rule_id);
450 })
451 .attr('id', function(index, val) {
452 return val.replace(/(\d+)/, rule_id);
453 })
454 ;
455
456 new_rule
457 .find('select')
458 .select2wpupg({
459 width: '100%'
460 })
461 ;
462
463 new_rule.find('.wpupg-date').datepicker();
464
465 WPUltimatePostGrid.changedRuleField(rule_id);
466 WPUltimatePostGrid.changedDateRule(rule_id);
467 };
468
469 WPUltimatePostGrid.removeRule = function(id) {
470 if(id != '0') {
471 jQuery('#wpupg_rule_' + id).remove();
472 }
473 };
474
475 WPUltimatePostGrid.changedRuleField = function(id) {
476 var row = jQuery('#wpupg_rule_' + id);
477 var field = jQuery('#wpupg_limit_posts_rule_field_' + id).val();
478 field = field.replace('|','_');
479
480
481
482 row.find('.rule_container').hide();
483 row.find('.rule_container_' + field).show();
484 };
485
486 WPUltimatePostGrid.changedDateRule = function(id) {
487 var condition = jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_condition_' + id).find(':selected').val();
488 var date = jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_date_' + id).val();
489 jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_' + id).val(condition + ';' + date);
490 };
491
492 WPUltimatePostGrid.changedFilterType = function() {
493 var filter_type = jQuery('#wpupg_filter_type').find(':selected').val();
494 var filter_type_search = false;
495
496 if(filter_type.substring(0,5) == 'text_') {
497 filter_type = filter_type.substring(5);
498 filter_type_search = true;
499 }
500
501 // Hide & Show Filter Settings
502 if(filter_type == 'none' || filter_type == 'text') {
503 jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').hide();
504 } else {
505 jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show();
506 }
507
508 // Premium only filters
509 if(filter_type == 'dropdown' || filter_type == 'text') {
510 WPUltimatePostGrid.checkPremiumFeatures('filter_type', true);
511 } else {
512 WPUltimatePostGrid.checkPremiumFeatures('filter_type', false);
513 }
514
515 // Hide & Show Filter Styles
516 jQuery('#wpupg_meta_box_isotope_filter').hide();
517 jQuery('#wpupg_meta_box_text_filter').hide();
518 jQuery('#wpupg_meta_box_dropdown_filter').hide();
519
520 if(WPUltimatePostGrid.filter_possible) {
521 jQuery('#wpupg_meta_box_' + filter_type + '_filter').show();
522
523 if(filter_type_search) {
524 jQuery('#wpupg_meta_box_text_filter').show();
525 }
526 }
527
528 WPUltimatePostGrid.changedLimitFilterTerms();
529 WPUltimatePostGrid.changedDropdownLabels();
530 };
531
532 WPUltimatePostGrid.changedShowCount = function() {
533 var show_count = jQuery('#wpupg_filter_count').is(':checked');
534
535 if(show_count) {
536 WPUltimatePostGrid.checkPremiumFeatures('show_count', true);
537 } else {
538 WPUltimatePostGrid.checkPremiumFeatures('show_count', false);
539 }
540 };
541
542 WPUltimatePostGrid.changedMultiselect = function() {
543 var multiselect = jQuery('#wpupg_filter_multiselect').is(':checked');
544
545 if(multiselect) {
546 WPUltimatePostGrid.checkPremiumFeatures('multiselect', true);
547 jQuery('.wpupg_multiselect').show();
548 } else {
549 WPUltimatePostGrid.checkPremiumFeatures('multiselect', false);
550 jQuery('.wpupg_multiselect').hide();
551 }
552 };
553
554 WPUltimatePostGrid.changedLimitFilterTerms = function() {
555 var limit_terms = jQuery('#wpupg_filter_limit').is(':checked');
556 var post_type = jQuery('#wpupg_post_types').find(':selected').val();
557 var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val();
558
559 if( !jQuery.isArray( taxonomies ) ) {
560 taxonomies = [taxonomies];
561 }
562
563 if(limit_terms && taxonomies) {
564 jQuery('.wpupg_limit_terms').show();
565 jQuery('.wpupg_filter_terms_taxonomy').hide();
566
567 for(var i = 0; i < taxonomies.length; i++) {
568 jQuery('#wpupg_filter_terms_taxonomy_' + taxonomies[i]).show();
569 }
570 } else {
571 jQuery('.wpupg_limit_terms').hide();
572 }
573 };
574
575 WPUltimatePostGrid.changedDropdownLabels = function() {
576 var filter_type = jQuery('#wpupg_filter_type').find(':selected').val();
577 var post_type = jQuery('#wpupg_post_types').find(':selected').val();
578 var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val();
579
580 if(filter_type.substring(0,5) == 'text_') {
581 filter_type = filter_type.substring(5);
582 }
583
584 if( !jQuery.isArray( taxonomies ) ) {
585 taxonomies = [taxonomies];
586 }
587
588 if(filter_type == 'dropdown' && taxonomies) {
589 jQuery('.wpupg_dropdown_labels').show();
590 jQuery('.wpupg_filter_dropdown_labels_taxonomy').hide();
591
592 for(var i = 0; i < taxonomies.length; i++) {
593 jQuery('#wpupg_filter_dropdown_label_taxonomy_' + taxonomies[i]).show();
594 }
595 } else {
596 jQuery('.wpupg_dropdown_labels').hide();
597 }
598 };
599
600 WPUltimatePostGrid.changedIsotopeFilterStyle = function() {
601 var margin_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_margin_vertical').val());
602 var margin_horizontal = parseInt(jQuery('#wpupg_isotope_filter_style_margin_horizontal').val());
603 var padding_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_padding_vertical').val());
604 var padding_horizontal = parseInt(jQuery('#wpupg_isotope_filter_style_padding_horizontal').val());
605 var border_width = parseInt(jQuery('#wpupg_isotope_filter_style_border_width').val());
606
607 var background_color = jQuery('#wpupg_isotope_filter_style_background_color').wpColorPicker('color');
608 var text_color = jQuery('#wpupg_isotope_filter_style_text_color').wpColorPicker('color');
609 var border_color = jQuery('#wpupg_isotope_filter_style_border_color').wpColorPicker('color');
610
611 var alignment = jQuery('#wpupg_isotope_filter_style_alignment').find(':selected').val();
612 jQuery('#wpupg_filter_preview_isotope_filter_style').css('text-align', alignment);
613
614 jQuery('.wpupg-filter-isotope-term')
615 .css( 'margin', margin_vertical + 'px ' + margin_horizontal + 'px' )
616 .css( 'padding', padding_vertical + 'px ' + padding_horizontal + 'px' )
617 .css( 'background-color', background_color )
618 .css( 'color', text_color )
619 .css( 'border', border_width + 'px solid ' + border_color )
620 ;
621
622 var background_active_color = jQuery('#wpupg_isotope_filter_style_background_active_color').wpColorPicker('color');
623 var text_active_color = jQuery('#wpupg_isotope_filter_style_text_active_color').wpColorPicker('color');
624 var border_active_color = jQuery('#wpupg_isotope_filter_style_border_active_color').wpColorPicker('color');
625
626 jQuery('.wpupg-filter-isotope-term.active')
627 .css( 'background-color', background_active_color )
628 .css( 'color', text_active_color )
629 .css( 'border', border_width + 'px solid ' + border_active_color )
630 ;
631 };
632
633 WPUltimatePostGrid.changedIsotopeFilterText = function() {
634 var text = jQuery('#wpupg_isotope_filter_style_all_button_text').val();
635
636 if(text.length > 0) {
637 jQuery('#wpupg_isotope_filter_style_all_button_text_preview').text(text).show();
638 } else {
639 jQuery('#wpupg_isotope_filter_style_all_button_text_preview').hide();
640 }
641 };
642
643
644 WPUltimatePostGrid.changedLayoutMode = function() {
645 var layout_mode = jQuery('#wpupg_layout_mode').find(':selected').val();
646
647 if(layout_mode == 'masonry') {
648 jQuery('.wpupg_masonry').show();
649 } else {
650 jQuery('.wpupg_masonry').hide();
651 }
652 };
653
654 WPUltimatePostGrid.changedPaginationStyle = function() {
655 var margin_vertical = parseInt(jQuery('#wpupg_pagination_style_margin_vertical').val());
656 var margin_horizontal = parseInt(jQuery('#wpupg_pagination_style_margin_horizontal').val());
657 var padding_vertical = parseInt(jQuery('#wpupg_pagination_style_padding_vertical').val());
658 var padding_horizontal = parseInt(jQuery('#wpupg_pagination_style_padding_horizontal').val());
659 var border_width = parseInt(jQuery('#wpupg_pagination_style_border_width').val());
660
661 var background_color = jQuery('#wpupg_pagination_style_background_color').wpColorPicker('color');
662 var text_color = jQuery('#wpupg_pagination_style_text_color').wpColorPicker('color');
663 var border_color = jQuery('#wpupg_pagination_style_border_color').wpColorPicker('color');
664
665 var alignment = jQuery('#wpupg_pagination_style_alignment').find(':selected').val();
666 jQuery('.wpupg_filter_preview_pagination_style').css('text-align', alignment);
667
668 jQuery('.wpupg-pagination-term')
669 .css( 'margin', margin_vertical + 'px ' + margin_horizontal + 'px' )
670 .css( 'padding', padding_vertical + 'px ' + padding_horizontal + 'px' )
671 .css( 'background-color', background_color )
672 .css( 'color', text_color )
673 .css( 'border', border_width + 'px solid ' + border_color )
674 ;
675
676 var background_active_color = jQuery('#wpupg_pagination_style_background_active_color').wpColorPicker('color');
677 var text_active_color = jQuery('#wpupg_pagination_style_text_active_color').wpColorPicker('color');
678 var border_active_color = jQuery('#wpupg_pagination_style_border_active_color').wpColorPicker('color');
679
680 jQuery('.wpupg-pagination-term.active')
681 .css( 'background-color', background_active_color )
682 .css( 'color', text_active_color )
683 .css( 'border', border_width + 'px solid ' + border_active_color )
684 ;
685 };
686
687 WPUltimatePostGrid.changedPaginationType = function() {
688 var pagination_type = jQuery('#wpupg_pagination_type').find(':selected').val();
689
690 // Hide & Show Pagination Settings
691 jQuery('#wpupg_form_pagination').find('tbody').not('.wpupg_pagination_' + pagination_type).not('.wpupg_pagination_none').hide();
692 jQuery('#wpupg_form_pagination').find('tbody.wpupg_pagination_' + pagination_type).show();
693
694 // Premium only pagination
695 if(pagination_type == 'none' || pagination_type == 'pages') {
696 WPUltimatePostGrid.checkPremiumFeatures('pagination_type', false);
697 } else {
698 WPUltimatePostGrid.checkPremiumFeatures('pagination_type', true);
699 }
700
701 // Hide & Show Pagination Styles
702 if(pagination_type != 'none' && pagination_type != 'infinite_load' && pagination_type != 'load_filter') {
703 pagination_type = pagination_type == 'load_more_filter' ? 'load_more' : pagination_type;
704 jQuery('#wpupg_meta_box_pagination_style').show().find('.wpupg_filter_preview').hide();
705 jQuery('#wpupg_filter_preview_pagination_style_' + pagination_type).show();
706 } else {
707 jQuery('#wpupg_meta_box_pagination_style').hide();
708 }
709 };
710
711 WPUltimatePostGrid.changedPaginationText = function() {
712 var text = jQuery('#wpupg_pagination_load_more_button_text').val();
713 jQuery('#wpupg_filter_preview_pagination_style_load_more').find('.wpupg-pagination-term').text(text);
714 };
715
716 WPUltimatePostGrid.checkPremiumFeatures = function(feature, using) {
717 if(using) {
718 WPUltimatePostGrid.premium_features_used.push(feature);
719 } else {
720 // Remove feature from array
721 WPUltimatePostGrid.premium_features_used = jQuery.grep(WPUltimatePostGrid.premium_features_used, function(value) {
722 return value != feature;
723 });
724 }
725
726 if(WPUltimatePostGrid.premium_features_used.length > 0) {
727 jQuery('#wpupg_meta_box_premium_only').show();
728 } else {
729 jQuery('#wpupg_meta_box_premium_only').hide();
730 }
731 };
732
733 jQuery(document).ready(function($) {
734 if($('#wpupg_meta_box_data_source').length > 0) {
735 WPUltimatePostGrid.initForm();
736 }
737 });