[[Template:catfix]] gadget improvements
Fragment of a discussion from User talk:Kephir
I made the changes you suggested, but I'm not sure I understand how declaring dependencies works. Am I supposed to wrap the whole jQuery(document).ready(function($){ ... }
in yet another function? Like this?
mw.loader.using(['mediawiki.Title'], function () { jQuery(document).ready(function($){ ... } }
I guess I just don't know enough about JS stuff to understand what I am doing. I understand the language, but not the framework.
Exactly. Though I would do it like:
if (mw.config.get('wgNamespaceNumber') === 14) // or mw.config.get('wgNamespaceIds').category for extra readability
jQuery(document).ready(function () {
var wrapper;
if (!(wrapper = document.getElementById("catfix")))
return;
mw.loader.using(['mediawiki.Title'], function () {
// ...
});
});
— Keφr