LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-site-shared.js”的版本间差异

跳转到导航 跳转到搜索
添加1,010字节 、​ 2021年4月4日 (日) 06:31
无编辑摘要
* 5. [[特殊:链入页面]]检索正确的繁简转换页面
* 6. 分类栏正确显示小写标题
* 7. 禁止使用InPageEdit快速编辑和快速重定向触摸屏将packed-hover模式的gallery替换为packed
* 8. 章节标题hash繁简转换
* 9. 禁止使用InPageEdit快速编辑和快速重定向
* @Dependencies: mediawiki.api, mediawiki.Uri, mediawiki.Title, ext.gadget.site-lib
* @Author: 如无特殊说明,均为[[User:Bhsd]]
});
});
 
/**
* @Function: 触摸屏代替gallery的hover效果
*/
if (matchMedia( 'screen and (hover: none)' ).matches) {
mw.hook( 'wikipage.content' ).add($content => {
console.log('Hook: wikipage.content, 开始移除gallery的hover效果');
$content.find( '.mw-gallery-packed-hover ' ).toggleClass( 'mw-gallery-packed-hover mw-gallery-packed' );
});
}
 
/**
* @Function: 自动实现hash繁简转换
* @Bug: 由于MediaWiki的hash转义算法有缺陷,可能无法识别转义前的“.”字符
*/
const hashConvert = () => {
const hash = location.hash.slice(1);
if (!hash || document.getElementById( hash )) { return; }
$('.mw-headline').filter(function() {
return this.textContent == hash || this.textContent == hash.replace(/\.(?=[\dA-Z]{2})/g, '%');
})[0].scrollIntoView({ behavior: 'smooth' });
};
hashConvert();
$(window).on('hashchange', hashConvert);
 
/**
'gadget-ipe-redirect': '無法正確判別頁面是否已存在'
}) );
const noRedirectnoIPE = function(msg) {
mw.notify( mw.msg( 'gadget-ipe-warn', mw.msg( 'gadget-ipe-' + (msg || 'redirect') ) ),
{type: 'warn', autoHide: false, tag: 'InPageEdit'} );
mw.hook( 'InPageEdit.quickEdit' ).add(function(data) {
data.$modalWindow.find( '.save-btn' ).prop('disabled', true);
noRedirectnoIPE( 'edit' );
});
mw.hook( 'InPageEdit.quickRedirect' ).add( noRedirectnoIPE );
mw.hook( 'InPageEdit.quickRename' ).add( noRedirectnoIPE );
 
//</nowiki>
16,874

个编辑

导航菜单