mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
Further refactoring of createSubclassesFromModules
This commit is contained in:
parent
2bef7c2c5c
commit
ac4b3ecef9
10
core/boot.js
10
core/boot.js
@ -445,14 +445,16 @@ $tw.modules.applyMethods = function(moduleType,targetObject) {
|
||||
};
|
||||
|
||||
/*
|
||||
Return an array of subclasses created from the modules of a specified type
|
||||
Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class
|
||||
*/
|
||||
$tw.modules.createSubclassesFromModules = function(moduleType,baseClass) {
|
||||
$tw.modules.createClassesFromModules = function(moduleType,baseClass) {
|
||||
var classes = {};
|
||||
$tw.modules.forEachModuleOfType(moduleType,function(title,moduleExports) {
|
||||
var newClass = function() {};
|
||||
newClass.prototype = new baseClass();
|
||||
newClass.prototype.constructor = baseClass;
|
||||
if(baseClass) {
|
||||
newClass.prototype = new baseClass();
|
||||
newClass.prototype.constructor = baseClass;
|
||||
}
|
||||
$tw.utils.extend(newClass.prototype,moduleExports);
|
||||
classes[moduleExports.name] = newClass;
|
||||
});
|
||||
|
@ -13,9 +13,9 @@ module-type: global
|
||||
var WikiVocabulary = function(options) {
|
||||
this.wiki = options.wiki;
|
||||
// Hashmaps of the various parse rule classes
|
||||
this.pragmaRuleClasses = $tw.modules.createSubclassesFromModules("wikipragmarule",$tw.WikiRule);
|
||||
this.blockRuleClasses = $tw.modules.createSubclassesFromModules("wikiblockrule",$tw.WikiRule);
|
||||
this.runRuleClasses = $tw.modules.createSubclassesFromModules("wikirunrule",$tw.WikiRule);
|
||||
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRule);
|
||||
this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRule);
|
||||
this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRule);
|
||||
// Hashmap of the various renderer classes
|
||||
this.rendererClasses = $tw.modules.applyMethods("wikirenderer");
|
||||
// Hashmap of the available widgets
|
||||
|
Loading…
Reference in New Issue
Block a user