diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 3daeec359..1c4c4dfc1 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -41,6 +41,7 @@ //= require repository_columns/index //= require perfect-scrollbar.min //= require shared/inline_editing +//= require shared/barcode_search //= require activestorage //= require global_activities/side_pane //= require protocols/header diff --git a/app/assets/javascripts/my_modules/repositories.js b/app/assets/javascripts/my_modules/repositories.js index ba38e0d9e..e6e8571da 100644 --- a/app/assets/javascripts/my_modules/repositories.js +++ b/app/assets/javascripts/my_modules/repositories.js @@ -172,6 +172,7 @@ var MyModuleRepositories = (function() { var dataTableWrapper = $(tableContainer).closest('.dataTables_wrapper'); DataTableHelpers.initLengthApearance(dataTableWrapper); DataTableHelpers.initSearchField(dataTableWrapper, I18n.t('repositories.show.filter_inventory_items')); + $('').appendTo($('.search-container')); dataTableWrapper.find('.main-actions, .pagination-row').removeClass('hidden'); if (options.assign_mode) { renderFullViewAssignButtons(); diff --git a/app/assets/javascripts/repositories/show.js b/app/assets/javascripts/repositories/show.js index f03fe0021..76ac28dd1 100644 --- a/app/assets/javascripts/repositories/show.js +++ b/app/assets/javascripts/repositories/show.js @@ -174,27 +174,6 @@ $('.create-new-repository').initSubmitModal('#create-repo-modal', 'repository'); - $('.repository-show').on('click', '.barcode-scanner', function() { - var search = $('.search-container .search-field'); - var input = $('').attr('type', 'text').css('opacity', 0).appendTo('body'); - search.val(''); - search.attr('disabled', true).addClass('barcode-mode'); - - input.focus(); - input.one('change', function() { - search.val($(this).val()); - search.trigger('keyup'); - $(document).click(); - }); - - setTimeout(function() { - $(document).one('click', function() { - search.attr('disabled', false).removeClass('barcode-mode'); - input.remove(); - }); - }); - }); - function initArchivingActionsInDropdown() { $('.archive-repository-option').on('click', function(event) { event.preventDefault(); diff --git a/app/assets/javascripts/shared/barcode_search.js b/app/assets/javascripts/shared/barcode_search.js new file mode 100644 index 000000000..996f3bbf5 --- /dev/null +++ b/app/assets/javascripts/shared/barcode_search.js @@ -0,0 +1,20 @@ +$(document).on('click', '.barcode-scanner', function() { + var search = $('.search-container .search-field'); + var input = $('').attr('type', 'text').css('opacity', 0).appendTo('body'); + search.val(''); + search.attr('disabled', true).addClass('barcode-mode'); + + input.focus(); + input.one('change', function() { + search.val($(this).val()); + search.trigger('keyup'); + $(document).click(); + }); + + setTimeout(function() { + $(document).one('click', function() { + search.attr('disabled', false).removeClass('barcode-mode'); + input.remove(); + }); + }); +}); diff --git a/app/assets/stylesheets/repositories.scss b/app/assets/stylesheets/repositories.scss index 3e3af7fc9..bdd14baff 100644 --- a/app/assets/stylesheets/repositories.scss +++ b/app/assets/stylesheets/repositories.scss @@ -127,24 +127,6 @@ } } - .barcode-scanner { - cursor: pointer; - position: absolute; - right: 12px; - top: 12px; - } - - .search-container { - .search-field { - padding-right: 32px; - - &.barcode-mode { - background-color: $brand-primary; - opacity: .3; - } - } - } - .main-actions { align-items: center; background-color: $color-white; @@ -597,3 +579,21 @@ max-height: 290px; } } + +.barcode-scanner { + cursor: pointer; + position: absolute; + right: 12px; + top: 12px; +} + +.search-container { + .search-field { + padding-right: 32px; + + &.barcode-mode { + background-color: $brand-primary; + opacity: .3; + } + } +}