Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | /* eslint-disable camelcase */ |
| 5 | /* eslint-disable no-unused-vars */ |
| 6 | |
| 7 | /** |
| 8 | * Sets up the legacy autocomplete editing widget on DOM elements that are |
| 9 | * set to use it. |
| 10 | */ |
| 11 | function TKR_install_ac() { |
| 12 | _ac_install(); |
| 13 | |
| 14 | _ac_register(function(input, event) { |
| 15 | if (input.id.startsWith('hotlists')) return TKR_hotlistsStore; |
| 16 | if (input.id.startsWith('search')) return TKR_searchStore; |
| 17 | if (input.id.startsWith('query_') || input.id.startsWith('predicate_')) { |
| 18 | return TKR_projectQueryStore; |
| 19 | } |
| 20 | if (input.id.startsWith('cmd')) return TKR_quickEditStore; |
| 21 | if (input.id.startsWith('labelPrefix')) return TKR_labelPrefixStore; |
| 22 | if (input.id.startsWith('label') && input.id != 'labelsInput') return TKR_labelStore; |
| 23 | if (input.dataset.acType === 'label' && input.id != 'labelsInput') return TKR_labelMultiStore; |
| 24 | if ((input.id.startsWith('component') || input.dataset.acType === 'component') |
| 25 | && input.id != 'componentsInput') return TKR_componentListStore; |
| 26 | if (input.id.startsWith('status')) return TKR_statusStore; |
| 27 | if (input.id.startsWith('member') || input.dataset.acType === 'member') return TKR_memberListStore; |
| 28 | |
| 29 | if (input.id == 'admin_names_editor') return TKR_memberListStore; |
| 30 | if (input.id.startsWith('owner') && input.id != 'ownerInput') return TKR_ownerStore; |
| 31 | if (input.name == 'needs_perm' || input.name == 'grants_perm') { |
| 32 | return TKR_customPermissionsStore; |
| 33 | } |
| 34 | if (input.id == 'owner_editor' || input.dataset.acType === 'owner') return TKR_ownerStore; |
| 35 | if (input.className.indexOf('userautocomplete') != -1) { |
| 36 | const customFieldIDStr = input.name; |
| 37 | const uac = TKR_userAutocompleteStores[customFieldIDStr]; |
| 38 | if (uac) return uac; |
| 39 | return TKR_ownerStore; |
| 40 | } |
| 41 | if (input.className.indexOf('autocomplete') != -1) { |
| 42 | return TKR_autoCompleteStore; |
| 43 | } |
| 44 | if (input.id.startsWith('copy_to') || input.id.startsWith('move_to') || |
| 45 | input.id.startsWith('new_savedquery_projects') || |
| 46 | input.id.startsWith('savedquery_projects')) { |
| 47 | return TKR_projectStore; |
| 48 | } |
| 49 | }); |
| 50 | }; |