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

627 lines 27.6 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.changedPostType();
217 WPUltimatePostGrid.changedOrderBy();
218 WPUltimatePostGrid.changedLimitPosts();
219 WPUltimatePostGrid.initRules();
220 WPUltimatePostGrid.changedFilterType();
221 WPUltimatePostGrid.changedMultiselect();
222 WPUltimatePostGrid.changedLimitTerms();
223 WPUltimatePostGrid.changedIsotopeFilterStyle();
224 WPUltimatePostGrid.changedIsotopeFilterText();
225 WPUltimatePostGrid.changedLayoutMode();
226 WPUltimatePostGrid.changedPaginationStyle();
227 WPUltimatePostGrid.changedPaginationType();
228 WPUltimatePostGrid.changedPaginationText();
229
230 // Events
231 jQuery('#wpupg_post_types').on('change', function() { WPUltimatePostGrid.changedPostType(); });
232 jQuery('#wpupg_order_by').on('change', function() { WPUltimatePostGrid.changedOrderBy(); });
233 jQuery('#wpupg_limit_posts').on('change', function() { WPUltimatePostGrid.changedLimitPosts(); });
234 jQuery('#wpupg_add_rule').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.addRule(); });
235 jQuery('.wpupg_rule_delete').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.removeRule(jQuery(this).parents('tr').attr('data-rule')); });
236 jQuery('.wpupg_rule_field').on('change', function(e) { WPUltimatePostGrid.changedRuleField(jQuery(this).parents('tr').attr('data-rule')); });
237 jQuery('.rule_container_wpupg_general_date').find('select').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); });
238 jQuery('.wpupg-date').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); });
239 jQuery('#wpupg_filter_type').on('change', function() { WPUltimatePostGrid.changedFilterType(); });
240 jQuery('#wpupg_filter_multiselect').on('change', function() { WPUltimatePostGrid.changedMultiselect(); });
241 jQuery('.wpupg_filter_taxonomy').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); });
242 jQuery('#wpupg_filter_limit').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); });
243 jQuery('#wpupg_layout_mode').on('change', function() { WPUltimatePostGrid.changedLayoutMode(); });
244 jQuery('#wpupg_pagination_type').on('change', function() { WPUltimatePostGrid.changedPaginationType(); });
245 jQuery('#wpupg_pagination_load_more_button_text').on('change keyup', function() { WPUltimatePostGrid.changedPaginationText(); });
246
247 isotope_margin_vertical.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
248 isotope_margin_horizontal.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
249 isotope_padding_vertical.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
250 isotope_padding_horizontal.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
251 isotope_border_width.on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
252 jQuery('#wpupg_isotope_filter_style_alignment').on('change', function() { WPUltimatePostGrid.changedIsotopeFilterStyle(); });
253 jQuery('#wpupg_isotope_filter_style_all_button_text').on('change keyup', function() { WPUltimatePostGrid.changedIsotopeFilterText(); });
254
255 pagination_margin_vertical.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
256 pagination_margin_horizontal.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
257 pagination_padding_vertical.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
258 pagination_padding_horizontal.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
259 pagination_border_width.on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
260 jQuery('#wpupg_pagination_style_alignment').on('change', function() { WPUltimatePostGrid.changedPaginationStyle(); });
261
262 jQuery('.wpupg-filter-isotope-term').hover(function() {
263 if(!jQuery(this).hasClass('active')) {
264 var background_hover_color = jQuery('#wpupg_isotope_filter_style_background_hover_color').wpColorPicker('color');
265 var text_hover_color = jQuery('#wpupg_isotope_filter_style_text_hover_color').wpColorPicker('color');
266 var border_hover_color = jQuery('#wpupg_isotope_filter_style_border_hover_color').wpColorPicker('color');
267
268 jQuery(this)
269 .css('background-color', background_hover_color)
270 .css('color', text_hover_color)
271 .css('border-color', border_hover_color)
272 ;
273 }
274 }, function() {
275 if(!jQuery(this).hasClass('active')) {
276 var background_color = jQuery('#wpupg_isotope_filter_style_background_color').wpColorPicker('color');
277 var text_color = jQuery('#wpupg_isotope_filter_style_text_color').wpColorPicker('color');
278 var border_color = jQuery('#wpupg_isotope_filter_style_border_color').wpColorPicker('color');
279
280 jQuery(this)
281 .css( 'background-color', background_color )
282 .css( 'color', text_color)
283 .css( 'border-color', border_color )
284 ;
285 }
286 });
287
288 jQuery('.wpupg-pagination-term').hover(function() {
289 if(!jQuery(this).hasClass('active')) {
290 var background_hover_color = jQuery('#wpupg_pagination_style_background_hover_color').wpColorPicker('color');
291 var text_hover_color = jQuery('#wpupg_pagination_style_text_hover_color').wpColorPicker('color');
292 var border_hover_color = jQuery('#wpupg_pagination_style_border_hover_color').wpColorPicker('color');
293
294 jQuery(this)
295 .css('background-color', background_hover_color)
296 .css('color', text_hover_color)
297 .css('border-color', border_hover_color)
298 ;
299 }
300 }, function() {
301 if(!jQuery(this).hasClass('active')) {
302 var background_color = jQuery('#wpupg_pagination_style_background_color').wpColorPicker('color');
303 var text_color = jQuery('#wpupg_pagination_style_text_color').wpColorPicker('color');
304 var border_color = jQuery('#wpupg_pagination_style_border_color').wpColorPicker('color');
305
306 jQuery(this)
307 .css( 'background-color', background_color )
308 .css( 'color', text_color)
309 .css( 'border-color', border_color )
310 ;
311 }
312 });
313 };
314
315 WPUltimatePostGrid.changedPostType = function() {
316 var post_type = jQuery('#wpupg_post_types').find(':selected').val();
317
318 jQuery('.wpupg_filter_taxonomy_container').hide();
319 var container = jQuery('#wpupg_filter_taxonomy_' + post_type + '_container');
320
321 if(container.length > 0) {
322 jQuery('#wpupg_no_taxonomies').hide();
323 jQuery('#wpupg_form_filter').show();
324 container.show();
325 WPUltimatePostGrid.filter_possible = true;
326 } else {
327 jQuery('#wpupg_no_taxonomies').show();
328 jQuery('#wpupg_form_filter').hide();
329 WPUltimatePostGrid.filter_possible = false;
330 }
331
332 WPUltimatePostGrid.changedFilterType();
333 WPUltimatePostGrid.changedLimitTerms();
334 };
335
336 WPUltimatePostGrid.changedOrderBy = function() {
337 var order_by = jQuery('#wpupg_order_by').find(':selected').val();
338
339 if(order_by == 'custom') {
340 WPUltimatePostGrid.checkPremiumFeatures('order_by', true);
341 jQuery('.wpupg_order_custom_key_container').show();
342 } else {
343 WPUltimatePostGrid.checkPremiumFeatures('order_by', false);
344 jQuery('.wpupg_order_custom_key_container').hide();
345 }
346 };
347
348 WPUltimatePostGrid.changedLimitPosts = function() {
349 if(jQuery('#wpupg_limit_posts').is(':checked')) {
350 WPUltimatePostGrid.checkPremiumFeatures('limit_posts', true);
351 jQuery('#wpupg_meta_box_limit_posts').show();
352 } else {
353 WPUltimatePostGrid.checkPremiumFeatures('limit_posts', false);
354 jQuery('#wpupg_meta_box_limit_posts').hide();
355 }
356 };
357
358 WPUltimatePostGrid.initRules = function() {
359 jQuery('#wpupg_rules').find('tr').each(function() {
360 var rule = jQuery(this);
361
362 rule
363 .find('select')
364 .select2wpupg({
365 width: '100%'
366 })
367 ;
368
369 WPUltimatePostGrid.changedRuleField(rule.attr('data-rule'));
370 });
371 };
372
373 WPUltimatePostGrid.addRule = function() {
374 var rules = jQuery('#wpupg_rules');
375 var rule_id = rules.find('tr:last').attr('data-rule');
376 rule_id = rule_id == undefined ? 1 : parseInt(rule_id) + 1;
377
378 var new_rule = jQuery('#wpupg_rule_placeholder').find('tr').first().clone(true);
379
380 new_rule
381 .appendTo(rules)
382 .attr('id', function(index, val) {
383 return val.replace(/(\d+)/, rule_id);
384 })
385 .attr('data-rule', function(index, val) {
386 return val.replace(/(\d+)/, rule_id);
387 })
388 .find('select, input')
389 .attr('name', function(index, val) {
390 return val.replace(/(\d+)/, rule_id);
391 })
392 .attr('id', function(index, val) {
393 return val.replace(/(\d+)/, rule_id);
394 })
395 ;
396
397 new_rule
398 .find('select')
399 .select2wpupg({
400 width: '100%'
401 })
402 ;
403
404 new_rule.find('.wpupg-date').datepicker();
405
406 WPUltimatePostGrid.changedRuleField(rule_id);
407 WPUltimatePostGrid.changedDateRule(rule_id);
408 };
409
410 WPUltimatePostGrid.removeRule = function(id) {
411 if(id != '0') {
412 jQuery('#wpupg_rule_' + id).remove();
413 }
414 };
415
416 WPUltimatePostGrid.changedRuleField = function(id) {
417 var row = jQuery('#wpupg_rule_' + id);
418 var field = jQuery('#wpupg_limit_posts_rule_field_' + id).val();
419 field = field.replace('|','_');
420
421
422
423 row.find('.rule_container').hide();
424 row.find('.rule_container_' + field).show();
425 };
426
427 WPUltimatePostGrid.changedDateRule = function(id) {
428 var condition = jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_condition_' + id).find(':selected').val();
429 var date = jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_date_' + id).val();
430 jQuery('#wpupg_limit_posts_rule_values_wpupg_general_date_' + id).val(condition + ';' + date);
431 };
432
433 WPUltimatePostGrid.changedFilterType = function() {
434 var filter_type = jQuery('#wpupg_filter_type').find(':selected').val();
435
436 // Hide & Show Filter Settings
437 if(filter_type == 'none') {
438 jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').hide();
439 } else {
440 jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show();
441 }
442
443 // Premium only filters
444 if(filter_type == 'dropdown') {
445 WPUltimatePostGrid.checkPremiumFeatures('filter_type', true);
446 } else {
447 WPUltimatePostGrid.checkPremiumFeatures('filter_type', false);
448 }
449
450 // Hide & Show Filter Styles
451 jQuery('#wpupg_meta_box_isotope_filter').hide();
452 jQuery('#wpupg_meta_box_dropdown_filter').hide();
453
454 if(WPUltimatePostGrid.filter_possible) {
455 jQuery('#wpupg_meta_box_' + filter_type + '_filter').show();
456 }
457
458 WPUltimatePostGrid.changedLimitTerms();
459 };
460
461 WPUltimatePostGrid.changedMultiselect = function() {
462 var multiselect = jQuery('#wpupg_filter_multiselect').is(':checked');
463
464 if(multiselect) {
465 WPUltimatePostGrid.checkPremiumFeatures('multiselect', true);
466 jQuery('.wpupg_multiselect').show();
467 } else {
468 WPUltimatePostGrid.checkPremiumFeatures('multiselect', false);
469 jQuery('.wpupg_multiselect').hide();
470 }
471 };
472
473 WPUltimatePostGrid.changedLimitTerms = function() {
474 var limit_terms = jQuery('#wpupg_filter_limit').is(':checked');
475 var post_type = jQuery('#wpupg_post_types').find(':selected').val();
476 var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val();
477
478 if(limit_terms && taxonomies) {
479 jQuery('.wpupg_limit_terms').show();
480 jQuery('.wpupg_filter_terms_taxonomy').hide();
481
482 for(var i = 0; i < taxonomies.length; i++) {
483 jQuery('#wpupg_filter_terms_taxonomy_' + taxonomies[i]).show();
484 }
485 } else {
486 jQuery('.wpupg_limit_terms').hide();
487 }
488 };
489
490 WPUltimatePostGrid.changedIsotopeFilterStyle = function() {
491 var margin_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_margin_vertical').val());
492 var margin_horizontal = parseInt(jQuery('#wpupg_isotope_filter_style_margin_horizontal').val());
493 var padding_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_padding_vertical').val());
494 var padding_horizontal = parseInt(jQuery('#wpupg_isotope_filter_style_padding_horizontal').val());
495 var border_width = parseInt(jQuery('#wpupg_isotope_filter_style_border_width').val());
496
497 var background_color = jQuery('#wpupg_isotope_filter_style_background_color').wpColorPicker('color');
498 var text_color = jQuery('#wpupg_isotope_filter_style_text_color').wpColorPicker('color');
499 var border_color = jQuery('#wpupg_isotope_filter_style_border_color').wpColorPicker('color');
500
501 var alignment = jQuery('#wpupg_isotope_filter_style_alignment').find(':selected').val();
502 jQuery('#wpupg_filter_preview_isotope_filter_style').css('text-align', alignment);
503
504 jQuery('.wpupg-filter-isotope-term')
505 .css( 'margin', margin_vertical + 'px ' + margin_horizontal + 'px' )
506 .css( 'padding', padding_vertical + 'px ' + padding_horizontal + 'px' )
507 .css( 'background-color', background_color )
508 .css( 'color', text_color )
509 .css( 'border', border_width + 'px solid ' + border_color )
510 ;
511
512 var background_active_color = jQuery('#wpupg_isotope_filter_style_background_active_color').wpColorPicker('color');
513 var text_active_color = jQuery('#wpupg_isotope_filter_style_text_active_color').wpColorPicker('color');
514 var border_active_color = jQuery('#wpupg_isotope_filter_style_border_active_color').wpColorPicker('color');
515
516 jQuery('.wpupg-filter-isotope-term.active')
517 .css( 'background-color', background_active_color )
518 .css( 'color', text_active_color )
519 .css( 'border', border_width + 'px solid ' + border_active_color )
520 ;
521 };
522
523 WPUltimatePostGrid.changedIsotopeFilterText = function() {
524 var text = jQuery('#wpupg_isotope_filter_style_all_button_text').val();
525
526 if(text.length > 0) {
527 jQuery('#wpupg_isotope_filter_style_all_button_text_preview').text(text).show();
528 } else {
529 jQuery('#wpupg_isotope_filter_style_all_button_text_preview').hide();
530 }
531 };
532
533
534 WPUltimatePostGrid.changedLayoutMode = function() {
535 var layout_mode = jQuery('#wpupg_layout_mode').find(':selected').val();
536
537 if(layout_mode == 'masonry') {
538 jQuery('.wpupg_masonry').show();
539 } else {
540 jQuery('.wpupg_masonry').hide();
541 }
542 };
543
544 WPUltimatePostGrid.changedPaginationStyle = function() {
545 var margin_vertical = parseInt(jQuery('#wpupg_pagination_style_margin_vertical').val());
546 var margin_horizontal = parseInt(jQuery('#wpupg_pagination_style_margin_horizontal').val());
547 var padding_vertical = parseInt(jQuery('#wpupg_pagination_style_padding_vertical').val());
548 var padding_horizontal = parseInt(jQuery('#wpupg_pagination_style_padding_horizontal').val());
549 var border_width = parseInt(jQuery('#wpupg_pagination_style_border_width').val());
550
551 var background_color = jQuery('#wpupg_pagination_style_background_color').wpColorPicker('color');
552 var text_color = jQuery('#wpupg_pagination_style_text_color').wpColorPicker('color');
553 var border_color = jQuery('#wpupg_pagination_style_border_color').wpColorPicker('color');
554
555 var alignment = jQuery('#wpupg_pagination_style_alignment').find(':selected').val();
556 jQuery('.wpupg_filter_preview_pagination_style').css('text-align', alignment);
557
558 jQuery('.wpupg-pagination-term')
559 .css( 'margin', margin_vertical + 'px ' + margin_horizontal + 'px' )
560 .css( 'padding', padding_vertical + 'px ' + padding_horizontal + 'px' )
561 .css( 'background-color', background_color )
562 .css( 'color', text_color )
563 .css( 'border', border_width + 'px solid ' + border_color )
564 ;
565
566 var background_active_color = jQuery('#wpupg_pagination_style_background_active_color').wpColorPicker('color');
567 var text_active_color = jQuery('#wpupg_pagination_style_text_active_color').wpColorPicker('color');
568 var border_active_color = jQuery('#wpupg_pagination_style_border_active_color').wpColorPicker('color');
569
570 jQuery('.wpupg-pagination-term.active')
571 .css( 'background-color', background_active_color )
572 .css( 'color', text_active_color )
573 .css( 'border', border_width + 'px solid ' + border_active_color )
574 ;
575 };
576
577 WPUltimatePostGrid.changedPaginationType = function() {
578 var pagination_type = jQuery('#wpupg_pagination_type').find(':selected').val();
579
580 // Hide & Show Pagination Settings
581 jQuery('#wpupg_form_pagination').find('tbody').not('.wpupg_pagination_' + pagination_type).not('.wpupg_pagination_none').hide();
582 jQuery('#wpupg_form_pagination').find('tbody.wpupg_pagination_' + pagination_type).show();
583
584 // Premium only pagination
585 if(pagination_type == 'none' || pagination_type == 'pages') {
586 WPUltimatePostGrid.checkPremiumFeatures('pagination_type', false);
587 } else {
588 WPUltimatePostGrid.checkPremiumFeatures('pagination_type', true);
589 }
590
591 // Hide & Show Pagination Styles
592 if(pagination_type != 'none' && pagination_type != 'infinite_load' && pagination_type != 'load_filter') {
593 pagination_type = pagination_type == 'load_more_filter' ? 'load_more' : pagination_type;
594 jQuery('#wpupg_meta_box_pagination_style').show().find('.wpupg_filter_preview').hide();
595 jQuery('#wpupg_filter_preview_pagination_style_' + pagination_type).show();
596 } else {
597 jQuery('#wpupg_meta_box_pagination_style').hide();
598 }
599 };
600
601 WPUltimatePostGrid.changedPaginationText = function() {
602 var text = jQuery('#wpupg_pagination_load_more_button_text').val();
603 jQuery('#wpupg_filter_preview_pagination_style_load_more').find('.wpupg-pagination-term').text(text);
604 };
605
606 WPUltimatePostGrid.checkPremiumFeatures = function(feature, using) {
607 if(using) {
608 WPUltimatePostGrid.premium_features_used.push(feature);
609 } else {
610 // Remove feature from array
611 WPUltimatePostGrid.premium_features_used = jQuery.grep(WPUltimatePostGrid.premium_features_used, function(value) {
612 return value != feature;
613 });
614 }
615
616 if(WPUltimatePostGrid.premium_features_used.length > 0) {
617 jQuery('#wpupg_meta_box_premium_only').show();
618 } else {
619 jQuery('#wpupg_meta_box_premium_only').hide();
620 }
621 };
622
623 jQuery(document).ready(function($) {
624 if($('#wpupg_meta_box_data_source').length > 0) {
625 WPUltimatePostGrid.initForm();
626 }
627 });