2022-03-08 15:55:41 +01:00
|
|
|
function InputfieldIcon() {
|
|
|
|
|
2024-04-04 14:37:20 +02:00
|
|
|
$('.InputfieldIcon select').on('change', function() {
|
2022-03-08 15:55:41 +01:00
|
|
|
var $select = $(this);
|
|
|
|
var val = $select.val();
|
|
|
|
if(val.length > 0) {
|
|
|
|
$select.closest('.InputfieldIcon').find('.InputfieldHeader > i.fa:first-child')
|
|
|
|
.attr('class', 'fa fa-fw ' + val)
|
|
|
|
.parent().effect('highlight', 500);
|
|
|
|
var $all = $select.siblings('.InputfieldIconAll');
|
|
|
|
if($all.is(':visible')) {
|
|
|
|
$all.find('.on').removeClass('on');
|
|
|
|
$all.find('.' + val).addClass('on');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$select.removeClass('on');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.InputfieldIconAll').hide();
|
|
|
|
|
|
|
|
$('a.InputfieldIconShowAll').on('click', function() {
|
|
|
|
|
|
|
|
var $a = $(this);
|
|
|
|
var $ai = $a.prev('i');
|
|
|
|
var $all = $a.siblings('.InputfieldIconAll');
|
|
|
|
var $select = $a.siblings("select");
|
|
|
|
|
|
|
|
$ai.toggleClass('fa-angle-down fa-angle-right');
|
|
|
|
|
|
|
|
if($all.is(":visible")) {
|
|
|
|
$all.hide();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$all.show();
|
|
|
|
|
|
|
|
if($all.hasClass('initialized')) return false;
|
|
|
|
|
|
|
|
$all.addClass('initialized');
|
|
|
|
|
|
|
|
$select.children('option').each(function() {
|
|
|
|
var val = $(this).val();
|
|
|
|
if(val.length == 0) return;
|
|
|
|
$all.append("<i class='fa fw " + val + "' title='" + val + "'>");
|
|
|
|
});
|
|
|
|
|
|
|
|
$all.on('click', 'i', function() {
|
|
|
|
var $i = $(this);
|
|
|
|
if($i.hasClass('on')) {
|
|
|
|
$i.removeClass('on');
|
2024-04-04 14:37:20 +02:00
|
|
|
$select.val('').trigger('change');
|
2022-03-08 15:55:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$all.find('.on').removeClass('on');
|
|
|
|
$i.addClass('on');
|
|
|
|
if(!$select.hasClass('on')) {
|
2024-04-04 14:37:20 +02:00
|
|
|
$select.val($i.attr('title')).trigger('change');
|
2022-03-08 15:55:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var val = $select.val();
|
|
|
|
if(val.length > 0) {
|
|
|
|
$all.find('.' + val).addClass('on');
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
InputfieldIcon();
|
|
|
|
});
|