|
490 | 490 | return str;
|
491 | 491 | }
|
492 | 492 |
|
493 |
| - this.$inlineFilters = $(".griddly-filters-inline input, .griddly-filters-inline select", this.$element); |
| 493 | + this.$inlineFilters = $(".griddly-filters-inline .filter-content input", this.$element); |
494 | 494 |
|
495 |
| - $(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event) |
| 495 | + $(".griddly-filters-inline .filter-content input", this.$element).on("change", $.proxy(function (event) |
496 | 496 | {
|
497 | 497 | var filter = $(event.currentTarget).data("griddly-filter");
|
498 | 498 | var content = filter.data("griddly-filter-content");
|
|
501 | 501 | var dataType = filter.data("filter-datatype");
|
502 | 502 | var display = null;
|
503 | 503 |
|
504 |
| - // ignore unselect change events on single selection lists |
505 |
| - //if (!filter.hasClass("griddly-filter-list") || filter.data("griddly-filter-ismultiple") || $(event.currentTarget).prop("checked")) |
506 |
| - //{ |
507 |
| - if (filter.hasClass("griddly-filter-box")) |
508 |
| - { |
509 |
| - filter.find(".filter-trigger").popover("hide"); |
| 504 | + if (filter.hasClass("griddly-filter-box")) |
| 505 | + { |
| 506 | + filter.find(".filter-trigger").popover("hide"); |
510 | 507 |
|
511 |
| - var val = trimToNull(content.find("input").first().val()); |
| 508 | + var val = trimToNull(content.find("input").first().val()); |
512 | 509 |
|
513 |
| - if (val != null) |
514 |
| - { |
515 |
| - if (dataType == "String") |
516 |
| - display = 'Contains "' + getFormattedValue(val, dataType) + '"'; |
517 |
| - else |
518 |
| - display = getFormattedValue(val, dataType); |
519 |
| - } |
| 510 | + if (val != null) |
| 511 | + { |
| 512 | + if (dataType == "String") |
| 513 | + display = 'Contains "' + getFormattedValue(val, dataType) + '"'; |
520 | 514 | else
|
521 |
| - { |
522 |
| - display = "Any " + filter.data("filter-name"); |
523 |
| - |
524 |
| - content.find("input").first().val(""); |
525 |
| - } |
| 515 | + display = getFormattedValue(val, dataType); |
526 | 516 | }
|
527 |
| - else if (filter.hasClass("griddly-filter-range")) |
| 517 | + else |
528 | 518 | {
|
529 |
| - var val = trimToNull(content.find("input").first().val()); |
530 |
| - var valEnd = trimToNull(content.find("input").last().val()); |
531 |
| - |
532 |
| - if (val != null && valEnd != null) |
533 |
| - display = getFormattedValue(val, dataType) + " - " + getFormattedValue(valEnd, dataType); |
534 |
| - else if (val != null) |
535 |
| - display = (dataType == "Date" ? "After " : ">= ") + getFormattedValue(val, dataType); |
536 |
| - else if (valEnd != null) |
537 |
| - display = (dataType == "Date" ? "Before " : "<= ") + getFormattedValue(valEnd, dataType); |
538 |
| - else |
539 |
| - { |
540 |
| - display = "All " + filter.data("filter-name-plural"); |
| 519 | + display = "Any " + filter.data("filter-name"); |
541 | 520 |
|
542 |
| - content.find("input").first().val(""); |
543 |
| - content.find("input").last().val(""); |
544 |
| - } |
| 521 | + content.find("input").first().val(""); |
545 | 522 | }
|
546 |
| - else if (filter.hasClass("griddly-filter-list")) |
| 523 | + } |
| 524 | + else if (filter.hasClass("griddly-filter-range")) |
| 525 | + { |
| 526 | + var val = trimToNull(content.find("input").first().val()); |
| 527 | + var valEnd = trimToNull(content.find("input").last().val()); |
| 528 | + |
| 529 | + if (val != null && valEnd != null) |
| 530 | + display = getFormattedValue(val, dataType) + " - " + getFormattedValue(valEnd, dataType); |
| 531 | + else if (val != null) |
| 532 | + display = (dataType == "Date" ? "After " : ">= ") + getFormattedValue(val, dataType); |
| 533 | + else if (valEnd != null) |
| 534 | + display = (dataType == "Date" ? "Before " : "<= ") + getFormattedValue(valEnd, dataType); |
| 535 | + else |
547 | 536 | {
|
548 |
| - var allItems = content.find("li"); |
549 |
| - var selectedItems = allItems.filter(".griddly-filter-selected"); |
550 |
| - |
551 |
| - if (selectedItems.length == allItems.length || (selectedItems.length == 0 && filter.data("griddly-filter-isnoneall"))) |
552 |
| - display = (allItems.length == 2 ? "Both " : "All ") + filter.data("filter-name-plural"); |
553 |
| - else if (selectedItems.length > 1) |
554 |
| - display = selectedItems.length + " " + filter.data("filter-name-plural"); |
555 |
| - else if (selectedItems.length == 1) |
556 |
| - display = selectedItems.find("a").text(); |
557 |
| - else |
558 |
| - display = "No " + filter.data("filter-name-plural"); |
| 537 | + display = "All " + filter.data("filter-name-plural"); |
| 538 | + |
| 539 | + content.find("input").first().val(""); |
| 540 | + content.find("input").last().val(""); |
559 | 541 | }
|
| 542 | + } |
| 543 | + else if (filter.hasClass("griddly-filter-list")) |
| 544 | + { |
| 545 | + var allItems = content.find("li"); |
| 546 | + var selectedItems = allItems.filter(".griddly-filter-selected"); |
| 547 | + |
| 548 | + if (selectedItems.length == allItems.length || (selectedItems.length == 0 && filter.data("griddly-filter-isnoneall"))) |
| 549 | + display = (allItems.length == 2 ? "Both " : "All ") + filter.data("filter-name-plural"); |
| 550 | + else if (selectedItems.length > 1) |
| 551 | + display = selectedItems.length + " " + filter.data("filter-name-plural"); |
| 552 | + else if (selectedItems.length == 1) |
| 553 | + display = selectedItems.find("a").text(); |
| 554 | + else |
| 555 | + display = "No " + filter.data("filter-name-plural"); |
| 556 | + } |
560 | 557 |
|
561 |
| - if (display) |
562 |
| - displayEl.text(display); |
| 558 | + if (display) |
| 559 | + displayEl.text(display); |
563 | 560 |
|
564 |
| - this.refresh(true); |
565 |
| - //} |
| 561 | + // TODO: remove below once M3 compat fixed |
| 562 | + // this.refresh(true); |
| 563 | + }, this)); |
| 564 | + |
| 565 | + $(".griddly-filters-inline input, .griddly-filters-inline select", this.$element).on("change", $.proxy(function (event) |
| 566 | + { |
| 567 | + this.refresh(true); |
566 | 568 | }, this));
|
567 | 569 |
|
568 |
| - $(".griddly-filters-inline input", this.$element).keyup(function (event) |
| 570 | + $(".griddly-filters-inline .filter-content input", this.$element).keyup(function (event) |
569 | 571 | {
|
570 |
| - // TODO: instead, fire blur and hide the popover so we don't get double change events |
571 | 572 | if (event.which == 13)
|
572 |
| - $(this).change(); |
| 573 | + { |
| 574 | + $(this).blur(); |
| 575 | + |
| 576 | + var filter = $(this).data("griddly-filter"); |
| 577 | + |
| 578 | + filter.find(".filter-trigger").popover("hide"); |
| 579 | + } |
573 | 580 | });
|
574 | 581 |
|
575 | 582 | $(".griddly-filters-inline .filter-trigger", this.$element).each($.proxy(function (i, el)
|
|
608 | 615 | });
|
609 | 616 | }, this));
|
610 | 617 |
|
611 |
| - $(".griddly-filters-inline .dropdown-menu", this.$element).each($.proxy(function (i, el) |
| 618 | + $(".griddly-filters-inline .filter-content .dropdown-menu", this.$element).each($.proxy(function (i, el) |
612 | 619 | {
|
613 | 620 | var self = this;
|
614 | 621 |
|
|
681 | 688 |
|
682 | 689 | buildRequest: function(paging)
|
683 | 690 | {
|
684 |
| - var filters = $(".griddly-filters input[type=text], .griddly-filters input[type=hidden], .griddly-filters select", this.$element); |
| 691 | + var filters = $(".griddly-filters input, .griddly-filters select", this.$element); |
685 | 692 |
|
686 | 693 | filters = filters.add(this.$inlineFilters);
|
687 | 694 |
|
|
0 commit comments