nl_tokens: Navigate through the dropdown
pl_tokens: function ( e ) { e = e || window . event ; // Filter out the keys we don"t want if ( ! this . items . length || ! this . opened || ! util . includes ( [ 13 , 38 , 40 ] , e . which ) ) { this . navigating = false ; return ; } e . preventDefault ( ) ; if ( e . which === 13 ) { if ( this . config . taggable && this . input . value . length > 0 ) { return false ; } return this . change ( this . navIndex ) ; } var direction , prevEl = this . items [ this . navIndex ] ; switch ( e . which ) { case 38 : direction = 0 ; if ( this . navIndex > 0 ) { this . navIndex -- ; } break ; case 40 : direction = 1 ; if ( this . navIndex < this . items . length - 1 ) { this . navIndex ++ ; } } this . navigating = true ; // Instead of wasting memory holding a copy of this.items // with disabled / excluded options omitted, skip them instead while ( util . hasClass ( this . items [ this . navIndex ] , "disabled" ) || util . hasClass ( this . items [ this . navIndex ] , "excluded" ) ) { if ( direction ) { this . navIndex ++ ; } else { this . navIndex -- ; } if ( this . searching ) { if ( this . navIndex > this . tree . lastElementChild . idx ) { this . navIndex = this . tree . lastElementChild . idx ; break ; } else if ( this . navIndex < this . tree . firstElementChild . idx ) { this . navIndex = this . tree . firstElementChild . idx ; break ; } } } // Autoscroll the dropdown during navigation var r = util . rect ( this . <mask> [ this . navIndex ] ) ; if ( ! direction ) { if ( this . navIndex === 0 ) { this . tree . scrollTop = 0 ; } else if ( r . top - this . optsRect . top < 0 ) { this . tree . scrollTop = this . tree . scrollTop + ( r . top - this . optsRect . top ) ; } } else { if ( this . navIndex === 0 ) { this . tree . scrollTop = 0 ; } else if ( ( r . top + r . height ) > ( this . optsRect . top + this . optsRect . height ) ) { this . tree . scrollTop = this . tree . scrollTop + ( ( r . top + r . height ) - ( this . optsRect . top + this . optsRect . height ) ) ; } // Load another page if needed if ( this . navIndex === this . tree . childElementCount - 1 && this . requiresPagination ) { load . call ( this ) ; } } if ( prevEl ) { util . removeClass ( prevEl , "active" ) ; } util . addClass ( this . items [ this . navIndex ] , "active" ) ; }