MediaWiki:Gadget-keybLayout.js
Перейти до навігації
Перейти до пошуку
Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.
- Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
- Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
- Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
- Opera: натисніть Ctrl-F5
mediaWiki.loader.using(['mediawiki.util']).done(function () {
var ns = mw.config.get('wgNamespaceNumber');
if (ns%2 == 0) {
jQuery.fn.highlight = function() {
var reg = /([A-Za-z]+(?=[А-Яа-яЄЇІҐєїіґ])|(?<=[А-Яа-яЄЇІҐєїіґ])[A-Za-z]+)/g;
var rep = '<span class="gadget-highlight">$1</span>';
var parent;
this.each(function() {
$(this).contents().each(function() {
if(this.nodeType === 3 && reg.test(this.nodeValue)) {
try {
$(this).replaceWith(this.nodeValue.replace(reg, rep));
} catch (e) {
// NotFoundError: Node.replaceChild: Child to be replaced is not a child of this node
}
}
else if(!$(this).hasClass('gadget-highlight') && this.type !== 'textarea') {
$(this).highlight();
}
});
});
};
var highlightKeybMixing = function () {
$('body').highlight();
};
highlightKeybMixing();
// Qpreview gadget compatibility
if (document.querySelector('#wikiPreview')) {
var target = document.querySelector('#wikiPreview');
var observer = new MutationObserver(function() {
highlightKeybMixing();
});
var config = {childList: true, subtree: true};
observer.observe(target, config);
}
}
});