Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
This patch provides a bit of a backend change that will allow #514990: Add a UI for browsing tokens to function. There is no front-end change to functionality.
Basically, the autocomplete has two mechanisms: an acJs object, which acts as a direct interface with the UI element, responding directly to it. This defers the actual AJAX / database interactions to another element, called ACDB (AutoComplete DataBase). This object can be interchangeable (this code makes it so), so that the token database could differ slightly.
This patch also does two other things:
- Moves the ugly -autocomplete element into a JS setting (pretty critical for this to function)
- Moves the bit of logic which decides when to hide the popup into the database (just two lines of code), because with tokens most of the time we'll want to keep the popup open.
Comment | File | Size | Author |
---|---|---|---|
#24 | ac-reroll.patch | 8.45 KB | bcn |
#18 | autocomplete-exchangeableACDB.patch | 8.18 KB | dmitrig01 |
#15 | autocomplete-exchangeableACDB.patch | 7.52 KB | dmitrig01 |
#14 | autocomplete-exchangeableACDB.patch | 7.25 KB | dmitrig01 |
#12 | autocomplete-exchangeableACDB.patch | 5.19 KB | dmitrig01 |
Comments
Comment #1
dmitrig01 CreditAttribution: dmitrig01 commentedI forgot to mention - it looks like the code was originally meant to have this, Steven just never seemed to get around to it - the distinction is pretty clear and they could have been one object if it wasn't meant to be this way.
Comment #2
Dave ReidWhat happens when there are two autocomplete elements on the same page with this patch? It seems like the JS settings might conflict?
Comment #3
dmitrig01 CreditAttribution: dmitrig01 commentedarray('Drupal.ACDB' => array('#' . $element['#id']))
It works as intended, and sticks with the original approach - there is one ACDB object per URL, but multiple jsAC objects - one for each element. I tried it on the node form, which has two (tags and username) and it worked great.
[Edit: since the element ID is in an array, and drupal_add_js uses array_merge_recursive, you can add multiple IDs per uri and ACDB]
Comment #5
dmitrig01 CreditAttribution: dmitrig01 commentedWhoops, fixed
Comment #6
sunWhy not #attached here?
Missing 'var' in for statements
Powered by Dreditor.
Comment #7
dmitrig01 CreditAttribution: dmitrig01 commentedwrt. #1, I'm just following existing code, but should I still split it out?
Comment #8
sunWe should use #attached wherever we can, because only #attached page requisites can be cached (and more easily altered).
Comment #9
dmitrig01 CreditAttribution: dmitrig01 commentedComment #11
sunThat's a bit sparse ;)
Use !empty()
Missing 'js' key after #attached
Missing hash '#' prefix for attributes.
Still missing 'var' statements here.
Did you test whether eval() is actually needed here?
Powered by Dreditor.
Comment #12
dmitrig01 CreditAttribution: dmitrig01 commentedYes, the eval is needed.
Comment #14
dmitrig01 CreditAttribution: dmitrig01 commentedwhoops
Comment #15
dmitrig01 CreditAttribution: dmitrig01 commentedComment #18
dmitrig01 CreditAttribution: dmitrig01 commentedSome thing strange happened with the CSS – this fixes it.
Comment #19
sunMissing trailing comma.
I'd be ok with this, since the overall changes of this patch are a big step forward... but ideally, I'd like to have kkaefer, Rob Loach, or quicksketch sign this off.
We support autocomplete on a textarea?
4 days to code freeze. Better review yourself.
Comment #20
Dave Reid@dmitrig01: Up for fixing this one more time?
Comment #21
Dave ReidAdding the generic 'token' tag for core. Anyone up for re-rolling this?
Comment #22
Dave ReidComment #23
Dave ReidComment #24
bcn CreditAttribution: bcn commentedre-roll
Comment #25
retester2010 CreditAttribution: retester2010 commentedtrailing white space
40 critical left. Go review some!
Comment #26
nod_Who's up for a reroll of a 2 years old patch?
Comment #27
tkoleary CreditAttribution: tkoleary commentedPlease follow progress on: #2346973: Improve usability, accessibility, and scalability of long select lists
Changing to Select2 may render this issue obsolete. If we move to Select2 AFAIK it has a much more robust method for handling tokens.
Comment #28
nod_I think we're covered with the new jQuery UI autocomplete. If not feel free to reopen.