MediaWiki:Mobile.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* All JavaScript here will be loaded for users of the mobile site */
// 修复 Minerva 皮肤下 InputBox 首次点击被主搜索框抢焦点的问题
$( function () {
// 等待页面基本就绪
mw.loader.using( 'mediawiki.page.ready' ).then( function () {
var $inputBox = $( '#homeSearchInput' );
if ( $inputBox.length ) {
// 当 InputBox 获得焦点时,立即让它“失焦”再重新聚焦,
// 以此打断 Minerva 的焦点劫持流程。
$inputBox.on( 'focus', function () {
var self = this;
// 使用 setTimeout 0 将操作推迟到当前事件循环之后,
// 让 Minerva 的处理器先运行,然后我们再“抢回”焦点。
setTimeout( function () {
self.blur();
self.focus();
}, 0 );
} );
}
} );
} );