| @@ -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 |
| @@ -30,8 +40,16 @@ | ||
| 30 | 40 | var posts_per_page = jQuery('#wpupg_pagination_pages_posts_per_page'); |
| 31 | 41 | slider_args.start = posts_per_page.val(); |
| 32 | 42 | jQuery('#wpupg_pagination_pages_posts_per_page_slider').noUiSlider(slider_args).Link('lower').to(posts_per_page); |
| 33 | 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 | + | |
| 34 | 52 | var initial_posts = jQuery('#wpupg_pagination_load_more_initial_posts'); |
| 35 | 53 | slider_args.start = initial_posts.val(); |
| 36 | 54 | jQuery('#wpupg_pagination_load_more_initial_posts_slider').noUiSlider(slider_args).Link('lower').to(initial_posts); |
| 37 | 55 | |
| @@ -194,14 +212,20 @@ | ||
| 194 | 212 | change: function () { WPUltimatePostGrid.changedPaginationStyle(); } |
| 195 | 213 | }); |
| 196 | 214 | |
| 197 | 215 | // Initial State |
| 216 | + WPUltimatePostGrid.changedType(); | |
| 198 | 217 | WPUltimatePostGrid.changedPostType(); |
| 218 | + WPUltimatePostGrid.changedTaxonomy(); | |
| 219 | + WPUltimatePostGrid.changedOrderBy(); | |
| 199 | 220 | WPUltimatePostGrid.changedLimitPosts(); |
| 221 | + WPUltimatePostGrid.changedLimitTerms(); | |
| 200 | 222 | WPUltimatePostGrid.initRules(); |
| 201 | 223 | WPUltimatePostGrid.changedFilterType(); |
| 224 | + WPUltimatePostGrid.changedShowCount(); | |
| 202 | 225 | WPUltimatePostGrid.changedMultiselect(); |
| 203 | - WPUltimatePostGrid.changedLimitTerms(); | |
| 226 | + WPUltimatePostGrid.changedLimitFilterTerms(); | |
| 227 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 204 | 228 | WPUltimatePostGrid.changedIsotopeFilterStyle(); |
| 205 | 229 | WPUltimatePostGrid.changedIsotopeFilterText(); |
| 206 | 230 | WPUltimatePostGrid.changedLayoutMode(); |
| 207 | 231 | WPUltimatePostGrid.changedPaginationStyle(); |
| @@ -208,10 +232,14 @@ | ||
| 208 | 232 | WPUltimatePostGrid.changedPaginationType(); |
| 209 | 233 | WPUltimatePostGrid.changedPaginationText(); |
| 210 | 234 | |
| 211 | 235 | // Events |
| 236 | + jQuery('#wpupg_type').on('change', function() { WPUltimatePostGrid.changedType(); }); | |
| 212 | 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(); }); | |
| 213 | 240 | jQuery('#wpupg_limit_posts').on('change', function() { WPUltimatePostGrid.changedLimitPosts(); }); |
| 241 | + jQuery('#wpupg_limit_terms').on('change', function() { WPUltimatePostGrid.changedLimitTerms(); }); | |
| 214 | 242 | jQuery('#wpupg_add_rule').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.addRule(); }); |
| 215 | 243 | jQuery('.wpupg_rule_delete').on('click', function(e) { e.preventDefault(); WPUltimatePostGrid.removeRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| 216 | 244 | jQuery('.wpupg_rule_field').on('change', function(e) { WPUltimatePostGrid.changedRuleField(jQuery(this).parents('tr').attr('data-rule')); }); |
| 217 | 245 | jQuery('.rule_container_wpupg_general_date').find('select').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| @@ -216,11 +244,12 @@ | ||
| 216 | 244 | jQuery('.wpupg_rule_field').on('change', function(e) { WPUltimatePostGrid.changedRuleField(jQuery(this).parents('tr').attr('data-rule')); }); |
| 217 | 245 | jQuery('.rule_container_wpupg_general_date').find('select').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| 218 | 246 | jQuery('.wpupg-date').on('change', function(e) { WPUltimatePostGrid.changedDateRule(jQuery(this).parents('tr').attr('data-rule')); }); |
| 219 | 247 | jQuery('#wpupg_filter_type').on('change', function() { WPUltimatePostGrid.changedFilterType(); }); |
| 248 | + jQuery('#wpupg_filter_count').on('change', function() { WPUltimatePostGrid.changedShowCount(); }); | |
| 220 | 249 | 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(); }); | |
| 250 | + jQuery('.wpupg_filter_taxonomy').on('change', function() { WPUltimatePostGrid.changedLimitFilterTerms(); WPUltimatePostGrid.changedDropdownLabels(); }); | |
| 251 | + jQuery('#wpupg_filter_limit').on('change', function() { WPUltimatePostGrid.changedLimitFilterTerms(); }); | |
| 223 | 252 | jQuery('#wpupg_layout_mode').on('change', function() { WPUltimatePostGrid.changedLayoutMode(); }); |
| 224 | 253 | jQuery('#wpupg_pagination_type').on('change', function() { WPUltimatePostGrid.changedPaginationType(); }); |
| 225 | 254 | jQuery('#wpupg_pagination_load_more_button_text').on('change keyup', function() { WPUltimatePostGrid.changedPaginationText(); }); |
| 226 | 255 | |
| @@ -291,8 +320,49 @@ | ||
| 291 | 320 | } |
| 292 | 321 | }); |
| 293 | 322 | }; |
| 294 | 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 | + | |
| 295 | 365 | WPUltimatePostGrid.changedPostType = function() { |
| 296 | 366 | var post_type = jQuery('#wpupg_post_types').find(':selected').val(); |
| 297 | 367 | |
| 298 | 368 | jQuery('.wpupg_filter_taxonomy_container').hide(); |
| @@ -309,11 +379,32 @@ | ||
| 309 | 379 | WPUltimatePostGrid.filter_possible = false; |
| 310 | 380 | } |
| 311 | 381 | |
| 312 | 382 | WPUltimatePostGrid.changedFilterType(); |
| 313 | - WPUltimatePostGrid.changedLimitTerms(); | |
| 383 | + WPUltimatePostGrid.changedLimitFilterTerms(); | |
| 384 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 314 | 385 | }; |
| 315 | 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 | + | |
| 316 | 407 | WPUltimatePostGrid.changedLimitPosts = function() { |
| 317 | 408 | if(jQuery('#wpupg_limit_posts').is(':checked')) { |
| 318 | 409 | WPUltimatePostGrid.checkPremiumFeatures('limit_posts', true); |
| 319 | 410 | jQuery('#wpupg_meta_box_limit_posts').show(); |
| @@ -399,11 +490,17 @@ | ||
| 399 | 490 | }; |
| 400 | 491 | |
| 401 | 492 | WPUltimatePostGrid.changedFilterType = function() { |
| 402 | 493 | var filter_type = jQuery('#wpupg_filter_type').find(':selected').val(); |
| 494 | + var filter_type_search = false; | |
| 403 | 495 | |
| 496 | + if(filter_type.substring(0,5) == 'text_') { | |
| 497 | + filter_type = filter_type.substring(5); | |
| 498 | + filter_type_search = true; | |
| 499 | + } | |
| 500 | + | |
| 404 | 501 | // Hide & Show Filter Settings |
| 405 | - if(filter_type == 'none') { | |
| 502 | + if(filter_type == 'none' || filter_type == 'text') { | |
| 406 | 503 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').hide(); |
| 407 | 504 | } else { |
| 408 | 505 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show(); |
| 409 | 506 | } |
| @@ -408,9 +505,9 @@ | ||
| 408 | 505 | jQuery('#wpupg_form_filter').find('tr').not('.wpupg_no_filter').show(); |
| 409 | 506 | } |
| 410 | 507 | |
| 411 | 508 | // Premium only filters |
| 412 | - if(filter_type == 'dropdown') { | |
| 509 | + if(filter_type == 'dropdown' || filter_type == 'text') { | |
| 413 | 510 | WPUltimatePostGrid.checkPremiumFeatures('filter_type', true); |
| 414 | 511 | } else { |
| 415 | 512 | WPUltimatePostGrid.checkPremiumFeatures('filter_type', false); |
| 416 | 513 | } |
| @@ -416,17 +513,33 @@ | ||
| 416 | 513 | } |
| 417 | 514 | |
| 418 | 515 | // Hide & Show Filter Styles |
| 419 | 516 | jQuery('#wpupg_meta_box_isotope_filter').hide(); |
| 517 | + jQuery('#wpupg_meta_box_text_filter').hide(); | |
| 420 | 518 | jQuery('#wpupg_meta_box_dropdown_filter').hide(); |
| 421 | 519 | |
| 422 | 520 | if(WPUltimatePostGrid.filter_possible) { |
| 423 | 521 | jQuery('#wpupg_meta_box_' + filter_type + '_filter').show(); |
| 522 | + | |
| 523 | + if(filter_type_search) { | |
| 524 | + jQuery('#wpupg_meta_box_text_filter').show(); | |
| 525 | + } | |
| 424 | 526 | } |
| 425 | 527 | |
| 426 | - WPUltimatePostGrid.changedLimitTerms(); | |
| 528 | + WPUltimatePostGrid.changedLimitFilterTerms(); | |
| 529 | + WPUltimatePostGrid.changedDropdownLabels(); | |
| 427 | 530 | }; |
| 428 | 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 | + | |
| 429 | 542 | WPUltimatePostGrid.changedMultiselect = function() { |
| 430 | 543 | var multiselect = jQuery('#wpupg_filter_multiselect').is(':checked'); |
| 431 | 544 | |
| 432 | 545 | if(multiselect) { |
| @@ -437,14 +550,18 @@ | ||
| 437 | 550 | jQuery('.wpupg_multiselect').hide(); |
| 438 | 551 | } |
| 439 | 552 | }; |
| 440 | 553 | |
| 441 | -WPUltimatePostGrid.changedLimitTerms = function() { | |
| 554 | +WPUltimatePostGrid.changedLimitFilterTerms = function() { | |
| 442 | 555 | var limit_terms = jQuery('#wpupg_filter_limit').is(':checked'); |
| 443 | 556 | var post_type = jQuery('#wpupg_post_types').find(':selected').val(); |
| 444 | 557 | var taxonomies = jQuery('#wpupg_filter_taxonomy_' + post_type).val(); |
| 445 | 558 | |
| 446 | - if(limit_terms) { | |
| 559 | + if( !jQuery.isArray( taxonomies ) ) { | |
| 560 | + taxonomies = [taxonomies]; | |
| 561 | + } | |
| 562 | + | |
| 563 | + if(limit_terms && taxonomies) { | |
| 447 | 564 | jQuery('.wpupg_limit_terms').show(); |
| 448 | 565 | jQuery('.wpupg_filter_terms_taxonomy').hide(); |
| 449 | 566 | |
| 450 | 567 | for(var i = 0; i < taxonomies.length; i++) { |
| @@ -454,8 +571,33 @@ | ||
| 454 | 571 | jQuery('.wpupg_limit_terms').hide(); |
| 455 | 572 | } |
| 456 | 573 | }; |
| 457 | 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 | + | |
| 458 | 600 | WPUltimatePostGrid.changedIsotopeFilterStyle = function() { |
| 459 | 601 | var margin_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_margin_vertical').val()); |
| 460 | 602 | var margin_horizontal = parseInt(jQuery('#wpupg_isotope_filter_style_margin_horizontal').val()); |
| 461 | 603 | var padding_vertical = parseInt(jQuery('#wpupg_isotope_filter_style_padding_vertical').val()); |
| @@ -549,9 +691,9 @@ | ||
| 549 | 691 | jQuery('#wpupg_form_pagination').find('tbody').not('.wpupg_pagination_' + pagination_type).not('.wpupg_pagination_none').hide(); |
| 550 | 692 | jQuery('#wpupg_form_pagination').find('tbody.wpupg_pagination_' + pagination_type).show(); |
| 551 | 693 | |
| 552 | 694 | // Premium only pagination |
| 553 | - if(pagination_type == 'pages') { | |
| 695 | + if(pagination_type == 'none' || pagination_type == 'pages') { | |
| 554 | 696 | WPUltimatePostGrid.checkPremiumFeatures('pagination_type', false); |
| 555 | 697 | } else { |
| 556 | 698 | WPUltimatePostGrid.checkPremiumFeatures('pagination_type', true); |
| 557 | 699 | } |
| @@ -556,9 +698,9 @@ | ||
| 556 | 698 | WPUltimatePostGrid.checkPremiumFeatures('pagination_type', true); |
| 557 | 699 | } |
| 558 | 700 | |
| 559 | 701 | // Hide & Show Pagination Styles |
| 560 | - if(pagination_type != 'none' && pagination_type != 'load_filter') { | |
| 702 | + if(pagination_type != 'none' && pagination_type != 'infinite_load' && pagination_type != 'load_filter') { | |
| 561 | 703 | pagination_type = pagination_type == 'load_more_filter' ? 'load_more' : pagination_type; |
| 562 | 704 | jQuery('#wpupg_meta_box_pagination_style').show().find('.wpupg_filter_preview').hide(); |
| 563 | 705 | jQuery('#wpupg_filter_preview_pagination_style_' + pagination_type).show(); |
| 564 | 706 | } else { |