PluginProbe
WP Ultimate Post Grid / 1.7.2
WP Ultimate Post Grid v1.7.2
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 1.7.2, at js/admin_form.js

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