File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,12 @@ var $articleContainer,
3636 // Override link behavior
3737 $ ( document . body ) . on ( "click" , "a" , function ( ev ) {
3838 var noModifierKeys = ! ev . altKey && ! ev . ctrlKey && ! ev . metaKey && ! ev . shiftKey ,
39- sameHostname = this . hostname === window . location . hostname ,
40- sameProtocol = this . protocol === window . location . protocol ;
39+ sameHostname = ( ev . target . hostname || this . hostname ) === window . location . hostname ,
40+ sameProtocol = ( ev . target . protocol || this . protocol ) === window . location . protocol ;
4141
4242 if ( noModifierKeys && sameHostname && sameProtocol ) {
4343 ev . preventDefault ( ) ;
44- var href = this . href ;
45- navigate ( href ) ;
44+ navigate ( ev . target . href || this . href ) ;
4645 }
4746 } ) . on ( 'keyup' , 'input[type="checkbox"]' , function ( e ) {
4847 var $target = $ ( e . target ) ;
Original file line number Diff line number Diff line change @@ -516,6 +516,17 @@ var Search = Control.extend({
516516 }
517517
518518 return "/" + this . url ;
519+ } ,
520+ addTargetToExternalURLs : function ( html ) {
521+ var $html = $ ( '<div>' ) . html ( html ) ;
522+ $html . find ( 'a' ) . each ( function ( ) {
523+ var $a = $ ( this ) ;
524+ var a = $a [ 0 ] ;
525+ if ( a . hostname !== location . hostname || a . protocol !== location . protocol ) {
526+ $a . attr ( 'target' , '_blank' ) ;
527+ }
528+ } ) ;
529+ return $html . contents ( ) ;
519530 }
520531 } ) ;
521532
Original file line number Diff line number Diff line change 3030
3131 {{#if result.description}}
3232 <div class="result-description" title="{{result.description}}">
33- {{{result.description}}}
33+ {{{addTargetToExternalURLs( result.description) }}}
3434 </div>
3535 {{/if}}
3636 </a>
You can’t perform that action at this time.
0 commit comments