Difference between revisions of "MediaWiki:Common.js"

From CRIU
Jump to navigation Jump to search
(created)
(No difference)

Revision as of 09:04, 30 July 2012

/* Any JavaScript here will be loaded for all users on every page load. */

/** Test if an element has a certain class **************************************
 *
 * Description: Uses regular expressions and caching for better performance.
 * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 */
 
var hasClass = ( function() {
        var reCache = {};
        return function( element, className ) {
                return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
        };
})();

// Import some more scripts
importScript('MediaWiki:Common.js/Collapsible.js');