protected $namespace = null;
protected $relative = null;
protected $suggestions = null;
+ protected $highlightFirst = null;
+ protected $validate = null;
/**
* @param array $config Configuration options
* @param bool|null $config['relative'] If a namespace is set,
* return a title relative to it (default: true)
* @param bool|null $config['suggestions'] Display search suggestions (default: true)
+ * @param bool|null $config['highlightFirst'] Automatically highlight
+ * the first result (default: true)
+ * @param bool|null $config['validate'] Whether the input must be a valid title (default: true)
*/
public function __construct( array $config = array() ) {
// Parent constructor
if ( isset( $config['highlightFirst'] ) ) {
$this->highlightFirst = $config['highlightFirst'];
}
+ if ( isset( $config['validate'] ) ) {
+ $this->validate = $config['validate'];
+ }
// Initialization
$this->addClasses( array( 'mw-widget-titleInputWidget' ) );
if ( $this->highlightFirst !== null ) {
$config['highlightFirst'] = $this->highlightFirst;
}
+ if ( $this->validate !== null ) {
+ $config['validate'] = $this->validate;
+ }
return parent::getConfig( $config );
}
}
* @cfg {boolean} [showRedlink] Show red link to exact match if it doesn't exist
* @cfg {boolean} [showImages] Show page images
* @cfg {boolean} [showDescriptions] Show page descriptions
+ * @cfg {boolean} [validate=true] Whether the input must be a valid title
* @cfg {Object} [cache] Result cache which implements a 'set' method, taking keyed values as an argument
*/
mw.widgets.TitleWidget = function MwWidgetsTitleWidget( config ) {
this.showRedlink = !!config.showRedlink;
this.showImages = !!config.showImages;
this.showDescriptions = !!config.showDescriptions;
+ this.validate = config.validate !== undefined ? config.validate : true;
this.cache = config.cache;
// Initialization
* @return {boolean} The query is valid
*/
mw.widgets.TitleWidget.prototype.isQueryValid = function () {
- return !!this.getTitle();
+ return this.validate ? !!this.getTitle() : true;
};
}( jQuery, mediaWiki ) );