[ResourceLoader2] Create getModuleNames() function
authorKrinkle <krinkle@users.mediawiki.org>
Mon, 1 Aug 2011 21:01:32 +0000 (21:01 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Mon, 1 Aug 2011 21:01:32 +0000 (21:01 +0000)
- Returns all keys from the (private) registry object as an array
- Needed for ResourceLoader 2 in order to do autosuggestions for dependancies and cheap non-http-request lookups to avoid duplicate keys when creating new modules/gadgets.

(bug 30160 ) Add public method to mw.loader to get module names from registry

RELEASE-NOTES-1.19
resources/mediawiki/mediawiki.js

index 818d982..4d2e622 100644 (file)
@@ -22,6 +22,7 @@ production.
 * (bug 30022) Add support for custom loadScript sources to ResourceLoader.
 * (bug 19052) Unicode space separator characters (Zs) now terminates external
   links and images links.
+* (bug 30160) Add public method to mw.loader to get module names from registry.
 
 === Bug fixes in 1.19 ===
 * $wgUploadNavigationUrl should be used for file redlinks if
index 9cf0bf1..fd5d79e 100644 (file)
@@ -1156,6 +1156,18 @@ window.mw = window.mediaWiki = new ( function( $ ) {
                        return null;
                };
 
+               /**
+                * Get names of all registered modules.
+                *
+                * @return {Array}
+                */
+               this.getModuleNames = function() {
+                       var names = $.map( registry, function( i, key ) {
+                               return key;
+                       } );
+                       return names;
+               };
+
                /* Cache document ready status */
 
                $(document).ready( function() { ready = true; } );