Skip to content

Commit 420be7e

Browse files
committed
Harden modal against being moved
1 parent 31d9018 commit 420be7e

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("2.0.2")]
19-
[assembly: AssemblyFileVersion("2.0.2")]
18+
[assembly: AssemblyVersion("2.0.3")]
19+
[assembly: AssemblyFileVersion("2.0.3")]
2020
//[assembly: AssemblyInformationalVersion("2.0-alpha6")]

Griddly/Scripts/griddly.js

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
var Griddly = function (element, options)
173173
{
174174
this.$element = $(element);
175+
this.$filterModal = $(".griddly-filter-modal", this.$element);
175176
this.options = options;
176177
this.create();
177178
this.isConstructed = false;
@@ -306,6 +307,24 @@
306307

307308
}, this);
308309

310+
var self = this;
311+
312+
this.$filterModal
313+
.on("show.bs.modal", function ()
314+
{
315+
var values = self.getFilterValues();
316+
317+
$(".griddly-filter-cancel, button.close", this).off("click").on("click", function ()
318+
{
319+
if (self.$element.triggerHandler("beforeclear.griddly") !== false)
320+
self.setFilterValues(values, null, true, true);
321+
});
322+
})
323+
.on("shown.bs.modal", function ()
324+
{
325+
$(".modal-body :input:visible:not([disabled]):not([data-griddly-filter-data-type=Date]):first", this).focus();
326+
});
327+
309328
this.isConstructed = true;
310329
};
311330

@@ -417,7 +436,7 @@
417436

418437
$("form", this.$element).on("submit", $.proxy(function (event)
419438
{
420-
$(event.currentTarget).closest(".griddly-filter-modal").modal("hide");
439+
this.$filterModal.modal("hide");
421440

422441
this.refresh(true);
423442

@@ -794,6 +813,13 @@
794813
this.triggerOrQueue(this.$element, "filterchange.griddly", this.$element, event.target);
795814
}, this));
796815

816+
// TODO: exclude this if the modal is still in griddly-filters-form? does it dupe?
817+
$(this.$filterModal).on("change", "input, select", $.proxy(function (event)
818+
{
819+
if (!this._isUpdatingFilters)
820+
this.triggerOrQueue(this.$element, "filterchange.griddly", this.$element, event.target);
821+
}, this));
822+
797823
$(".griddly-filters-inline .filter-content input", this.$element).keyup(function (event)
798824
{
799825
if (event.which == 13)
@@ -1049,24 +1075,7 @@
10491075

10501076
invokeFilterModal: function ()
10511077
{
1052-
var self = this;
1053-
1054-
$(".griddly-filter-modal", this.$element)
1055-
.on("show.bs.modal", function ()
1056-
{
1057-
var values = self.getFilterValues();
1058-
1059-
$(".griddly-filter-cancel", this).off("click").on("click", function ()
1060-
{
1061-
if (self.$element.triggerHandler("beforeclear.griddly") !== false)
1062-
self.setFilterValues(values, null, false, true);
1063-
});
1064-
})
1065-
.on("shown.bs.modal", function ()
1066-
{
1067-
$(".modal-body :input:visible:not([disabled]):first", this).focus();
1068-
})
1069-
.modal("show");
1078+
this.$filterModal.modal("show");
10701079
},
10711080

10721081
getAllFilterElements: function ()
@@ -1079,7 +1088,8 @@
10791088
}
10801089
else
10811090
{
1082-
allFilters = $(".griddly-filters-form input[name], .griddly-filters-form select[name]", this.$element);
1091+
allFilters = $(".griddly-filters-form input[name], .griddly-filters-form select[name]", this.$element)
1092+
.add($("input[name], select[name]", this.$filterModal));
10831093
}
10841094

10851095
return allFilters;
@@ -1092,7 +1102,8 @@
10921102
if (this.options.filterMode == "Inline")
10931103
return this.$inlineFilters.filter(filter);
10941104
else
1095-
return $(".griddly-filters-form input" + filter + ", .griddly-filters-form select" + filter, this.$element);
1105+
return $(".griddly-filters-form input" + filter + ", .griddly-filters-form select" + filter, this.$element)
1106+
.add($("input[name], select[name]", this.$filterModal));
10961107
},
10971108

10981109
getFilterValues: function ()
@@ -1199,7 +1210,9 @@
11991210

12001211
if (resetNone)
12011212
// clear any none's that were inadvertently reset
1202-
this.$element.find(".griddly-filters-form [data-griddly-filter-isnoneall=true] [multiple] option[value='']").prop("selected", false);
1213+
this.$element.find(".griddly-filters-form [data-griddly-filter-isnoneall=true] [multiple] option[value='']")
1214+
.add(this.$filterModal.find("[data-griddly-filter-isnoneall=true] [multiple] option[value='']"))
1215+
.prop("selected", false);
12031216

12041217
this.triggerOrQueue(this.$element, "setfilters.griddly", filters);
12051218

0 commit comments

Comments
 (0)