| @@ -9,8 +9,18 @@ | ||
| 9 | 9 | jQuery('.wpupg-select2').select2wpupg({ |
| 10 | 10 | width: '100%' |
| 11 | 11 | }); |
| 12 | 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 | + | |
| 13 | 23 | // Datepicker |
| 14 | 24 | jQuery('#wpupg_rules').find('.wpupg-date').datepicker(); |
| 15 | 25 | |
| 16 | 26 | // Sliders |
| @@ -202,15 +212,18 @@ | ||
| 202 | 212 | change: function () { WPUltimatePostGrid.changedPaginationStyle(); } |
| 203 | 213 | }); |
| 204 | 214 | |
| 205 | 215 | // Initial State |
| 216 | + WPUltimatePostGrid.changedType(); | |
| 206 | 217 | WPUltimatePostGrid.changedPostType(); |
| 207 | 218 | WPUltimatePostGrid.changedOrderBy(); |
| 208 | 219 | WPUltimatePostGrid.changedLimitPosts(); |
| 209 | 220 | WPUltimatePostGrid.initRules(); |
| 210 | 221 | WPUltimatePostGrid.changedFilterType(); |
| 222 | + WPUltimatePostGrid.changedShowCount(); | |
| 211 | 223 | WPUltimatePostGrid.changedMultiselect(); |
| 212 | 224 | WPUltimatePostGrid.changedLimitTerms(); |
| 225 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 213 | 226 | WPUltimatePostGrid.changedIsotopeFilterStyle(); |
| 214 | 227 | WPUltimatePostGrid.changedIsotopeFilterText(); |
| 215 | 228 | WPUltimatePostGrid.changedLayoutMode(); |
| 216 | 229 | WPUltimatePostGrid.changedPaginationStyle(); |
| @@ -217,8 +230,9 @@ | ||
| 217 | 230 | WPUltimatePostGrid.changedPaginationType(); |
| 218 | 231 | WPUltimatePostGrid.changedPaginationText(); |
| 219 | 232 | |
| 220 | 233 | // Events |
| 234 | + jQuery('#wpupg_type').on('change', function() { WPUltimatePostGrid.changedType(); }); | |
| 221 | 235 | jQuery('#wpupg_post_types').on('change', function() { WPUltimatePostGrid.changedPostType(); }); |
| 222 | 236 | jQuery('#wpupg_order_by').on('change', function() { WPUltimatePostGrid.changedOrderBy(); }); |
| 223 | 237 | jQuery('#wpupg_limit_posts').on('change', function() { WPUltimatePostGrid.changedLimitPosts(); }); |
| 224 | 238 | jQuery('#wpupg_add_rule').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.addRule(); }); |
| @@ -226,10 +240,11 @@ | ||
| 226 | 240 | jQuery('.wpupg_rule_field').on('change', function(e) { WPUltimatePostGrid.changedRuleField(jQuery(this).parents('tr').attr('data-rule')); }); |
| 227 | 241 | jQuery('.rule_container_wpupg_general_date').find('select').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| 228 | 242 | jQuery('.wpupg-date').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| 229 | 243 | jQuery('#wpupg_filter_type').on('change', function() { WPUltimatePostGrid.changedFilterType(); }); |
| 244 | + jQuery('#wpupg_filter_count').on('change', function() { WPUltimatePostGrid.changedShowCount(); }); | |
| 230 | 245 | jQuery('#wpupg_filter_multiselect').on('change', function() { WPUltimatePostGrid.changedMultiselect(); }); |
| 231 | - jQuery('.wpupg_filter_taxonomy').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); }); | |
| 246 | + jQuery('.wpupg_filter_taxonomy').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); WPUltimatePostGrid.changedDropdownLabels(); }); | |
| 232 | 247 | jQuery('#wpupg_filter_limit').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); }); |
| 233 | 248 | jQuery('#wpupg_layout_mode').on('change', function() { WPUltimatePostGrid.changedLayoutMode(); }); |
| 234 | 249 | jQuery('#wpupg_pagination_type').on('change', function() { WPUltimatePostGrid.changedPaginationType(); }); |
| 235 | 250 | jQuery('#wpupg_pagination_load_more_button_text').on('change keyup', function() { WPUltimatePostGrid.changedPaginationText(); }); |
| @@ -301,8 +316,38 @@ | ||
| 301 | 316 | } |
| 302 | 317 | }); |
| 303 | 318 | }; |
| 304 | 319 | |
| 320 | +WPUltimatePostGrid.changedType = function() { | |
| 321 | + var type = jQuery('#wpupg_type').find(':selected').val(); | |
| 322 | + | |
| 323 | + if( type == 'terms' ) { | |
| 324 | + WPUltimatePostGrid.checkPremiumFeatures('type', true); | |
| 325 | + jQuery('#wpupg_meta_box_data_source_terms').show(); | |
| 326 | + | |
| 327 | + jQuery('#wpupg_meta_box_data_source').hide(); | |
| 328 | + jQuery('#wpupg_meta_box_limit_posts').hide(); | |
| 329 | + jQuery('#wpupg_meta_box_filter').hide(); | |
| 330 | + jQuery('#wpupg_meta_box_isotope_filter').hide(); | |
| 331 | + jQuery('#wpupg_meta_box_pagination').hide(); | |
| 332 | + jQuery('#wpupg_meta_box_pagination_style').hide(); | |
| 333 | + } else { | |
| 334 | + WPUltimatePostGrid.checkPremiumFeatures('type', false); | |
| 335 | + jQuery('#wpupg_meta_box_data_source_terms').hide(); | |
| 336 | + | |
| 337 | + jQuery('#wpupg_meta_box_data_source').show(); | |
| 338 | + jQuery('#wpupg_meta_box_limit_posts').show(); | |
| 339 | + jQuery('#wpupg_meta_box_filter').show(); | |
| 340 | + jQuery('#wpupg_meta_box_isotope_filter').show(); | |
| 341 | + jQuery('#wpupg_meta_box_pagination').show(); | |
| 342 | + jQuery('#wpupg_meta_box_pagination_style').show(); | |
| 343 | + | |
| 344 | + WPUltimatePostGrid.changedLimitPosts(); | |
| 345 | + WPUltimatePostGrid.changedFilterType(); | |
| 346 | + WPUltimatePostGrid.changedPaginationType(); | |
| 347 | + } | |
| 348 | +}; | |
| 349 | + | |
| 305 | 350 | WPUltimatePostGrid.changedPostType = function() { |
| 306 | 351 | var post_type = jQuery('#wpupg_post_types').find(':selected').val(); |
| 307 | 352 | |
| 308 | 353 | jQuery('.wpupg_filter_taxonomy_container').hide(); |
| @@ -320,8 +365,9 @@ | ||
| 320 | 365 | } |
| 321 | 366 | |
| 322 | 367 | WPUltimatePostGrid.changedFilterType(); |
| 323 | 368 | WPUltimatePostGrid.changedLimitTerms(); |
| 369 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 324 | 370 | }; |
| 325 | 371 | |
| 326 | 372 | WPUltimatePostGrid.changedOrderBy = function() { |
| 327 | 373 | var order_by = jQuery('#wpupg_order_by').find(':selected').val(); |
| @@ -422,10 +468,14 @@ | ||
| 422 | 468 | |
| 423 | 469 | WPUltimatePostGrid.changedFilterType = function() { |
| 424 | 470 | var filter_type = jQuery('#wpupg_filter_type').find(':selected').val(); |
| 425 | 471 | |
| 472 | + if(filter_type.substring(0,5) == 'text_') { | |
| 473 | + filter_type = filter_type.substring(5); | |
| 474 | + } | |
| 475 | + | |
| 426 | 476 | // Hide & Show Filter Settings |
| 427 | - if(filter_type == 'none') { | |
| 477 | + if(filter_type == 'none' || filter_type == 'text') { | |
| 428 | 478 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').hide(); |
| 429 | 479 | } else { |
| 430 | 480 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show(); |
| 431 | 481 | } |
| @@ -430,9 +480,9 @@ | ||
| 430 | 480 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show(); |
| 431 | 481 | } |
| 432 | 482 | |
| 433 | 483 | // Premium only filters |
| 434 | - if(filter_type == 'dropdown') { | |
| 484 | + if(filter_type == 'dropdown' || filter_type == 'text') { | |
| 435 | 485 | WPUltimatePostGrid.checkPremiumFeatures('filter_type', true); |
| 436 | 486 | } else { |
| 437 | 487 | WPUltimatePostGrid.checkPremiumFeatures('filter_type', false); |
| 438 | 488 | } |
| @@ -445,10 +495,21 @@ | ||
| 445 | 495 | jQuery('#wpupg_meta_box_' + filter_type + '_filter').show(); |
| 446 | 496 | } |
| 447 | 497 | |
| 448 | 498 | WPUltimatePostGrid.changedLimitTerms(); |
| 499 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 449 | 500 | }; |
| 450 | 501 | |
| 502 | +WPUltimatePostGrid.changedShowCount = function() { | |
| 503 | + var show_count = jQuery('#wpupg_filter_count').is(':checked'); | |
| 504 | + | |
| 505 | + if(show_count) { | |
| 506 | + WPUltimatePostGrid.checkPremiumFeatures('show_count', true); | |
| 507 | + } else { | |
| 508 | + WPUltimatePostGrid.checkPremiumFeatures('show_count', false); | |
| 509 | + } | |
| 510 | +}; | |
| 511 | + | |
| 451 | 512 | WPUltimatePostGrid.changedMultiselect = function() { |
| 452 | 513 | var multiselect = jQuery('#wpupg_filter_multiselect').is(':checked'); |
| 453 | 514 | |
| 454 | 515 | if(multiselect) { |
| @@ -464,8 +525,12 @@ | ||
| 464 | 525 | var limit_terms = jQuery('#wpupg_filter_limit').is(':checked'); |
| 465 | 526 | var post_type = jQuery('#wpupg_post_types').find(':selected').val(); |
| 466 | 527 | var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val(); |
| 467 | 528 | |
| 529 | + if( !jQuery.isArray( taxonomies ) ) { | |
| 530 | + taxonomies = [taxonomies]; | |
| 531 | + } | |
| 532 | + | |
| 468 | 533 | if(limit_terms && taxonomies) { |
| 469 | 534 | jQuery('.wpupg_limit_terms').show(); |
| 470 | 535 | jQuery('.wpupg_filter_terms_taxonomy').hide(); |
| 471 | 536 | |
| @@ -473,8 +538,33 @@ | ||
| 473 | 538 | jQuery('#wpupg_filter_terms_taxonomy_' + taxonomies[i]).show(); |
| 474 | 539 | } |
| 475 | 540 | } else { |
| 476 | 541 | jQuery('.wpupg_limit_terms').hide(); |
| 542 | + } | |
| 543 | +}; | |
| 544 | + | |
| 545 | +WPUltimatePostGrid.changedDropdownLabels = function() { | |
| 546 | + var filter_type = jQuery('#wpupg_filter_type').find(':selected').val(); | |
| 547 | + var post_type = jQuery('#wpupg_post_types').find(':selected').val(); | |
| 548 | + var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val(); | |
| 549 | + | |
| 550 | + if(filter_type.substring(0,5) == 'text_') { | |
| 551 | + filter_type = filter_type.substring(5); | |
| 552 | + } | |
| 553 | + | |
| 554 | + if( !jQuery.isArray( taxonomies ) ) { | |
| 555 | + taxonomies = [taxonomies]; | |
| 556 | + } | |
| 557 | + | |
| 558 | + if(filter_type == 'dropdown' && taxonomies) { | |
| 559 | + jQuery('.wpupg_dropdown_labels').show(); | |
| 560 | + jQuery('.wpupg_filter_dropdown_labels_taxonomy').hide(); | |
| 561 | + | |
| 562 | + for(var i = 0; i < taxonomies.length; i++) { | |
| 563 | + jQuery('#wpupg_filter_dropdown_label_taxonomy_' + taxonomies[i]).show(); | |
| 564 | + } | |
| 565 | + } else { | |
| 566 | + jQuery('.wpupg_dropdown_labels').hide(); | |
| 477 | 567 | } |
| 478 | 568 | }; |
| 479 | 569 | |
| 480 | 570 | WPUltimatePostGrid.changedIsotopeFilterStyle = function() { |