2424
2525 // Init Typeahead on search-fields
2626 $searchFields . typeahead ( {
27- hint : true ,
27+ hint : false ,
2828 highlight : true ,
2929 minLength : 1
3030 } ,
3535 } ) ;
3636 }
3737
38- // Insert the icons
39- $searchFields . after ( '<span class="icon icon--close" data-form-search-clear></span>' ) ;
40- $ ( '.form-search' ) . append ( '<button class="icon icon--search icon--before"><span class="sr-only">Search</span></button>' ) ;
41-
42- $ ( 'body' ) . on ( 'click' , '[data-form-search-clear]' , function ( ) {
43- $ ( '#search-field' ) . val ( '' ) . focus ( ) ; // clear search field and refocus it
44- } ) ;
45-
4638} ) ( jQuery , ( typeof searchData === 'undefined' ? false : searchData ) ) ;
4739
4840/* ==========================================================
@@ -192,7 +184,7 @@ function disableControl(element) {
192184 // Ensure every first collapse toggle for accordions is accessible
193185 // (cf. https://github.com/paypal/bootstrap-accessibility-plugin/issues/98):
194186 $ ( '[aria-multiselectable="true"]' ) . each ( function ( ) {
195- console . log ( $ ( this ) . find ( '[data-toggle="collapse"][data-parent]' ) . first ( ) . attr ( { tabindex : 0 } ) ) ;
187+ $ ( this ) . find ( '[data-toggle="collapse"][data-parent]' ) . first ( ) . attr ( { tabindex : 0 } ) ;
196188 } ) ;
197189
198190} ) ( jQuery ) ;
@@ -330,7 +322,7 @@ $.printPreview = {
330322 footnoteLinks = "" ,
331323 linksIndex = 0 ;
332324
333- $body . find ( '.nav-mobile, .drilldown, .nav-main, .header-separator, .nav-service, .nav-lang, .form-search, .yamm--select, header > div:first-child, footer, .alert, .icon--print, .social-sharing, form, .nav-process, .carousel-indicators, .carousel-control, .breadcrumb, .pagination-container' ) . remove ( ) ;
325+ $body . find ( '.nav-mobile, .drilldown, .nav-main, .header-separator, .nav-service, .nav-lang, .form-search, .yamm--select, footer, .alert, .icon--print, .social-sharing, form, .nav-process, .carousel-indicators, .carousel-control, .breadcrumb, .pagination-container' ) . remove ( ) ;
334326
335327 // if an element is passed, we want it to be the only thing to print out
336328 if ( element ) {
@@ -442,6 +434,11 @@ $.printPreview = {
442434 } ) ;
443435 } ) ;
444436
437+ // "tabindex = -1" is added by bootstrap-accessibility-plugin to dropdown's elements.
438+ // The yamm menu uses the dropdown class, but is not a conventional dropdown, hence, the tabindex must not
439+ // be present.
440+ $dropdown . find ( 'li a' ) . removeAttr ( 'tabindex' ) ;
441+
445442 $dropdownToggle . on ( 'click' , function ( ) {
446443 $ ( this ) . parents ( $dropdown ) . trigger ( 'get.hidden' ) ;
447444 } ) ;
@@ -492,10 +489,10 @@ $.printPreview = {
492489 var links = $ ( '.dropdown-menu li a' , $ ( this ) ) ;
493490 var suggestions = [ ] ;
494491 links . each ( function ( ) {
495- suggestions . push ( {
496- title : $ ( this ) . html ( ) ,
497- link : $ ( this ) . attr ( 'href' )
498- } ) ;
492+ suggestions . push ( {
493+ title : $ ( this ) . html ( ) ,
494+ link : $ ( this ) . attr ( 'href' )
495+ } ) ;
499496 } ) ;
500497 if ( ! suggestions . length ) {
501498 return ;
@@ -515,19 +512,19 @@ $.printPreview = {
515512 templates : {
516513 empty : function ( ) {
517514 return [
518- '<li><h3 >' ,
515+ '<li class="search-result-header" >' ,
519516 title ,
520- '</h3></ li>' ,
517+ '</li>' ,
521518 '<li>' ,
522519 window . translations [ 'global-search' ] [ 'nothing-found' ] ,
523- '</li>' ,
520+ '</li>'
524521 ] . join ( '' ) ;
525522 } ,
526523 header : function ( ) {
527524 return [
528- '<li><h3 >' ,
525+ '<li class="search-result-header" >' ,
529526 title ,
530- '</h3></ li>'
527+ '</li>'
531528 ] . join ( '' ) ;
532529 } ,
533530 dataset : '<ul><ul>' ,
@@ -540,6 +537,7 @@ $.printPreview = {
540537
541538 function initTypeahead ( element ) {
542539 $ ( '.search-input' , element ) . typeahead ( {
540+ hint : false ,
543541 highlight : true ,
544542 menu : $ ( '.search-results .search-results-list' , element ) ,
545543 classNames : {
@@ -548,45 +546,51 @@ $.printPreview = {
548546 }
549547 } , datasets )
550548 . on ( 'typeahead:selected' , function ( event , selection ) {
551- event . preventDefault ( ) ;
552- $ ( this ) . typeahead ( 'val' , '' )
553- . closest ( '.global-search' ) . removeClass ( 'has-input' ) ;
554- window . location . replace ( selection . link ) ;
555- } )
549+ event . preventDefault ( ) ;
550+ window . location . replace ( selection . link ) ;
551+ } )
556552 . on ( 'typeahead:open' , function ( ) {
557553 $ ( this ) . closest ( '.global-search' ) . addClass ( 'focused' ) ;
558- console . log ( $ ( this ) . typeahead ( 'val' ) ) ;
559554 } )
560- . on ( 'typeahead:close' , function ( ) {
555+ . on ( 'typeahead:close' , function ( ) {
561556 $ ( this ) . closest ( '.global-search' ) . removeClass ( 'focused' ) ;
557+ //$(this).closest('form').trigger('reset');
562558 } )
563559 . on ( 'keyup' , function ( event ) {
564560 if ( event . keyCode === 27 ) { // ESC
565561 $ ( this ) . closest ( 'form' ) . trigger ( 'reset' ) ;
566562 } else if ( $ ( this ) . typeahead ( 'val' ) ) {
567- $ ( this ) . closest ( '.global-search' ) . addClass ( 'has-input' ) ;
563+ $ ( this ) . closest ( '.global-search' ) . addClass ( 'has-input' ) ;
568564 } else {
569565 $ ( this ) . closest ( '.global-search' ) . removeClass ( 'has-input' ) ;
570- }
571- } ) ;
566+ }
567+ } ) ;
572568
573569 $ ( 'form' , element )
574570 . on ( 'submit' , function ( ) {
575571 return false ;
576572 } )
577573 . on ( 'reset' , function ( ) {
578- $ ( '.search-input' , this ) . blur ( ) . typeahead ( 'val' , '' ) ;
574+ $ ( '.search-input' , this ) . typeahead ( 'val' , '' ) ;
579575 $ ( this ) . closest ( '.global-search' ) . removeClass ( 'has-input' ) ;
580576 } ) ;
581577
582578 $ ( '.search-reset' , element ) . on ( 'click' , function ( ) {
583579 $ ( this ) . closest ( 'form' ) . trigger ( 'reset' ) ;
580+ $ ( '.search-input' , element ) . focus ( ) ;
584581 } ) ;
585582 }
586583
587584 initTypeahead ( $ ( '.global-search-standard' ) ) ;
588585 initTypeahead ( $ ( '.global-search-mobile' ) ) ;
589586
587+ // Mobile improvements:
588+ $ ( '.nav-mobile .nav-mobile-menu' ) . parent ( ) . on ( 'show.bs.dropdown' , function ( ) {
589+ setTimeout ( function ( ) {
590+ $ ( '.nav-mobile .search-input.tt-input' ) . val ( null ) . focus ( ) ;
591+ } , 100 ) ;
592+ } ) ;
593+
590594} ) ( jQuery ) ;
591595
592596/* ==========================================================
@@ -671,7 +675,7 @@ $.printPreview = {
671675 $that . find ( '.item:first' ) . addClass ( 'active' ) ;
672676 $that . find ( '.carousel-indicators li:first-child' ) . addClass ( 'active' ) ;
673677
674- $that . append ( '<a class="left carousel-control icon icon--before icon--less" href="#tab-focus-' + focusIndex + '" data-slide="prev"></a><a class="right carousel-control icon icon--before icon--greater" href="#tab-focus-' + focusIndex + '" data-slide="next"></a>' ) ;
678+ $that . append ( '<a class="left carousel-control icon icon--before icon--less" href="#tab-focus-' + focusIndex + '" data-slide="prev" aria-label="previous" ></a><a class="right carousel-control icon icon--before icon--greater" href="#tab-focus-' + focusIndex + '" data-slide="next" aria-label ="next"></a>' ) ;
675679 } ) ;
676680 }
677681 else if ( $tabFocus && $ ( window ) . width ( ) > 767 && isCarouselified ) {
0 commit comments