|
566 | 566 | this.setFilterValues(values, true, null, true);
|
567 | 567 | };
|
568 | 568 |
|
569 |
| - var hidePopover = function (selector, isBootstrap4or5) { |
| 569 | + var hidePopover = function (selector, bootstrapVersion) { |
570 | 570 | selector.each(function () {
|
571 | 571 | var filter = $(this);
|
572 | 572 | if (filter.attr("aria-describedby")) { //This attribute will be present only when the popover is currently shown
|
573 | 573 | filter.popover("hide");
|
574 | 574 |
|
575 | 575 | //Workaround for bug introduced in Bootstrap 3.3.5, where hide() doesn't clear out the click state, so toggle() after hide() does not show.
|
576 |
| - if (!isBootstrap4or5 && filter.data("bs.popover").inState) { |
| 576 | + if (bootstrapVersion < 4 && filter.data("bs.popover").inState) { |
577 | 577 | filter.data("bs.popover").inState.click = false;
|
578 | 578 | }
|
579 | 579 | }
|
|
585 | 585 | this.$element = $(element);
|
586 | 586 | this.$filterModal = $(".griddly-filter-modal", this.$element);
|
587 | 587 | this.options = options;
|
588 |
| - this.bootstrapVersion = $.fn.tooltip.Constructor.VERSION.substr(0, 1); |
589 |
| - this.isBootstrap4or5 = this.bootstrapVersion == "4" || this.bootstrapVersion == "5"; |
| 588 | + this.bootstrapVersion = parseInt($.fn.tooltip.Constructor.VERSION.substr(0, 1)); |
| 589 | + if (isNaN(this.bootstrapVersion)) |
| 590 | + this.bootstrapVersion = 3; |
| 591 | + |
590 | 592 | this.create();
|
591 | 593 | this.isConstructed = false;
|
592 | 594 | this.eventQueue = [];
|
|
681 | 683 | tip = filter.data('bs.popover').tip; /*BS4*/
|
682 | 684 |
|
683 | 685 | if ($(tip).hasClass('in') || $(tip).hasClass('show')/*BS4*/) {
|
684 |
| - hidePopover(filter, self.isBootstrap4or5); |
| 686 | + hidePopover(filter, self.bootstrapVersion); |
685 | 687 |
|
686 | 688 | if (!self.options.autoRefreshOnFilter && self.pendingInlineFilterRefresh) {
|
687 | 689 | self.refresh(true);
|
|
1155 | 1157 | if (filter.hasClass("griddly-filter-box"))
|
1156 | 1158 | {
|
1157 | 1159 | if (!dontHide && this.options.autoRefreshOnFilter)
|
1158 |
| - hidePopover(filter.find(".filter-trigger"), self.isBootstrap4or5); |
| 1160 | + hidePopover(filter.find(".filter-trigger"), self.bootstrapVersion); |
1159 | 1161 |
|
1160 | 1162 | var val = trimToNull(getCleanedValue(content.find("input").first().val(), dataType));
|
1161 | 1163 |
|
|
1201 | 1203 | else if (filter.hasClass("griddly-filter-list"))
|
1202 | 1204 | {
|
1203 | 1205 | if (!filter.data("griddly-filter-ismultiple") && !dontHide && this.options.autoRefreshOnFilter)
|
1204 |
| - hidePopover(filter.find(".filter-trigger"), self.isBootstrap4or5); |
| 1206 | + hidePopover(filter.find(".filter-trigger"), self.bootstrapVersion); |
1205 | 1207 |
|
1206 | 1208 | var allItems = content.find("li:not(.griddly-list-group-header), .dropdown-item");
|
1207 | 1209 | var selectedItems = allItems.filter(":has(:checked)");
|
|
1218 | 1220 | display = selectedItems.length + " " + filter.data("filter-name-plural");
|
1219 | 1221 | else if (selectedItems.length > 0 && selectedItems.length <= displayItemCount)
|
1220 | 1222 | {
|
1221 |
| - var itemTexts = self.isBootstrap4or5 ? selectedItems : selectedItems.find("a"); |
| 1223 | + var itemTexts = self.bootstrapVersion == 4 || self.bootstrapVersion == 5 ? selectedItems : selectedItems.find("a"); |
1222 | 1224 | var display = $.trim($(itemTexts[0]).text());
|
1223 | 1225 |
|
1224 | 1226 | for (var i = 1; i < selectedItems.length && i < displayItemCount; i++)
|
|
1272 | 1274 | }
|
1273 | 1275 |
|
1274 | 1276 | var filter = $input.data("griddly-filter");
|
1275 |
| - hidePopover(filter.find(".filter-trigger"), this.isBootstrap4or5); |
| 1277 | + hidePopover(filter.find(".filter-trigger"), this.bootstrapVersion); |
1276 | 1278 | }
|
1277 | 1279 | }, this));
|
1278 | 1280 |
|
|
1293 | 1295 | placement: "bottom",
|
1294 | 1296 | container: $(".griddly-filters-inline", this.$element),
|
1295 | 1297 | template:
|
1296 |
| - self.isBootstrap4or5 ? '<div class="popover griddly-filter-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
| 1298 | + self.bootstrapVersion == 4 || self.bootstrapVersion == 5 ? '<div class="popover griddly-filter-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
1297 | 1299 | : '<div class="popover griddly-filter-popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
1298 | 1300 | content: function ()
|
1299 | 1301 | {
|
1300 | 1302 | return content;
|
1301 | 1303 | }
|
1302 | 1304 | }).on("show.bs.popover", function ()
|
1303 | 1305 | {
|
1304 |
| - hidePopover(self.$element.find(".griddly-filters-inline .filter-trigger").not(this), self.isBootstrap4or5); |
| 1306 | + hidePopover(self.$element.find(".griddly-filters-inline .filter-trigger").not(this), self.bootstrapVersion); |
1305 | 1307 |
|
1306 | 1308 | content.find("input:first").select();
|
1307 | 1309 |
|
|
1332 | 1334 | if (this.pendingInlineFilterRefresh) {
|
1333 | 1335 | this.refresh(true);
|
1334 | 1336 | }
|
1335 |
| - hidePopover(filterTrigger, this.isBootstrap4or5); |
| 1337 | + hidePopover(filterTrigger, this.bootstrapVersion); |
1336 | 1338 | }, this));
|
1337 | 1339 | }
|
1338 | 1340 |
|
|
1367 | 1369 | }
|
1368 | 1370 | else
|
1369 | 1371 | {
|
1370 |
| - var item = self.isBootstrap4or5 ? $(this) : $(this).parents("li"); |
| 1372 | + var item = self.bootstrapVersion == 4 || self.bootstrapVersion == 5 ? $(this) : $(this).parents("li"); |
1371 | 1373 |
|
1372 | 1374 | var checkbox = $(this).find("input");
|
1373 | 1375 |
|
|
0 commit comments