Set input#fa-filter value to name of selected icon

- Set selected icon before modal is visible.
- Select input#fa-filter content to allow
  immediate typing/searching.
v1.18.x
Raphael Beer 9 years ago
parent aaef2d4362
commit c9b2011a11

@ -20,6 +20,7 @@ define('iconSelect', function() {
var picker = bootbox.dialog({ var picker = bootbox.dialog({
onEscape: true, onEscape: true,
backdrop: true, backdrop: true,
show: false,
message: html, message: html,
title: 'Select an Icon', title: 'Select an Icon',
buttons: { buttons: {
@ -51,6 +52,16 @@ define('iconSelect', function() {
} }
}); });
picker.on('show.bs.modal', function() {
var modalEl = $(this),
searchEl = modalEl.find('input');
if (selected) {
modalEl.find('.' + selected).addClass('selected');
searchEl.val(selected.replace('fa-', ''));
}
}).modal('show');
picker.on('shown.bs.modal', function() { picker.on('shown.bs.modal', function() {
var modalEl = $(this), var modalEl = $(this),
searchEl = modalEl.find('input'), searchEl = modalEl.find('input'),
@ -71,11 +82,7 @@ define('iconSelect', function() {
} }
// Focus on the input box // Focus on the input box
searchEl.focus(); searchEl.selectRange(0, searchEl.val().length);
if (selected) {
modalEl.find('.' + selected).addClass('selected');
}
modalEl.find('.icon-container').on('click', 'i', function() { modalEl.find('.icon-container').on('click', 'i', function() {
searchEl.val($(this).attr('class').replace('fa fa-', '').replace('selected', '')); searchEl.val($(this).attr('class').replace('fa fa-', '').replace('selected', ''));

Loading…
Cancel
Save