66 lines
2.7 KiB
PHP
66 lines
2.7 KiB
PHP
<script>
|
|
|
|
$(function(){
|
|
$(".select-dropdown .search").on("keyup", function(){
|
|
var bu = $(this);
|
|
var parent = bu.parent(); //tr
|
|
var value = $(this).val().toLowerCase();
|
|
parent.find('.dropdown-list .dropdown-item').filter(function() {
|
|
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
|
});
|
|
|
|
});
|
|
$(".select-dropdown > input").on("click", function(e) {
|
|
e.stopPropagation();
|
|
$(this).parent().find('[data-toggle=dropdown]').dropdown('toggle');
|
|
});
|
|
$(".select-dropdown > input").on("keypress", function(e) {
|
|
return false;
|
|
});
|
|
$(".select-dropdown .dropdown-item").on("click", function(){
|
|
var parent = $(this).parent().parent().parent().parent();
|
|
var parentGroupName = parent.attr("data-group");
|
|
var dataGroupParent = $("." + parentGroupName);
|
|
try {
|
|
var json = JSON.parse($(this).attr("data-filter-value"));
|
|
} catch (error) {
|
|
var json = [];
|
|
}
|
|
|
|
var affected = $(this).parent().attr("affected");
|
|
var exceptReadOnly = ['outside_diameter', 'thickness'];
|
|
if(affected !== undefined) {
|
|
affected = JSON.parse(affected);
|
|
|
|
if(affected[0]=="all") {
|
|
$.each(json, function(resultKey, resultValue){
|
|
// replaceString = replaceString.replace("{"+resultKey+"}",resultValue);
|
|
dataGroupParent.find("[name='"+resultKey+"']").val(resultValue).trigger("blur");
|
|
|
|
if(!exceptReadOnly.includes(resultKey)) {
|
|
dataGroupParent.find("[name='"+resultKey+"']").attr("readonly","readonly");
|
|
}
|
|
});
|
|
}
|
|
$.each(affected,function(key,value){
|
|
var replaceString = value;
|
|
|
|
$.each(json, function(resultKey, resultValue){
|
|
replaceString = replaceString.replace("{"+resultKey+"}",resultValue);
|
|
});
|
|
dataGroupParent.find("[name='"+key+"']").val(replaceString).trigger("blur");
|
|
|
|
if(!exceptReadOnly.includes(key)) {
|
|
dataGroupParent.find("[name='"+key+"']").attr("readonly","readonly");
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
parent.find(".select-dropdown-input").val($(this).text().trim()).trigger("blur");
|
|
});
|
|
});
|
|
</script> |