diff --git a/core/modules/parsers/wikiparser/rules/wikirule.js b/core/modules/parsers/wikiparser/rules/wikirulebase.js similarity index 70% rename from core/modules/parsers/wikiparser/rules/wikirule.js rename to core/modules/parsers/wikiparser/rules/wikirulebase.js index dfec85a39..8aa960ef7 100644 --- a/core/modules/parsers/wikiparser/rules/wikirule.js +++ b/core/modules/parsers/wikiparser/rules/wikirulebase.js @@ -1,5 +1,5 @@ /*\ -title: $:/core/modules/parsers/wikiparser/rules/wikirule.js +title: $:/core/modules/parsers/wikiparser/rules/wikirulebase.js type: application/javascript module-type: global @@ -15,25 +15,25 @@ Base class for wiki parser rules /* This constructor is always overridden with a blank constructor, and so shouldn't be used */ -var WikiRule = function() { +var WikiRuleBase = function() { }; /* To be overridden by individual rules */ -WikiRule.prototype.init = function(parser) { +WikiRuleBase.prototype.init = function(parser) { this.parser = parser; }; /* Default implementation of findNextMatch uses RegExp matching */ -WikiRule.prototype.findNextMatch = function(startPos) { +WikiRuleBase.prototype.findNextMatch = function(startPos) { this.matchRegExp.lastIndex = startPos; this.match = this.matchRegExp.exec(this.parser.source); return this.match ? this.match.index : undefined; }; -exports.WikiRule = WikiRule; +exports.WikiRuleBase = WikiRuleBase; })(); diff --git a/core/modules/widgetbase.js b/core/modules/widgetbase.js new file mode 100644 index 000000000..ef659f712 --- /dev/null +++ b/core/modules/widgetbase.js @@ -0,0 +1,30 @@ +/*\ +title: $:/core/modules/widgetbase.js +type: application/javascript +module-type: global + +Base class for widgets + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +This constructor is always overridden with a blank constructor, and so shouldn't be used +*/ +var WidgetBase = function() { +}; + +/* +To be overridden by individual widgets +*/ +WidgetBase.prototype.init = function(renderer) { + this.renderer = renderer; +}; + +exports.WidgetBase = WidgetBase; + +})(); diff --git a/core/modules/wikivocabulary.js b/core/modules/wikivocabulary.js index 7ab59b554..db5780ff8 100644 --- a/core/modules/wikivocabulary.js +++ b/core/modules/wikivocabulary.js @@ -13,13 +13,13 @@ module-type: global var WikiVocabulary = function(options) { this.wiki = options.wiki; // Hashmaps of the various parse rule classes - this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRule); - this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRule); - this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRule); + this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRuleBase); + this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRuleBase); + this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRuleBase); // Hashmap of the various renderer classes this.rendererClasses = $tw.modules.applyMethods("wikirenderer"); // Hashmap of the available widgets - this.widgetClasses = $tw.modules.createClassesFromModules("widget"); + this.widgetClasses = $tw.modules.createClassesFromModules("widget",$tw.WidgetBase); }; WikiVocabulary.prototype.parseText = function(type,text) {