@@ -75,14 +75,12 @@ var Search = {
7575
7676 init : function ( ) {
7777 var params = $ . getQueryParameters ( ) ;
78+ let doc_section = params . doc_section ? params . doc_section [ 0 ] : 'all' ;
79+ $ ( 'input[id="doc_section_' + doc_section + '"]' ) . prop ( "checked" , true )
7880 if ( params . q ) {
7981 var query = params . q [ 0 ] ;
8082 $ ( 'input[name="q"]' ) [ 0 ] . value = query ;
8183 $ ( 'input[name="q"]' ) [ 1 ] . value = query ;
82- if ( params . doc_section ) {
83- var doc_section = params . doc_section [ 0 ] ;
84- $ ( 'select[name="doc_section"]' ) [ 0 ] . value = doc_section ;
85- }
8684 this . performSearch ( query , doc_section ) ;
8785 }
8886 } ,
@@ -234,7 +232,7 @@ var Search = {
234232
235233 // Enrich item with parent doc_section title
236234 for ( i = 0 ; i < results . length ; i ++ )
237- results [ i ] [ 6 ] = results [ i ] [ 6 ] || 'TODO Documentation title ' ;
235+ results [ i ] [ 6 ] = results [ i ] [ 6 ] || 'Plone Documentation' ;
238236
239237 // now sort the results by score (in opposite order of appearance, since the
240238 // display function below uses pop() to retrieve items) and then
@@ -255,24 +253,21 @@ var Search = {
255253 } ) ;
256254
257255 function _getBreadcrumbs ( item , linkUrl ) {
258- let path = item [ 0 ] ;
259256 let parentTitles = item [ 6 ] ;
260- let markup = path . split ( '/' )
257+ let path = item [ 0 ] . split ( '/' )
261258 . slice ( 0 , - 1 ) ;
262- markup = markup . map ( ( el , index ) => {
259+ path = path . map ( ( el , index ) => {
263260 return {
264- "path" : markup . slice ( 0 , index + 1 ) . join ( '/' ) ,
261+ "path" : path . slice ( 0 , index + 1 ) . join ( '/' ) ,
265262 "title" : parentTitles [ index ]
266263 }
267264 } )
268- markup = markup
269- . map ( ( el ) => {
270- let foo = `<a href="/${ el . path } "> ${ el . title } </a>`
271- return foo ;
265+ let markup = path
266+ . map ( ( el , idx ) => {
267+ return idx === 0 ? `<a href="/${ el . path } "><b>${ el . title } </b></a>` : `<a href="/${ el . path } ">${ el . title } </a>`
272268 } )
273269 markup . push ( `<span class="lastbreadcrumb">${ item [ 1 ] } </span>` )
274- markup = markup . join ( '<span class="pathseparator">></span>' ) ;
275- return markup
270+ return markup . join ( '<span class="pathseparator">></span>' ) ;
276271 }
277272
278273 // Print the results.
@@ -587,7 +582,14 @@ var Search = {
587582
588583$ ( document ) . ready ( function ( ) {
589584 Search . init ( ) ;
590- $ ( 'select[name="doc_section"]' ) . change ( function ( ) {
585+ $ ( '#q' ) . focus ( ) ;
586+ $ ( 'input[name="doc_section"]' ) . change ( function ( ) {
591587 this . form . submit ( ) ;
592588 } ) ;
589+
590+ function clearSearchField ( ) {
591+ $ ( '#q' ) . val ( '' ) ;
592+ this . form . submit ( ) ;
593+ }
594+ $ ( "button.clear_search" ) . on ( "click" , clearSearchField ) ;
593595} ) ;
0 commit comments