11/* search_tp53.js */
22'use strict' ;
33
4+ var syncChosenFromSelect = function ( selectEl ) {
5+ var s = selectEl ;
6+ if ( ! s || ! s . id ) {
7+ return ;
8+ }
9+ var container = document . getElementById ( s . id + '_chosen' ) ;
10+ if ( ! container ) {
11+ return ;
12+ }
13+ var labelledBy = s . getAttribute ( 'aria-labelledby' ) ;
14+ var ariaLabel = s . getAttribute ( 'aria-label' ) ;
15+ var plTrim = s . getAttribute ( 'data-placeholder' ) ;
16+ if ( plTrim ) {
17+ plTrim = String ( plTrim ) . replace ( / \s * \. \. \. \s * $ / , '' ) . trim ( ) ;
18+ } else {
19+ plTrim = '' ;
20+ }
21+ var inputs = container . querySelectorAll ( 'input' ) ;
22+ for ( var i = 0 ; i < inputs . length ; i ++ ) {
23+ var inp = inputs [ i ] ;
24+ if ( inp . type === 'hidden' || inp . type === 'checkbox' || inp . type === 'radio' ) {
25+ continue ;
26+ }
27+ if ( labelledBy ) {
28+ inp . removeAttribute ( 'aria-label' ) ;
29+ inp . setAttribute ( 'aria-labelledby' , labelledBy ) ;
30+ } else if ( ariaLabel ) {
31+ inp . removeAttribute ( 'aria-labelledby' ) ;
32+ inp . setAttribute ( 'aria-label' , ariaLabel ) ;
33+ } else if ( plTrim ) {
34+ inp . removeAttribute ( 'aria-labelledby' ) ;
35+ inp . setAttribute ( 'aria-label' , plTrim ) ;
36+ }
37+ if ( plTrim ) {
38+ inp . setAttribute ( 'placeholder' , plTrim ) ;
39+ }
40+ }
41+ } ;
42+
43+ var syncAllChosen = function ( ) {
44+ $ ( 'select.chosen-select' ) . each ( function ( ) {
45+ syncChosenFromSelect ( this ) ;
46+ } ) ;
47+ } ;
448
549$ ( document ) . ready ( function ( ) {
650 if ( $ ( 'table.result-table' ) . length === 0 )
@@ -18,6 +62,11 @@ $(document).ready(function () {
1862 search_contains : true ,
1963 max_shown_results : 300
2064 } ) ;
65+ syncAllChosen ( ) ;
66+ setTimeout ( syncAllChosen , 0 ) ;
67+ $ ( document ) . on ( 'chosen:updated' , 'select.chosen-select' , function ( ) {
68+ syncChosenFromSelect ( this ) ;
69+ } ) ;
2170
2271 $ ( '.topo-morph-select' ) . on ( 'change' , function ( ) {
2372 var topo_morph_assc = $ ( this ) . data ( 'topo-morph-assc' ) ;
0 commit comments