มีเดียวิกิ:Common.js
หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง
- ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
- กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
- ไมโครซอฟท์ เอดจ์: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
/**
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
* loaded for all users on every wiki page. If possible create a gadget that is
* enabled by default instead of adding it here (since gadgets are fully
* optimized ResourceLoader modules with possibility to add dependencies etc.)
*
* Since Common.js isn't a gadget, there is no place to declare its
* dependencies, so we have to lazy load them with mw.loader.using on demand and
* then execute the rest in the callback. In most cases these dependencies will
* be loaded (or loading) already and the callback will not be delayed. In case a
* dependency hasn't arrived yet it'll make sure those are loaded before this.
*/
'use strict';
// [[หมวดหมู่:สคริปต์วิกิพจนานุกรม]] <nowiki>
/*jshint shadow:true, undef:true, latedef:true, unused:true, es3:true */
/*global window, jQuery, mw, importScript, importStylesheet, $ */
// XXX is the following code redundant to the above?
if (mw.config.get("wgTitle").indexOf("แบ่งตามภาษา") != -1)
$("a.CategoryTreeLabelCategory").text(
function(index, content) {
return content.replace(
/^Requests for (?:verification|deletion|cleanup) in (.+) entries$/,
"$1"
);
}
);
// removes "0 c" for categories that do not have subcategories
$(".CategoryTreeEmptyBullet + a + span")
.html(
function(index, content) {
return content.replace(
"0 ม, ",
""
);
}
);
// Various fixes for the trees generated by [[Module:family tree]].
$(function () {
// Show the top toggle.
$('.familytree-toptoggle').css('display', '');
// Initialize the text of the toggles.
$('.familytree').get().forEach(function (tree) {
var isCollapsed = tree.classList.contains('mw-collapsed');
var toggles = $(tree).find('.familytree-toggle');
if (toggles[0]) {
var customToggleClass = Array.prototype.filter.call(toggles[0].classList, function (className) {
return className.indexOf('mw-customtoggle') === 0;
})[0];
if (customToggleClass) {
var toggledElement = $('#' + customToggleClass.replace('mw-customtoggle', 'mw-customcollapsible'));
if (toggledElement) {
toggles.html(toggledElement.data(isCollapsed ? 'expandtext' : 'collapsetext'));
}
}
}
});
// Change the text in the custom toggles generated by [[Module:family tree]]
// when they are clicked.
$('.mw-collapsible').on('beforeExpand.mw-collapsible beforeCollapse.mw-collapsible',
function (event) {
if (this.id.indexOf('mw-customcollapsible') === 0) {
var toggle = $('.' + this.id.replace('mw-customcollapsible', 'mw-customtoggle'));
if (event.type === 'beforeExpand') {
toggle.html(this.dataset.collapsetext);
} else { // beforeCollapse
toggle.html(this.dataset.expandtext);
}
event.stopPropagation();
}
});
});
// </nowiki>
// The rest of the scripts are at [[MediaWiki:Gadget-legacy.js]].
// Most of them should be converted into gadgets as time and resources allow.