From c9b2011a11ed1b7f3d69affc2badc2469aab0b0b Mon Sep 17 00:00:00 2001 From: Raphael Beer Date: Wed, 20 Apr 2016 10:59:09 +0200 Subject: [PATCH] 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. --- public/src/modules/iconSelect.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/public/src/modules/iconSelect.js b/public/src/modules/iconSelect.js index 252f8778d9..0f8cf6d182 100644 --- a/public/src/modules/iconSelect.js +++ b/public/src/modules/iconSelect.js @@ -20,6 +20,7 @@ define('iconSelect', function() { var picker = bootbox.dialog({ onEscape: true, backdrop: true, + show: false, message: html, title: 'Select an Icon', 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() { var modalEl = $(this), searchEl = modalEl.find('input'), @@ -71,11 +82,7 @@ define('iconSelect', function() { } // Focus on the input box - searchEl.focus(); - - if (selected) { - modalEl.find('.' + selected).addClass('selected'); - } + searchEl.selectRange(0, searchEl.val().length); modalEl.find('.icon-container').on('click', 'i', function() { searchEl.val($(this).attr('class').replace('fa fa-', '').replace('selected', ''));