2012-10-24 22:20:41 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model InspectorFactory class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel Inspector factory.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.Factory}
|
|
|
|
*/
|
|
|
|
ve.ui.InspectorFactory = function VeDmInspectorFactory() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.Factory.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.inheritClass( ve.ui.InspectorFactory, ve.Factory );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an inspector constructor for a given annotation type.
|
|
|
|
*
|
2012-10-27 00:03:54 +00:00
|
|
|
* If {static.typePattern} is not defined in an inspector subclass a regular expression that matches
|
|
|
|
* nothing will be returned.
|
2012-10-24 22:20:41 +00:00
|
|
|
*
|
|
|
|
* @method
|
2012-10-27 00:03:54 +00:00
|
|
|
* @param {String} name Symbolic name of inspector to get pattern for
|
|
|
|
* @returns {RegExp} Regular expression matching annotations relevant to a given inspector
|
2012-10-24 22:20:41 +00:00
|
|
|
*/
|
2012-10-27 00:03:54 +00:00
|
|
|
ve.ui.InspectorFactory.prototype.getTypePattern = function ( name ) {
|
|
|
|
if ( name in this.registry ) {
|
|
|
|
if ( this.registry[name].static && this.registry[name].static.typePattern ) {
|
|
|
|
return this.registry[name].static.typePattern;
|
2012-10-24 22:20:41 +00:00
|
|
|
}
|
2012-10-27 00:03:54 +00:00
|
|
|
return new RegExp();
|
2012-10-24 22:20:41 +00:00
|
|
|
}
|
2012-10-27 00:03:54 +00:00
|
|
|
throw new Error( 'Unknown inspector: ' + name );
|
2012-10-24 22:20:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
|
|
|
|
ve.ui.inspectorFactory = new ve.ui.InspectorFactory();
|