MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Tag: Reverted
Line 307:
 
/* DO NOT ADD CODE BELOW THIS LINE */
 
/* ======================================================= */
/* MOBILE AI ASSISTANT: INJECT CLOSE BUTTON IN FOOTER */
/* ======================================================= */
$(function() {
// Only run on mobile devices
if (window.innerWidth > 768) return;
 
var checkFooter = setInterval(function() {
var $footer = $('.ext-aiassistant-footer');
// Wait until the footer exists
if ($footer.length) {
clearInterval(checkFooter);
// Prevent duplicate buttons
if ($('#ai-assistant-close-mobile').length === 0) {
// 1. Create the button
// We use the EXACT same Codex classes as the Send button for visual consistency
var $closeBtn = $('<button>', {
id: 'ai-assistant-close-mobile',
class: 'cdx-button cdx-button--action-progressive cdx-button--weight-primary cdx-button--size-medium cdx-button--framed cdx-button--icon-only',
title: 'Close Assistant',
click: function() {
// Action: Hide the panel when clicked
$('.ext-aiassistant-panel').hide();
}
});
 
// 2. Add the "X" Icon (SVG)
var iconSvg = '<span class="cdx-icon cdx-icon--medium"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M4.34 2.93l12.73 12.73-1.41 1.41L2.93 4.35z"/><path d="M17.07 4.34L4.34 17.07l-1.41-1.41L15.66 2.93z" fill="white"/></svg></span>';
$closeBtn.html(iconSvg);
 
// 3. Prepend to footer (Places it on the LEFT of the text input)
$footer.prepend($closeBtn);
}
}
}, 200); // Check every 200ms
});