Skip to content

Commit 27877e8

Browse files
committed
Fix segement search
1 parent db2c44d commit 27877e8

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

plugins/SegmentEditor/javascripts/Segmentation.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ Segmentation = (function($) {
3939

4040
self.editorTemplate = self.editorTemplate.detach();
4141

42-
self.timer = ""; // variable for further use in timing events
43-
self.searchAllowed = true;
4442
self.filterTimer = "";
45-
self.filterAllowed = true;
4643

4744
self.availableMatches = [];
4845
self.availableMatches["metric"] = [];
@@ -350,25 +347,25 @@ Segmentation = (function($) {
350347
var filterSegmentList = function (keyword) {
351348
var curTitle;
352349
clearFilterSegmentList();
353-
$(self.target).find(" .filterNoResults").remove();
350+
$(self.target).find(".filterNoResults").remove();
354351

355352
$(self.target).find(".segmentList li").each(function () {
356-
curTitle = $(this).prop('title');
353+
curTitle = $(this).find('.segname').prop('title');
357354
$(this).hide();
358355
if (curTitle.toLowerCase().indexOf(keyword.toLowerCase()) !== -1) {
359356
$(this).show();
360357
}
361358
});
362359

363-
if ($(self.target).find(".segmentList li:visible").length == 0) {
360+
if ($(self.target).find(".segmentList li:visible").length === 0) {
364361
$(self.target).find(".segmentList li:first")
365362
.before("<li class=\"filterNoResults grayed\">" + self.translations['General_SearchNoResults'] + "</li>");
366363
}
367364

368-
if ($(self.target).find(".segmentList .segmentsVisibleToSuperUser li:visible").length == 0) {
365+
if ($(self.target).find(".segmentList .segmentsVisibleToSuperUser li:visible").length === 0) {
369366
$(self.target).find(".segmentList .segmentsVisibleToSuperUser").hide();
370367
}
371-
if ($(self.target).find(".segmentList .segmentsSharedWithMeBySuperUser li:visible").length == 0) {
368+
if ($(self.target).find(".segmentList .segmentsSharedWithMeBySuperUser li:visible").length === 0) {
372369
$(self.target).find(".segmentList .segmentsSharedWithMeBySuperUser").hide();
373370
}
374371
};
@@ -502,20 +499,18 @@ Segmentation = (function($) {
502499

503500
self.target.on('keyup', ".segmentFilter", function (e) {
504501
var search = $(e.currentTarget).val();
505-
if (search == self.translations['General_Search']) {
502+
if (search === self.translations['General_Search']) {
506503
search = "";
507504
}
508505

506+
clearTimeout(self.filterTimer);
507+
self.filterTimer = false;
509508
if (search.length >= 2) {
510-
clearTimeout(self.filterTimer);
511-
self.filterAllowed = true;
512509
self.filterTimer = setTimeout(function () {
513510
filterSegmentList(search);
514511
}, 500);
515-
}
516-
else {
517-
self.filterTimer = false;
518-
clearFilterSegmentList();
512+
} else {
513+
self.filterTimer = setTimeout(clearFilterSegmentList, 500);
519514
}
520515
});
521516

@@ -768,10 +763,9 @@ Segmentation = (function($) {
768763
};
769764

770765
// determine if save or update should be performed
771-
if(segmentId === ""){
766+
if (segmentId === "") {
772767
self.addMethod(params);
773-
}
774-
else{
768+
} else {
775769
jQuery.extend(params, {
776770
"idSegment": segmentId
777771
});
@@ -902,7 +896,7 @@ Segmentation = (function($) {
902896

903897
var html = getListHtml();
904898

905-
if(typeof self.content !== "undefined"){
899+
if (typeof self.content !== "undefined") {
906900
this.content.html($(html).html());
907901
} else {
908902
this.target.append(html);

0 commit comments

Comments
 (0)