Difference between revisions of "MediaWiki:Common.js"

From CRIU
Jump to: navigation, search
(created)
 
(link to source)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 +
 +
// Stolen from http://www.mediawiki.org/wiki/Manual:Collapsible_elements
  
 
/** Test if an element has a certain class **************************************
 
/** Test if an element has a certain class **************************************

Revision as of 09:05, 30 July 2012

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

// Stolen from http://www.mediawiki.org/wiki/Manual:Collapsible_elements

/** 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');