No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
/* ===== BlueSpice Galaxy – chatbot hero banner by Claude.ai===== | /* ===== BlueSpice Galaxy – chatbot hero banner by Claude.ai===== | ||
Makes "Chat with Nova" open your existing chatbot instead of following the link. | Makes "Chat with Nova" open your existing chatbot instead of following the link. | ||
Without JavaScript, the link still leads to the Help:ChatBot page as a fallback. */ | Without JavaScript, the link still leads to the Help:ChatBot page as a fallback. */ | ||
mw.hook( 'wikipage.content' ).add( function ( $content ) { | mw.hook( 'wikipage.content' ).add( function ( $content ) { | ||
$content.find( '.bs-hero__cta a' ).each( function () { | $content.find( '.bs-hero__cta a' ).each( function () { | ||
var link = this; | var link = this; | ||
// bind only once, even if the hook fires several times | |||
if ( link.dataset.bsChatBound ) { | |||
return; | |||
} | |||
link.dataset.bsChatBound = '1'; | |||
link.setAttribute( 'role', 'button' ); | link.setAttribute( 'role', 'button' ); | ||
link.addEventListener( 'click', function ( e ) { | link.addEventListener( 'click', function ( e ) { | ||
var launcher = document.getElementById( 'maximizeChat' ); | var launcher = document.getElementById( 'maximizeChat' ); | ||
if ( launcher ) { | if ( !launcher ) { | ||
e.preventDefault(); | return; // no chat on this page: follow the link to the help page | ||
} | |||
e.preventDefault(); | |||
// keep this click from reaching the chat's own "click outside" handling | |||
e.stopPropagation(); | |||
// open the chat after this click has finished | |||
setTimeout( function () { | |||
launcher.click(); | launcher.click(); | ||
} | }, 0 ); | ||
} ); | } ); | ||
link.addEventListener( 'keydown', function ( e ) { | link.addEventListener( 'keydown', function ( e ) { | ||
if ( e.key === ' ' ) { e.preventDefault(); link.click(); } | if ( e.key === ' ' ) { | ||
e.preventDefault(); | |||
link.click(); | |||
} | |||
} ); | } ); | ||
} ); | } ); | ||
} ); | } ); | ||
Revision as of 10:47, 16 October 2026
/* Any JavaScript here will be loaded for all users on every page load. */
/* ===== BlueSpice Galaxy – chatbot hero banner by Claude.ai=====
Makes "Chat with Nova" open your existing chatbot instead of following the link.
Without JavaScript, the link still leads to the Help:ChatBot page as a fallback. */
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$content.find( '.bs-hero__cta a' ).each( function () {
var link = this;
// bind only once, even if the hook fires several times
if ( link.dataset.bsChatBound ) {
return;
}
link.dataset.bsChatBound = '1';
link.setAttribute( 'role', 'button' );
link.addEventListener( 'click', function ( e ) {
var launcher = document.getElementById( 'maximizeChat' );
if ( !launcher ) {
return; // no chat on this page: follow the link to the help page
}
e.preventDefault();
// keep this click from reaching the chat's own "click outside" handling
e.stopPropagation();
// open the chat after this click has finished
setTimeout( function () {
launcher.click();
}, 0 );
} );
link.addEventListener( 'keydown', function ( e ) {
if ( e.key === ' ' ) {
e.preventDefault();
link.click();
}
} );
} );
} );