Skip to content

Commit

Permalink
Merge pull request #510 from NobletSolutions/patch-jms
Browse files Browse the repository at this point in the history
Test if filter exists before use
  • Loading branch information
gnat42 committed May 14, 2019
2 parents 93c654d + e501769 commit 2cf85c6
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Resources/public/js/jms.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,35 @@ function JMSTranslationManager(updateMessagePath, isWritable)
$(JMS.messageFilter.selector).val(window.location.hash.substr(1));
},
filter: function () {
var filterString = $(JMS.messageFilter.selector).val().trim().replace(/[-[\]{}()+?,\\^$|#\s]/g, "\\$&");
var filter = $(JMS.messageFilter.selector);
var messageRow = $(".messageRow");

if (filter.length === 0) {
messageRow.each(function () {
$(this).show();
});

return;
}

var filterString = filter.val().trim().replace(/[-[\]{}()+?,\\^$|#\s]/g, "\\$&");
var regExp = new RegExp(".*" + filterString + ".*", "i");
window.location.hash = filterString;
if (filterString !== "") {
$(".messageRow").each(function () {
messageRow.each(function () {
var id = this.id.substr(4);
if (id.match(regExp)) {
$(this).show();
} else {
$(this).hide();
}
});

} else {
$(".messageRow").each(function () {
$(this).show();
});
return ;
}

messageRow.each(function () {
$(this).show();
});
}
};
};

0 comments on commit 2cf85c6

Please sign in to comment.