$collection = [] if defined($collection) && !ref($collection) && ($collection eq '');
+ my $with_filter = delete($attributes{with_filter});
+ my $fil_placeholder = delete($attributes{filter_placeholder});
my $value_key = delete($attributes{value_key}) || 'id';
my $title_key = delete($attributes{title_key}) || $value_key;
my $default_key = delete($attributes{default_key}) || 'selected';
} @{ $collection };
}
- html_tag('select', $code, %attributes, name => $name);
+ my $select_html = html_tag('select', $code, %attributes, name => $name);
+
+ if ($with_filter) {
+ my $input_style;
+
+ if (($attributes{style} // '') =~ m{width: *(\d+) *px}i) {
+ $input_style = "width: " . ($1 - 22) . "px";
+ }
+
+ my $input_html = html_tag(
+ 'input', undef,
+ autocomplete => 'off',
+ type => 'text',
+ id => $attributes{id} . '_filter',
+ 'data-select-id' => $attributes{id},
+ (placeholder => $fil_placeholder) x !!$fil_placeholder,
+ (style => $input_style) x !!$input_style,
+ );
+ $select_html = html_tag('div', $input_html . $select_html, class => "filtered_select");
+ }
+
+ return $select_html;
}
sub checkbox_tag {
.cke_button {
padding: 0px; 6px !important;
}
+
+/* selects with text filters */
+div.filtered_select input, div.filtered_select select {
+ display: block;
+}
+
+div.filtered_select input {
+ background-image: url(../../image/glass14x14.png);
+ background-repeat: no-repeat;
+ background-position: 2px 2px;
+ border-radius: 0px;
+ border: solid #a0a0a0 1px;
+ border-bottom: none;
+ padding: 0px;
+ padding-left: 20px;
+ margin: 0;
+ width: 500px;
+}
+
+div.filtered_select select {
+ width: 522px;
+}
.cke_button {
padding: 0px; 6px !important;
}
+
+/* selects with text filters */
+div.filtered_select input, div.filtered_select select {
+ display: block;
+}
+
+div.filtered_select > input {
+ background-image: url(../../image/glass14x14.png);
+ background-repeat: no-repeat;
+ background-position: 2px 2px;
+ border-radius: 0px;
+ border: solid #a0a0a0 1px;
+ border-bottom: none;
+ padding: 0px;
+ padding-left: 20px;
+ margin: 0;
+ width: 500px;
+}
+
+div.filtered_select select {
+ width: 522px;
+}
editor.on('instanceReady', function() { ns.focus_ckeditor($e); });
};
+ ns.filter_select = function() {
+ var $input = $(this);
+ var $select = $('#' + $input.data('select-id'));
+ var filter = $input.val().toLocaleLowerCase();
+
+ $select.find('option').each(function() {
+ if ($(this).text().toLocaleLowerCase().indexOf(filter) != -1)
+ $(this).show();
+ else
+ $(this).hide();
+ });
+ };
+
ns.reinit_widgets = function() {
ns.run_once_for('.datepicker', 'datepicker', function(elt) {
$(elt).datepicker();
kivi.ChartPicker($(elt));
});
+ ns.run_once_for('div.filtered_select input', 'filtered_select', function(elt) {
+ $(elt).bind('change keyup', ns.filter_select);
+ });
var func = kivi.get_function_by_name('local_reinit_widgets');
if (func)