Commit 5e0ff65d authored by Maxym Borodenko's avatar Maxym Borodenko

Apply button on "Latitude" filter e.g.,isn't disabled

parent 99b516ba
......@@ -29,6 +29,35 @@ var BrowseUtil = {
});
},
validateInput: function (element) {
var emptyFilterVal = true;
$.each($(element).parent().parent().find('.filtval'), function () {
emptyFilterVal = false;
});
if($(element).parent().hasClass('js-range-filter')) {
var firstRangeVal = $.trim($(element).val());
var secondRangeVal = '';
$.each($(element).parent().find('input'), function () {
if($.trim($(this).val()) !== firstRangeVal) {
secondRangeVal = $.trim($(this).val());
}
});
if(firstRangeVal === '' && secondRangeVal !== '' || secondRangeVal === '' && firstRangeVal !== '') {
$(element).parent().parent().parent().find('.applyBtn').removeClass('disabled');
}
else if(firstRangeVal === '' && secondRangeVal === '') {
$(element).parent().parent().parent().find('.applyBtn').addClass('disabled');
}
} else {
if($.trim($(element).val()) !== '') {
$(element).parent().parent().parent().find('.applyBtn').removeClass('disabled');
} else if (emptyFilterVal === true) {
$(element).parent().parent().parent().find('.applyBtn').addClass('disabled');
}
}
},
renderListFilterSuggestions: function (filters, messages) {
$.each(filters, function (option) {
$('div.' + option).find('div[class!="panel-body"][class!="filtval complex"]').remove();
......
......@@ -345,29 +345,7 @@
});
$('body').on('input', '.panel-group .input-group .form-control', function () {
var emptyFilterVal = true;
$.each($(this).parent().parent().find('.filtval'), function () {
emptyFilterVal = false;
});
if($(this).parent().hasClass('js-range-filter')) {
var firstRangeVal = $.trim($(this).val());
var secondRangeVal = '';
$.each($(this).parent().find('input'), function () {
if($.trim($(this).val()) !== firstRangeVal) {
secondRangeVal = $.trim($(this).val());
}
});
if(firstRangeVal === '' && secondRangeVal !== '' || secondRangeVal === '' && firstRangeVal !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
}
} else {
if($.trim($(this).val()) !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
} else if (emptyFilterVal === true) {
$(this).parent().parent().parent().find('.applyBtn').addClass('disabled');
}
}
BrowseUtil.validateInput($(this));
});
$("body").on("click", ".filter-auto", function () {
......@@ -410,7 +388,7 @@
var needToApply = true;
$.each($(parentEl).find('.filtval'), function () {
needToApply = false;
});
});
if(needToApply) {
applyFilters();
}
......@@ -436,7 +414,7 @@
var needToApply = true;
$.each($(parentEl).find('.filtval'), function () {
needToApply = false;
});
});
if(needToApply) {
applyFilters();
}
......@@ -549,6 +527,7 @@
}
else {
this.value = val.substring(0, len-1);
BrowseUtil.validateInput($(this));
}
}
});
......@@ -681,7 +660,7 @@
$(this).collapse("show");
if(!$(this).is('#panel_additional_collapse')) {
$(this).children().children().find('.applyBtn').removeClass('disabled');
}
}
}
</c:forEach>
});
......@@ -842,8 +821,8 @@
window.history.pushState(requestUrl, '', displayUrl);
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Accept", "application/json");
},
url: requestUrl,
method: 'get',
......
......@@ -271,29 +271,7 @@
});
$('body').on('input', '.panel-group .input-group .form-control', function () {
var emptyFilterVal = true;
$.each($(this).parent().parent().find('.filtval'), function () {
emptyFilterVal = false;
});
if($(this).parent().hasClass('js-range-filter')) {
var firstRangeVal = $.trim($(this).val());
var secondRangeVal = '';
$.each($(this).parent().find('input'), function () {
if($.trim($(this).val()) !== firstRangeVal) {
secondRangeVal = $.trim($(this).val());
}
});
if(firstRangeVal === '' && secondRangeVal !== '' || secondRangeVal === '' && firstRangeVal !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
}
} else {
if($.trim($(this).val()) !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
} else if (emptyFilterVal === true) {
$(this).parent().parent().parent().find('.applyBtn').addClass('disabled');
}
}
BrowseUtil.validateInput($(this));
});
GenesysFilterUtil.registerAutocomplete(".filters", jsonData);
......@@ -440,6 +418,7 @@
}
else {
this.value = val.substring(0, len-1);
BrowseUtil.validateInput($(this));
}
}
});
......
......@@ -190,29 +190,7 @@
});
$('body').on('input', '.panel-group .input-group .form-control', function () {
var emptyFilterVal = true;
$.each($(this).parent().parent().find('.filtval'), function () {
emptyFilterVal = false;
});
if($(this).parent().hasClass('js-range-filter')) {
var firstRangeVal = $.trim($(this).val());
var secondRangeVal = '';
$.each($(this).parent().find('input'), function () {
if($.trim($(this).val()) !== firstRangeVal) {
secondRangeVal = $.trim($(this).val());
}
});
if(firstRangeVal === '' && secondRangeVal !== '' || secondRangeVal === '' && firstRangeVal !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
}
} else {
if($.trim($(this).val()) !== '') {
$(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
} else if (emptyFilterVal === true) {
$(this).parent().parent().parent().find('.applyBtn').addClass('disabled');
}
}
BrowseUtil.validateInput($(this));
});
GenesysFilterUtil.registerAutocomplete(".filters", jsonData);
......@@ -354,6 +332,7 @@
}
else {
this.value = val.substring(0, len-1);
BrowseUtil.validateInput($(this));
}
}
});
......@@ -503,7 +482,6 @@
["statsStorage"],
["i18n.accession.storage"], divModeContent, pagedData);
$("#content-area").append(divModeContent);
}
......@@ -522,7 +500,7 @@
$("<h4/>").addClass("section-heading").text(message).appendTo(div);
div.appendTo(parentDiv);
var div2 = $("<div/>").addClass("section-inner-content clearfix")
var div2 = $("<div/>").addClass("section-inner-content clearfix");
var termTable = $("<div/>").addClass("terms-table");
for (var i = 0; i < terms.length; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment