import jQuery from "jquery"; import "jquery-ui/ui/widget"; import "jquery-ui/ui/widgets/autocomplete"; import I18n from "./i18n"; (function ($) { "use strict"; $.widget("ra.filteringSelect", { options: { createQuery: function (query) { return { query: query }; }, minLength: 0, searchDelay: 200, remote_source: null, source: null, xhr: false, }, button: null, input: null, select: null, filtering_select: null, _create: function () { this.filtering_select = this.element.siblings( '[data-input-for="' + this.element.attr("id") + '"]' ); // When using the browser back and forward buttons, it is possible that // the autocomplete field will be cached which causes duplicate fields // to be generated. if (this.filtering_select.length > 0) { this.input = this.filtering_select.children("input"); this.button = this.filtering_select.children(".input-group-btn"); } else { this.element.hide(); this.filtering_select = this._inputGroup(this.element.attr("id")); this.input = this._inputField(); this.button = this._buttonField(); } this.clearOption = $('').append( ' ' + $("").text(I18n.t("clear")).html() ); this.noObjectsPlaceholder = $('