File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 < li >
1111 < a href ="# " data-target ="templates-user " data-i18n ="templates.user.heading "> My Templates</ a >
1212 </ li >
13+ < li class ="templates-search ">
14+ < label for ="templates-search-input " class ="visually-hidden " data-i18n ="templates.search.label "> Search templates</ label >
15+ < input id ="templates-search-input " type ="search " placeholder ="Filter languages... " aria-label ="Filter templates by language " />
16+ </ li >
1317 </ ul >
1418
1519 < div id ="templates-starter " class ="tab-content active ">
2832 </ div >
2933 </ div >
3034</ div >
35+
36+ <!-- Inline: emit a "templates:filter" event with the current query so other scripts can perform filtering -->
37+ < script >
38+ ( function ( ) {
39+ var input = document . getElementById ( 'templates-search-input' ) ;
40+ if ( ! input ) return ;
41+
42+ var emit = function ( value ) {
43+ var ev = new CustomEvent ( 'templates:filter' , { detail : { query : value } } ) ;
44+ document . getElementById ( 'templates-container' ) . dispatchEvent ( ev ) ;
45+ } ;
46+
47+ var timeout = null ;
48+ input . addEventListener ( 'input' , function ( e ) {
49+ var val = e . target . value || '' ;
50+ // debounce to avoid excessive events while typing
51+ clearTimeout ( timeout ) ;
52+ timeout = setTimeout ( function ( ) { emit ( val . trim ( ) ) ; } , 150 ) ;
53+ } ) ;
54+ } ) ( ) ;
55+ </ script >
You can’t perform that action at this time.
0 commit comments