import jQuery from "jquery"; import "jquery-ui/ui/widget.js"; import I18n from "./i18n"; (function ($) { $.widget("ra.filteringMultiselect", { _cache: {}, options: { createQuery: function (query) { return { query: query }; }, sortable: false, removable: true, regional: { add: "Add", chooseAll: "Choose all", clearAll: "Clear all", down: "Down", remove: "Remove", search: "Search", up: "Up", }, searchDelay: 400, remote_source: null, xhr: false, }, wrapper: null, filter: null, collection: null, addAll: null, add: null, remove: null, up: null, down: null, selection: null, removeAll: null, _create: function () { this._cache = {}; this._build(); this._buildCache(); this._bindEvents(); }, _build: function () { var i; this.wrapper = this.element.siblings( '.ra-multiselect[data-input-for="' + this.element.attr("id") + '"]' ); // Prevent duplication on browser back if (this.wrapper.length > 0) { this.filter = this.wrapper.find("input.ra-multiselect-search"); this.collection = this.wrapper.find("select.ra-multiselect-collection"); this.addAll = this.wrapper.find("a.ra-multiselect-item-add-all"); this.add = this.wrapper.find("a.ra-multiselect-item-add"); this.remove = this.wrapper.find("a.ra-multiselect-item-remove"); this.up = this.wrapper.find("a.ra-multiselect-item-up"); this.down = this.wrapper.find("a.ra-multiselect-item-down"); this.selection = this.wrapper.find("select.ra-multiselect-selection"); this.removeAll = this.wrapper.find("a.ra-multiselect-item-remove-all"); return; } this.wrapper = $('